From fde23817f0a017e31e48b5534cc7f9d980b3528c Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 8 Jun 2015 15:04:09 +0200 Subject: [PATCH] Sketcher: Bug fixes to Auto-Update Mode ======================================= - Fixing toggle AutoUpdate Mode - Fix Auto-Update Sketcher tools - Fix missing createGeo recomputes - Missing constraints recomputes fixed Various fixes for non-Update mode: - Fixes lack of update upon entering a conflicting datum constraint. - Fixes lack of update upon setting the reference/driving status of a constraint - Added tooltips to buttons --- src/Mod/Sketcher/App/SketchObject.cpp | 6 ++ src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp | 7 ++- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 59 ++++++++++++++++--- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 30 ++++++++-- src/Mod/Sketcher/Gui/CommandSketcherTools.cpp | 27 +++++++-- src/Mod/Sketcher/Gui/TaskSketcherMessages.ui | 6 ++ 6 files changed, 118 insertions(+), 17 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index c16890b326..d0d046b542 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -289,6 +289,9 @@ int SketchObject::setDriving(int ConstrId, bool isdriving) newVals[ConstrId] = constNew; this->Constraints.setValues(newVals); delete constNew; + + if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); return 0; } @@ -342,6 +345,9 @@ int SketchObject::toggleDriving(int ConstrId) newVals[ConstrId] = constNew; this->Constraints.setValues(newVals); delete constNew; + + if(noRecomputes) // if we do not have a recompute, the sketch must be solved to update the DoF of the solver + solve(); return 0; } diff --git a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp index a77524ab23..c8693a2137 100644 --- a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp +++ b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp @@ -145,7 +145,12 @@ void CmdSketcherToggleConstruction::activated(int iMsg) } // finish the transaction and update commitCommand(); - updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); // clear the selection (convenience) getSelection().clearSelection(); diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 2cf642d523..9752425fdb 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -165,7 +165,14 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr) catch (const Base::Exception& e) { QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what())); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + else + sketch->solve(); // we have to update the solver after this aborted addition. } } } @@ -349,7 +356,13 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(const Sketcher::SketchObject* catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + return; } @@ -416,7 +429,13 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(const Sketcher::SketchObj catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + return; } @@ -1714,7 +1733,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) QObject::tr("Error"), QString::fromLatin1(e.what())); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + return; } @@ -1865,7 +1890,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + return; } @@ -2016,8 +2047,13 @@ void CmdSketcherConstrainTangent::activated(int iMsg) QObject::tr("Error"), QString::fromLatin1(e.what())); Gui::Command::abortCommand(); - Gui::Command::updateActive(); - return; + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + return; } commitCommand(); @@ -2414,7 +2450,14 @@ void CmdSketcherConstrainRadius::activated(int iMsg) catch (const Base::Exception& e) { QMessageBox::critical(qApp->activeWindow(), QObject::tr("Dimensional constraint"), QString::fromUtf8(e.what())); abortCommand(); - updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); + else + Obj->solve(); // we have to update the solver after this aborted addition. } } else { diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 34c81ddb47..1bb712f1cf 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -2826,7 +2826,13 @@ private: catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); + return; } @@ -3243,7 +3249,13 @@ public: catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); + return false; } @@ -4857,7 +4869,11 @@ public: catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); } ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true); @@ -5097,8 +5113,14 @@ public: catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) // toggling does not modify the DoF of the solver, however it may affect features depending on the sketch + Gui::Command::updateActive(); } + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); bool continuousMode = hGrp->GetBool("ContinuousCreationMode",true); diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 22153ef008..58d6f10bc8 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -157,7 +157,11 @@ void CmdSketcherCloseShape::activated(int iMsg) // finish the transaction and update commitCommand(); - updateActive(); + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); // clear the selection (convenience) getSelection().clearSelection(); @@ -239,7 +243,12 @@ void CmdSketcherConnect::activated(int iMsg) // finish the transaction and update commitCommand(); - updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); // clear the selection (convenience) getSelection().clearSelection(); @@ -937,13 +946,23 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) } Gui::Command::commitCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); Gui::Command::abortCommand(); - Gui::Command::updateActive(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); } } // if(geo->getTypeId() == Part::GeomEllipse::getClassTypeId()) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherMessages.ui b/src/Mod/Sketcher/Gui/TaskSketcherMessages.ui index 67c6bb173e..5639440922 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherMessages.ui +++ b/src/Mod/Sketcher/Gui/TaskSketcherMessages.ui @@ -63,6 +63,9 @@ + + Executes a recompute of the active document after every command + Auto Update @@ -79,6 +82,9 @@ + + Forces a recompute of the active document + Update