def setCursor(self,mode=None): "setCursor(self,mode=None): sets or resets the cursor to the given mode or resets" if not mode: for v in self.views: v.unsetCursor() self.views = [] self.cursorMode = None else: if mode != self.cursorMode: if not self.views: mw = DraftGui.getMainWindow() self.views = mw.findChildren(QtGui.QWidget,"QtGLArea") baseicon = QtGui.QPixmap(":/icons/Draft_Cursor.svg") newicon = QtGui.QPixmap(32,24) newicon.fill(QtCore.Qt.transparent) qp = QtGui.QPainter() qp.begin(newicon) qp.drawPixmap(0,0,baseicon) if not (mode == 'passive'): tp = QtGui.QPixmap(self.cursors[mode]).scaledToWidth(16) qp.drawPixmap(QtCore.QPoint(16, 8), tp); qp.end() cur = QtGui.QCursor(newicon,8,8) for v in self.views: v.setCursor(cur) self.cursorMode = mode
def numericInput(self,numx,numy,numz): "this function gets called by the toolbar when a valid base point has been entered" self.point = Vector(numx,numy,numz) self.node.append(self.point) if not self.pickmode: self.ui.offUi() if self.call: self.view.removeEventCallback("SoEvent",self.call) self.task = DraftGui.ScaleTaskPanel() self.task.sourceCmd = self DraftGui.todo.delay(FreeCADGui.Control.showDialog,self.task) if self.ghost: self.ghost.on() elif len(self.node) == 2: msg(translate("draft", "Pick new distance from base point:")+"\n") elif len(self.node) == 3: if hasattr(FreeCADGui,"Snapper"): FreeCADGui.Snapper.off() if self.call: self.view.removeEventCallback("SoEvent",self.call) d1 = (self.node[1].sub(self.node[0])).Length d2 = (self.node[2].sub(self.node[0])).Length #print d2,"/",d1,"=",d2/d1 if hasattr(self,"task"): if self.task: self.task.lock.setChecked(True) self.task.setValue(d2/d1)
def setCursor(self, mode=None): "setCursor(self,mode=None): sets or resets the cursor to the given mode or resets" if not mode: for v in self.views: v.unsetCursor() self.views = [] self.cursorMode = None else: if mode != self.cursorMode: if not self.views: mw = DraftGui.getMainWindow() self.views = mw.findChildren(QtGui.QWidget, "QtGLArea") baseicon = QtGui.QPixmap(":/icons/Draft_Cursor.svg") newicon = QtGui.QPixmap(32, 24) newicon.fill(QtCore.Qt.transparent) qp = QtGui.QPainter() qp.begin(newicon) qp.drawPixmap(0, 0, baseicon) if not (mode == 'passive'): tp = QtGui.QPixmap(self.cursors[mode]).scaledToWidth(16) qp.drawPixmap(QtCore.QPoint(16, 8), tp) qp.end() cur = QtGui.QCursor(newicon, 8, 8) for v in self.views: v.setCursor(cur) self.cursorMode = mode
def Activated(self): self.Align = "Center" self.Length = None self.lengthValue = 0 self.continueCmd = False p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") self.Width = p.GetFloat("WallWidth", 200) self.Height = p.GetFloat("WallHeight", 3000) self.JOIN_WALLS_SKETCHES = p.GetBool("joinWallSketches", False) self.AUTOJOIN = p.GetBool("autoJoinWalls", True) self.DECIMALS = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) import DraftGui self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, 'Length') sel = FreeCADGui.Selection.getSelectionEx() done = False self.existing = [] if sel: # automatic mode import Draft if Draft.getType(sel[0].Object) != "Wall": FreeCAD.ActiveDocument.openTransaction( translate("Arch", "Create Wall")) FreeCADGui.addModule("Arch") for selobj in sel: if Draft.getType(selobj.Object) == "Space": spacedone = False if selobj.HasSubObjects: if "Face" in selobj.SubElementNames[0]: idx = int(selobj.SubElementNames[0][4:]) FreeCADGui.doCommand( "Arch.makeWall(FreeCAD.ActiveDocument." + selobj.Object.Name + ",face=" + str(idx) + ")") spacedone = True if not spacedone: FreeCADGui.doCommand( 'Arch.makeWall(FreeCAD.ActiveDocument.' + selobj.Object.Name + ')') else: FreeCADGui.doCommand( 'Arch.makeWall(FreeCAD.ActiveDocument.' + selobj.Object.Name + ')') FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() done = True if not done: # interactive mode import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() if hasattr(FreeCAD, "DraftWorkingPlane"): FreeCAD.DraftWorkingPlane.setup() FreeCADGui.Snapper.getPoint(callback=self.getPoint, extradlg=self.taskbox())
def setEdit(self, vobj, mode): if mode != 0: return None import DraftGui # Moving this to the top of the file results in a circular import. taskd = DraftGui.FacebinderTaskPanel() taskd.obj = vobj.Object taskd.update() Gui.Control.showDialog(taskd) return True
def Activated(self): self.Align = "Center" self.Length = None self.continueCmd = False p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") self.Width = p.GetFloat("WallWidth", 200) self.Height = p.GetFloat("WallHeight", 3000) self.JOIN_WALLS_SKETCHES = p.GetBool("joinWallSketches", False) self.AUTOJOIN = p.GetBool("autoJoinWalls", True) self.DECIMALS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) import DraftGui self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, "Length") sel = FreeCADGui.Selection.getSelectionEx() done = False self.existing = [] if sel: # automatic mode import Draft if Draft.getType(sel[0].Object) != "Wall": FreeCAD.ActiveDocument.openTransaction(translate("Arch", "Create Wall")) FreeCADGui.doCommand("import Arch") for selobj in sel: if Draft.getType(selobj.Object) == "Space": spacedone = False if selobj.HasSubObjects: if "Face" in selobj.SubElementNames[0]: idx = int(selobj.SubElementNames[0][4:]) FreeCADGui.doCommand( "Arch.makeWall(FreeCAD.ActiveDocument." + selobj.Object.Name + ",face=" + str(idx) + ")" ) spacedone = True if not spacedone: FreeCADGui.doCommand("Arch.makeWall(FreeCAD.ActiveDocument." + selobj.Object.Name + ")") else: FreeCADGui.doCommand("Arch.makeWall(FreeCAD.ActiveDocument." + selobj.Object.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() done = True if not done: # interactive mode import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() if hasattr(FreeCAD, "DraftWorkingPlane"): FreeCAD.DraftWorkingPlane.setup() FreeCADGui.Snapper.getPoint(callback=self.getPoint, extradlg=self.taskbox())
def Activated(self): p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") self.Length = p.GetFloat("StructureLength", 100) self.Width = p.GetFloat("StructureWidth", 100) self.Height = p.GetFloat("StructureHeight", 1000) self.Profile = None self.continueCmd = False self.DECIMALS = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) import DraftGui self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, 'Length') sel = FreeCADGui.Selection.getSelection() if sel: st = Draft.getObjectsOfType(sel, "Structure") ax = Draft.getObjectsOfType(sel, "Axis") if ax: FreeCAD.ActiveDocument.openTransaction( str(translate("Arch", "Create Structural System"))) FreeCADGui.addModule("Arch") if st: FreeCADGui.doCommand("Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")") else: FreeCADGui.doCommand("Arch.makeStructuralSystem(axes=" + ArchCommands.getStringList(ax) + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return elif not (ax) and not (st): FreeCAD.ActiveDocument.openTransaction( str(translate("Arch", "Create Structure"))) FreeCADGui.addModule("Arch") for obj in sel: FreeCADGui.doCommand( "Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return # interactive mode if hasattr(FreeCAD, "DraftWorkingPlane"): FreeCAD.DraftWorkingPlane.setup() import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() self.tracker.width(self.Width) self.tracker.height(self.Height) self.tracker.length(self.Length) self.tracker.on() FreeCADGui.Snapper.getPoint(callback=self.getPoint, movecallback=self.update, extradlg=self.taskbox())
def Activated(self): p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") self.Length = p.GetFloat("StructureLength", 100) self.Width = p.GetFloat("StructureWidth", 100) self.Height = p.GetFloat("StructureHeight", 1000) self.Profile = None self.continueCmd = False self.DECIMALS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) import DraftGui self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, "Length") sel = FreeCADGui.Selection.getSelection() if sel: st = Draft.getObjectsOfType(sel, "Structure") ax = Draft.getObjectsOfType(sel, "Axis") if ax: FreeCAD.ActiveDocument.openTransaction(str(translate("Arch", "Create Structural System"))) FreeCADGui.addModule("Arch") if st: FreeCADGui.doCommand( "Arch.makeStructuralSystem(" + ArchCommands.getStringList(st) + "," + ArchCommands.getStringList(ax) + ")" ) else: FreeCADGui.doCommand("Arch.makeStructuralSystem(axes=" + ArchCommands.getStringList(ax) + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return elif not (ax) and not (st): FreeCAD.ActiveDocument.openTransaction(str(translate("Arch", "Create Structure"))) FreeCADGui.addModule("Arch") for obj in sel: FreeCADGui.doCommand("Arch.makeStructure(FreeCAD.ActiveDocument." + obj.Name + ")") FreeCAD.ActiveDocument.commitTransaction() FreeCAD.ActiveDocument.recompute() return # interactive mode if hasattr(FreeCAD, "DraftWorkingPlane"): FreeCAD.DraftWorkingPlane.setup() import DraftTrackers self.points = [] self.tracker = DraftTrackers.boxTracker() self.tracker.width(self.Width) self.tracker.height(self.Height) self.tracker.length(self.Length) self.tracker.on() FreeCADGui.Snapper.getPoint(callback=self.getPoint, movecallback=self.update, extradlg=self.taskbox())
def update(self): #print("TimberTaskPanel update") 'fills the treewidget' self.tree.clear() dirIcon = QtGui.QApplication.style().standardIcon( QtGui.QStyle.SP_DirIcon) for a in self.attribs: setattr(self, "tree" + a, QtGui.QTreeWidgetItem(self.tree)) c = getattr(self, "tree" + a) c.setIcon(0, dirIcon) c.ChildIndicatorPolicy = 2 if self.obj: if not hasattr(self.obj, a): c.setHidden(True) else: c.setHidden(True) if self.obj: for attrib in self.attribs: if hasattr(self.obj, attrib): Oattrib = getattr(self.obj, attrib) Tattrib = getattr(self, "tree" + attrib) if Oattrib: if attrib == "Base": Oattrib = [Oattrib] for o in Oattrib: item = QtGui.QTreeWidgetItem() item.setText(0, o.Name) item.setIcon(0, self.getIcon(o)) Tattrib.addChild(item) self.tree.expandItem(Tattrib) self.DECIMALS = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Units").GetInt( "Decimals", 2) self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, 'Length') self.vWidth.setText(self.FORMAT % self.obj.Width) self.vHeight.setText(self.FORMAT % self.obj.Height) "fill the presets combobox" presetslist = getPresetsList() presetname = self.obj.Preset idx = presetslist.index(presetname) self.presetsCBB.clear() self.presetsCBB.addItems(presetslist) self.presetsCBB.setCurrentIndex(idx) if idx < 1: self.presetRenameBT.setEnabled(False) self.presetSaveBT.setEnabled(False) else: self.presetRenameBT.setEnabled(True) self.presetSaveBT.setEnabled(True) self.retranslateUi(self.form)
def show(self): "shows the toolbar and the grid" if not hasattr(self, "toolbar"): self.makeSnapToolBar() mw = DraftGui.getMainWindow() bt = mw.findChild(QtGui.QToolBar, "Draft Snap") if not bt: mw.addToolBar(self.toolbar) self.toolbar.setParent(mw) self.toolbar.show() self.toolbar.toggleViewAction().setVisible(True) if FreeCADGui.ActiveDocument: self.setTrackers()
def show(self): "shows the toolbar and the grid" if not hasattr(self,"toolbar"): self.makeSnapToolBar() mw = DraftGui.getMainWindow() bt = mw.findChild(QtGui.QToolBar,"Draft Snap") if not bt: mw.addToolBar(self.toolbar) self.toolbar.setParent(mw) self.toolbar.show() self.toolbar.toggleViewAction().setVisible(True) if FreeCADGui.ActiveDocument: self.setTrackers()
def update(self): #print("TimberTaskPanel update") 'fills the treewidget' self.tree.clear() dirIcon = QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_DirIcon) for a in self.attribs: setattr(self,"tree"+a,QtGui.QTreeWidgetItem(self.tree)) c = getattr(self,"tree"+a) c.setIcon(0,dirIcon) c.ChildIndicatorPolicy = 2 if self.obj: if not hasattr(self.obj,a): c.setHidden(True) else: c.setHidden(True) if self.obj: for attrib in self.attribs: if hasattr(self.obj,attrib): Oattrib = getattr(self.obj,attrib) Tattrib = getattr(self,"tree"+attrib) if Oattrib: if attrib == "Base": Oattrib = [Oattrib] for o in Oattrib: item = QtGui.QTreeWidgetItem() item.setText(0,o.Name) item.setIcon(0,self.getIcon(o)) Tattrib.addChild(item) self.tree.expandItem(Tattrib) self.DECIMALS = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt("Decimals",2) self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS,'Length') self.vWidth.setText(self.FORMAT % self.obj.Width) self.vHeight.setText(self.FORMAT % self.obj.Height) "fill the presets combobox" presetslist = getPresetsList() presetname = self.obj.Preset idx = presetslist.index(presetname) self.presetsCBB.clear() self.presetsCBB.addItems(presetslist) self.presetsCBB.setCurrentIndex(idx) if idx < 1: self.presetRenameBT.setEnabled(False) self.presetSaveBT.setEnabled(False) else: self.presetRenameBT.setEnabled(True) self.presetSaveBT.setEnabled(True) self.retranslateUi(self.form)
def setEdit(self, vobj, mode): taskd = DraftGui.FacebinderTaskPanel() taskd.obj = vobj.Object taskd.update() Gui.Control.showDialog(taskd) return True
def snap(self,screenpos,lastpoint=None,active=True,constrain=False,noTracker=False): """snap(screenpos,lastpoint=None,active=True,constrain=False,noTracker=False): returns a snapped point from the given (x,y) screenpos (the position of the mouse cursor), active is to activate active point snapping or not (passive), lastpoint is an optional other point used to draw an imaginary segment and get additional snap locations. Constrain can be True to constrain the point against the closest working plane axis. Screenpos can be a list, a tuple or a coin.SbVec2s object. If noTracker is True, the tracking line is not displayed.""" global Part, DraftGeomUtils import Part, DraftGeomUtils if not hasattr(self,"toolbar"): self.makeSnapToolBar() mw = DraftGui.getMainWindow() bt = mw.findChild(QtGui.QToolBar,"Draft Snap") if not bt: mw.addToolBar(self.toolbar) else: if Draft.getParam("showSnapBar"): bt.show() def cstr(point): "constrains if needed" if constrain or self.mask: fpt = self.constrain(point,lastpoint) else: self.unconstrain() fpt = point if self.radiusTracker: self.radiusTracker.update(fpt) return fpt snaps = [] self.snapInfo = None # type conversion if needed if isinstance(screenpos,list): screenpos = tuple(screenpos) elif isinstance(screenpos,coin.SbVec2s): screenpos = tuple(screenpos.getValue()) elif not isinstance(screenpos,tuple): print "snap needs valid screen position (list, tuple or sbvec2s)" return None # setup trackers if needed self.setTrackers() # getting current snap Radius self.radius = self.getScreenDist(Draft.getParam("snapRange"),screenpos) if self.radiusTracker: self.radiusTracker.update(self.radius) self.radiusTracker.off() # activate snap oldActive = False if Draft.getParam("alwaysSnap"): oldActive = active active = True if not self.active: active = False self.setCursor('passive') if self.tracker: self.tracker.off() if self.extLine: self.extLine.off() if self.trackLine: self.trackLine.off() if self.dim1: self.dim1.off() if self.dim2: self.dim2.off() point = self.getApparentPoint(screenpos[0],screenpos[1]) # setup a track line if we got a last point if lastpoint: if not self.trackLine: self.trackLine = DraftTrackers.lineTracker() self.trackLine.p1(lastpoint) # check if we snapped to something self.snapInfo = Draft.get3DView().getObjectInfo((screenpos[0],screenpos[1])) # checking if parallel to one of the edges of the last objects or to a polar direction if active: eline = None point,eline = self.snapToPolar(point,lastpoint) point,eline = self.snapToExtensions(point,lastpoint,constrain,eline) if not self.snapInfo: # nothing has been snapped, check fro grid snap if active: point = self.snapToGrid(point) fp = cstr(point) if self.trackLine and lastpoint and (not noTracker): self.trackLine.p2(fp) self.trackLine.on() # set the arch point tracking if self.lastArchPoint: self.setArchDims(self.lastArchPoint,fp) return fp else: # we have an object to snap to obj = FreeCAD.ActiveDocument.getObject(self.snapInfo['Object']) if not obj: return cstr(point) self.lastSnappedObject = obj if hasattr(obj.ViewObject,"Selectable"): if not obj.ViewObject.Selectable: return cstr(point) if not active: # passive snapping snaps = [self.snapToVertex(self.snapInfo)] else: # first stick to the snapped object s = self.snapToVertex(self.snapInfo) if s: point = s[0] # active snapping comp = self.snapInfo['Component'] if (Draft.getType(obj) == "Wall") and not oldActive: # special snapping for wall: only to its base shape (except when CTRL is pressed) edges = [] for o in [obj]+obj.Additions: if Draft.getType(o) == "Wall": if o.Base: edges.extend(o.Base.Shape.Edges) for edge in edges: snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend(self.snapToPerpendicular(edge,lastpoint)) snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge,eline)) elif (Draft.getType(obj) == "Structure") and not oldActive: # special snapping for struct: only to its base point (except when CTRL is pressed) if obj.Base: for edge in obj.Base.Shape.Edges: snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend(self.snapToPerpendicular(edge,lastpoint)) snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge,eline)) else: b = obj.Placement.Base snaps.append([b,'endpoint',b]) elif obj.isDerivedFrom("Part::Feature"): if Draft.getType(obj) == "Polygon": snaps.extend(self.snapToPolygon(obj)) if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges): if "Edge" in comp: # we are snapping to an edge en = int(comp[4:])-1 if len(obj.Shape.Edges) > en: edge = obj.Shape.Edges[en] snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend(self.snapToPerpendicular(edge,lastpoint)) #snaps.extend(self.snapToOrtho(edge,lastpoint,constrain)) # now part of snapToPolar snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge,eline)) if DraftGeomUtils.geomType(edge) == "Circle": # the edge is an arc, we have extra options snaps.extend(self.snapToAngles(edge)) snaps.extend(self.snapToCenter(edge)) elif "Vertex" in comp: # directly snapped to a vertex snaps.append(self.snapToVertex(self.snapInfo,active=True)) elif comp == '': # workaround for the new view provider snaps.append(self.snapToVertex(self.snapInfo,active=True)) else: # all other cases (face, etc...) default to passive snap snapArray = [self.snapToVertex(self.snapInfo)] elif Draft.getType(obj) == "Dimension": # for dimensions we snap to their 3 points for pt in [obj.Start,obj.End,obj.Dimline]: snaps.append([pt,'endpoint',pt]) elif Draft.getType(obj) == "Mesh": # for meshes we only snap to vertices snaps.extend(self.snapToEndpoints(obj.Mesh)) elif Draft.getType(obj) == "Points": # for points we only snap to points snaps.extend(self.snapToEndpoints(obj.Points)) # updating last objects list if not self.lastObj[1]: self.lastObj[1] = obj.Name elif self.lastObj[1] != obj.Name: self.lastObj[0] = self.lastObj[1] self.lastObj[1] = obj.Name if not snaps: return cstr(point) # calculating the nearest snap point shortest = 1000000000000000000 origin = Vector(self.snapInfo['x'],self.snapInfo['y'],self.snapInfo['z']) winner = [Vector(0,0,0),None,Vector(0,0,0)] for snap in snaps: if (not snap) or (snap[0] == None): print "debug: Snapper: invalid snap point: ",snaps else: delta = snap[0].sub(origin) if delta.Length < shortest: shortest = delta.Length winner = snap # see if we are out of the max radius, if any if self.radius: dv = point.sub(winner[2]) if (dv.Length > self.radius): if (not oldActive) and self.isEnabled("passive"): winner = self.snapToVertex(self.snapInfo) # setting the cursors if self.tracker: self.tracker.setCoords(winner[2]) self.tracker.setMarker(self.mk[winner[1]]) self.tracker.on() # setting the trackline fp = cstr(winner[2]) if self.trackLine and lastpoint: self.trackLine.p2(fp) self.trackLine.on() # set the cursor self.setCursor(winner[1]) # set the arch point tracking if self.lastArchPoint: self.setArchDims(self.lastArchPoint,fp) if Draft.getType(obj) in ["Wall","Structure"]: self.lastArchPoint = winner[2] else: self.lastArchPoint = None # return the final point return fp
def __init__(self, obj): QtGui.QDialog.__init__(self) self.setObjectName(_fromUtf8("TooltableEditor")) self.resize(468, 476) self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.DECIMALS = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, 'Length') # left groupbox self.groupBox = QtGui.QGroupBox(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.horizontalLayout_9 = QtGui.QHBoxLayout() self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) # import button self.ButtonImport = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("document-import")) self.ButtonImport.setIcon(icon) self.ButtonImport.setObjectName(_fromUtf8("ButtonImport")) self.horizontalLayout_9.addWidget(self.ButtonImport) # export button self.ButtonExport = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("document-export")) self.ButtonExport.setIcon(icon) self.ButtonExport.setObjectName(_fromUtf8("ButtonExport")) self.horizontalLayout_9.addWidget(self.ButtonExport) # tools list self.verticalLayout_2.addLayout(self.horizontalLayout_9) self.ToolsList = QtGui.QTreeWidget(self.groupBox) self.ToolsList.setObjectName(_fromUtf8("ToolsList")) self.ToolsList.header().setDefaultSectionSize(40) self.verticalLayout_2.addWidget(self.ToolsList) # add button self.horizontalLayout_8 = QtGui.QHBoxLayout() self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.ButtonAdd = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-add")) self.ButtonAdd.setIcon(icon) self.ButtonAdd.setObjectName(_fromUtf8("ButtonAdd")) self.horizontalLayout_8.addWidget(self.ButtonAdd) # delete button self.ButtonDelete = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-delete")) self.ButtonDelete.setIcon(icon) self.ButtonDelete.setObjectName(_fromUtf8("ButtonDelete")) self.horizontalLayout_8.addWidget(self.ButtonDelete) # up button self.ButtonUp = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("go-up")) self.ButtonUp.setIcon(icon) self.ButtonDelete.setObjectName(_fromUtf8("ButtonUp")) self.horizontalLayout_8.addWidget(self.ButtonUp) # down button self.ButtonDown = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("go-down")) self.ButtonDown.setIcon(icon) self.ButtonDown.setObjectName(_fromUtf8("ButtonDown")) self.horizontalLayout_8.addWidget(self.ButtonDown) # right groupbox self.verticalLayout_2.addLayout(self.horizontalLayout_8) self.horizontalLayout.addWidget(self.groupBox) self.groupBox_2 = QtGui.QGroupBox(self) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.groupBox_2) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) # name self.label = QtGui.QLabel(self.groupBox_2) self.label.setObjectName(_fromUtf8("label")) self.verticalLayout_3.addWidget(self.label) self.NameField = QtGui.QLineEdit(self.groupBox_2) self.NameField.setObjectName(_fromUtf8("NameField")) self.verticalLayout_3.addWidget(self.NameField) # type self.label_2 = QtGui.QLabel(self.groupBox_2) self.label_2.setObjectName(_fromUtf8("label_2")) self.verticalLayout_3.addWidget(self.label_2) self.TypeField = QtGui.QComboBox(self.groupBox_2) self.TypeField.setObjectName(_fromUtf8("TypeField")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.verticalLayout_3.addWidget(self.TypeField) # material self.label_3 = QtGui.QLabel(self.groupBox_2) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout_3.addWidget(self.label_3) self.MaterialField = QtGui.QComboBox(self.groupBox_2) self.MaterialField.setObjectName(_fromUtf8("MaterialField")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.verticalLayout_3.addWidget(self.MaterialField) self.label_4 = QtGui.QLabel(self.groupBox_2) self.label_4.setObjectName(_fromUtf8("label_4")) self.verticalLayout_3.addWidget(self.label_4) # diameter self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_5 = QtGui.QLabel(self.groupBox_2) self.label_5.setObjectName(_fromUtf8("label_5")) self.horizontalLayout_2.addWidget(self.label_5) self.DiameterField = QtGui.QDoubleSpinBox(self.groupBox_2) self.DiameterField.setMaximum(9999) self.DiameterField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.DiameterField.setObjectName(_fromUtf8("DiameterField")) self.horizontalLayout_2.addWidget(self.DiameterField) self.verticalLayout_3.addLayout(self.horizontalLayout_2) # length offset self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.label_6 = QtGui.QLabel(self.groupBox_2) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_3.addWidget(self.label_6) self.LengthOffsetField = QtGui.QDoubleSpinBox(self.groupBox_2) self.LengthOffsetField.setMaximum(9999) self.LengthOffsetField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.LengthOffsetField.setObjectName(_fromUtf8("LengthOffsetField")) self.horizontalLayout_3.addWidget(self.LengthOffsetField) self.verticalLayout_3.addLayout(self.horizontalLayout_3) # flat radius self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_7 = QtGui.QLabel(self.groupBox_2) self.label_7.setObjectName(_fromUtf8("label_7")) self.horizontalLayout_4.addWidget(self.label_7) self.FlatRadiusField = QtGui.QDoubleSpinBox(self.groupBox_2) self.FlatRadiusField.setMaximum(9999) self.FlatRadiusField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.FlatRadiusField.setObjectName(_fromUtf8("FlatRadiusField")) self.horizontalLayout_4.addWidget(self.FlatRadiusField) self.verticalLayout_3.addLayout(self.horizontalLayout_4) # corner radius self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) self.label_8 = QtGui.QLabel(self.groupBox_2) self.label_8.setObjectName(_fromUtf8("label_8")) self.horizontalLayout_5.addWidget(self.label_8) self.CornerRadiusField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CornerRadiusField.setMaximum(9999) self.CornerRadiusField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CornerRadiusField.setObjectName(_fromUtf8("CornerRadiusField")) self.horizontalLayout_5.addWidget(self.CornerRadiusField) self.verticalLayout_3.addLayout(self.horizontalLayout_5) # cutting edge angle self.horizontalLayout_6 = QtGui.QHBoxLayout() self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.label_9 = QtGui.QLabel(self.groupBox_2) self.label_9.setObjectName(_fromUtf8("label_9")) self.horizontalLayout_6.addWidget(self.label_9) self.CuttingEdgeAngleField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CuttingEdgeAngleField.setMaximum(360) self.CuttingEdgeAngleField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CuttingEdgeAngleField.setObjectName( _fromUtf8("CuttingEdgeAngleField")) self.horizontalLayout_6.addWidget(self.CuttingEdgeAngleField) self.verticalLayout_3.addLayout(self.horizontalLayout_6) # cutting edge height self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) self.label_10 = QtGui.QLabel(self.groupBox_2) self.label_10.setObjectName(_fromUtf8("label_10")) self.horizontalLayout_7.addWidget(self.label_10) self.CuttingEdgeHeightField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CuttingEdgeHeightField.setMaximum(9999) self.CuttingEdgeHeightField.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CuttingEdgeHeightField.setObjectName( _fromUtf8("CuttingEdgeHeightField")) self.horizontalLayout_7.addWidget(self.CuttingEdgeHeightField) self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout.addWidget(self.groupBox_2) self.verticalLayout.addLayout(self.horizontalLayout) # ok / cancel box self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi() # connect buttons QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), self.reject) QtCore.QObject.connect(self.ButtonImport, QtCore.SIGNAL(_fromUtf8("clicked()")), self.read) QtCore.QObject.connect(self.ButtonExport, QtCore.SIGNAL(_fromUtf8("clicked()")), self.write) QtCore.QObject.connect(self.ButtonAdd, QtCore.SIGNAL(_fromUtf8("clicked()")), self.addnew) QtCore.QObject.connect(self.ButtonDelete, QtCore.SIGNAL(_fromUtf8("clicked()")), self.delete) QtCore.QObject.connect(self.ButtonUp, QtCore.SIGNAL(_fromUtf8("clicked()")), self.moveup) QtCore.QObject.connect(self.ButtonDown, QtCore.SIGNAL(_fromUtf8("clicked()")), self.movedown) QtCore.QObject.connect( self.ToolsList, QtCore.SIGNAL( _fromUtf8( "currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)") ), self.selectTool) QtCore.QObject.connect(self.NameField, QtCore.SIGNAL(_fromUtf8("textEdited(QString)")), self.changeName) QtCore.QObject.connect( self.TypeField, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.changeType) QtCore.QObject.connect( self.MaterialField, QtCore.SIGNAL(_fromUtf8("currentIndexChanged(int)")), self.changeMaterial) QtCore.QObject.connect( self.DiameterField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeDiameter) QtCore.QObject.connect( self.LengthOffsetField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeLengthOffset) QtCore.QObject.connect( self.FlatRadiusField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeFlatRadius) QtCore.QObject.connect( self.CornerRadiusField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeCornerRadius) QtCore.QObject.connect( self.CuttingEdgeAngleField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeCuttingEdgeAngle) QtCore.QObject.connect( self.CuttingEdgeHeightField, QtCore.SIGNAL(_fromUtf8("valueChanged(double)")), self.changeCuttingEdgeHeight) QtCore.QMetaObject.connectSlotsByName(self) self.tooltable = obj.Tooltable.copy() self.tool = None self.number = None self.reset()
def translate(text, context='trails'): """ Translate convenience fn for the DraftGui.translate() convenience fn """ DraftGui.translate(context, text)
def updateData(self, obj, prop): """called when the base object is changed""" import DraftGui if prop in ["Start", "End", "Dimline", "Direction"]: if obj.Start == obj.End: return if not hasattr(self, "node"): return import Part, DraftGeomUtils from pivy import coin # calculate the 4 points self.p1 = obj.Start self.p4 = obj.End base = None if hasattr(obj, "Direction"): if not DraftVecUtils.isNull(obj.Direction): v2 = self.p1.sub(obj.Dimline) v3 = self.p4.sub(obj.Dimline) v2 = DraftVecUtils.project(v2, obj.Direction) v3 = DraftVecUtils.project(v3, obj.Direction) self.p2 = obj.Dimline.add(v2) self.p3 = obj.Dimline.add(v3) if DraftVecUtils.equals(self.p2, self.p3): base = None proj = None else: base = Part.LineSegment(self.p2, self.p3).toShape() proj = DraftGeomUtils.findDistance(self.p1, base) if proj: proj = proj.negative() if not base: if DraftVecUtils.equals(self.p1, self.p4): base = None proj = None else: base = Part.LineSegment(self.p1, self.p4).toShape() proj = DraftGeomUtils.findDistance(obj.Dimline, base) if proj: self.p2 = self.p1.add(proj.negative()) self.p3 = self.p4.add(proj.negative()) else: self.p2 = self.p1 self.p3 = self.p4 if proj: if hasattr(obj.ViewObject, "ExtLines") and hasattr( obj.ViewObject, "ScaleMultiplier"): dmax = obj.ViewObject.ExtLines.Value * obj.ViewObject.ScaleMultiplier if dmax and (proj.Length > dmax): if (dmax > 0): self.p1 = self.p2.add( DraftVecUtils.scaleTo(proj, dmax)) self.p4 = self.p3.add( DraftVecUtils.scaleTo(proj, dmax)) else: rest = proj.Length + dmax self.p1 = self.p2.add( DraftVecUtils.scaleTo(proj, rest)) self.p4 = self.p3.add( DraftVecUtils.scaleTo(proj, rest)) else: proj = (self.p3.sub(self.p2)).cross(App.Vector(0, 0, 1)) # calculate the arrows positions self.trans1.translation.setValue((self.p2.x, self.p2.y, self.p2.z)) self.coord1.point.setValue((self.p2.x, self.p2.y, self.p2.z)) self.trans2.translation.setValue((self.p3.x, self.p3.y, self.p3.z)) self.coord2.point.setValue((self.p3.x, self.p3.y, self.p3.z)) # calculate dimension and extension lines overshoots positions self.transDimOvershoot1.translation.setValue( (self.p2.x, self.p2.y, self.p2.z)) self.transDimOvershoot2.translation.setValue( (self.p3.x, self.p3.y, self.p3.z)) self.transExtOvershoot1.translation.setValue( (self.p2.x, self.p2.y, self.p2.z)) self.transExtOvershoot2.translation.setValue( (self.p3.x, self.p3.y, self.p3.z)) # calculate the text position and orientation if hasattr(obj, "Normal"): if DraftVecUtils.isNull(obj.Normal): if proj: norm = (self.p3.sub(self.p2).cross(proj)).negative() else: norm = App.Vector(0, 0, 1) else: norm = App.Vector(obj.Normal) else: if proj: norm = (self.p3.sub(self.p2).cross(proj)).negative() else: norm = App.Vector(0, 0, 1) if not DraftVecUtils.isNull(norm): norm.normalize() u = self.p3.sub(self.p2) u.normalize() v1 = norm.cross(u) rot1 = App.Placement(DraftVecUtils.getPlaneRotation( u, v1, norm)).Rotation.Q self.transDimOvershoot1.rotation.setValue( (rot1[0], rot1[1], rot1[2], rot1[3])) self.transDimOvershoot2.rotation.setValue( (rot1[0], rot1[1], rot1[2], rot1[3])) if hasattr(obj.ViewObject, "FlipArrows"): if obj.ViewObject.FlipArrows: u = u.negative() v2 = norm.cross(u) rot2 = App.Placement(DraftVecUtils.getPlaneRotation( u, v2, norm)).Rotation.Q self.trans1.rotation.setValue((rot2[0], rot2[1], rot2[2], rot2[3])) self.trans2.rotation.setValue((rot2[0], rot2[1], rot2[2], rot2[3])) if self.p1 != self.p2: u3 = self.p1.sub(self.p2) u3.normalize() v3 = norm.cross(u3) rot3 = App.Placement( DraftVecUtils.getPlaneRotation(u3, v3, norm)).Rotation.Q self.transExtOvershoot1.rotation.setValue( (rot3[0], rot3[1], rot3[2], rot3[3])) self.transExtOvershoot2.rotation.setValue( (rot3[0], rot3[1], rot3[2], rot3[3])) if hasattr(obj.ViewObject, "TextSpacing") and hasattr( obj.ViewObject, "ScaleMultiplier"): ts = obj.ViewObject.TextSpacing.Value * obj.ViewObject.ScaleMultiplier offset = DraftVecUtils.scaleTo(v1, ts) else: offset = DraftVecUtils.scaleTo(v1, 0.05) rott = rot1 if hasattr(obj.ViewObject, "FlipText"): if obj.ViewObject.FlipText: rott = App.Rotation(*rott).multiply(App.Rotation( norm, 180)).Q offset = offset.negative() # setting text try: m = obj.ViewObject.DisplayMode except: # swallow all exceptions here since it always fails on first run (Displaymode enum no set yet) m = ["2D", "3D"][utils.get_param("dimstyle", 0)] if m == "3D": offset = offset.negative() self.tbase = (self.p2.add( (self.p3.sub(self.p2).multiply(0.5)))).add(offset) if hasattr(obj.ViewObject, "TextPosition"): if not DraftVecUtils.isNull(obj.ViewObject.TextPosition): self.tbase = obj.ViewObject.TextPosition self.textpos.translation.setValue( [self.tbase.x, self.tbase.y, self.tbase.z]) self.textpos.rotation = coin.SbRotation(rott[0], rott[1], rott[2], rott[3]) su = True if hasattr(obj.ViewObject, "ShowUnit"): su = obj.ViewObject.ShowUnit # set text value l = self.p3.sub(self.p2).Length unit = None if hasattr(obj.ViewObject, "UnitOverride"): unit = obj.ViewObject.UnitOverride # special representation if "Building US" scheme if App.ParamGet("User parameter:BaseApp/Preferences/Units").GetInt( "UserSchema", 0) == 5: s = App.Units.Quantity(l, App.Units.Length).UserString self.string = s.replace("' ", "'- ") self.string = s.replace("+", " ") elif hasattr(obj.ViewObject, "Decimals"): self.string = DraftGui.displayExternal(l, obj.ViewObject.Decimals, 'Length', su, unit) else: self.string = DraftGui.displayExternal(l, None, 'Length', su, unit) if hasattr(obj.ViewObject, "Override"): if obj.ViewObject.Override: self.string = obj.ViewObject.Override.replace("$dim",\ self.string) self.text.string = self.text3d.string = utils.string_encode_coin( self.string) # set the lines if m == "3D": # calculate the spacing of the text textsize = (len(self.string) * obj.ViewObject.FontSize.Value) / 4.0 spacing = ((self.p3.sub(self.p2)).Length / 2.0) - textsize self.p2a = self.p2.add( DraftVecUtils.scaleTo(self.p3.sub(self.p2), spacing)) self.p2b = self.p3.add( DraftVecUtils.scaleTo(self.p2.sub(self.p3), spacing)) self.coords.point.setValues( [[self.p1.x, self.p1.y, self.p1.z], [self.p2.x, self.p2.y, self.p2.z], [self.p2a.x, self.p2a.y, self.p2a.z], [self.p2b.x, self.p2b.y, self.p2b.z], [self.p3.x, self.p3.y, self.p3.z], [self.p4.x, self.p4.y, self.p4.z]]) #self.line.numVertices.setValues([3,3]) self.line.coordIndex.setValues(0, 7, (0, 1, 2, -1, 3, 4, 5)) else: self.coords.point.setValues([[self.p1.x, self.p1.y, self.p1.z], [self.p2.x, self.p2.y, self.p2.z], [self.p3.x, self.p3.y, self.p3.z], [self.p4.x, self.p4.y, self.p4.z]]) #self.line.numVertices.setValue(4) self.line.coordIndex.setValues(0, 4, (0, 1, 2, 3))
def snap(self, screenpos, lastpoint=None, active=True, constrain=False, noTracker=False): """snap(screenpos,lastpoint=None,active=True,constrain=False,noTracker=False): returns a snapped point from the given (x,y) screenpos (the position of the mouse cursor), active is to activate active point snapping or not (passive), lastpoint is an optional other point used to draw an imaginary segment and get additional snap locations. Constrain can be True to constrain the point against the closest working plane axis. Screenpos can be a list, a tuple or a coin.SbVec2s object. If noTracker is True, the tracking line is not displayed.""" global Part, DraftGeomUtils import Part, DraftGeomUtils if not hasattr(self, "toolbar"): self.makeSnapToolBar() mw = DraftGui.getMainWindow() bt = mw.findChild(QtGui.QToolBar, "Draft Snap") if not bt: mw.addToolBar(self.toolbar) else: if Draft.getParam("showSnapBar"): bt.show() def cstr(point): "constrains if needed" if constrain or self.mask: fpt = self.constrain(point, lastpoint) else: self.unconstrain() fpt = point if self.radiusTracker: self.radiusTracker.update(fpt) return fpt snaps = [] self.snapInfo = None # type conversion if needed if isinstance(screenpos, list): screenpos = tuple(screenpos) elif isinstance(screenpos, coin.SbVec2s): screenpos = tuple(screenpos.getValue()) elif not isinstance(screenpos, tuple): print "snap needs valid screen position (list, tuple or sbvec2s)" return None # setup trackers if needed self.setTrackers() # getting current snap Radius self.radius = self.getScreenDist(Draft.getParam("snapRange"), screenpos) if self.radiusTracker: self.radiusTracker.update(self.radius) self.radiusTracker.off() # activate snap oldActive = False if Draft.getParam("alwaysSnap"): oldActive = active active = True if not self.active: active = False self.setCursor('passive') if self.tracker: self.tracker.off() if self.extLine: self.extLine.off() if self.trackLine: self.trackLine.off() if self.dim1: self.dim1.off() if self.dim2: self.dim2.off() point = self.getApparentPoint(screenpos[0], screenpos[1]) # setup a track line if we got a last point if lastpoint: if not self.trackLine: self.trackLine = DraftTrackers.lineTracker() self.trackLine.p1(lastpoint) # check if we snapped to something self.snapInfo = Draft.get3DView().getObjectInfo( (screenpos[0], screenpos[1])) # checking if parallel to one of the edges of the last objects or to a polar direction if active: eline = None point, eline = self.snapToPolar(point, lastpoint) point, eline = self.snapToExtensions(point, lastpoint, constrain, eline) if not self.snapInfo: # nothing has been snapped, check fro grid snap if active: point = self.snapToGrid(point) fp = cstr(point) if self.trackLine and lastpoint and (not noTracker): self.trackLine.p2(fp) self.trackLine.on() # set the arch point tracking if self.lastArchPoint: self.setArchDims(self.lastArchPoint, fp) return fp else: # we have an object to snap to obj = FreeCAD.ActiveDocument.getObject(self.snapInfo['Object']) if not obj: return cstr(point) self.lastSnappedObject = obj if hasattr(obj.ViewObject, "Selectable"): if not obj.ViewObject.Selectable: return cstr(point) if not active: # passive snapping snaps = [self.snapToVertex(self.snapInfo)] else: # first stick to the snapped object s = self.snapToVertex(self.snapInfo) if s: point = s[0] # active snapping comp = self.snapInfo['Component'] if (Draft.getType(obj) == "Wall") and not oldActive: # special snapping for wall: only to its base shape (except when CTRL is pressed) edges = [] for o in [obj] + obj.Additions: if Draft.getType(o) == "Wall": if o.Base: edges.extend(o.Base.Shape.Edges) for edge in edges: snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend(self.snapToPerpendicular(edge, lastpoint)) snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge, eline)) elif (Draft.getType(obj) == "Structure") and not oldActive: # special snapping for struct: only to its base point (except when CTRL is pressed) if obj.Base: for edge in o.Base.Shape.Edges: snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend( self.snapToPerpendicular(edge, lastpoint)) snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge, eline)) else: b = obj.Placement.Base snaps.append([b, 'endpoint', b]) elif obj.isDerivedFrom("Part::Feature"): if Draft.getType(obj) == "Polygon": snaps.extend(self.snapToPolygon(obj)) if (not self.maxEdges) or (len(obj.Edges) <= self.maxEdges): if "Edge" in comp: # we are snapping to an edge en = int(comp[4:]) - 1 if len(obj.Shape.Edges) > en: edge = obj.Shape.Edges[en] snaps.extend(self.snapToEndpoints(edge)) snaps.extend(self.snapToMidpoint(edge)) snaps.extend( self.snapToPerpendicular(edge, lastpoint)) #snaps.extend(self.snapToOrtho(edge,lastpoint,constrain)) # now part of snapToPolar snaps.extend(self.snapToIntersection(edge)) snaps.extend(self.snapToElines(edge, eline)) if DraftGeomUtils.geomType(edge) == "Circle": # the edge is an arc, we have extra options snaps.extend(self.snapToAngles(edge)) snaps.extend(self.snapToCenter(edge)) elif "Vertex" in comp: # directly snapped to a vertex snaps.append( self.snapToVertex(self.snapInfo, active=True)) elif comp == '': # workaround for the new view provider snaps.append( self.snapToVertex(self.snapInfo, active=True)) else: # all other cases (face, etc...) default to passive snap snapArray = [self.snapToVertex(self.snapInfo)] elif Draft.getType(obj) == "Dimension": # for dimensions we snap to their 3 points for pt in [obj.Start, obj.End, obj.Dimline]: snaps.append([pt, 'endpoint', pt]) elif Draft.getType(obj) == "Mesh": # for meshes we only snap to vertices snaps.extend(self.snapToEndpoints(obj.Mesh)) elif Draft.getType(obj) == "Points": # for points we only snap to points snaps.extend(self.snapToEndpoints(obj.Points)) # updating last objects list if not self.lastObj[1]: self.lastObj[1] = obj.Name elif self.lastObj[1] != obj.Name: self.lastObj[0] = self.lastObj[1] self.lastObj[1] = obj.Name if not snaps: return cstr(point) # calculating the nearest snap point shortest = 1000000000000000000 origin = Vector(self.snapInfo['x'], self.snapInfo['y'], self.snapInfo['z']) winner = [Vector(0, 0, 0), None, Vector(0, 0, 0)] for snap in snaps: if (not snap) or (snap[0] == None): print "debug: Snapper: invalid snap point: ", snaps else: delta = snap[0].sub(origin) if delta.Length < shortest: shortest = delta.Length winner = snap # see if we are out of the max radius, if any if self.radius: dv = point.sub(winner[2]) if (dv.Length > self.radius): if (not oldActive) and self.isEnabled("passive"): winner = self.snapToVertex(self.snapInfo) # setting the cursors if self.tracker: self.tracker.setCoords(winner[2]) self.tracker.setMarker(self.mk[winner[1]]) self.tracker.on() # setting the trackline fp = cstr(winner[2]) if self.trackLine and lastpoint: self.trackLine.p2(fp) self.trackLine.on() # set the cursor self.setCursor(winner[1]) # set the arch point tracking if self.lastArchPoint: self.setArchDims(self.lastArchPoint, fp) if Draft.getType(obj) in ["Wall", "Structure"]: self.lastArchPoint = winner[2] else: self.lastArchPoint = None # return the final point return fp
def updateData(self, obj, prop): if hasattr(self, "arc"): from pivy import coin import Part, DraftGeomUtils import DraftGui arcsegs = 24 # calculate the arc data if DraftVecUtils.isNull(obj.Normal): norm = App.Vector(0, 0, 1) else: norm = obj.Normal radius = (obj.Dimline.sub(obj.Center)).Length self.circle = Part.makeCircle(radius, obj.Center, norm, obj.FirstAngle.Value, obj.LastAngle.Value) self.p2 = self.circle.Vertexes[0].Point self.p3 = self.circle.Vertexes[-1].Point mp = DraftGeomUtils.findMidpoint(self.circle.Edges[0]) ray = mp.sub(obj.Center) # set text value if obj.LastAngle.Value > obj.FirstAngle.Value: a = obj.LastAngle.Value - obj.FirstAngle.Value else: a = (360 - obj.FirstAngle.Value) + obj.LastAngle.Value su = True if hasattr(obj.ViewObject, "ShowUnit"): su = obj.ViewObject.ShowUnit if hasattr(obj.ViewObject, "Decimals"): self.string = DraftGui.displayExternal(a, obj.ViewObject.Decimals, 'Angle', su) else: self.string = DraftGui.displayExternal(a, None, 'Angle', su) if obj.ViewObject.Override: self.string = obj.ViewObject.Override.replace("$dim",\ self.string) self.text.string = self.text3d.string = utils.string_encode_coin( self.string) # check display mode try: m = obj.ViewObject.DisplayMode except: # swallow all exceptions here since it always fails on first run (Displaymode enum no set yet) m = ["2D", "3D"][utils.get_param("dimstyle", 0)] # set the arc if m == "3D": # calculate the spacing of the text spacing = (len(self.string) * obj.ViewObject.FontSize.Value) / 8.0 pts1 = [] cut = None pts2 = [] for i in range(arcsegs + 1): p = self.circle.valueAt(self.circle.FirstParameter + ( (self.circle.LastParameter - self.circle.FirstParameter) / arcsegs) * i) if (p.sub(mp)).Length <= spacing: if cut is None: cut = i else: if cut is None: pts1.append([p.x, p.y, p.z]) else: pts2.append([p.x, p.y, p.z]) self.coords.point.setValues(pts1 + pts2) i1 = len(pts1) i2 = i1 + len(pts2) self.arc.coordIndex.setValues( 0, len(pts1) + len(pts2) + 1, list(range(len(pts1))) + [-1] + list(range(i1, i2))) if (len(pts1) >= 3) and (len(pts2) >= 3): self.circle1 = Part.Arc( App.Vector(pts1[0][0], pts1[0][1], pts1[0][2]), App.Vector(pts1[1][0], pts1[1][1], pts1[1][2]), App.Vector(pts1[-1][0], pts1[-1][1], pts1[-1][2])).toShape() self.circle2 = Part.Arc( App.Vector(pts2[0][0], pts2[0][1], pts2[0][2]), App.Vector(pts2[1][0], pts2[1][1], pts2[1][2]), App.Vector(pts2[-1][0], pts2[-1][1], pts2[-1][2])).toShape() else: pts = [] for i in range(arcsegs + 1): p = self.circle.valueAt(self.circle.FirstParameter + ( (self.circle.LastParameter - self.circle.FirstParameter) / arcsegs) * i) pts.append([p.x, p.y, p.z]) self.coords.point.setValues(pts) self.arc.coordIndex.setValues(0, arcsegs + 1, list(range(arcsegs + 1))) # set the arrow coords and rotation self.trans1.translation.setValue((self.p2.x, self.p2.y, self.p2.z)) self.coord1.point.setValue((self.p2.x, self.p2.y, self.p2.z)) self.trans2.translation.setValue((self.p3.x, self.p3.y, self.p3.z)) self.coord2.point.setValue((self.p3.x, self.p3.y, self.p3.z)) # calculate small chords to make arrows look better arrowlength = 4 * obj.ViewObject.ArrowSize.Value u1 = (self.circle.valueAt(self.circle.FirstParameter + arrowlength) ).sub(self.circle.valueAt( self.circle.FirstParameter)).normalize() u2 = (self.circle.valueAt(self.circle.LastParameter)).sub( self.circle.valueAt(self.circle.LastParameter - arrowlength)).normalize() if hasattr(obj.ViewObject, "FlipArrows"): if obj.ViewObject.FlipArrows: u1 = u1.negative() u2 = u2.negative() w2 = self.circle.Curve.Axis w1 = w2.negative() v1 = w1.cross(u1) v2 = w2.cross(u2) q1 = App.Placement(DraftVecUtils.getPlaneRotation(u1, v1, w1)).Rotation.Q q2 = App.Placement(DraftVecUtils.getPlaneRotation(u2, v2, w2)).Rotation.Q self.trans1.rotation.setValue((q1[0], q1[1], q1[2], q1[3])) self.trans2.rotation.setValue((q2[0], q2[1], q2[2], q2[3])) # setting text pos & rot self.tbase = mp if hasattr(obj.ViewObject, "TextPosition"): if not DraftVecUtils.isNull(obj.ViewObject.TextPosition): self.tbase = obj.ViewObject.TextPosition u3 = ray.cross(norm).normalize() v3 = norm.cross(u3) r = App.Placement(DraftVecUtils.getPlaneRotation(u3, v3, norm)).Rotation offset = r.multVec(App.Vector(0, 1, 0)) if hasattr(obj.ViewObject, "TextSpacing"): offset = DraftVecUtils.scaleTo( offset, obj.ViewObject.TextSpacing.Value) else: offset = DraftVecUtils.scaleTo(offset, 0.05) if m == "3D": offset = offset.negative() self.tbase = self.tbase.add(offset) q = r.Q self.textpos.translation.setValue( [self.tbase.x, self.tbase.y, self.tbase.z]) self.textpos.rotation = coin.SbRotation(q[0], q[1], q[2], q[3]) # set the angle property if round(obj.Angle, utils.precision()) != round( a, utils.precision()): obj.Angle = a
def __init__(self, obj): QtGui.QDialog.__init__(self) self.setObjectName(_fromUtf8("TooltableEditor")) self.resize(468, 476) self.verticalLayout = QtGui.QVBoxLayout(self) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.DECIMALS = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Units").GetInt("Decimals", 2) self.FORMAT = DraftGui.makeFormatSpec(self.DECIMALS, 'Length') # left groupbox self.groupBox = QtGui.QGroupBox(self) sizePolicy = QtGui.QSizePolicy( QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.groupBox.sizePolicy().hasHeightForWidth()) self.groupBox.setSizePolicy(sizePolicy) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.horizontalLayout_9 = QtGui.QHBoxLayout() self.horizontalLayout_9.setObjectName(_fromUtf8("horizontalLayout_9")) # import button self.ButtonImport = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("document-import")) self.ButtonImport.setIcon(icon) self.ButtonImport.setObjectName(_fromUtf8("ButtonImport")) self.horizontalLayout_9.addWidget(self.ButtonImport) # export button self.ButtonExport = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("document-export")) self.ButtonExport.setIcon(icon) self.ButtonExport.setObjectName(_fromUtf8("ButtonExport")) self.horizontalLayout_9.addWidget(self.ButtonExport) # tools list self.verticalLayout_2.addLayout(self.horizontalLayout_9) self.ToolsList = QtGui.QTreeWidget(self.groupBox) self.ToolsList.setObjectName(_fromUtf8("ToolsList")) self.ToolsList.header().setDefaultSectionSize(40) self.verticalLayout_2.addWidget(self.ToolsList) # add button self.horizontalLayout_8 = QtGui.QHBoxLayout() self.horizontalLayout_8.setObjectName(_fromUtf8("horizontalLayout_8")) self.ButtonAdd = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-add")) self.ButtonAdd.setIcon(icon) self.ButtonAdd.setObjectName(_fromUtf8("ButtonAdd")) self.horizontalLayout_8.addWidget(self.ButtonAdd) # delete button self.ButtonDelete = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-delete")) self.ButtonDelete.setIcon(icon) self.ButtonDelete.setObjectName(_fromUtf8("ButtonDelete")) self.horizontalLayout_8.addWidget(self.ButtonDelete) # up button self.ButtonUp = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("go-up")) self.ButtonUp.setIcon(icon) self.ButtonDelete.setObjectName(_fromUtf8("ButtonUp")) self.horizontalLayout_8.addWidget(self.ButtonUp) # down button self.ButtonDown = QtGui.QPushButton(self.groupBox) icon = QtGui.QIcon.fromTheme(_fromUtf8("go-down")) self.ButtonDown.setIcon(icon) self.ButtonDown.setObjectName(_fromUtf8("ButtonDown")) self.horizontalLayout_8.addWidget(self.ButtonDown) # right groupbox self.verticalLayout_2.addLayout(self.horizontalLayout_8) self.horizontalLayout.addWidget(self.groupBox) self.groupBox_2 = QtGui.QGroupBox(self) self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) self.verticalLayout_3 = QtGui.QVBoxLayout(self.groupBox_2) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) # name self.label = QtGui.QLabel(self.groupBox_2) self.label.setObjectName(_fromUtf8("label")) self.verticalLayout_3.addWidget(self.label) self.NameField = QtGui.QLineEdit(self.groupBox_2) self.NameField.setObjectName(_fromUtf8("NameField")) self.verticalLayout_3.addWidget(self.NameField) # type self.label_2 = QtGui.QLabel(self.groupBox_2) self.label_2.setObjectName(_fromUtf8("label_2")) self.verticalLayout_3.addWidget(self.label_2) self.TypeField = QtGui.QComboBox(self.groupBox_2) self.TypeField.setObjectName(_fromUtf8("TypeField")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.TypeField.addItem(_fromUtf8("")) self.verticalLayout_3.addWidget(self.TypeField) # material self.label_3 = QtGui.QLabel(self.groupBox_2) self.label_3.setObjectName(_fromUtf8("label_3")) self.verticalLayout_3.addWidget(self.label_3) self.MaterialField = QtGui.QComboBox(self.groupBox_2) self.MaterialField.setObjectName(_fromUtf8("MaterialField")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.MaterialField.addItem(_fromUtf8("")) self.verticalLayout_3.addWidget(self.MaterialField) self.label_4 = QtGui.QLabel(self.groupBox_2) self.label_4.setObjectName(_fromUtf8("label_4")) self.verticalLayout_3.addWidget(self.label_4) # diameter self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_5 = QtGui.QLabel(self.groupBox_2) self.label_5.setObjectName(_fromUtf8("label_5")) self.horizontalLayout_2.addWidget(self.label_5) self.DiameterField = QtGui.QDoubleSpinBox(self.groupBox_2) self.DiameterField.setMaximum(9999) self.DiameterField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.DiameterField.setObjectName(_fromUtf8("DiameterField")) self.horizontalLayout_2.addWidget(self.DiameterField) self.verticalLayout_3.addLayout(self.horizontalLayout_2) # length offset self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.label_6 = QtGui.QLabel(self.groupBox_2) self.label_6.setObjectName(_fromUtf8("label_6")) self.horizontalLayout_3.addWidget(self.label_6) self.LengthOffsetField = QtGui.QDoubleSpinBox(self.groupBox_2) self.LengthOffsetField.setMaximum(9999) self.LengthOffsetField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.LengthOffsetField.setObjectName(_fromUtf8("LengthOffsetField")) self.horizontalLayout_3.addWidget(self.LengthOffsetField) self.verticalLayout_3.addLayout(self.horizontalLayout_3) # flat radius self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4")) self.label_7 = QtGui.QLabel(self.groupBox_2) self.label_7.setObjectName(_fromUtf8("label_7")) self.horizontalLayout_4.addWidget(self.label_7) self.FlatRadiusField = QtGui.QDoubleSpinBox(self.groupBox_2) self.FlatRadiusField.setMaximum(9999) self.FlatRadiusField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.FlatRadiusField.setObjectName(_fromUtf8("FlatRadiusField")) self.horizontalLayout_4.addWidget(self.FlatRadiusField) self.verticalLayout_3.addLayout(self.horizontalLayout_4) # corner radius self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5")) self.label_8 = QtGui.QLabel(self.groupBox_2) self.label_8.setObjectName(_fromUtf8("label_8")) self.horizontalLayout_5.addWidget(self.label_8) self.CornerRadiusField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CornerRadiusField.setMaximum(9999) self.CornerRadiusField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CornerRadiusField.setObjectName(_fromUtf8("CornerRadiusField")) self.horizontalLayout_5.addWidget(self.CornerRadiusField) self.verticalLayout_3.addLayout(self.horizontalLayout_5) # cutting edge angle self.horizontalLayout_6 = QtGui.QHBoxLayout() self.horizontalLayout_6.setObjectName(_fromUtf8("horizontalLayout_6")) self.label_9 = QtGui.QLabel(self.groupBox_2) self.label_9.setObjectName(_fromUtf8("label_9")) self.horizontalLayout_6.addWidget(self.label_9) self.CuttingEdgeAngleField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CuttingEdgeAngleField.setMaximum(360) self.CuttingEdgeAngleField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CuttingEdgeAngleField.setObjectName( _fromUtf8("CuttingEdgeAngleField")) self.horizontalLayout_6.addWidget(self.CuttingEdgeAngleField) self.verticalLayout_3.addLayout(self.horizontalLayout_6) # cutting edge height self.horizontalLayout_7 = QtGui.QHBoxLayout() self.horizontalLayout_7.setObjectName(_fromUtf8("horizontalLayout_7")) self.label_10 = QtGui.QLabel(self.groupBox_2) self.label_10.setObjectName(_fromUtf8("label_10")) self.horizontalLayout_7.addWidget(self.label_10) self.CuttingEdgeHeightField = QtGui.QDoubleSpinBox(self.groupBox_2) self.CuttingEdgeHeightField.setMaximum(9999) self.CuttingEdgeHeightField.setAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.CuttingEdgeHeightField.setObjectName( _fromUtf8("CuttingEdgeHeightField")) self.horizontalLayout_7.addWidget(self.CuttingEdgeHeightField) self.verticalLayout_3.addLayout(self.horizontalLayout_7) self.horizontalLayout.addWidget(self.groupBox_2) self.verticalLayout.addLayout(self.horizontalLayout) # ok / cancel box self.buttonBox = QtGui.QDialogButtonBox(self) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) self.buttonBox.setStandardButtons( QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.retranslateUi() # connect buttons QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL( _fromUtf8("accepted()")), self.accept) QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL( _fromUtf8("rejected()")), self.reject) QtCore.QObject.connect(self.ButtonImport, QtCore.SIGNAL( _fromUtf8("clicked()")), self.read) QtCore.QObject.connect(self.ButtonExport, QtCore.SIGNAL( _fromUtf8("clicked()")), self.write) QtCore.QObject.connect(self.ButtonAdd, QtCore.SIGNAL( _fromUtf8("clicked()")), self.addnew) QtCore.QObject.connect(self.ButtonDelete, QtCore.SIGNAL( _fromUtf8("clicked()")), self.delete) QtCore.QObject.connect(self.ButtonUp, QtCore.SIGNAL( _fromUtf8("clicked()")), self.moveup) QtCore.QObject.connect(self.ButtonDown, QtCore.SIGNAL( _fromUtf8("clicked()")), self.movedown) QtCore.QObject.connect(self.ToolsList, QtCore.SIGNAL(_fromUtf8( "currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)")), self.selectTool) QtCore.QObject.connect(self.NameField, QtCore.SIGNAL( _fromUtf8("textEdited(QString)")), self.changeName) QtCore.QObject.connect(self.TypeField, QtCore.SIGNAL( _fromUtf8("currentIndexChanged(int)")), self.changeType) QtCore.QObject.connect(self.MaterialField, QtCore.SIGNAL( _fromUtf8("currentIndexChanged(int)")), self.changeMaterial) QtCore.QObject.connect(self.DiameterField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeDiameter) QtCore.QObject.connect(self.LengthOffsetField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeLengthOffset) QtCore.QObject.connect(self.FlatRadiusField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeFlatRadius) QtCore.QObject.connect(self.CornerRadiusField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeCornerRadius) QtCore.QObject.connect(self.CuttingEdgeAngleField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeCuttingEdgeAngle) QtCore.QObject.connect(self.CuttingEdgeHeightField, QtCore.SIGNAL( _fromUtf8("valueChanged(double)")), self.changeCuttingEdgeHeight) QtCore.QMetaObject.connectSlotsByName(self) self.tooltable = obj.Tooltable.copy() self.tool = None self.number = None self.reset()