Solved some bugs

This commit is contained in:
Michele Sottile sottile 2010-04-21 12:28:29 +00:00
parent 14792c0095
commit fb53fc20cb
5 changed files with 97 additions and 17 deletions

View File

@ -33,11 +33,12 @@
using namespace std;
using namespace vcg;
GLArea:: GLArea(QWidget *parent, RichParameterSet *current, int id, MeshDocument *meshDoc)
GLArea:: GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterSet *current, int id, MeshDocument *meshDoc)
: QGLWidget(parent)
{
this->id =id;
this->meshDoc = meshDoc;
mvc = mvcont;
this->updateCustomSettingValues(*current);
animMode=AnimNone;
@ -559,9 +560,12 @@ void GLArea::keyReleaseEvent ( QKeyEvent * e )
e->ignore();
if(iEdit && !suspendedEditor) iEdit->keyReleaseEvent(e,*mm(),this);
else{
if(e->key()==Qt::Key_Control) trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
if(e->key()==Qt::Key_Shift) trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
if(e->key()==Qt::Key_Alt) trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::AltModifier ) );
if(e->key()==Qt::Key_Control)
trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
if(e->key()==Qt::Key_Shift)
trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
if(e->key()==Qt::Key_Alt)
trackball.ButtonUp(QT2VCG(Qt::NoButton, Qt::AltModifier ) );
}
}
@ -570,9 +574,12 @@ void GLArea::keyPressEvent ( QKeyEvent * e )
e->ignore();
if(iEdit && !suspendedEditor) iEdit->keyPressEvent(e,*mm(),this);
else{
if(e->key()==Qt::Key_Control) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
if(e->key()==Qt::Key_Shift) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
if(e->key()==Qt::Key_Alt) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::AltModifier ) );
if(e->key()==Qt::Key_Control)
trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
if(e->key()==Qt::Key_Shift)
trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
if(e->key()==Qt::Key_Alt)
trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::AltModifier ) );
}
}
@ -605,8 +612,40 @@ void GLArea::mousePressEvent(QMouseEvent*e)
emit currentViewerChanged(id);
emit updateMainWindowMenus();
update();
if(isCurrent())
if(e->modifiers() & Qt::MetaModifier)
mvc->updatePressViewers(e);
}
void GLArea::mousePressEvent2(QMouseEvent*e)
{
e->accept();
if( (iEdit && !suspendedEditor) && !(e->buttons() & Qt::MidButton) )
iEdit->mousePressEvent(e,*mm(),this);
else {
if ((e->modifiers() & Qt::ShiftModifier) && (e->modifiers() & Qt::ControlModifier) &&
(e->button()==Qt::LeftButton) )
activeDefaultTrackball=false;
else activeDefaultTrackball=true;
if (isDefaultTrackBall())
{
if(QApplication::keyboardModifiers () & Qt::Key_Control) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
else trackball.ButtonUp (QT2VCG(Qt::NoButton, Qt::ControlModifier ) );
if(QApplication::keyboardModifiers () & Qt::Key_Shift) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
else trackball.ButtonUp (QT2VCG(Qt::NoButton, Qt::ShiftModifier ) );
if(QApplication::keyboardModifiers () & Qt::Key_Alt) trackball.ButtonDown(QT2VCG(Qt::NoButton, Qt::AltModifier ) );
else trackball.ButtonUp (QT2VCG(Qt::NoButton, Qt::AltModifier ) );
trackball.MouseDown(e->x(),height()-e->y(), QT2VCG(e->button(), e->modifiers() ) );
}
else trackball_light.MouseDown(e->x(),height()-e->y(), QT2VCG(e->button(), Qt::NoModifier ) );
}
update();
}
void GLArea::mouseMoveEvent(QMouseEvent*e)
{
if( (iEdit && !suspendedEditor) && !(e->buttons() & Qt::MidButton) )
@ -620,6 +659,10 @@ void GLArea::mouseMoveEvent(QMouseEvent*e)
else trackball_light.MouseMove(e->x(),height()-e->y());
update();
}
if(isCurrent())
if(e->modifiers() & Qt::MetaModifier)
mvc->updateMoveViewers(e);
}
// When mouse is released we set the correct mouse cursor
void GLArea::mouseReleaseEvent(QMouseEvent*e)
@ -635,6 +678,8 @@ void GLArea::mouseReleaseEvent(QMouseEvent*e)
}
update();
if(isCurrent())
mvc->updateReleaseViewers(e);
}
//Processing of tablet events, interesting only for painting plugins

View File

