def updateGhost(self, obj, node_idx, v): self.ghost.on() if self.current_editing_object_gui_tools: self.current_editing_object_gui_tools.update_preview_object(self, obj, node_idx, v) gui_tool_utils.redraw_3d_view()
def update(self, obj, nodeIndex, v): """Apply the App.Vector to the modified point and update obj.""" v = self.localize_vector(obj, v) App.ActiveDocument.openTransaction("Edit") self.update_object(obj, nodeIndex, v) App.ActiveDocument.commitTransaction() self.resetTrackers(obj) try: gui_tool_utils.redraw_3d_view() except AttributeError as err: pass
def endEditing(self, obj, nodeIndex, v=None): """Terminate editing and start object updating process.""" self.finalizeGhost() self.trackers[obj.Name][nodeIndex].on() Gui.Snapper.setSelectMode(True) if v is None: # endEditing is called by mousePressed v = self.trackers[obj.Name][nodeIndex].get() else: # endEditing is called by numericInput, so tracker # position should be updated manually self.trackers[obj.Name][nodeIndex].set(v) self.update(obj, nodeIndex, v) self.alt_edit_mode = 0 self.ui.editUi(self.ui.lastMode) self.node = [] self.editing = None self.showTrackers() gui_tool_utils.redraw_3d_view()
def updateGhost(self, obj, idx, pt): if utils.get_type(obj) in ["Wire"]: self.ghost.on() pointList = self.globalize_vectors(obj, obj.Points) pointList[idx] = pt if obj.Closed: pointList.append(pointList[0]) self.ghost.updateFromPointlist(pointList) elif utils.get_type(obj) == "BSpline": self.ghost.on() pointList = self.globalize_vectors(obj, obj.Points) pointList[idx] = pt if obj.Closed: pointList.append(pointList[0]) self.ghost.update(pointList) elif utils.get_type(obj) == "BezCurve": self.ghost.on() plist = self.globalize_vectors(obj, obj.Points) pointList = edit_draft.recomputePointsBezier(obj,plist,idx,pt,obj.Degree,moveTrackers=False) self.ghost.update(pointList,obj.Degree) elif utils.get_type(obj) == "Circle": self.ghost.on() self.ghost.setCenter(obj.getGlobalPlacement().Base) self.ghost.setRadius(obj.Radius) if obj.FirstAngle == obj.LastAngle: # obj is a circle self.ghost.circle = True if self.editing == 0: self.ghost.setCenter(pt) elif self.editing == 1: radius = pt.sub(obj.getGlobalPlacement().Base).Length self.ghost.setRadius(radius) else: if self.alt_edit_mode == 0: # edit by 3 points if self.editing == 0: # center point p1 = self.relativize_vector(obj, obj.Shape.Vertexes[0].Point) p2 = self.relativize_vector(obj, obj.Shape.Vertexes[1].Point) p0 = DraftVecUtils.project(self.relativize_vector(obj, pt), self.relativize_vector(obj, (edit_draft.getArcMid(obj, global_placement=True)))) self.ghost.autoinvert=False self.ghost.setRadius(p1.sub(p0).Length) self.ghost.setStartPoint(obj.Shape.Vertexes[1].Point) self.ghost.setEndPoint(obj.Shape.Vertexes[0].Point) self.ghost.setCenter(self.globalize_vector(obj, p0)) return else: p1 = edit_draft.getArcStart(obj, global_placement=True) p2 = edit_draft.getArcMid(obj, global_placement=True) p3 = edit_draft.getArcEnd(obj, global_placement=True) if self.editing == 1: p1=pt elif self.editing == 3: p2=pt elif self.editing == 2: p3=pt self.ghost.setBy3Points(p1,p2,p3) elif self.alt_edit_mode == 1: # edit by center radius angles self.ghost.setStartAngle(math.radians(obj.FirstAngle)) self.ghost.setEndAngle(math.radians(obj.LastAngle)) if self.editing == 0: self.ghost.setCenter(pt) elif self.editing == 1: self.ghost.setStartPoint(pt) elif self.editing == 2: self.ghost.setEndPoint(pt) elif self.editing == 3: self.ghost.setRadius(self.relativize_vector(obj, pt).Length) gui_tool_utils.redraw_3d_view()