Draft: Std_TransformManip should not be called from setEdit (#9375)

The object then seems to be put into edit mode twice (?) and Esc will not cancel the command.
This commit is contained in:
Roy-043
2023-05-07 09:57:10 +02:00
committed by GitHub
parent 6d59f9fa78
commit bd3f71b478
4 changed files with 37 additions and 16 deletions

View File

@@ -1081,6 +1081,11 @@ class ViewProviderPanelCut(Draft.ViewProviderDraft):
self.onChanged(obj.ViewObject,"Margin")
Draft.ViewProviderDraft.updateData(self,obj,prop)
def doubleClicked(self,vobj):
# See setEdit in ViewProviderDraft.
FreeCADGui.runCommand("Std_TransformManip")
return True
class PanelSheet(Draft.DraftObject):

View File

@@ -388,20 +388,23 @@ class ViewProviderDraft(object):
if mode == 1 or mode == 2:
return None
tp = utils.get_type(vobj.Object)
# Fillet, Point, Shape2DView and PanelCut objects rely on a doubleClicked
# function which takes precedence over all double-click edit modes. This
# is a workaround as calling Gui.runCommand("Std_TransformManip") from
# setEdit does not work properly. The object then seems to be put into
# edit mode twice (?) and Esc will not cancel the command.
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
"BSpline", "BezCurve"): # Facebinder, ShapeString, PanelSheet and Profile objects have their own setEdit.
# Facebinder, ShapeString, PanelSheet and Profile objects have their own
# setEdit and unsetEdit.
if utils.get_type(vobj.Object) in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
"BSpline", "BezCurve"):
if not "Draft_Edit" in Gui.listCommands():
self.wb_before_edit = Gui.activeWorkbench()
Gui.activateWorkbench("DraftWorkbench")
Gui.runCommand("Draft_Edit")
return True
if tp in ("Fillet", "Point", "Shape2DView", "PanelCut"):
Gui.runCommand("Std_TransformManip")
return True
return None
def unsetEdit(self, vobj, mode):
@@ -412,10 +415,8 @@ class ViewProviderDraft(object):
if mode == 1 or mode == 2:
return None
tp = utils.get_type(vobj.Object)
if tp in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
"BSpline", "BezCurve"): # Facebinder, ShapeString, PanelSheet and Profile objects have their own unsetEdit.
if utils.get_type(vobj.Object) in ("Wire", "Circle", "Ellipse", "Rectangle", "Polygon",
"BSpline", "BezCurve"):
if hasattr(App, "activeDraftCommand") and App.activeDraftCommand:
App.activeDraftCommand.finish()
Gui.Control.closeDialog()
@@ -424,9 +425,6 @@ class ViewProviderDraft(object):
delattr(self, "wb_before_edit")
return True
if tp in ("Fillet", "Point", "Shape2DView", "PanelCut"):
return True
return None
def setupContextMenu(self, vobj, menu):
@@ -542,15 +540,21 @@ class ViewProviderDraftAlt(ViewProviderDraft):
The `claimChildren` method is overridden to return an empty list.
The `doubleClicked` method is defined.
Only used by the `Shape2DView` object.
"""
def __init__(self, vobj):
super(ViewProviderDraftAlt, self).__init__(vobj)
def doubleClicked(self, vobj):
# See setEdit in ViewProviderDraft.
Gui.runCommand("Std_TransformManip")
return True
def claimChildren(self):
objs = []
return objs
return []
# Alias for compatibility with v0.18 and earlier

View File

@@ -39,5 +39,11 @@ class ViewProviderFillet(ViewProviderWire):
def __init__(self, vobj):
super(ViewProviderFillet, self).__init__(vobj)
def doubleClicked(self, vobj):
# See setEdit in ViewProviderDraft.
import FreeCADGui as Gui
Gui.runCommand("Std_TransformManip")
return True
## @}

View File

@@ -52,6 +52,12 @@ class ViewProviderPoint(ViewProviderDraft):
def getIcon(self):
return ":/icons/Draft_Dot.svg"
def doubleClicked(self, vobj):
# See setEdit in ViewProviderDraft.
import FreeCADGui as Gui
Gui.runCommand("Std_TransformManip")
return True
# Alias for compatibility with v0.18 and earlier
_ViewProviderPoint = ViewProviderPoint