@ -40,6 +40,7 @@
//#include "layerDialog.h" **
#include "glarea_setting.h"
#include "viewer.h"
#include "multiViewer_Container.h"
#define SSHOT_BYTES_PER_PIXEL 4
@ -69,7 +70,7 @@ class GLArea : public QGLWidget, public Viewer
Q_OBJECT
public:
GLArea(QWidget *parent, RichParameterSet *current, int id, MeshDocument *meshDoc);
GLArea(QWidget *parent, MultiViewer_Container *mvcont, RichParameterSet *current, int id, MeshDocument *meshDoc);
~GLArea();
static void initGlobalParameterSet( RichParameterSet * /*globalparam*/);
private:
@ -80,6 +81,7 @@ public:
// Layer Management stuff.
MeshDocument *meshDoc;
MeshModel *mm(){return meshDoc->mm();}
MultiViewer_Container *mvc;
vcg::Trackball trackball;
vcg::Trackball trackball_light;
@ -114,6 +116,8 @@ public:
bool isTrackBallVisible() {return trackBallVisible;}
bool isDefaultTrackBall() {return activeDefaultTrackball;}
bool isCurrent() { return mvc->currentId == id;}
void toggleHelpVisible() {helpVisible = !helpVisible; update();}
void setBackFaceCulling(bool enabled);
void setSnapshotSetting(const SnapshotSetting & s);
@ -239,8 +243,13 @@ protected:
void keyReleaseEvent ( QKeyEvent * e );
void keyPressEvent ( QKeyEvent * e );
void mousePressEvent(QMouseEvent *event);
public:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent2(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
protected:
void mouseDoubleClickEvent ( QMouseEvent * event ) ;
void wheelEvent(QWheelEvent*e);
void tabletEvent(QTabletEvent *e);

View File

@ -849,10 +849,10 @@ bool MainWindow::open(QString fileName, GLArea *gla)
//MeshIOInterface* pCurrentIOPlugin = meshIOPlugins[idx-1];
bool newGla = false;
MultiViewer_Container *mvcont;
if(mdiarea->currentSubWindow()==0){
if(gla==0){
mvcont = new MultiViewer_Container(mdiarea);
int id = mvcont->getNextViewerId();
gla=new GLArea(mdiarea,&currentGlobalParams,id, &(mvcont->meshDoc)); //SAREBBE MEGLIO METTERE DA SUBITO CHE E'FIGLIO DI MVC MA DEVI MODIFICARE IL COSTRUTTORE DI GLAREA
gla=new GLArea(mdiarea,mvcont, &currentGlobalParams,id, &(mvcont->meshDoc)); //SAREBBE MEGLIO METTERE DA SUBITO CHE E'FIGLIO DI MVC MA DEVI MODIFICARE IL COSTRUTTORE DI GLAREA
mvcont->addView(gla, Qt::Horizontal);
addDockWidget(Qt::RightDockWidgetArea,mvcont->layerDialog);
mvcont->connectToLayerDialog(gla);
@ -1144,7 +1144,7 @@ void MainWindow::setSplit(QAction *qa)
mvc = qobject_cast<MultiViewer_Container *>(mdiarea->currentSubWindow()->widget());
GLArea *glw = (GLArea*)(mvc->currentView());
int id = mvc->getNextViewerId();
GLArea *glwClone=new GLArea(mdiarea,&currentGlobalParams,id, &(mvc->meshDoc));
GLArea *glwClone=new GLArea(mdiarea,mvc, &currentGlobalParams,id, &(mvc->meshDoc));
if(qa->text() == tr("&Horizontally"))
mvc->addView(glwClone, Qt::Vertical);
else

View File

@ -213,6 +213,28 @@ void MultiViewer_Container::updateCurrent(int current){
currentId=current;
}
void MultiViewer_Container::updatePressViewers(QMouseEvent *e){
foreach(Viewer* viewer, viewerList)
if(viewer->getId() != currentId){
((GLArea*) viewer)->mousePressEvent2(e);
}
}
void MultiViewer_Container::updateMoveViewers(QMouseEvent *e){
foreach(Viewer* viewer, viewerList)
if(viewer->getId() != currentId){
((GLArea*) viewer)->mouseMoveEvent(e);
}
}
void MultiViewer_Container::updateReleaseViewers(QMouseEvent *e){
foreach(Viewer* viewer, viewerList)
if(viewer->getId() != currentId){
((GLArea*) viewer)->mouseReleaseEvent(e);
}
}
void MultiViewer_Container::updateLayout(){
foreach(Viewer* viewer, viewerList)
//splitter->removeWidget((GLArea*)viewer);
@ -233,11 +255,11 @@ int MultiViewer_Container::viewerCounter(){
return viewerList.count();
}
void MultiViewer_Container::resizeEvent ( QResizeEvent * event ) {
/*if(data->imageList.size()!=0){
imageVis->adjustSize();
}*/
}
//void MultiViewer_Container::resizeEvent ( QResizeEvent * event ) {
// /*if(data->imageList.size()!=0){
// imageVis->adjustSize();
// }*/
//}
/// update all the visual widgets at one time (glw, imageVis, tree, imageMag)
void MultiViewer_Container::updateAll(){
/*glw->update();

View File

@ -61,6 +61,10 @@ public:
void connectToLayerDialog(Viewer* viewer);
void updatePressViewers(QMouseEvent *e);
void updateMoveViewers(QMouseEvent *e);
void updateReleaseViewers(QMouseEvent *e);
LayerDialog *layerDialog;
MeshDocument meshDoc;
int currentId;
@ -76,7 +80,7 @@ private:
void keyPressEvent(QKeyEvent *keyEv);
// other stuff
void resizeEvent ( QResizeEvent *);
//void resizeEvent ( QResizeEvent *);
};