diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 4d3f542100..5d88f70268 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -1540,10 +1540,12 @@ class DraftToolBar: translate("draft", "Please enter a font file.")) - def finish(self): + def finish(self, cont=None): """finish button action""" if self.sourceCmd: - self.sourceCmd.finish(False) + if cont is None: + cont = self.continueMode + self.sourceCmd.finish(cont=cont) if self.cancel: self.cancel() self.cancel = None @@ -1552,15 +1554,11 @@ class DraftToolBar: def escape(self): """escapes the current command""" - self.continueMode = False - if not self.taskmode: - # self.taskmode == 0 Draft toolbar is obsolete and has been disabled (February 2020) - self.continueCmd.setChecked(False) - self.finish() + self.finish(cont=False) def closeLine(self): """close button action""" - self.sourceCmd.finish(True) + self.sourceCmd.finish(cont=self.continueMode, closed=True) FreeCADGui.ActiveDocument.resetEdit() def wipeLine(self): @@ -1624,7 +1622,6 @@ class DraftToolBar: elif txt.upper().startswith(inCommandShortcuts["Exit"][0]): if self.finishButton.isVisible(): self.finish() - spec = True elif txt.upper().startswith(inCommandShortcuts["Continue"][0]): if self.continueCmd.isVisible(): self.toggleContinue() diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index b23f780213..1fe23452e1 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -87,20 +87,21 @@ class Arc(gui_base_original.Creator): self.call = self.view.addEventCallback("SoEvent", self.action) _msg(translate("draft", "Pick center point")) - def finish(self, closed=False, cont=False): - """Terminate the operation and close the arc if asked. + def finish(self, cont=False): + """Terminate the operation. Parameters ---------- - closed: bool, optional - Close the line if `True`. + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. """ super(Arc, self).finish() if self.ui: self.linetrack.finalize() self.arctrack.finalize() self.doc.recompute() - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() def updateAngle(self, angle): @@ -392,7 +393,7 @@ class Arc(gui_base_original.Creator): _err("Draft: error delaying commit") # Finalize full circle or cirular arc - self.finish(cont=True) + self.finish(cont=None) def numericInput(self, numx, numy, numz): """Validate the entry fields in the user interface. @@ -565,9 +566,7 @@ class Arc_3Points(gui_base.GuiCommandSimplest): self.points[1], self.points[2]], primitive=False) - self.finish() - if Gui.Snapper.ui.continueMode: - self.Activated() + self.finish(cont=None) def drawArc(self, point, info): """Draw preview arc when we move the pointer in the 3D view. @@ -589,9 +588,19 @@ class Arc_3Points(gui_base.GuiCommandSimplest): self.points[1], point) - def finish(self, close=False): + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ self.tracker.finalize() self.doc.recompute() + if cont or (cont is None and Gui.Snapper.ui and Gui.Snapper.ui.continueMode): + self.Activated() Draft_Arc_3Points = Arc_3Points diff --git a/src/Mod/Draft/draftguitools/gui_base_original.py b/src/Mod/Draft/draftguitools/gui_base_original.py index 90c42ea81e..ada4d30486 100644 --- a/src/Mod/Draft/draftguitools/gui_base_original.py +++ b/src/Mod/Draft/draftguitools/gui_base_original.py @@ -154,7 +154,7 @@ class DraftTool: _msg("{}".format(16*"-")) _msg("GuiCommand: {}".format(self.featureName)) - def finish(self, close=False): + def finish(self, cont=False): """Finish the current command. These are general cleaning tasks that are performed diff --git a/src/Mod/Draft/draftguitools/gui_beziers.py b/src/Mod/Draft/draftguitools/gui_beziers.py index a711a06a02..29424b9c31 100644 --- a/src/Mod/Draft/draftguitools/gui_beziers.py +++ b/src/Mod/Draft/draftguitools/gui_beziers.py @@ -102,7 +102,8 @@ class BezCurve(gui_lines.Line): and arg["State"] == "DOWN" and arg["Button"] == "BUTTON1"): # left click if arg["Position"] == self.pos: - self.finish(False, cont=True) + self.finish(cont=None) + return if (not self.node) and (not self.support): # first point gui_tool_utils.getSupport(arg) @@ -118,7 +119,7 @@ class BezCurve(gui_lines.Line): # then create 2 handle points? self.drawUpdate(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) if len(self.node) > 2: # does this make sense for a BCurve? # DNC: allows to close the curve @@ -127,7 +128,7 @@ class BezCurve(gui_lines.Line): # old code has been to insensitive if (self.point-self.node[0]).Length < utils.tolerance(): self.undolast() - self.finish(True, cont=True) + self.finish(cont=None, closed=True) _msg(translate("draft", "Bézier curve has been closed")) @@ -148,9 +149,7 @@ class BezCurve(gui_lines.Line): _msg(translate("draft", "Pick next point")) else: self.obj.Shape = self.updateShape(self.node) - _msg(translate("draft", - "Pick next point, " - "or finish (A) or close (O)")) + _msg(translate("draft", "Pick next point")) def updateShape(self, pts): """Create shape for display during creation process.""" @@ -174,13 +173,16 @@ class BezCurve(gui_lines.Line): w = Part.Wire(edges) return w - def finish(self, closed=False, cont=False): + def finish(self, cont=False, closed=False): """Terminate the operation and close the curve if asked. Parameters ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. closed: bool, optional - Close the line if `True`. + Close the curve if `True`. """ if self.ui: if hasattr(self, "bezcurvetrack"): @@ -220,7 +222,7 @@ class BezCurve(gui_lines.Line): # another method that performs cleanup (superfinish) # that is not re-implemented by any of the child classes. gui_base_original.Creator.finish(self) - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() @@ -309,7 +311,7 @@ class CubicBezCurve(gui_lines.Line): # then create 2 handle points? self.drawUpdate(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) # does this make sense for a BCurve? if len(self.node) > 2: # add point to "clicked list" @@ -327,7 +329,7 @@ class CubicBezCurve(gui_lines.Line): # close the curve with a smooth symmetric knot _sym = 2 * self.node[0] - self.node[1] self.node.append(_sym) - self.finish(True, cont=True) + self.finish(cont=None, closed=True) _msg(translate("draft", "Bézier curve has been closed")) @@ -349,7 +351,7 @@ class CubicBezCurve(gui_lines.Line): # then create 2 handle points? self.drawUpdate(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) # Does this make sense for a BCurve? if len(self.node) > 2: self.node[-3] = 2 * self.node[-2] - self.node[-1] @@ -377,9 +379,7 @@ class CubicBezCurve(gui_lines.Line): elif (len(self.node) - 1) % self.degree == 1 and len(self.node) > 2: # is a knot self.obj.Shape = self.updateShape(self.node[:-1]) - _msg(translate("draft", - "Click and drag to define next knot, " - "or finish (A) or close (O)")) + _msg(translate("draft", "Click and drag to define next knot")) def updateShape(self, pts): """Create shape for display during creation process.""" @@ -408,13 +408,16 @@ class CubicBezCurve(gui_lines.Line): w = Part.Wire(edges) return w - def finish(self, closed=False, cont=False): + def finish(self, cont=False, closed=False): """Terminate the operation and close the curve if asked. Parameters ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. closed: bool, optional - Close the line if `True`. + Close the curve if `True`. """ if self.ui: if hasattr(self, "bezcurvetrack"): @@ -460,7 +463,7 @@ class CubicBezCurve(gui_lines.Line): # another method that performs cleanup (superfinish) # that is not re-implemented by any of the child classes. gui_base_original.Creator.finish(self) - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() diff --git a/src/Mod/Draft/draftguitools/gui_circulararray.py b/src/Mod/Draft/draftguitools/gui_circulararray.py index 71877b75c0..2b13f59539 100644 --- a/src/Mod/Draft/draftguitools/gui_circulararray.py +++ b/src/Mod/Draft/draftguitools/gui_circulararray.py @@ -132,7 +132,7 @@ class CircularArray(gui_base.GuiCommandBase): self.callback_click) if Gui.Control.activeDialog(): Gui.Control.closeDialog() - super(CircularArray, self).finish() + self.finish() Gui.addCommand('Draft_CircularArray', CircularArray()) diff --git a/src/Mod/Draft/draftguitools/gui_clone.py b/src/Mod/Draft/draftguitools/gui_clone.py index b59bdb12c3..b50262c6f7 100644 --- a/src/Mod/Draft/draftguitools/gui_clone.py +++ b/src/Mod/Draft/draftguitools/gui_clone.py @@ -110,9 +110,9 @@ class Clone(gui_base_original.Modifier): Gui.Selection.addSelection(objects[-(1 + i)]) self.finish() - def finish(self, close=False): + def finish(self): """Terminate the operation of the tool.""" - super(Clone, self).finish(close=False) + super(Clone, self).finish() if self.moveAfterCloning: todo.ToDo.delay(Gui.runCommand, "Draft_Move") diff --git a/src/Mod/Draft/draftguitools/gui_dimensions.py b/src/Mod/Draft/draftguitools/gui_dimensions.py index 7f9949e365..7257727230 100644 --- a/src/Mod/Draft/draftguitools/gui_dimensions.py +++ b/src/Mod/Draft/draftguitools/gui_dimensions.py @@ -172,7 +172,7 @@ class Dimension(gui_base_original.Creator): return False return True - def finish(self, closed=False): + def finish(self, cont=False): """Terminate the operation.""" self.cont = None self.dir = None diff --git a/src/Mod/Draft/draftguitools/gui_edit.py b/src/Mod/Draft/draftguitools/gui_edit.py index 72e6924f88..e422988093 100644 --- a/src/Mod/Draft/draftguitools/gui_edit.py +++ b/src/Mod/Draft/draftguitools/gui_edit.py @@ -324,17 +324,14 @@ class Edit(gui_base_original.Modifier): App.ActiveDocument.recompute() - def finish(self, closed=False): + def finish(self, cont=False): """Terminate Edit Tool.""" self.unregister_selection_callback() self.unregister_editing_callbacks() self.editing = None self.finalizeGhost() Gui.Snapper.setSelectMode(False) - if self.obj and closed: - if "Closed" in self.obj.PropertiesList: - if not self.obj.Closed: - self.obj.Closed = True + if self.ui: self.removeTrackers() @@ -416,10 +413,6 @@ class Edit(gui_base_original.Modifier): # App.Console.PrintMessage("pressed key : "+str(key)+"\n") if key == 65307: # ESC self.finish() - if key == 97: # "a" - self.finish() - if key == 111: # "o" - self.finish(closed=True) if key == 101: # "e" self.display_tracker_menu(event) if key == 65535 and Gui.Selection.GetSelection() is None: # BUG: delete key activate Std::Delete command at the same time! diff --git a/src/Mod/Draft/draftguitools/gui_ellipses.py b/src/Mod/Draft/draftguitools/gui_ellipses.py index 4a7611e41d..9411703294 100644 --- a/src/Mod/Draft/draftguitools/gui_ellipses.py +++ b/src/Mod/Draft/draftguitools/gui_ellipses.py @@ -70,13 +70,20 @@ class Ellipse(gui_base_original.Creator): self.rect = trackers.rectangleTracker() _msg(translate("draft", "Pick first point")) - def finish(self, closed=False, cont=False): - """Terminate the operation.""" + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ super(Ellipse, self).finish(self) if self.ui: self.rect.off() self.rect.finalize() - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() def createObject(self): @@ -139,7 +146,7 @@ class Ellipse(gui_base_original.Creator): _cmd_list) except Exception: _err("Draft: Error: Unable to create object.") - self.finish(cont=True) + self.finish(cont=None) def action(self, arg): """Handle the 3D scene events. @@ -164,18 +171,21 @@ class Ellipse(gui_base_original.Creator): gui_tool_utils.redraw3DView() elif arg["Type"] == "SoMouseButtonEvent": if arg["State"] == "DOWN" and arg["Button"] == "BUTTON1": + if arg["Position"] == self.pos: - self.finish() - else: - if (not self.node) and (not self.support): - gui_tool_utils.getSupport(arg) - (self.point, - ctrlPoint, info) = gui_tool_utils.getPoint(self, arg, - mobile=True, - noTracker=True) - if self.point: - self.ui.redraw() - self.appendPoint(self.point) + self.finish(cont=None) + return + + if (not self.node) and (not self.support): + gui_tool_utils.getSupport(arg) + (self.point, + ctrlPoint, info) = gui_tool_utils.getPoint(self, arg, + mobile=True, + noTracker=True) + if self.point: + self.ui.redraw() + self.pos = arg["Position"] + self.appendPoint(self.point) def numericInput(self, numx, numy, numz): """Validate the entry fields in the user interface. diff --git a/src/Mod/Draft/draftguitools/gui_fillets.py b/src/Mod/Draft/draftguitools/gui_fillets.py index a54de74ff7..32f2a0f70a 100644 --- a/src/Mod/Draft/draftguitools/gui_fillets.py +++ b/src/Mod/Draft/draftguitools/gui_fillets.py @@ -58,7 +58,7 @@ class Fillet(gui_base_original.Creator): self.featureName = "Fillet" def GetResources(self): - """Set icon, menu and tooltip.""" + """Set icon, menu and tooltip.""" return {'Pixmap': 'Draft_Fillet', 'Accel':'F,I', 'MenuText': QT_TRANSLATE_NOOP("Draft_Fillet", "Fillet"), @@ -188,7 +188,7 @@ class Fillet(gui_base_original.Creator): self.commit(translate("draft", "Create fillet"), _cmd_list) - def finish(self, close=False): + def finish(self, cont=False): """Terminate the operation.""" super(Fillet, self).finish() if self.ui: diff --git a/src/Mod/Draft/draftguitools/gui_labels.py b/src/Mod/Draft/draftguitools/gui_labels.py index 362bc066b2..b33889d79a 100644 --- a/src/Mod/Draft/draftguitools/gui_labels.py +++ b/src/Mod/Draft/draftguitools/gui_labels.py @@ -86,7 +86,7 @@ class Label(gui_base_original.Creator): self.labeltype = get_label_types()[i] utils.setParam("labeltype", self.labeltype) - def finish(self, closed=False, cont=False): + def finish(self, cont=False): """Finish the command.""" if self.ghost: self.ghost.finalize() diff --git a/src/Mod/Draft/draftguitools/gui_lines.py b/src/Mod/Draft/draftguitools/gui_lines.py index 9398722502..cfe5f607bd 100644 --- a/src/Mod/Draft/draftguitools/gui_lines.py +++ b/src/Mod/Draft/draftguitools/gui_lines.py @@ -102,7 +102,8 @@ class Line(gui_base_original.Creator): and arg["State"] == "DOWN" and arg["Button"] == "BUTTON1"): if arg["Position"] == self.pos: - return self.finish(False, cont=True) + self.finish(cont=None) + return if (not self.node) and (not self.support): gui_tool_utils.getSupport(arg) (self.point, @@ -113,21 +114,24 @@ class Line(gui_base_original.Creator): self.node.append(self.point) self.drawSegment(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) if len(self.node) > 2: # The wire is closed if (self.point - self.node[0]).Length < utils.tolerance(): self.undolast() if len(self.node) > 2: - self.finish(True, cont=True) + self.finish(cont=None, closed=True) else: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) - def finish(self, closed=False, cont=False): + def finish(self, cont=False, closed=False): """Terminate the operation and close the polyline if asked. Parameters ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. closed: bool, optional Close the line if `True`. """ @@ -185,7 +189,7 @@ class Line(gui_base_original.Creator): self.commit(translate("draft", "Create Wire"), _cmd_list) super(Line, self).finish() - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() def removeTemporaryObject(self): @@ -280,7 +284,7 @@ class Line(gui_base_original.Creator): self.node.append(self.point) self.drawSegment(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) self.ui.setNextFocus() diff --git a/src/Mod/Draft/draftguitools/gui_mirror.py b/src/Mod/Draft/draftguitools/gui_mirror.py index d3c2d7f801..f0f7f01dec 100644 --- a/src/Mod/Draft/draftguitools/gui_mirror.py +++ b/src/Mod/Draft/draftguitools/gui_mirror.py @@ -92,15 +92,11 @@ class Mirror(gui_base_original.Modifier): _msg(translate("draft", "Pick start point of mirror line")) self.ui.isCopy.hide() - def finish(self, closed=False, cont=False): + def finish(self, cont=False): """Terminate the operation of the tool.""" if self.ghost: self.ghost.finalize() super(Mirror, self).finish() - if cont and self.ui: - if self.ui.continueMode: - Gui.Selection.clearSelection() - self.Activated() def mirror(self, p1, p2, copy=False): """Mirror the real shapes.""" @@ -187,7 +183,7 @@ class Mirror(gui_base_original.Modifier): if gui_tool_utils.hasMod(arg, gui_tool_utils.MODALT): self.extendedCopy = True else: - self.finish(cont=True) + self.finish() def numericInput(self, numx, numy, numz): """Validate the entry fields in the user interface. diff --git a/src/Mod/Draft/draftguitools/gui_move.py b/src/Mod/Draft/draftguitools/gui_move.py index 98a80a449a..1ede0b5e8d 100644 --- a/src/Mod/Draft/draftguitools/gui_move.py +++ b/src/Mod/Draft/draftguitools/gui_move.py @@ -102,13 +102,19 @@ class Move(gui_base_original.Modifier): self.call = self.view.addEventCallback("SoEvent", self.action) _msg(translate("draft", "Pick start point")) - def finish(self, closed=False, cont=False): - """Finish the move operation.""" + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ for ghost in self.ghosts: ghost.finalize() - if cont and self.ui: - if self.ui.continueMode: - todo.ToDo.delayAfter(self.Activated, []) + if cont or (cont is None and self.ui and self.ui.continueMode): + todo.ToDo.delayAfter(self.Activated, []) super(Move, self).finish() def action(self, arg): @@ -170,7 +176,7 @@ class Move(gui_base_original.Modifier): if gui_tool_utils.hasMod(arg, gui_tool_utils.MODALT): self.extendedCopy = True else: - self.finish(cont=True) + self.finish(cont=None) def set_ghosts(self): """Set the ghost to display.""" diff --git a/src/Mod/Draft/draftguitools/gui_offset.py b/src/Mod/Draft/draftguitools/gui_offset.py index 2d441632e1..7562ebcadd 100644 --- a/src/Mod/Draft/draftguitools/gui_offset.py +++ b/src/Mod/Draft/draftguitools/gui_offset.py @@ -264,7 +264,7 @@ class Offset(gui_base_original.Modifier): else: self.finish() - def finish(self, closed=False): + def finish(self, cont=False): """Finish the offset operation.""" if self.running: if self.linetrack: diff --git a/src/Mod/Draft/draftguitools/gui_orthoarray.py b/src/Mod/Draft/draftguitools/gui_orthoarray.py index 29a5f536a9..36c1a025ce 100644 --- a/src/Mod/Draft/draftguitools/gui_orthoarray.py +++ b/src/Mod/Draft/draftguitools/gui_orthoarray.py @@ -119,7 +119,7 @@ class OrthoArray(gui_base.GuiCommandBase): self.callback_click) if Gui.Control.activeDialog(): Gui.Control.closeDialog() - super(OrthoArray, self).finish() + self.finish() Gui.addCommand('Draft_OrthoArray', OrthoArray()) diff --git a/src/Mod/Draft/draftguitools/gui_points.py b/src/Mod/Draft/draftguitools/gui_points.py index c3daf149f6..90a076062c 100644 --- a/src/Mod/Draft/draftguitools/gui_points.py +++ b/src/Mod/Draft/draftguitools/gui_points.py @@ -148,19 +148,24 @@ class Point(gui_base_original.Creator): _cmd_list)) todo.ToDo.delayCommit(commitlist) Gui.Snapper.off() - self.finish() + self.finish(cont=None) def finish(self, cont=False): - """Terminate the operation and restart if needed.""" + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ super(Point, self).finish() if self.callbackClick: self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick) if self.callbackMove: self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove) - - if self.ui: - if self.ui.continueMode: - self.Activated() + if cont or (cont is None and self.ui and self.ui.continueMode): + self.Activated() Gui.addCommand('Draft_Point', Point()) diff --git a/src/Mod/Draft/draftguitools/gui_polararray.py b/src/Mod/Draft/draftguitools/gui_polararray.py index a7f29f676f..2f6b1ddc46 100644 --- a/src/Mod/Draft/draftguitools/gui_polararray.py +++ b/src/Mod/Draft/draftguitools/gui_polararray.py @@ -132,7 +132,7 @@ class PolarArray(gui_base.GuiCommandBase): self.callback_click) if Gui.Control.activeDialog(): Gui.Control.closeDialog() - super(PolarArray, self).finish() + self.finish() Gui.addCommand('Draft_PolarArray', PolarArray()) diff --git a/src/Mod/Draft/draftguitools/gui_polygons.py b/src/Mod/Draft/draftguitools/gui_polygons.py index b3b62e9fa6..26e08c85b1 100644 --- a/src/Mod/Draft/draftguitools/gui_polygons.py +++ b/src/Mod/Draft/draftguitools/gui_polygons.py @@ -77,14 +77,21 @@ class Polygon(gui_base_original.Creator): self.call = self.view.addEventCallback("SoEvent", self.action) _msg(translate("draft", "Pick center point")) - def finish(self, closed=False, cont=False): - """Terminate the operation.""" + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ super(Polygon, self).finish(self) if self.ui: self.arctrack.finalize() self.doc.recompute() - if self.ui.continueMode: - self.Activated() + if cont or (cont is None and self.ui and self.ui.continueMode): + self.Activated() def action(self, arg): """Handle the 3D scene events. @@ -242,7 +249,7 @@ class Polygon(gui_base_original.Creator): 'FreeCAD.ActiveDocument.recompute()'] self.commit(translate("draft", "Create Polygon"), _cmd_list) - self.finish(cont=True) + self.finish(cont=None) def numericInput(self, numx, numy, numz): """Validate the entry fields in the user interface. diff --git a/src/Mod/Draft/draftguitools/gui_rectangles.py b/src/Mod/Draft/draftguitools/gui_rectangles.py index 3d9776fb1a..39797030fc 100644 --- a/src/Mod/Draft/draftguitools/gui_rectangles.py +++ b/src/Mod/Draft/draftguitools/gui_rectangles.py @@ -68,10 +68,14 @@ class Rectangle(gui_base_original.Creator): self.rect = trackers.rectangleTracker() _msg(translate("draft", "Pick first point")) - def finish(self, closed=False, cont=False): + def finish(self, cont=False): """Terminate the operation. - The arguments of this function are not used and should be removed. + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. """ super(Rectangle, self).finish() if self.ui: @@ -80,8 +84,8 @@ class Rectangle(gui_base_original.Creator): del self.fillstate self.rect.off() self.rect.finalize() - if self.ui.continueMode: - self.Activated() + if cont or (cont is None and self.ui and self.ui.continueMode): + self.Activated() def createObject(self): """Create the final object in the current document.""" @@ -143,7 +147,7 @@ class Rectangle(gui_base_original.Creator): _cmd_list) except Exception: _err("Draft: error delaying commit") - self.finish(cont=True) + self.finish(cont=None) def action(self, arg): """Handle the 3D scene events. @@ -171,7 +175,8 @@ class Rectangle(gui_base_original.Creator): and arg["Button"] == "BUTTON1"): if arg["Position"] == self.pos: - self.finish() + self.finish(cont=None) + return if (not self.node) and (not self.support): gui_tool_utils.getSupport(arg) @@ -181,6 +186,7 @@ class Rectangle(gui_base_original.Creator): noTracker=True) if self.point: self.ui.redraw() + self.pos = arg["Position"] self.appendPoint(self.point) def numericInput(self, numx, numy, numz): diff --git a/src/Mod/Draft/draftguitools/gui_rotate.py b/src/Mod/Draft/draftguitools/gui_rotate.py index 709f5f4964..0a5c932f9d 100644 --- a/src/Mod/Draft/draftguitools/gui_rotate.py +++ b/src/Mod/Draft/draftguitools/gui_rotate.py @@ -230,7 +230,7 @@ class Rotate(gui_base_original.Modifier): if gui_tool_utils.hasMod(arg, gui_tool_utils.MODALT): self.extendedCopy = True else: - self.finish(cont=True) + self.finish(cont=None) def set_ghosts(self): """Set the ghost to display.""" @@ -255,15 +255,21 @@ class Rotate(gui_base_original.Modifier): ghosts.append(trackers.ghostTracker(subelement)) return ghosts - def finish(self, closed=False, cont=False): - """Finish the rotate operation.""" + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ if self.arctrack: self.arctrack.finalize() for ghost in self.ghosts: ghost.finalize() - if cont and self.ui: - if self.ui.continueMode: - todo.ToDo.delayAfter(self.Activated, []) + if cont or (cont is None and self.ui and self.ui.continueMode): + todo.ToDo.delayAfter(self.Activated, []) super(Rotate, self).finish() if self.doc: self.doc.recompute() @@ -419,7 +425,7 @@ class Rotate(gui_base_original.Modifier): else: self.angle = math.radians(rad) self.rotate(self.ui.isCopy.isChecked()) - self.finish(cont=True) + self.finish(cont=None) Gui.addCommand('Draft_Rotate', Rotate()) diff --git a/src/Mod/Draft/draftguitools/gui_scale.py b/src/Mod/Draft/draftguitools/gui_scale.py index 7bd08c68c9..73ff6c4c3c 100644 --- a/src/Mod/Draft/draftguitools/gui_scale.py +++ b/src/Mod/Draft/draftguitools/gui_scale.py @@ -418,7 +418,7 @@ class Scale(gui_base_original.Modifier): self.task.lock.setChecked(True) self.task.setValue(d2/d1) - def finish(self, closed=False, cont=False): + def finish(self, cont=False): """Terminate the operation.""" super(Scale, self).finish() for ghost in self.ghosts: diff --git a/src/Mod/Draft/draftguitools/gui_selectplane.py b/src/Mod/Draft/draftguitools/gui_selectplane.py index 1017e0c419..40efeb17d7 100644 --- a/src/Mod/Draft/draftguitools/gui_selectplane.py +++ b/src/Mod/Draft/draftguitools/gui_selectplane.py @@ -150,7 +150,7 @@ class Draft_SelectPlane: "Pick a face, 3 vertices or a WP Proxy to define the drawing plane")) self.call = self.view.addEventCallback("SoEvent", self.action) - def finish(self, close=False): + def finish(self): """Execute when the command is terminated.""" # Store values self.param.SetBool("CenterPlaneOnView", diff --git a/src/Mod/Draft/draftguitools/gui_shapestrings.py b/src/Mod/Draft/draftguitools/gui_shapestrings.py index 3fec8ee023..c2b3034fc6 100644 --- a/src/Mod/Draft/draftguitools/gui_shapestrings.py +++ b/src/Mod/Draft/draftguitools/gui_shapestrings.py @@ -85,7 +85,6 @@ class ShapeString(gui_base_original.Creator): _msg(translate("draft", "Pick ShapeString location point")) todo.ToDo.delay(Gui.Control.showDialog, self.task) else: - self.dialog = None self.text = '' self.ui.sourceCmd = self self.ui.pointUi(title=translate("draft",self.featureName), @@ -98,6 +97,8 @@ class ShapeString(gui_base_original.Creator): _msg(translate("draft", "Pick ShapeString location point")) Gui.draftToolBar.show() + # The createObject function is no longer used. + # See the function with the same name in task_shapestring.py. def createObject(self): """Create the actual object in the current document.""" # print("debug: D_T ShapeString.createObject type(self.SString):" @@ -210,14 +211,6 @@ class ShapeString(gui_base_original.Creator): # last step in ShapeString parm capture, create object self.createObject() - def finish(self, finishbool=False): - """Terminate the operation.""" - super(ShapeString, self).finish() - if self.ui: - # del self.dialog # what does this do?? - if self.ui.continueMode: - self.Activated() - Gui.addCommand('Draft_ShapeString', ShapeString()) diff --git a/src/Mod/Draft/draftguitools/gui_splines.py b/src/Mod/Draft/draftguitools/gui_splines.py index ba013b2db3..0e883ec271 100644 --- a/src/Mod/Draft/draftguitools/gui_splines.py +++ b/src/Mod/Draft/draftguitools/gui_splines.py @@ -94,7 +94,8 @@ class BSpline(gui_lines.Line): and arg["State"] == "DOWN" and arg["Button"] == "BUTTON1"): if arg["Position"] == self.pos: - self.finish(False, cont=True) + self.finish(cont=None) + return if (not self.node) and (not self.support): gui_tool_utils.getSupport(arg) @@ -107,7 +108,7 @@ class BSpline(gui_lines.Line): self.node.append(self.point) self.drawUpdate(self.point) if not self.isWire and len(self.node) == 2: - self.finish(False, cont=True) + self.finish(cont=None, closed=False) if len(self.node) > 2: # DNC: allows to close the curve # by placing ends close to each other @@ -115,9 +116,8 @@ class BSpline(gui_lines.Line): # old code has been to insensitive if (self.point - self.node[0]).Length < utils.tolerance(): self.undolast() - self.finish(True, cont=True) - _msg(translate("draft", - "Spline has been closed")) + self.finish(cont=None, closed=True) + _msg(translate("draft", "Spline has been closed")) def undolast(self): """Undo last line segment.""" @@ -142,17 +142,18 @@ class BSpline(gui_lines.Line): spline = Part.BSplineCurve() spline.interpolate(self.node, False) self.obj.Shape = spline.toShape() - _msg(translate("draft", - "Pick next point, " - "or finish (A) or close (O)")) + _msg(translate("draft", "Pick next point")) - def finish(self, closed=False, cont=False): + def finish(self, cont=False, closed=False): """Terminate the operation and close the spline if asked. Parameters ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. closed: bool, optional - Close the line if `True`. + Close the spline if `True`. """ if self.ui: self.bsplinetrack.finalize() @@ -192,7 +193,7 @@ class BSpline(gui_lines.Line): # another method that performs cleanup (superfinish) # that is not re-implemented by any of the child classes. gui_base_original.Creator.finish(self) - if self.ui and self.ui.continueMode: + if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index 17aa462883..10a0195d0c 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -254,7 +254,7 @@ class Stretch(gui_base_original.Modifier): point = App.Vector(numx, numy, numz) self.addPoint(point) - def finish(self, closed=False): + def finish(self, cont=False): """Terminate the operation of the command. and clean up.""" if self.rectracker: self.rectracker.finalize() diff --git a/src/Mod/Draft/draftguitools/gui_styles.py b/src/Mod/Draft/draftguitools/gui_styles.py index 0636cd01f8..f32930fdbc 100644 --- a/src/Mod/Draft/draftguitools/gui_styles.py +++ b/src/Mod/Draft/draftguitools/gui_styles.py @@ -74,7 +74,7 @@ class ApplyStyle(gui_base_original.Modifier): _cmd_list.append(_cmd) self.commit(translate("draft", "Change Style"), _cmd_list) - super(ApplyStyle, self).finish() + self.finish() def formatGroup(self, group): """Format a group instead of simple object.""" diff --git a/src/Mod/Draft/draftguitools/gui_texts.py b/src/Mod/Draft/draftguitools/gui_texts.py index 5fdbb3e162..7f69bd8e96 100644 --- a/src/Mod/Draft/draftguitools/gui_texts.py +++ b/src/Mod/Draft/draftguitools/gui_texts.py @@ -64,7 +64,6 @@ class Text(gui_base_original.Creator): """Execute when the command is called.""" super(Text, self).Activated(name="Text") if self.ui: - self.dialog = None self.text = '' self.ui.sourceCmd = self self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Text") @@ -77,13 +76,18 @@ class Text(gui_base_original.Creator): _msg(translate("draft", "Pick location point")) Gui.draftToolBar.show() - def finish(self, closed=False, cont=False): - """Terminate the operation.""" + def finish(self, cont=False): + """Terminate the operation. + + Parameters + ---------- + cont: bool or None, optional + Restart (continue) the command if `True`, or if `None` and + `ui.continueMode` is `True`. + """ super(Text, self).finish(self) - if self.ui: - del self.dialog - if self.ui.continueMode: - self.Activated() + if cont or (cont is None and self.ui and self.ui.continueMode): + self.Activated() def createObject(self): """Create the actual object in the current document.""" @@ -120,7 +124,7 @@ class Text(gui_base_original.Creator): 'FreeCAD.ActiveDocument.recompute()'] self.commit(translate("draft", "Create Text"), _cmd_list) - self.finish(cont=True) + self.finish(cont=None) def action(self, arg): """Handle the 3D scene events. diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index fd809ea63d..42ec8c081e 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -547,7 +547,7 @@ class Trimex(gui_base_original.Modifier): obj.FirstAngle = ang self.doc.recompute() - def finish(self, closed=False): + def finish(self, cont=False): """Terminate the operation of the Trimex tool.""" super(Trimex, self).finish() self.force = None