diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index bffbf1b57..6dafdcbb9 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4405,7 +4405,7 @@ public: return false; } - Gui::Command::commitCommand(); + //Gui::Command::commitCommand(); //static_cast(sketchgui->getObject())->solve(); @@ -4413,7 +4413,7 @@ public: // add auto constraints on pole if (sugConstr[CurrentConstraint].size() > 0) { - createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId, Sketcher::mid); + createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId, Sketcher::mid, false); } static_cast(sketchgui->getObject())->solve(); @@ -4450,7 +4450,7 @@ public: // insert circle point for pole, defer internal alignment constraining. try { - Gui::Command::openCommand("Add Pole circle"); + //Gui::Command::openCommand("Add Pole circle"); //Add pole Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)", @@ -4475,16 +4475,16 @@ public: return false; } - Gui::Command::commitCommand(); + //Gui::Command::commitCommand(); //static_cast(sketchgui->getObject())->solve(); // add auto constraints on pole if (sugConstr[CurrentConstraint].size() > 0) { - createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId + EditCurve.size()-1, Sketcher::mid); + createAutoConstraints(sugConstr[CurrentConstraint], FirstPoleGeoId + EditCurve.size()-1, Sketcher::mid, false); } - static_cast(sketchgui->getObject())->solve(); + //static_cast(sketchgui->getObject())->solve(); if (!IsClosed) { EditCurve.resize(EditCurve.size() + 1); // add one place for a pole @@ -4523,7 +4523,7 @@ public: try { - Gui::Command::openCommand("Add B-spline curve"); + //Gui::Command::openCommand("Add B-spline curve"); //Add arc of parabola Gui::Command::doCommand(Gui::Command::Doc, @@ -4623,7 +4623,18 @@ public: } else if(CurrentConstraint == 1) { // if we just have one point and we can not close anything, then cancel this creation but continue according to continuous mode - sketchgui->getDocument()->undo(1); + //sketchgui->getDocument()->undo(1); + + Gui::Command::abortCommand(); + + ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); + bool autoRecompute = hGrp->GetBool("AutoRecompute",false); + + if(autoRecompute) + Gui::Command::updateActive(); + else + static_cast(sketchgui->getObject())->solve(); + if(!continuousMode){ DrawSketchHandler::quit(); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index fb4554e7a..cc8a783ec 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -383,15 +383,18 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested } void DrawSketchHandler::createAutoConstraints(const std::vector &autoConstrs, - int geoId1, Sketcher::PointPos posId1) + int geoId1, Sketcher::PointPos posId1, bool createowncommand /*= true*/) { if (!sketchgui->Autoconstraints.getValue()) return; // If Autoconstraints property is not set quit if (autoConstrs.size() > 0) { - // Open the Command - Gui::Command::openCommand("Add auto constraints"); - + + if(createowncommand) { + // Open the Command + Gui::Command::openCommand("Add auto constraints"); + } + // Iterate through constraints std::vector::const_iterator it = autoConstrs.begin(); for (; it != autoConstrs.end(); ++it) { @@ -512,7 +515,9 @@ void DrawSketchHandler::createAutoConstraints(const std::vector break; } - Gui::Command::commitCommand(); + if(createowncommand) { + Gui::Command::commitCommand(); + } //Gui::Command::updateActive(); // There is already an recompute in each command creation, this is redundant. } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.h b/src/Mod/Sketcher/Gui/DrawSketchHandler.h index b71337405..cbdd47a14 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.h @@ -82,8 +82,10 @@ public: int seekAutoConstraint(std::vector &suggestedConstraints, const Base::Vector2d &Pos, const Base::Vector2d &Dir, AutoConstraint::TargetType type = AutoConstraint::VERTEX); + // createowncommand indicates whether a separate command shall be create and committed (for example for undo purposes) or not + // is not it is the responsibility of the developer to create and commit the command appropriately. void createAutoConstraints(const std::vector &autoConstrs, - int geoId, Sketcher::PointPos pointPos=Sketcher::none); + int geoId, Sketcher::PointPos pointPos=Sketcher::none, bool createowncommand = true); void setPositionText(const Base::Vector2d &Pos, const SbString &text); void setPositionText(const Base::Vector2d &Pos);