def action(self, arg): #re-defintition of the method of parent "scene event handler" if arg["Type"] == "SoKeyboardEvent" and arg["State"] == 'DOWN': # key detection if arg["Key"] == "ESCAPE": self.finish() elif arg["ShiftDown"] and arg["CtrlDown"]: if arg["Key"] in ('M', 'm'): if self.hackedUI.cb1.isChecked(): self.hackedUI.cb1.setChecked(False) else: self.hackedUI.cb1.setChecked(True) elif arg["Key"] in ('O', 'o'): self.offsetWP() elif arg["Key"] in ('R', 'r'): self.rotateWP() elif arg["Type"] == "SoLocation2Event": # mouse movement detection self.point, ctrlPoint, info = DraftTools.getPoint(self, arg) elif arg["Type"] == "SoMouseButtonEvent": # mouse button detection if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): if (arg["Position"] == self.pos): self.finish(False, cont=True) else: if (not self.node) and (not self.support): DraftTools.getSupport(arg) self.point, ctrlPoint, info = DraftTools.getPoint( self, arg) if self.point: self.ui.redraw() self.pos = arg["Position"] self.node.append(self.point) self.drawSegment(self.point) if self.hackedUI.cb1.isChecked(): rot = FreeCAD.DraftWorkingPlane.getPlacement( ).Rotation normal = rot.multVec(FreeCAD.Vector(0, 0, 1)) FreeCAD.DraftWorkingPlane.alignToPointAndAxis( self.point, normal) FreeCADGui.Snapper.setGrid() if (not self.isWire and len(self.node) == 2): self.finish(False, cont=True) if (len(self.node) > 2): if ((self.point - self.node[0]).Length < Draft.tolerance()): self.undolast() self.finish(True, cont=True)
def action(self,arg): #re-defintition of the method of parent "scene event handler" if arg["Type"] == "SoKeyboardEvent" and arg["State"]=='DOWN': # key detection if arg["Key"] == "ESCAPE": self.finish() elif arg["ShiftDown"] and arg["CtrlDown"]: if arg["Key"] in ('M','m'): if self.hackedUI.cb1.isChecked(): self.hackedUI.cb1.setChecked(False) else: self.hackedUI.cb1.setChecked(True) elif arg["Key"] in ('O','o'): self.offsetWP() elif arg["Key"] in ('R','r'): self.rotateWP() elif arg["Type"] == "SoLocation2Event": # mouse movement detection self.point,ctrlPoint,info = DraftTools.getPoint(self,arg) elif arg["Type"] == "SoMouseButtonEvent": # mouse button detection if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): if (arg["Position"] == self.pos): self.finish(False,cont=True) else: if (not self.node) and (not self.support): DraftTools.getSupport(arg) self.point,ctrlPoint,info = DraftTools.getPoint(self,arg) if self.point: self.ui.redraw() self.pos = arg["Position"] self.node.append(self.point) self.drawSegment(self.point) if self.hackedUI.cb1.isChecked(): rot=FreeCAD.DraftWorkingPlane.getPlacement().Rotation normal=rot.multVec(FreeCAD.Vector(0,0,1)) FreeCAD.DraftWorkingPlane.alignToPointAndAxis(self.point,normal) FreeCADGui.Snapper.setGrid() if (not self.isWire and len(self.node) == 2): self.finish(False,cont=True) if (len(self.node) > 2): if ((self.point-self.node[0]).Length < Draft.tolerance()): self.undolast() self.finish(True,cont=True)
def action(self, arg): "scene event handler" if arg["Type"] == "SoKeyboardEvent": if arg["Key"] == "ESCAPE": self.finish() elif arg["Type"] == "SoLocation2Event": #mouse movement detection self.point, ctrlPoint, info = DraftTools.getPoint(self, arg, mobile=True, noTracker=True) self.rect.update(self.point) DraftTools.redraw3DView() elif arg["Type"] == "SoMouseButtonEvent": if (arg["State"] == "DOWN") and (arg["Button"] == "BUTTON1"): if (arg["Position"] == self.pos): self.finish() else: if (not self.node) and (not self.support): DraftTools.getSupport(arg) self.point, ctrlPoint, info = DraftTools.getPoint( self, arg, mobile=True, noTracker=True) if self.point: self.ui.redraw() self.appendPoint(self.point)