Added a new property for edit plugins: isSingleMesh. To clarify if a given plugin works on a single layer at a time or on multple ones (like arc3d and align).

Added resetTrackBall slot to the glarea to allow the trackball resetting from an editing tool
This commit is contained in:
Paolo Cignoni cignoni 2012-02-02 10:04:32 +00:00
parent d499fb1216
commit a133f4f4e8
3 changed files with 21 additions and 9 deletions

View File

@ -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();}

View File

@ -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();
}

View File

@ -124,7 +124,6 @@ public:
void saveSnapshot();
void setLightModel();
void setView();
void resetTrackBall();
QList<QAction *> 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);