Refactoring solve+recompute and reinstating initial solve+recompute behaviour
This commit is contained in:
@@ -175,8 +175,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr)
|
||||
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
sketch->solve(); // we have to update the solver after this aborted addition.
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(sketch);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,8 +183,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr)
|
||||
// command canceled
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
sketch->solve(); // we have to update the solver after this aborted addition.
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(sketch); // we have to update the solver after this aborted addition.
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,15 +625,24 @@ std::string SketcherGui::getStrippedPythonExceptionString(const Base::Exception
|
||||
return msg;
|
||||
}
|
||||
|
||||
void SketcherGui::tryAutoRecompute()
|
||||
bool SketcherGui::tryAutoRecompute()
|
||||
{
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool autoRecompute = hGrp->GetBool("AutoRecompute",false);
|
||||
|
||||
if (autoRecompute)
|
||||
Gui::Command::updateActive();
|
||||
|
||||
return autoRecompute;
|
||||
}
|
||||
|
||||
void SketcherGui::tryAutoRecomputeIfNotSolve(Sketcher::SketchObject* obj)
|
||||
{
|
||||
if(!tryAutoRecompute())
|
||||
obj->solve();
|
||||
}
|
||||
|
||||
|
||||
namespace SketcherGui {
|
||||
|
||||
struct SelIdPair{
|
||||
@@ -4767,8 +4774,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
|
||||
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
|
||||
abortCommand();
|
||||
|
||||
Obj->solve(); // we have to update the solver after this aborted addition.
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition.
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -4791,8 +4797,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
|
||||
commitCommand();
|
||||
|
||||
if(updateNeeded) {
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4902,8 +4907,7 @@ void CmdSketcherConstrainRadius::applyConstraint(std::vector<SelIdPair> &selSeq,
|
||||
QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what()));
|
||||
abortCommand();
|
||||
|
||||
Obj->solve(); // we have to update the solver after this aborted addition.
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition.
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -4925,8 +4929,7 @@ void CmdSketcherConstrainRadius::applyConstraint(std::vector<SelIdPair> &selSeq,
|
||||
commitCommand();
|
||||
|
||||
if(updateNeeded) {
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj); // we have to update the solver after this aborted addition.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,12 @@ std::string getStrippedPythonExceptionString(const Base::Exception);
|
||||
|
||||
/// This function tries to auto-recompute the active document if the option
|
||||
/// is set in the user parameter. If the option is not set nothing will be done
|
||||
void tryAutoRecompute();
|
||||
/// @return true if a recompute was undertaken, false if not.
|
||||
bool tryAutoRecompute();
|
||||
|
||||
/// This function tries to auto-recompute as tryAutoRecompute. If tryAutoRecompute
|
||||
/// is not enabled, then it solves the SketchObject.
|
||||
void tryAutoRecomputeIfNotSolve(Sketcher::SketchObject* obj);
|
||||
}
|
||||
#endif // SKETCHERGUI_DrawSketchHandler_H
|
||||
|
||||
|
||||
@@ -361,8 +361,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
EditCurve.clear();
|
||||
sketchgui->drawEdit(EditCurve);
|
||||
@@ -598,8 +597,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -1118,8 +1116,7 @@ public:
|
||||
}
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
}
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
@@ -1205,8 +1202,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
// remember the vertex for the next rounds constraint..
|
||||
previousCurve = getHighestCurveIndex();
|
||||
@@ -1578,8 +1574,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -1889,8 +1884,7 @@ public:
|
||||
sugConstr3.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -2194,8 +2188,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -2989,8 +2982,7 @@ private:
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3028,8 +3020,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
// This code enables the continuous creation mode.
|
||||
if (constrMethod == 0) {
|
||||
@@ -3407,8 +3398,7 @@ public:
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -3439,8 +3429,7 @@ public:
|
||||
sugConstr4.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -3790,8 +3779,7 @@ public:
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -3822,8 +3810,7 @@ public:
|
||||
sugConstr4.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -4137,8 +4124,7 @@ public:
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -4169,8 +4155,7 @@ public:
|
||||
sugConstr4.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -4669,16 +4654,14 @@ public:
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -4731,8 +4714,7 @@ public:
|
||||
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
if(!continuousMode){
|
||||
DrawSketchHandler::quit();
|
||||
@@ -5149,8 +5131,7 @@ public:
|
||||
sugConstr3.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -5402,8 +5383,7 @@ public:
|
||||
sugConstr.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true);
|
||||
@@ -5688,8 +5668,7 @@ public:
|
||||
Gui::Command::abortCommand();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -6494,8 +6473,7 @@ public:
|
||||
// redraw a changed Sketch if the solver geometry amount is the same as the SkethObject
|
||||
// geometry amount (as this avoids other issues).
|
||||
// This solver is a very low cost one anyway (there is actually nothing to solve).
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
/* this is ok not to call to purgeHandler
|
||||
@@ -6708,8 +6686,7 @@ static const char *cursor_carboncopy[]={
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
Gui::Selection().clearSelection();
|
||||
/* this is ok not to call to purgeHandler
|
||||
@@ -6970,8 +6947,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Failed to add slot: %s\n", e.what());
|
||||
@@ -7200,8 +7176,7 @@ public:
|
||||
sugConstr2.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Failed to add hexagon: %s\n", e.what());
|
||||
|
||||
@@ -410,8 +410,7 @@ void CmdSketcherConvertToNURB::activated(int iMsg)
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
}
|
||||
|
||||
bool CmdSketcherConvertToNURB::isActive(void)
|
||||
@@ -474,8 +473,7 @@ void CmdSketcherIncreaseDegree::activated(int iMsg)
|
||||
|
||||
commitCommand();
|
||||
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
@@ -634,8 +632,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg)
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
|
||||
getSelection().clearSelection();
|
||||
|
||||
@@ -782,8 +779,7 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg)
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
|
||||
getSelection().clearSelection();
|
||||
}
|
||||
|
||||
@@ -783,16 +783,14 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg)
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(Obj)->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(Obj));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(Obj)->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(Obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -982,8 +980,7 @@ void CmdSketcherSymmetry::activated(int iMsg)
|
||||
Gui::Command::abortCommand();
|
||||
}
|
||||
|
||||
Obj->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(Obj);
|
||||
}
|
||||
|
||||
bool CmdSketcherSymmetry::isActive(void)
|
||||
@@ -1123,8 +1120,7 @@ static const char *cursor_createcopy[]={
|
||||
sugConstr1.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
EditCurve.clear();
|
||||
sketchgui->drawEdit(EditCurve);
|
||||
@@ -1566,8 +1562,8 @@ static const char *cursor_createrectangulararray[]={
|
||||
sugConstr1.clear();
|
||||
}
|
||||
|
||||
static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(static_cast<Sketcher::SketchObject *>(sketchgui->getObject()));
|
||||
|
||||
|
||||
EditCurve.clear();
|
||||
sketchgui->drawEdit(EditCurve);
|
||||
|
||||
@@ -769,9 +769,8 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
,GeoId, PosId, x-xInit, y-yInit, relative ? 1 : 0
|
||||
);
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
getSketchObject()->solve();
|
||||
tryAutoRecompute();
|
||||
|
||||
tryAutoRecomputeIfNotSolve(getSketchObject());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Gui::Command::abortCommand();
|
||||
@@ -804,8 +803,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
||||
);
|
||||
Gui::Command::commitCommand();
|
||||
|
||||
getSketchObject()->solve();
|
||||
tryAutoRecompute();
|
||||
tryAutoRecomputeIfNotSolve(getSketchObject());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Gui::Command::abortCommand();
|
||||
|
||||
Reference in New Issue
Block a user