Draft: Fixed Draft edit again! (better this time...)

This commit is contained in:
Yorik van Havre 2014-01-13 17:54:45 -02:00
parent c1aea6337c
commit 96ff9e37c2

View File

@ -531,6 +531,7 @@ class Line(Creator):
else: else:
currentshape = self.obj.Shape.copy() currentshape = self.obj.Shape.copy()
last = self.node[len(self.node)-2] last = self.node[len(self.node)-2]
if not DraftVecUtils.equals(last,point):
newseg = Part.Line(last,point).toShape() newseg = Part.Line(last,point).toShape()
newshape=currentshape.fuse(newseg) newshape=currentshape.fuse(newseg)
self.obj.Shape = newshape self.obj.Shape = newshape
@ -3177,27 +3178,28 @@ class Edit(Modifier):
self.point,ctrlPoint,info = getPoint(self,arg) self.point,ctrlPoint,info = getPoint(self,arg)
if self.editing != None: if self.editing != None:
self.trackers[self.editing].set(self.point) self.trackers[self.editing].set(self.point)
self.update(self.trackers[self.editing].get()) # commented out the following line to disable updating
# the object during edit, otherwise it confuses the snapper
#self.update(self.trackers[self.editing].get())
elif arg["Type"] == "SoMouseButtonEvent": elif arg["Type"] == "SoMouseButtonEvent":
if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"):
self.ui.redraw() self.ui.redraw()
if self.editing == None: if self.editing == None:
sel = FreeCADGui.Selection.getSelectionEx() p = FreeCADGui.ActiveDocument.ActiveView.getCursorPos()
if sel: info = FreeCADGui.ActiveDocument.ActiveView.getObjectInfo(p)
sel = sel[0] if info:
if sel.ObjectName == self.obj.Name: if info["Object"] == self.obj.Name:
if self.ui.addButton.isChecked(): if self.ui.addButton.isChecked():
if self.point: if self.point:
self.pos = arg["Position"] self.pos = arg["Position"]
self.addPoint(self.point) self.addPoint(self.point)
elif self.ui.delButton.isChecked(): elif self.ui.delButton.isChecked():
if sel.SubElementNames: if 'EditNode' in info["Component"]:
if 'EditNode' in sel.SubElementNames[0]: self.delPoint(int(info["Component"][8:]))
self.delPoint(int(sel.SubElementNames[0][8:])) elif 'EditNode' in info["Component"]:
elif 'EditNode' in sel.SubElementNames[0]:
self.ui.pointUi() self.ui.pointUi()
self.ui.isRelative.show() self.ui.isRelative.show()
self.editing = int(sel.SubElementNames[0][8:]) self.editing = int(info["Component"][8:])
self.trackers[self.editing].off() self.trackers[self.editing].off()
if hasattr(self.obj.ViewObject,"Selectable"): if hasattr(self.obj.ViewObject,"Selectable"):
self.obj.ViewObject.Selectable = False self.obj.ViewObject.Selectable = False
@ -3288,6 +3290,7 @@ class Edit(Modifier):
self.doc.openTransaction("Edit "+self.obj.Name) self.doc.openTransaction("Edit "+self.obj.Name)
self.update(v) self.update(v)
self.doc.commitTransaction() self.doc.commitTransaction()
self.doc.recompute()
self.editing = None self.editing = None
self.ui.editUi() self.ui.editUi()
self.node = [] self.node = []