diff --git a/src/common/interfaces.h b/src/common/interfaces.h index df7bc0f78..debcc13f0 100644 --- a/src/common/interfaces.h +++ b/src/common/interfaces.h @@ -538,12 +538,20 @@ public: // Called when the user press the second time the button virtual void EndEdit(MeshModel &/*m*/, GLArea * /*parent*/){} + + // There are two classes of editing tools, the one that works on a single layer at a time + // and the ones that works on all layers and have to manage in a correct way the action of changing the current layer. + // For the edit tools that works ona single layer changing the layer means the restart of the edit tool. + virtual bool isSingleMeshEdit() const { return true; } + // Called when the user changes the selected layer //by default it calls end edit with the layer that was selected and start with the new layer that is //selected. This ensures that plugins who dont support layers do not get sent pointers to meshes - //they are not expecting + //they are not expecting. + // If your editing plugins is not singleMesh you MUST reimplement this to correctly handle the change of layer. virtual void LayerChanged(MeshDocument &md, MeshModel &oldMeshModel, GLArea *parent) { + assert(this->isSingleMeshEdit()); EndEdit(oldMeshModel, parent); StartEdit(md, parent); } @@ -554,8 +562,7 @@ public: virtual void mousePressEvent (QMouseEvent *event, MeshModel &/*m*/, GLArea * )=0; virtual void mouseMoveEvent (QMouseEvent *event, MeshModel &/*m*/, GLArea * )=0; virtual void mouseReleaseEvent(QMouseEvent *event, MeshModel &/*m*/, GLArea * )=0; - //virtual void wheelEvent (QWheelEvent*e, MeshModel &/*m*/, GLArea * ); - virtual void keyReleaseEvent (QKeyEvent *, MeshModel &/*m*/, GLArea *){} + virtual void keyReleaseEvent (QKeyEvent *, MeshModel &/*m*/, GLArea *){} virtual void keyPressEvent (QKeyEvent *, MeshModel &/*m*/, GLArea *){} virtual void wheelEvent(QWheelEvent*, MeshModel &/*m*/, GLArea * ){} virtual void tabletEvent(QTabletEvent * e, MeshModel &/*m*/, GLArea *){e->ignore();} diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index 8c0822214..7f9e03f60 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -648,7 +648,10 @@ void GLArea::updateLayer() //if we have an edit tool open, notify it that the current layer has changed if(iEdit) { - assert(lastModelEdited); //if there is an editor last model edited should always be set when start edit is called + if(iEdit->isSingleMeshEdit()) + assert(lastModelEdited); // if there is an editor that works on a single mesh + // last model edited should always be set when start edit is called + iEdit->LayerChanged(*this->md(), *lastModelEdited, this); //now update the last model edited @@ -686,7 +689,9 @@ void GLArea::setCurrentEditAction(QAction *editAction) else { log->Logf(GLLogStream::SYSTEM,"Started Mode %s", qPrintable(currentEditor->text())); - mm()->meshModified() = true; + if(mm()!=NULL) + mm()->meshModified() = true; + else assert(!iEdit->isSingleMeshEdit()); } } @@ -1114,9 +1119,9 @@ void GLArea::updateFps(float deltaTime) void GLArea::resetTrackBall() { - trackball.Reset(); + trackball.Reset(); float newScale= 3.0f/this->md()->bbox().Diag(); - trackball.track.sca = newScale; + trackball.track.sca = newScale; trackball.track.tra = -this->md()->bbox().Center(); update(); } diff --git a/src/meshlab/glarea.h b/src/meshlab/glarea.h index 5508d8640..6340cc0e7 100644 --- a/src/meshlab/glarea.h +++ b/src/meshlab/glarea.h @@ -124,7 +124,6 @@ public: void saveSnapshot(); void setLightModel(); void setView(); - void resetTrackBall(); QList iDecoratorsList; void setRenderer(MeshRenderInterface *rend, QAction *shader){ iRenderer = rend; currentShader = shader;} @@ -139,7 +138,8 @@ public: public slots: void updateTexture(); // slot for forcing the texture reload. - + void resetTrackBall(); + //slots for changing the draw rendering and texturing mode void setDrawMode(vcg::GLW::DrawMode mode); void setColorMode(vcg::GLW::ColorMode mode);