Draft: close task panels on doc close
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.
This commit is contained in:
@@ -142,7 +142,6 @@ class ShapeStringTaskPanelCmd(ShapeStringTaskPanel):
|
||||
|
||||
def reject(self):
|
||||
"""Run when clicking the Cancel button."""
|
||||
Gui.ActiveDocument.resetEdit()
|
||||
self.sourceCmd.finish()
|
||||
self.platWinDialog("Restore")
|
||||
return True
|
||||
@@ -160,15 +159,14 @@ class ShapeStringTaskPanelCmd(ShapeStringTaskPanel):
|
||||
z = App.Units.Quantity(self.form.sbZ.text()).Value
|
||||
ssBase = App.Vector(x, y, z)
|
||||
try:
|
||||
qr, sup, points, fil = self.sourceCmd.getStrings()
|
||||
Gui.addModule("Draft")
|
||||
Gui.addModule("WorkingPlane")
|
||||
self.sourceCmd.commit(translate('draft', 'Create ShapeString'),
|
||||
['ss = Draft.make_shapestring(String=' + String + ', FontFile=' + FFile + ', Size=' + Size + ', Tracking=' + Tracking + ')',
|
||||
'plm = FreeCAD.Placement()',
|
||||
'plm.Base = ' + toString(ssBase),
|
||||
'plm.Rotation.Q = ' + qr,
|
||||
'ss.Placement = plm',
|
||||
'ss.AttachmentSupport = ' + sup,
|
||||
'pl = FreeCAD.Placement()',
|
||||
'pl.Base = ' + toString(ssBase),
|
||||
'pl.Rotation = WorkingPlane.get_working_plane().get_placement().Rotation',
|
||||
'ss.Placement = pl',
|
||||
'Draft.autogroup(ss)',
|
||||
'FreeCAD.ActiveDocument.recompute()'])
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user