Sketcher: Bug fix: Undo/Redo implementation

================================================

Fixes a bug in master that the dependent 3D geometry would not update on Undo (in Auto update mode enabled).

Undo and redo signals are handled by ViewProvider in order to introduce an recompute or solve() of the sketchObject
as determined by the Auto Update Mode in order to update DoF and dependent geometry if necessary.
This commit is contained in:
Abdullah Tahiri
2015-06-08 17:21:53 +02:00
committed by wmayer
parent da5270131c
commit d1acd124cc
4 changed files with 44 additions and 2 deletions

View File

@@ -70,6 +70,10 @@
# include <QTextStream>
#endif
#ifndef _PreComp_
# include <boost/bind.hpp>
#endif
#include <Inventor/SbTime.h>
#include <boost/scoped_ptr.hpp>
@@ -292,6 +296,22 @@ ViewProviderSketch::~ViewProviderSketch()
{
delete rubberband;
}
void ViewProviderSketch::slotUndoDocument(const Gui::Document& doc)
{
if(getSketchObject()->noRecomputes)
getSketchObject()->solve(); // the sketch must be solved to update the DoF of the solver
else
getSketchObject()->getDocument()->recompute(); // or fully recomputed if applicable
}
void ViewProviderSketch::slotRedoDocument(const Gui::Document& doc)
{
if(getSketchObject()->noRecomputes)
getSketchObject()->solve(); // the sketch must be solved to update the DoF of the solver
else
getSketchObject()->getDocument()->recompute(); // or fully recomputed if applicable
}
// handler management ***************************************************************
void ViewProviderSketch::activateHandler(DrawSketchHandler *newHandler)
@@ -4205,6 +4225,11 @@ bool ViewProviderSketch::setEdit(int ModNum)
getSketchObject()->solve(); // This call to the solver is needed to initialize the DoF and solve time controls
//draw(); is not necessary, because a solve triggers an updateData.
connectUndoDocument = Gui::Application::Instance->activeDocument()
->signalUndoDocument.connect(boost::bind(&ViewProviderSketch::slotUndoDocument, this, _1));
connectRedoDocument = Gui::Application::Instance->activeDocument()
->signalRedoDocument.connect(boost::bind(&ViewProviderSketch::slotRedoDocument, this, _1));
return true;
}
@@ -4494,7 +4519,10 @@ void ViewProviderSketch::unsetEdit(int ModNum)
std::string ObjName = getSketchObject()->getNameInDocument();
std::string DocName = getSketchObject()->getDocument()->getName();
Gui::Selection().addSelection(DocName.c_str(),ObjName.c_str());
connectUndoDocument.disconnect();
connectRedoDocument.disconnect();
// when pressing ESC make sure to close the dialog
Gui::Control().closeDialog();
}