diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index abe1d90ecb..6fc7f6b1d2 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -1336,11 +1336,12 @@ public: if (selIdPair.GeoId == GeoEnum::GeoUndef) { // If mouse is released on "blank" space, finalize and start over finalizeCommand(); + return true; } - else if (notSelectedYet(selIdPair)) { - std::vector& selVector = getSelectionVector(newselGeoType); + std::vector& selVector = getSelectionVector(newselGeoType); + if (notSelectedYet(selIdPair)) { //add the geometry to its type vector. Temporarily if not selAllowed selVector.push_back(selIdPair); @@ -1357,6 +1358,21 @@ public: selVector.pop_back(); } } + else { + //if it is already selected we unselect it. + selVector.pop_back(); + if (!selectionEmpty()) { + makeAppropriateConstraint(onSketchPos); + } + else { + restartCommand(QT_TRANSLATE_NOOP("Command", "Dimension")); + } + + Gui::Selection().rmvSelection(Obj->getDocument()->getName(), + Obj->getNameInDocument(), + ss.str().c_str()); + sketchgui->draw(false, false); // Redraw + } return true; } protected: @@ -1494,6 +1510,11 @@ protected: && !contains(selEllipseAndCo, elem); } + bool selectionEmpty() + { + return selPoints.empty() && selLine.empty() && selCircleArc.empty() && selEllipseAndCo.empty(); + } + bool makeAppropriateConstraint(Base::Vector2d onSketchPos) { bool selAllowed = false;