From fb53fc20cb3323338f9b54be1e49e14ad0dbd65e Mon Sep 17 00:00:00 2001 From: Michele Sottile sottile Date: Wed, 21 Apr 2010 12:28:29 +0000 Subject: [PATCH] Solved some bugs --- src/meshlab_2.0/glarea.cpp | 59 ++++++++++++++++++++--- src/meshlab_2.0/glarea.h | 11 ++++- src/meshlab_2.0/mainwindow_RunTime.cpp | 6 +-- src/meshlab_2.0/multiViewer_Container.cpp | 32 ++++++++++-- src/meshlab_2.0/multiViewer_Container.h | 6 ++- 5 files changed, 97 insertions(+), 17 deletions(-) diff --git a/src/meshlab_2.0/glarea.cpp b/src/meshlab_2.0/glarea.cpp index 8bb76b4e8..14e17e071 100644 --- a/src/meshlab_2.0/glarea.cpp +++ b/src/meshlab_2.0/glarea.cpp @@ -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 diff --git a/src/meshlab_2.0/glarea.h b/src/meshlab_2.0/glarea.h index 72a4b6735..b7a4bd24b 100644 --- a/src/meshlab_2.0/glarea.h +++ b/src/meshlab_2.0/glarea.h @@ -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); diff --git a/src/meshlab_2.0/mainwindow_RunTime.cpp b/src/meshlab_2.0/mainwindow_RunTime.cpp index 4bdec4157..bfe1f1ff4 100644 --- a/src/meshlab_2.0/mainwindow_RunTime.cpp +++ b/src/meshlab_2.0/mainwindow_RunTime.cpp @@ -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,¤tGlobalParams,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, ¤tGlobalParams,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(mdiarea->currentSubWindow()->widget()); GLArea *glw = (GLArea*)(mvc->currentView()); int id = mvc->getNextViewerId(); - GLArea *glwClone=new GLArea(mdiarea,¤tGlobalParams,id, &(mvc->meshDoc)); + GLArea *glwClone=new GLArea(mdiarea,mvc, ¤tGlobalParams,id, &(mvc->meshDoc)); if(qa->text() == tr("&Horizontally")) mvc->addView(glwClone, Qt::Vertical); else diff --git a/src/meshlab_2.0/multiViewer_Container.cpp b/src/meshlab_2.0/multiViewer_Container.cpp index 628290313..9686c8f04 100644 --- a/src/meshlab_2.0/multiViewer_Container.cpp +++ b/src/meshlab_2.0/multiViewer_Container.cpp @@ -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(); diff --git a/src/meshlab_2.0/multiViewer_Container.h b/src/meshlab_2.0/multiViewer_Container.h index 9a2960aa2..3e3997d3d 100644 --- a/src/meshlab_2.0/multiViewer_Container.h +++ b/src/meshlab_2.0/multiViewer_Container.h @@ -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 *); };