Skip to content

Commit ee3a5a6

Browse files
committed
Draft: Draft_Point minor consistency update
1 parent af9c60f commit ee3a5a6

File tree

1 file changed

+25
-35
lines changed

1 file changed

+25
-35
lines changed

src/Mod/Draft/draftguitools/gui_points.py

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def GetResources(self):
6565
def Activated(self):
6666
"""Execute when the command is called."""
6767
super().Activated(name="Point")
68-
self.stack = []
6968
if self.ui:
7069
self.ui.pointUi(title=translate("draft", self.featureName), icon="Draft_Point")
7170
self.ui.isRelative.hide()
@@ -108,39 +107,30 @@ def click(self, event_cb=None):
108107
event.getButton() != event.BUTTON1):
109108
return
110109
if self.point:
111-
self.stack.append(self.point)
112-
if len(self.stack) == 1:
113-
# The command to run is built as a series of text strings
114-
# to be committed through the `draftutils.todo.ToDo` class.
115-
commitlist = []
116-
Gui.addModule("Draft")
117-
if params.get_param("UsePartPrimitives"):
118-
# Insert a Part::Primitive object
119-
_cmd = 'FreeCAD.ActiveDocument.'
120-
_cmd += 'addObject("Part::Vertex", "Point")'
121-
_cmd_list = ['point = ' + _cmd,
122-
'point.X = ' + str(self.stack[0][0]),
123-
'point.Y = ' + str(self.stack[0][1]),
124-
'point.Z = ' + str(self.stack[0][2]),
125-
'Draft.autogroup(point)',
126-
'FreeCAD.ActiveDocument.recompute()']
127-
commitlist.append((translate("draft", "Create Point"),
128-
_cmd_list))
129-
else:
130-
# Insert a Draft point
131-
_cmd = 'Draft.make_point'
132-
_cmd += '('
133-
_cmd += str(self.stack[0][0]) + ', '
134-
_cmd += str(self.stack[0][1]) + ', '
135-
_cmd += str(self.stack[0][2])
136-
_cmd += ')'
137-
_cmd_list = ['point = ' + _cmd,
138-
'Draft.autogroup(point)',
139-
'FreeCAD.ActiveDocument.recompute()']
140-
commitlist.append((translate("draft", "Create Point"),
141-
_cmd_list))
142-
todo.ToDo.delayCommit(commitlist)
143-
Gui.Snapper.off()
110+
Gui.addModule("Draft")
111+
if params.get_param("UsePartPrimitives"):
112+
# Insert a Part::Primitive object
113+
_cmd = 'FreeCAD.ActiveDocument.'
114+
_cmd += 'addObject("Part::Vertex", "Point")'
115+
_cmd_list = ['point = ' + _cmd,
116+
'point.X = ' + str(self.point[0]),
117+
'point.Y = ' + str(self.point[1]),
118+
'point.Z = ' + str(self.point[2]),
119+
'Draft.autogroup(point)',
120+
'FreeCAD.ActiveDocument.recompute()']
121+
self.commit(translate("draft", "Create Point"), _cmd_list)
122+
else:
123+
# Insert a Draft point
124+
_cmd = 'Draft.make_point'
125+
_cmd += '('
126+
_cmd += str(self.point[0]) + ', '
127+
_cmd += str(self.point[1]) + ', '
128+
_cmd += str(self.point[2])
129+
_cmd += ')'
130+
_cmd_list = ['point = ' + _cmd,
131+
'Draft.autogroup(point)',
132+
'FreeCAD.ActiveDocument.recompute()']
133+
self.commit(translate("draft", "Create Point"), _cmd_list)
144134
self.finish(cont=None)
145135

146136
def finish(self, cont=False):
@@ -152,11 +142,11 @@ def finish(self, cont=False):
152142
Restart (continue) the command if `True`, or if `None` and
153143
`ui.continueMode` is `True`.
154144
"""
155-
super().finish()
156145
if self.callbackClick:
157146
self.view.removeEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.callbackClick)
158147
if self.callbackMove:
159148
self.view.removeEventCallbackPivy(coin.SoLocation2Event.getClassTypeId(), self.callbackMove)
149+
super().finish()
160150
if cont or (cont is None and self.ui and self.ui.continueMode):
161151
self.Activated()
162152

0 commit comments

Comments
 (0)