From 9f5e215751cd6b0e3adf549019a567a63eb6281e Mon Sep 17 00:00:00 2001 From: vocx-fc Date: Mon, 30 Mar 2020 02:09:19 -0600 Subject: [PATCH] Draft: move Creator class to gui_base_original module --- src/Mod/Draft/DraftTools.py | 11 +----- .../Draft/draftguitools/gui_base_original.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index 18ab76699d..69c88b5b67 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -148,17 +148,8 @@ from draftguitools.gui_base_original import DraftTool # --------------------------------------------------------------------------- from draftguitools.gui_tool_utils import redraw3DView +from draftguitools.gui_base_original import Creator -class Creator(DraftTool): - """A generic Draft Creator Tool used by creation tools such as line or arc""" - - def __init__(self): - DraftTool.__init__(self) - - def Activated(self,name="None",noplanesetup=False): - DraftTool.Activated(self,name,noplanesetup) - if not noplanesetup: - self.support = getSupport() class Line(Creator): """The Line FreeCAD command definition""" diff --git a/src/Mod/Draft/draftguitools/gui_base_original.py b/src/Mod/Draft/draftguitools/gui_base_original.py index 77ffcde084..c0bc6aa968 100644 --- a/src/Mod/Draft/draftguitools/gui_base_original.py +++ b/src/Mod/Draft/draftguitools/gui_base_original.py @@ -38,6 +38,7 @@ import draftutils.utils as utils import draftutils.gui_utils as gui_utils import draftutils.todo as todo import draftguitools.gui_trackers as trackers +import draftguitools.gui_tool_utils as gui_tool_utils from draftutils.messages import _msg, _log @@ -251,3 +252,36 @@ class DraftTool: fil = "True" return qr, sup, points, fil + + +class Creator(DraftTool): + """A generic Creator tool, used by creation tools such as line or arc. + + It runs the Activated method from the parent class. + If `noplanesetup` is `False`, it sets the appropriate `support` attribute + and sets the working plane with `gui_tool_utils.get_support`. + + It inherits `DraftTool`, which sets up the majority of the behavior + of this class. + """ + + def __init__(self): + super().__init__() + + def Activated(self, name="None", noplanesetup=False): + """Execute when the command is called. + + Parameters + ---------- + name: str, optional + It defaults to `'None'`. + It is the `featureName` of the object, to know what is being run. + + noplanesetup: bool, optional + It defaults to `False`. + If it is `False` it will set up the working plane + by running `App.DraftWorkingPlane.setup()`. + """ + super().Activated(name, noplanesetup) + if not noplanesetup: + self.support = gui_tool_utils.get_support()