Related: #17952.
This PR introduces a document observer to close task panels on doc close.
For now it is for the Draft Workbench only. The BIM Workbench will be dealt with in a future PR.
The basic code is simple, but to make things works some additional things were addressed:
* gui_base.py: the GuiCommandBase class was enhanced to handle App.activeDraftCommand, self.doc, self.view and self.planetracker. Strictly speaking only the first 2 are required for this PR.
* gui_base.py: self.command_name was changed to self.featureName for compatibility with gui_base_original.py. Not required for this PR.
* gui_arcs.py, gui_circulararray.py, gui_polararray.py and gui_orthoarray.py: updated in relation to the GuiCommandBase class.
* gui_arcs.py Arc_3Points: The command now has a ui property and shows a plane tracker. Only the first is required for this PR.
* gui_shapestrings.py: This command had two ui attributes: self.ui and self.task. This was problematic. To fix this the base class of the command was changed from gui_base_original.Creator to gui_base.GuiCommandBase. As a result the getStrings method is no longer available meaning that the useSupport parameter is ignored when creating a ShapeString. But since that mechanism does not work properly anyway, I feel that this is acceptable. Should many user complain the functionality can of course be reintroduced.
Avoid `Draft.py` in the `make_circular_array` function because
it creates a circular dependency.
Use function to find the object in `make_circular_array`.
Now the make function accepts as input a `"String"` which must be
the `Label` of an object in the document, so it is easier to create
arrays interactively from the Python console.
Clean up the GuiCommand and task panel code, and avoid printing
messages to the terminal, as this is already done
by the make function.
In Python 3 `super()` can be used without an argument
in order to get the parent class, `super()`.
In Python 2 the present class must be used as an argument,
`super(ThisClass, self)`.
This commit is done to support Python 2,
as without it all Gui Command tools will be broken
and will fail to launch, even if the unit tests pass.
Also, set the `__metaclass__` variable to `type`.
This is done to turn all classes into "new style" classes
in Python 2. This is required so `super()` works correctly
in this version of Pyton.
This commit can be reverted once Python 2 support
is completely dropped, and only Python 3 compatible code
is used.
The internal GuiCommand classes are renamed to `CircularArray`,
`OrthoArray`, and `PolarArray`. This is a shorter name than the
previous `GuiCommandCircularArray`, `GuiCommandOrthoArray`,
and `GuiCommandPolarArray`.
These classes are not part of the scripting interface of Draft
so we don't risk breaking previous files.
Small spacing fixes like imports in separate lines
for more clarity, the module docstring,
and the position of the license.
Remove unnecessary check for the graphical interface
as this command should be imported when the interface
is already up and running.
Use proper `ToDo` class instead of importing `DraftGui`.