def attach(self, vobj): '''Setup the scene sub-graph of the view provider''' from pivy import coin self.Object = vobj.Object self.color = coin.SoBaseColor() if hasattr(vobj, "LineColor"): self.color.rgb.setValue(vobj.LineColor[0], vobj.LineColor[1], vobj.LineColor[2]) self.font = coin.SoFont() self.font3d = coin.SoFont() self.text = coin.SoAsciiText() self.text3d = coin.SoText2() self.text.string = "d" # some versions of coin crash if string is not set self.text3d.string = "d" self.text.justification = self.text3d.justification = coin.SoAsciiText.CENTER self.textpos = coin.SoTransform() label = coin.SoSeparator() label.addChild(self.textpos) label.addChild(self.color) label.addChild(self.font) label.addChild(self.text) label3d = coin.SoSeparator() label3d.addChild(self.textpos) label3d.addChild(self.color) label3d.addChild(self.font3d) label3d.addChild(self.text3d) self.coord1 = coin.SoCoordinate3() self.trans1 = coin.SoTransform() self.coord2 = coin.SoCoordinate3() self.trans2 = coin.SoTransform() self.marks = coin.SoSeparator() self.drawstyle = coin.SoDrawStyle() self.coords = coin.SoCoordinate3() self.arc = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.node = coin.SoGroup() self.node.addChild(self.color) self.node.addChild(self.drawstyle) self.node.addChild(self.coords) self.node.addChild(self.arc) self.node.addChild(self.marks) self.node.addChild(label) self.node3d = coin.SoGroup() self.node3d.addChild(self.color) self.node3d.addChild(self.drawstyle) self.node3d.addChild(self.coords) self.node3d.addChild(self.arc) self.node3d.addChild(self.marks) self.node3d.addChild(label3d) vobj.addDisplayMode(self.node, "2D") vobj.addDisplayMode(self.node3d, "3D") self.updateData(vobj.Object, None) self.onChanged(vobj, "FontSize") self.onChanged(vobj, "FontName") self.onChanged(vobj, "ArrowType") self.onChanged(vobj, "LineColor") # backwards compatibility self.ScaleMultiplier = 1.00
def __init__(self, points, sh=None): super(MarkerOnEdge, self).__init__(points, True) self._shape = None self._sublink = None self._tangent = None self._text_type = 0 self._text_translate = coin.SoTranslation() self._text_font = coin.SoFont() self._text_font.name = "Arial:Bold" self._text_font.size = 13.0 self._text = coin.SoText2() self._text_switch = coin.SoSwitch() self._text_switch.whichChild = coin.SO_SWITCH_ALL self._text_switch.addChild(self._text_translate) self._text_switch.addChild(self._text_font) self._text_switch.addChild(self._text) #self.on_drag_start.append(self.add_text) #self.on_drag_release.append(self.remove_text) self.on_drag.append(self.update_text) self.update_text() self.addChild(self._text_switch) if isinstance(sh, Part.Shape): self.snap_shape = sh elif isinstance(sh, (tuple, list)): self.sublink = sh
def attach(self,vobj): '''Setup the scene sub-graph of the view provider''' self.mattext = coin.SoMaterial() textdrawstyle = coin.SoDrawStyle() textdrawstyle.style = coin.SoDrawStyle.FILLED self.trans = coin.SoTransform() self.font = coin.SoFont() self.text2d = coin.SoAsciiText() self.text3d = coin.SoText2() self.text2d.string = self.text3d.string = "Label" # need to init with something, otherwise, crash! self.text2d.justification = coin.SoAsciiText.LEFT self.text3d.justification = coin.SoText2.LEFT self.node2d = coin.SoGroup() self.node2d.addChild(self.trans) self.node2d.addChild(self.mattext) self.node2d.addChild(textdrawstyle) self.node2d.addChild(self.font) self.node2d.addChild(self.text2d) self.node3d = coin.SoGroup() self.node3d.addChild(self.trans) self.node3d.addChild(self.mattext) self.node3d.addChild(textdrawstyle) self.node3d.addChild(self.font) self.node3d.addChild(self.text3d) vobj.addDisplayMode(self.node2d,"2D text") vobj.addDisplayMode(self.node3d,"3D text") self.onChanged(vobj,"TextColor") self.onChanged(vobj,"FontSize") self.onChanged(vobj,"FontName") self.onChanged(vobj,"Justification") self.onChanged(vobj,"LineSpacing")
def displaytext(self, pos, color=(1, 1, 1), text=["aaa", "bbb"]): textpos = coin.SoTransform() p = pos textpos.translation.setValue(p.x + 10, p.y + 10, p.z + 10) font = coin.SoFont() font.size = 20 text2d = coin.SoText2() text3d = coin.SoAsciiText() text2d.string.setValues([l.encode("utf8") for l in text if l]) text3d.string.setValues([l.encode("utf8") for l in text if l]) myMaterial = SoMaterial() myMaterial.diffuseColor.set1Value(0, SbColor(*color)) try: sg = self._sg except: sg = SoSeparator() self._sg = sg root = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() root.addChild(sg) node2d = SoSeparator() node2d.addChild(textpos) node2d.addChild(myMaterial) node2d.addChild(font) node2d.addChild(text2d) #node2d.addChild(text3d) sg.addChild(node2d)
def attach(self,vobj): '''Setup the scene sub-graph of the view provider''' self.arrow = coin.SoSeparator() self.arrowpos = coin.SoTransform() self.arrow.addChild(self.arrowpos) self.matline = coin.SoMaterial() self.drawstyle = coin.SoDrawStyle() self.drawstyle.style = coin.SoDrawStyle.LINES self.lcoords = coin.SoCoordinate3() self.line = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.mattext = coin.SoMaterial() textdrawstyle = coin.SoDrawStyle() textdrawstyle.style = coin.SoDrawStyle.FILLED self.textpos = coin.SoTransform() self.font = coin.SoFont() self.text2d = coin.SoText2() self.text3d = coin.SoAsciiText() self.text2d.string = self.text3d.string = "Label" # need to init with something, otherwise, crash! self.text2d.justification = coin.SoText2.RIGHT self.text3d.justification = coin.SoAsciiText.RIGHT self.fcoords = coin.SoCoordinate3() self.frame = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.lineswitch = coin.SoSwitch() switchnode = coin.SoSeparator() switchnode.addChild(self.line) switchnode.addChild(self.arrow) self.lineswitch.addChild(switchnode) self.lineswitch.whichChild = 0 self.node2d = coin.SoGroup() self.node2d.addChild(self.matline) self.node2d.addChild(self.arrow) self.node2d.addChild(self.drawstyle) self.node2d.addChild(self.lcoords) self.node2d.addChild(self.lineswitch) self.node2d.addChild(self.mattext) self.node2d.addChild(textdrawstyle) self.node2d.addChild(self.textpos) self.node2d.addChild(self.font) self.node2d.addChild(self.text2d) self.node2d.addChild(self.fcoords) self.node2d.addChild(self.frame) self.node3d = coin.SoGroup() self.node3d.addChild(self.matline) self.node3d.addChild(self.arrow) self.node3d.addChild(self.drawstyle) self.node3d.addChild(self.lcoords) self.node3d.addChild(self.lineswitch) self.node3d.addChild(self.mattext) self.node3d.addChild(textdrawstyle) self.node3d.addChild(self.textpos) self.node3d.addChild(self.font) self.node3d.addChild(self.text3d) self.node3d.addChild(self.fcoords) self.node3d.addChild(self.frame) vobj.addDisplayMode(self.node2d,"2D text") vobj.addDisplayMode(self.node3d,"3D text") self.onChanged(vobj,"LineColor") self.onChanged(vobj,"TextColor") self.onChanged(vobj,"ArrowSize") self.onChanged(vobj,"Line")
def __createGraphTitle(self): font = coin.SoFont() font.name.setValue('Times-Roman') font.size.setValue(16) g = coin.SoSeparator() # translation t = coin.SoTranslation() t.translation.setValue(self.__AxisWidth / 2, self.__AxisHeight * 1.1, 0) g.addChild(t) # color g.addChild(__baseColor__) #font g.addChild(font) # text text = coin.SoText3() text.string = self.__graphTitle text.justification = coin.SoText3.CENTER g.addChild(text) self.__root.addChild(g)
def __createHintTextsAndColors(self): rootHint = coin.SoSeparator() # hint lines colorLines = coin.SoSeparator() rootHint.addChild(colorLines) mat = coin.SoMaterial() mat.diffuseColor.setValues(0, len(self.__hintColors), self.__hintColors) colorLines.addChild(mat) bind = coin.SoMaterialBinding() bind.value = coin.SoMaterialBinding.PER_PART colorLines.addChild(bind) lineCoords = coin.SoCoordinate3() colorLines.addChild(lineCoords) lineset = coin.SoLineSet() colorLines.addChild(lineset) space = self.__AxisHeight / self.__scalesNum4XAxis startX = self.__AxisWidth * 1.05 pts = [] for i, s in enumerate(self.__hintTexts): pts.append((startX, self.__AxisHeight - i * space, 0)) pts.append((startX + space, self.__AxisHeight - i * space, 0)) lineCoords.point.setValues(0, len(pts), pts) nums = [2] * (len(pts) / 2) lineset.numVertices.setValues(0, len(nums), nums) # add texts font = coin.SoFont() font.name.setValue('Times-Roman') font.size.setValue(9) scaleLen = self.__AxisHeight / self.__scalesNum4XAxis for i in range(len(self.__hintColors)): g = coin.SoSeparator() # translation t = coin.SoTranslation() t.translation.setValue(startX + space * 2, self.__AxisHeight - i * space, 0) g.addChild(t) # color col = coin.SoBaseColor() col.rgb.setValue(self.__hintColors[i][:3]) g.addChild(col) #font g.addChild(font) # text text = coin.SoText3() text.string = self.__hintTexts[i] text.justification = coin.SoText3.LEFT g.addChild(text) rootHint.addChild(g) self.__root.addChild(rootHint)
def attach(self, vobj): ArchComponent.ViewProviderComponent.attach(self, vobj) from pivy import coin self.color = coin.SoBaseColor() self.font = coin.SoFont() self.text1 = coin.SoAsciiText() self.text1.string = " " self.text1.justification = coin.SoAsciiText.LEFT self.text2 = coin.SoAsciiText() self.text2.string = " " self.text2.justification = coin.SoAsciiText.LEFT self.coords = coin.SoTransform() self.header = coin.SoTransform() label = coin.SoSeparator() label.addChild(self.coords) label.addChild(self.color) label.addChild(self.font) label.addChild(self.text2) label.addChild(self.header) label.addChild(self.text1) vobj.Annotation.addChild(label) self.onChanged(vobj, "TextColor") self.onChanged(vobj, "FontSize") self.onChanged(vobj, "FirstLine") self.onChanged(vobj, "LineSpacing") self.onChanged(vobj, "FontName")
def attach(self, vobj): self.Object = vobj.Object self.clip = None from pivy import coin self.sep = coin.SoGroup() self.mat = coin.SoMaterial() self.sep.addChild(self.mat) self.dst = coin.SoDrawStyle() self.sep.addChild(self.dst) self.lco = coin.SoCoordinate3() self.sep.addChild(self.lco) lin = coin.SoType.fromName("SoBrepEdgeSet").createInstance() lin.coordIndex.setValues([0, 1, -1, 2, 3, -1, 4, 5, -1]) self.sep.addChild(lin) self.tra = coin.SoTransform() self.tra.rotation.setValue(FreeCAD.Rotation(0, 0, 90).Q) self.sep.addChild(self.tra) self.fon = coin.SoFont() self.sep.addChild(self.fon) self.txt = coin.SoAsciiText() self.txt.justification = coin.SoText2.LEFT self.txt.string.setValue("level") self.sep.addChild(self.txt) vobj.addDisplayMode(self.sep, "Default") self.onChanged(vobj, "ShapeColor") self.onChanged(vobj, "FontName") self.onChanged(vobj, "ShowLevel") self.onChanged(vobj, "FontSize") return
def __createTexts(self): font = coin.SoFont() font.name.setValue('Times-Roman') font.size.setValue(9) scaleLen = self.__AxisWidth / self.__scalesNum4XAxis # add x scales flag = False if self.__xMax - self.__xMin > 10: flag = True nums = self.__AxisWidth / scaleLen for i in range(nums): g = coin.SoSeparator() # translation t = coin.SoTranslation() t.translation.setValue(i * scaleLen, -scaleLen * (i % 3 + 1), 0) g.addChild(t) # color g.addChild(__baseColor__) #font g.addChild(font) # text text = coin.SoText3() if flag: text.string = '%d' % int( (self.__xMax - self.__xMin) * i / nums) else: text.string = '%.4lf' % ( (self.__xMax - self.__xMin) * i / nums) text.justification = coin.SoText3.RIGHT g.addChild(text) self.__rootTexts.addChild(g) # add y scales nums = self.__AxisHeight / scaleLen for i in range(nums): g = coin.SoSeparator() # translation t = coin.SoTranslation() t.translation.setValue(-scaleLen, i * scaleLen, 0) g.addChild(t) # color g.addChild(__baseColor__) #font g.addChild(font) # text text = coin.SoText3() text.string = '%.4lf' % (self.__yMin + (self.__yMax - self.__yMin) * i / nums) text.justification = coin.SoText3.RIGHT g.addChild(text) self.__rootTexts.addChild(g)
def __init__(self): GRID_TRANSPARENCY = 0 col = self.getGridColor() pick = coin.SoPickStyle() pick.style.setValue(coin.SoPickStyle.UNPICKABLE) self.trans = coin.SoTransform() self.trans.translation.setValue([0, 0, 0]) mat1 = coin.SoMaterial() mat1.transparency.setValue(0.7*(1-GRID_TRANSPARENCY)) mat1.diffuseColor.setValue(col) self.font = coin.SoFont() self.coords1 = coin.SoCoordinate3() self.lines1 = coin.SoLineSet() texts = coin.SoSeparator() t1 = coin.SoSeparator() self.textpos1 = coin.SoTransform() self.text1 = coin.SoAsciiText() self.text1.string = " " t2 = coin.SoSeparator() self.textpos2 = coin.SoTransform() self.textpos2.rotation.setValue((0.0, 0.0, 0.7071067811865475, 0.7071067811865476)) self.text2 = coin.SoAsciiText() self.text2.string = " " t1.addChild(self.textpos1) t1.addChild(self.text1) t2.addChild(self.textpos2) t2.addChild(self.text2) texts.addChild(self.font) texts.addChild(t1) texts.addChild(t2) mat2 = coin.SoMaterial() mat2.transparency.setValue(0.3*(1-GRID_TRANSPARENCY)) mat2.diffuseColor.setValue(col) self.coords2 = coin.SoCoordinate3() self.lines2 = coin.SoLineSet() mat3 = coin.SoMaterial() mat3.transparency.setValue(GRID_TRANSPARENCY) mat3.diffuseColor.setValue(col) self.coords3 = coin.SoCoordinate3() self.lines3 = coin.SoLineSet() self.pts = [] s = coin.SoSeparator() s.addChild(pick) s.addChild(self.trans) s.addChild(mat1) s.addChild(self.coords1) s.addChild(self.lines1) s.addChild(mat2) s.addChild(self.coords2) s.addChild(self.lines2) s.addChild(mat3) s.addChild(self.coords3) s.addChild(self.lines3) s.addChild(texts) Tracker.__init__(self, children=[s], name="gridTracker") self.reset()
def makeBubbles(self): import Part def getNode(): # make sure we already have the complete node built r = self.ViewObject.RootNode if r.getChildren().getLength() > 2: if r.getChild(2).getChildren().getLength() > 0: if r.getChild(2).getChild(0).getChildren().getLength() > 0: return self.ViewObject.RootNode.getChild(2).getChild( 0).getChild(0) return None rn = getNode() if rn: if self.bubbles: rn.removeChild(self.bubbles) self.bubbles = None self.bubbles = coin.SoSeparator() isep = coin.SoSeparator() self.bubblestyle = coin.SoDrawStyle() self.bubblestyle.linePattern = 0xffff self.bubbles.addChild(self.bubblestyle) for i in range(len(self.ViewObject.Object.Distances)): invpl = self.ViewObject.Object.Placement.inverse() verts = self.ViewObject.Object.Shape.Edges[i].Vertexes p1 = invpl.multVec(verts[0].Point) p2 = invpl.multVec(verts[1].Point) dv = p2.sub(p1) dv.normalize() rad = self.ViewObject.BubbleSize center = p2.add(dv.scale(rad, rad, rad)) ts = Part.makeCircle(rad, center).writeInventor() cin = coin.SoInput() cin.setBuffer(ts) cob = coin.SoDB.readAll(cin) co = cob.getChild(1).getChild(0).getChild(2) li = cob.getChild(1).getChild(0).getChild(3) self.bubbles.addChild(co) self.bubbles.addChild(li) st = coin.SoSeparator() tr = coin.SoTransform() tr.translation.setValue( (center.x, center.y - rad / 4, center.z)) fo = coin.SoFont() fo.name = "Arial,Sans" fo.size = rad * 100 tx = coin.SoText2() tx.justification = coin.SoText2.CENTER tx.string = self.getNumber(i) st.addChild(tr) st.addChild(fo) st.addChild(tx) isep.addChild(st) self.bubbles.addChild(isep) rn.addChild(self.bubbles)
def __init__(self, view, coneHeight=5): self.view = view self.tsze = coneHeight self.cam = coin.SoOrthographicCamera() self.cam.aspectRatio = 1 self.cam.viewportMapping = coin.SoCamera.LEAVE_ALONE self.pos = coin.SoTranslation() self.mat = coin.SoMaterial() self.mat.diffuseColor = coin.SbColor(0.9, 0.0, 0.9) self.mat.transparency = 0 self.fnt = coin.SoFont() self.txt = coin.SoText2() self.txt.string = 'setValues' self.txt.justification = coin.SoText2.LEFT self.sep = coin.SoSeparator() self.sep.addChild(self.cam) self.sep.addChild(self.pos) self.sep.addChild(self.mat) self.sep.addChild(self.fnt) self.sep.addChild(self.txt) self.tTrf = coin.SoTransform() self.tTrf.translation.setValue((0, -self.tsze / 2, 0)) self.tTrf.center.setValue((0, self.tsze / 2, 0)) self.tTrf.rotation.setValue(coin.SbVec3f((1, 0, 0)), -math.pi / 2) self.tPos = coin.SoTranslation() self.tMat = coin.SoMaterial() self.tMat.diffuseColor = coin.SbColor(0.4, 0.4, 0.4) self.tMat.transparency = 0.8 self.tool = coin.SoCone() self.tool.height.setValue(self.tsze) self.tool.bottomRadius.setValue(self.tsze / 4) self.tSep = coin.SoSeparator() self.tSep.addChild(self.tPos) self.tSep.addChild(self.tTrf) self.tSep.addChild(self.tMat) self.tSep.addChild(self.tool) self.viewer = self.view.getViewer() self.render = self.viewer.getSoRenderManager() self.sup = None self.updatePreferences() self.setPosition(0, 0, 0, 0, 0, 0, False, False)
def __init__(self, color = (0.,0.,0.), font = 'sans', size = 16, offset = 0): super(multiTextNode, self).__init__() self.fontNode = coin.SoFont() self.textSep = coin.SoSeparator() self.nodeList = [] self._data = [] self.addChild(self.fontNode) self.addChild(self.textSep) self.color = color self.font = font self.size = size self.offset = offset
def __init__(self, color = (0.,0.,0.), font = 'sans', size = 16, trans = (0,0,0), text = ''): super(text2dNode, self).__init__() self.fontNode = coin.SoFont() self.transNode = coin.SoTransform() self.textNode = coin.SoText2() self.addChild(self.fontNode) self.addChild(self.transNode) self.addChild(self.textNode) self.color = color self.font = font self.size = size self.trans = trans self.text = text
def draw_label(text=[], prop: propertyValues=None): ''' Draw widgets label relative to the position with alignment''' if text=='' or prop ==None: return # Nothing to do here try: delta=App.Vector(0,0,0) print (prop.vectors) p1=App.Vector(prop.vectors[0]) #You must cast the value or it will fail p2=App.Vector(prop.vectors[1]) delta.x=p1.x+2 delta.y=p1.y+2 delta.z=p1.z (r,thi,phi)=calculateLineSpherical(prop.vectors) #get spherical representation of the point(p2) _transPositionPOS=coin.SoTransform() #_transPositionX = coin.SoTransform() _transPositionY = coin.SoTransform() _transPositionZ = coin.SoTransform() _transPositionPOS.translation.setValue(delta) _transPositionY.translation.setValue(App.Vector(0,0,0)) _transPositionZ.translation.setValue(App.Vector(0,0,0)) print (delta) _transPositionY.rotation.setValue(coin.SbVec3f(1,0, 0),phi) _transPositionZ.rotation.setValue(coin.SbVec3f(0, 0, 1),thi) font = coin.SoFont() font.size = prop.fontsize # Font size font.Name = prop.labelfont # Font used _text3D = coin.SoAsciiText() # Draw text in the 3D world _text3D.string.setValues([l.encode("utf8") for l in text if l]) #_text3D.justification = coin.SoAsciiText.LEFT coinColor = coin.SoMaterial() # Font color coinColor.diffuseColor.set1Value(0, coin.SbColor(*prop.labelcolor)) _textNode = coin.SoSeparator() # A Separator to separate the text from the drawing _textNode.addChild(_transPositionPOS) if phi!=0: _textNode.addChild(_transPositionY) if thi!=0: _textNode.addChild(_transPositionZ) _textNode.addChild(coinColor) _textNode.addChild(font) _textNode.addChild(_text3D) return _textNode # Return the created SoSeparator that contains the text except Exception as err: App.Console.PrintError("'draw_label' Failed. " "{err}\n".format(err=str(err))) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_lineno)
def __init__(self, parent, dynamic=False): super(CustomText, self).__init__(parent.points, dynamic) #self._text_offset = FreeCAD.Vector(0,0,0) self._text_translate = coin.SoTranslation() self._text_font = coin.SoFont() self._text_font.name = "Arial:Bold" self._text_font.size = 13.0 self._text = coin.SoText2() self._text_switch = coin.SoSwitch() self._text_switch.addChild(self._text_translate) self._text_switch.addChild(self._text_font) self._text_switch.addChild(self._text) self.addChild(self._text_switch) self.parent = parent self.parent.on_drag.append(self.translate) self.translate()
def attach(self,vobj): self.Object = vobj.Object self.clip = None from pivy import coin self.sep = coin.SoGroup() self.mat = coin.SoMaterial() self.sep.addChild(self.mat) self.dst = coin.SoDrawStyle() self.sep.addChild(self.dst) self.lco = coin.SoCoordinate3() self.sep.addChild(self.lco) lin = coin.SoType.fromName("SoBrepEdgeSet").createInstance() lin.coordIndex.setValues([0,1,-1,2,3,-1,4,5,-1]) self.sep.addChild(lin) self.bbox = coin.SoSwitch() self.bbox.whichChild = -1 bboxsep = coin.SoSeparator() self.bbox.addChild(bboxsep) drawstyle = coin.SoDrawStyle() drawstyle.style = coin.SoDrawStyle.LINES drawstyle.lineWidth = 3 drawstyle.linePattern = 0x0f0f # 0xaa bboxsep.addChild(drawstyle) self.bbco = coin.SoCoordinate3() bboxsep.addChild(self.bbco) lin = coin.SoIndexedLineSet() lin.coordIndex.setValues([0,1,2,3,0,-1,4,5,6,7,4,-1,0,4,-1,1,5,-1,2,6,-1,3,7,-1]) bboxsep.addChild(lin) self.sep.addChild(self.bbox) self.tra = coin.SoTransform() self.tra.rotation.setValue(FreeCAD.Rotation(0,0,90).Q) self.sep.addChild(self.tra) self.fon = coin.SoFont() self.sep.addChild(self.fon) self.txt = coin.SoAsciiText() self.txt.justification = coin.SoText2.LEFT self.txt.string.setValue("level") self.sep.addChild(self.txt) vobj.addDisplayMode(self.sep,"Default") self.onChanged(vobj,"ShapeColor") self.onChanged(vobj,"FontName") self.onChanged(vobj,"ShowLevel") self.onChanged(vobj,"FontSize") self.onChanged(vobj,"AutogroupBox") self.setProperties(vobj) return
def Activated(self): self.states = [ 'selecting_face', 'choosing_drafting_tools', 'drawing', 'extruding', 'finalizing' ] self.state = self.states[0] # Coin Separator for text helping user during the command textSep = coin.SoSeparator() cam = coin.SoOrthographicCamera() cam.aspectRatio = 1 cam.viewportMapping = coin.SoCamera.LEAVE_ALONE trans = coin.SoTranslation() trans.translation = (-0.98, 0.85, 0) myFont = coin.SoFont() myFont.name = "Arial" size = 50 myFont.size.setValue(size) self.SoText2 = coin.SoText2() self.SoText2.string.setValues( 0, 2, ["Sélectionner une face d'un composant", ""]) color = coin.SoBaseColor() color.rgb = (0, 0, 0) textSep.addChild(cam) textSep.addChild(trans) textSep.addChild(color) textSep.addChild(myFont) textSep.addChild(self.SoText2) activeDoc = Gui.ActiveDocument view = activeDoc.ActiveView self.sg = view.getSceneGraph() viewer = view.getViewer() self.render = viewer.getSoRenderManager() self.sup = self.render.addSuperimposition(textSep) self.sg.touch() # Timer to check what the user is doing self.machining_timer = QtCore.QTimer() self.machining_timer.setInterval(200) self.machining_timer.timeout.connect(self.check) self.start()
def onChanged(self, vobj, prop): ''' Update Object visuals when a view property changed. ''' labels = vobj.getPropertyByName("Labels") self.point_labels.removeAllChildren() if labels: if prop == "Labels" or prop == "Name" or prop == "NortingEasting"\ or prop == "Elevation" or prop == "Description": origin = geo_origin.get(vobj.Object.Points[0]) show_name = vobj.getPropertyByName("Name") show_ne = vobj.getPropertyByName("NortingEasting") show_z = vobj.getPropertyByName("Elevation") show_des = vobj.getPropertyByName("Description") for vector in vobj.Object.Points: font = coin.SoFont() font.size = 1000 point_label = coin.SoSeparator() location = coin.SoTranslation() text = coin.SoAsciiText() index = vobj.Object.Points.index(vector) labels =[] if show_name: labels.append(vobj.Object.PointNames[index]) if show_ne: labels.extend([str(round(vector.x/1000, 3)), str(round(vector.y/1000,3))]) if show_z: labels.append(str(round(vector.z/1000,3))) if show_des and vobj.Object.Descriptions: labels.append(vobj.Object.Descriptions[index]) location.translation = vector.sub(FreeCAD.Vector(origin.Origin.x, origin.Origin.y, 0)) text.string.setValues(labels) point_label.addChild(font) point_label.addChild(location) point_label.addChild(text) self.point_labels.addChild(point_label) if prop == "PointSize": size = vobj.getPropertyByName("PointSize") self.point_style.pointSize = size if prop == "PointColor": color = vobj.getPropertyByName("PointColor") self.color_mat.diffuseColor = (color[0],color[1],color[2])
def Activated(self, index=0): if index == 1: debug("GeomInfo activated") self.stack = [] # install the function in resident mode FreeCADGui.Selection.addObserver(self) self.active = True self.textSep = coin.SoSeparator() self.cam = coin.SoOrthographicCamera() self.cam.aspectRatio = 1 self.cam.viewportMapping = coin.SoCamera.LEAVE_ALONE self.trans = coin.SoTranslation() self.trans.translation = (-0.98, 0.90, 0) self.myFont = coin.SoFont() self.myFont.name = "FreeMono,FreeSans,sans" size = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/Curves").GetInt( 'GeomInfoFontSize', 14) print(size) self.myFont.size.setValue(size) self.SoText2 = coin.SoText2() self.SoText2.string = "" # "Nothing Selected\r2nd line" self.color = coin.SoBaseColor() self.color.rgb = (0, 0, 0) self.textSep.addChild(self.cam) self.textSep.addChild(self.trans) self.textSep.addChild(self.color) self.textSep.addChild(self.myFont) self.textSep.addChild(self.SoText2) self.addHUD() self.Active = True self.viz = False self.getTopo() elif (index == 0) and self.Active: debug("GeomInfo off") self.removeHUD() self.Active = False FreeCADGui.Selection.removeObserver(self)
def attach(self,vobj): ArchComponent.ViewProviderComponent.attach(self,vobj) from pivy import coin self.color = coin.SoBaseColor() self.font = coin.SoFont() self.text1 = coin.SoAsciiText() self.text1.string = " " self.text1.justification = coin.SoAsciiText.LEFT self.text2 = coin.SoAsciiText() self.text2.string = " " self.text2.justification = coin.SoAsciiText.LEFT self.coords = coin.SoTransform() self.header = coin.SoTransform() self.label = coin.SoSwitch() sep = coin.SoSeparator() self.label.whichChild = 0 sep.addChild(self.coords) sep.addChild(self.color) sep.addChild(self.font) sep.addChild(self.text2) sep.addChild(self.header) sep.addChild(self.text1) self.label.addChild(sep) vobj.Annotation.addChild(self.label) self.onChanged(vobj,"TextColor") self.onChanged(vobj,"FontSize") self.onChanged(vobj,"FirstLine") self.onChanged(vobj,"LineSpacing") self.onChanged(vobj,"FontName") self.Object = vobj.Object # footprint mode self.fmat = coin.SoMaterial() self.fcoords = coin.SoCoordinate3() self.fset = coin.SoIndexedFaceSet() fhints = coin.SoShapeHints() fhints.vertexOrdering = fhints.COUNTERCLOCKWISE sep = coin.SoSeparator() sep.addChild(self.fmat) sep.addChild(self.fcoords) sep.addChild(fhints) sep.addChild(self.fset) vobj.RootNode.addChild(sep)
def __init__(self,pl=None, sizeFont=30, color=(1.0,0.6,0.0), text='TEXT'): import FreeCAD, FreeCADGui self.node=coin.SoSeparator() self.color=coin.SoBaseColor() self.color.rgb=color self.node.addChild(self.color) self.transform=coin.SoTransform() self.node.addChild(self.transform) self.font=coin.SoFont() self.node.addChild(self.font) self.font.size=sizeFont self.text=coin.SoText2() self.text.string=text self.node.addChild(self.text) self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() self.sg.addChild(self.node) if not pl: pl=FreeCAD.Placement() self.moveto(pl)
def __init__(self): super(textArea, self).__init__() self.trans = coin.SoTranslation() self.trans.translation = (-0.98,0.95,0) self.font = coin.SoFont() self.font.name = "osiFont,FreeSans,sans" self.font.size.setValue(16.0) self.str = coin.SoText2() self.str.string = "" self.color = coin.SoBaseColor() self.color.rgb = (0,0,0) self.addChild(self.trans) self.addChild(self.color) self.addChild(self.font) self.addChild(self.str)
def attach(self, vobj): """Set up the scene sub-graph of the view provider.""" # Main attributes of the Coin scenegraph self.mattext = coin.SoMaterial() self.trans = coin.SoTransform() self.font = coin.SoFont() self.text2d = coin.SoText2() # Faces the camera always self.text3d = coin.SoAsciiText() # Can be oriented in 3D space textdrawstyle = coin.SoDrawStyle() textdrawstyle.style = coin.SoDrawStyle.FILLED # The text string needs to be initialized to something, # otherwise it may crash self.text2d.string = self.text3d.string = "Label" self.text2d.justification = coin.SoText2.LEFT self.text3d.justification = coin.SoAsciiText.LEFT self.node2d = coin.SoGroup() self.node2d.addChild(self.trans) self.node2d.addChild(self.mattext) self.node2d.addChild(textdrawstyle) self.node2d.addChild(self.font) self.node2d.addChild(self.text2d) self.node3d = coin.SoGroup() self.node3d.addChild(self.trans) self.node3d.addChild(self.mattext) self.node3d.addChild(textdrawstyle) self.node3d.addChild(self.font) self.node3d.addChild(self.text3d) vobj.addDisplayMode(self.node2d, "2D text") vobj.addDisplayMode(self.node3d, "3D text") self.onChanged(vobj, "TextColor") self.onChanged(vobj, "FontSize") self.onChanged(vobj, "FontName") self.onChanged(vobj, "Justification") self.onChanged(vobj, "LineSpacing") self.onChanged(vobj, "ScaleMultiplier") self.Object = vobj.Object
def __init__(self, view): self.view = view self.pos = coin.SoTranslation() self.mat = coin.SoMaterial() self.mat.diffuseColor = coin.SbColor( MachinekitPreferences.hudFontColorUnhomed()) self.mat.transparency = 0 self.fnt = coin.SoFont() self.txt = coin.SoText2() self.txt.string = 'setValues' self.txt.justification = coin.SoText2.LEFT self.sep = coin.SoSeparator() self.sep.addChild(self.pos) self.sep.addChild(self.mat) self.sep.addChild(self.fnt) self.sep.addChild(self.txt)
def onChanged(self, vobj, prop): if prop == "LineColor": l = vobj.LineColor self.mat.diffuseColor.setValue([l[0], l[1], l[2]]) elif prop == "DrawStyle": if vobj.DrawStyle == "Solid": self.linestyle.linePattern = 0xffff elif vobj.DrawStyle == "Dashed": self.linestyle.linePattern = 0xf00f elif vobj.DrawStyle == "Dotted": self.linestyle.linePattern = 0x0f0f else: self.linestyle.linePattern = 0xff88 elif prop == "LineWidth": self.linestyle.lineWidth = vobj.LineWidth elif prop in ["BubbleSize", "BubblePosition", "FontName", "FontSize"]: if hasattr(self, "bubbleset"): if self.bubbles: self.bubbleset.removeChild(self.bubbles) self.bubbles = None if vobj.Object.Shape: if vobj.Object.Shape.Edges: self.bubbles = coin.SoSeparator() self.bubblestyle = coin.SoDrawStyle() self.bubblestyle.linePattern = 0xffff self.bubbles.addChild(self.bubblestyle) import Part, Draft self.bubbletexts = [] pos = ["Start"] if hasattr(vobj, "BubblePosition"): if vobj.BubblePosition == "Both": pos = ["Start", "End"] elif vobj.BubblePosition == "None": pos = [] else: pos = [vobj.BubblePosition] for i in range(len(vobj.Object.Shape.Edges)): for p in pos: verts = vobj.Object.Shape.Edges[i].Vertexes if p == "Start": p1 = verts[0].Point p2 = verts[1].Point else: p1 = verts[1].Point p2 = verts[0].Point dv = p2.sub(p1) dv.normalize() if hasattr(vobj.BubbleSize, "Value"): rad = vobj.BubbleSize.Value / 2 else: rad = vobj.BubbleSize / 2 center = p2.add(dv.scale(rad, rad, rad)) buf = Part.makeCircle(rad, center).writeInventor() try: cin = coin.SoInput() cin.setBuffer(buf) cob = coin.SoDB.readAll(cin) except: import re # workaround for pivy SoInput.setBuffer() bug buf = buf.replace("\n", "") pts = re.findall("point \[(.*?)\]", buf)[0] pts = pts.split(",") pc = [] for p in pts: v = p.strip().split() pc.append([ float(v[0]), float(v[1]), float(v[2]) ]) coords = coin.SoCoordinate3() coords.point.setValues(0, len(pc), pc) line = coin.SoLineSet() line.numVertices.setValue(-1) else: coords = cob.getChild(1).getChild( 0).getChild(2) line = cob.getChild(1).getChild( 0).getChild(3) self.bubbles.addChild(coords) self.bubbles.addChild(line) st = coin.SoSeparator() tr = coin.SoTransform() fs = rad * 1.5 if hasattr(vobj, "FontSize"): fs = vobj.FontSize.Value tr.translation.setValue( (center.x, center.y - fs / 2.5, center.z)) fo = coin.SoFont() fn = Draft.getParam("textfont", "Arial,Sans") if hasattr(vobj, "FontName"): if vobj.FontName: try: fn = str(vobj.FontName) except: pass fo.name = fn fo.size = fs tx = coin.SoAsciiText() tx.justification = coin.SoText2.CENTER self.bubbletexts.append(tx) st.addChild(tr) st.addChild(fo) st.addChild(tx) self.bubbles.addChild(st) self.bubbleset.addChild(self.bubbles) self.onChanged(vobj, "NumberingStyle") if prop in ["FontName", "FontSize"]: self.onChanged(vobj, "ShowLabel") elif prop in ["NumberingStyle", "StartNumber"]: if hasattr(self, "bubbletexts"): chars = "abcdefghijklmnopqrstuvwxyz" roman = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1)) num = 0 if hasattr(vobj, "StartNumber"): if vobj.StartNumber > 1: num = vobj.StartNumber - 1 alt = False for t in self.bubbletexts: if hasattr(vobj, "NumberingStyle"): if vobj.NumberingStyle == "1,2,3": t.string = str(num + 1) elif vobj.NumberingStyle == "01,02,03": t.string = str(num + 1).zfill(2) elif vobj.NumberingStyle == "001,002,003": t.string = str(num + 1).zfill(3) elif vobj.NumberingStyle == "A,B,C": result = "" base = num / 26 if base: result += chars[base].upper() remainder = num % 26 result += chars[remainder].upper() t.string = result elif vobj.NumberingStyle == "a,b,c": result = "" base = num / 26 if base: result += chars[base] remainder = num % 26 result += chars[remainder] t.string = result elif vobj.NumberingStyle == "I,II,III": result = "" n = num n += 1 for numeral, integer in roman: while n >= integer: result += numeral n -= integer t.string = result elif vobj.NumberingStyle == "L0,L1,L2": t.string = "L" + str(num) else: t.string = str(num + 1) num += 1 if hasattr(vobj, "BubblePosition"): if vobj.BubblePosition == "Both": if not alt: num -= 1 alt = not alt elif prop in ["ShowLabel", "LabelOffset"]: if hasattr(self, "labels"): if self.labels: self.labelset.removeChild(self.labels) self.labels = None if hasattr(vobj, "ShowLabel") and hasattr(vobj.Object, "Labels"): if vobj.ShowLabel: self.labels = coin.SoSeparator() for i in range(len(vobj.Object.Shape.Edges)): if len(vobj.Object.Labels) > i: if vobj.Object.Labels[i]: import Draft vert = vobj.Object.Shape.Edges[i].Vertexes[ 0].Point if hasattr(vobj, "LabelOffset"): pl = FreeCAD.Placement(vobj.LabelOffset) pl.Base = vert.add(pl.Base) st = coin.SoSeparator() tr = coin.SoTransform() fo = coin.SoFont() tx = coin.SoAsciiText() tx.justification = coin.SoText2.LEFT t = vobj.Object.Labels[i] if isinstance(t, unicode): t = t.encode("utf8") tx.string.setValue(t) if hasattr(vobj, "FontSize"): fs = vobj.FontSize.Value elif hasattr(vobj.BubbleSize, "Value"): fs = vobj.BubbleSize.Value * 0.75 else: fs = vobj.BubbleSize * 0.75 tr.translation.setValue(tuple(pl.Base)) tr.rotation.setValue(pl.Rotation.Q) fn = Draft.getParam("textfont", "Arial,Sans") if hasattr(vobj, "FontName"): if vobj.FontName: try: fn = str(vobj.FontName) except: pass fo.name = fn fo.size = fs st.addChild(tr) st.addChild(fo) st.addChild(tx) self.labels.addChild(st) self.labelset.addChild(self.labels)
def attach(self, vobj): '''Setup the scene sub-graph of the view provider''' self.Object = vobj.Object self.color = coin.SoBaseColor() self.font = coin.SoFont() self.font3d = coin.SoFont() self.text = coin.SoAsciiText() self.text3d = coin.SoText2() self.text.string = "d" # some versions of coin crash if string is not set self.text3d.string = "d" self.textpos = coin.SoTransform() self.text.justification = self.text3d.justification = coin.SoAsciiText.CENTER label = coin.SoSeparator() label.addChild(self.textpos) label.addChild(self.color) label.addChild(self.font) label.addChild(self.text) label3d = coin.SoSeparator() label3d.addChild(self.textpos) label3d.addChild(self.color) label3d.addChild(self.font3d) label3d.addChild(self.text3d) self.coord1 = coin.SoCoordinate3() self.trans1 = coin.SoTransform() self.coord2 = coin.SoCoordinate3() self.trans2 = coin.SoTransform() self.transDimOvershoot1 = coin.SoTransform() self.transDimOvershoot2 = coin.SoTransform() self.transExtOvershoot1 = coin.SoTransform() self.transExtOvershoot2 = coin.SoTransform() self.marks = coin.SoSeparator() self.marksDimOvershoot = coin.SoSeparator() self.marksExtOvershoot = coin.SoSeparator() self.drawstyle = coin.SoDrawStyle() self.line = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.coords = coin.SoCoordinate3() self.node = coin.SoGroup() self.node.addChild(self.color) self.node.addChild(self.drawstyle) self.lineswitch2 = coin.SoSwitch() self.lineswitch2.whichChild = -3 self.node.addChild(self.lineswitch2) self.lineswitch2.addChild(self.coords) self.lineswitch2.addChild(self.line) self.lineswitch2.addChild(self.marks) self.lineswitch2.addChild(self.marksDimOvershoot) self.lineswitch2.addChild(self.marksExtOvershoot) self.node.addChild(label) self.node3d = coin.SoGroup() self.node3d.addChild(self.color) self.node3d.addChild(self.drawstyle) self.lineswitch3 = coin.SoSwitch() self.lineswitch3.whichChild = -3 self.node3d.addChild(self.lineswitch3) self.lineswitch3.addChild(self.coords) self.lineswitch3.addChild(self.line) self.lineswitch3.addChild(self.marks) self.lineswitch3.addChild(self.marksDimOvershoot) self.lineswitch3.addChild(self.marksExtOvershoot) self.node3d.addChild(label3d) vobj.addDisplayMode(self.node, "2D") vobj.addDisplayMode(self.node3d, "3D") self.updateData(vobj.Object, "Start") self.onChanged(vobj, "FontSize") self.onChanged(vobj, "FontName") self.onChanged(vobj, "ArrowType") self.onChanged(vobj, "LineColor") self.onChanged(vobj, "DimOvershoot") self.onChanged(vobj, "ExtOvershoot")
def attach(self, vobj): """Set up the scene sub-graph of the viewprovider.""" # Attributes of the Coin scenegraph self.arrow = coin.SoSeparator() self.arrowpos = coin.SoTransform() self.arrow.addChild(self.arrowpos) self.matline = coin.SoMaterial() self.drawstyle = coin.SoDrawStyle() self.drawstyle.style = coin.SoDrawStyle.LINES self.lcoords = coin.SoCoordinate3() self.line = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.mattext = coin.SoMaterial() self.textpos = coin.SoTransform() self.font = coin.SoFont() self.text2d = coin.SoText2() # Faces the camera always self.text3d = coin.SoAsciiText() # Can be oriented in 3D space self.fcoords = coin.SoCoordinate3() self.frame = coin.SoType.fromName("SoBrepEdgeSet").createInstance() self.lineswitch = coin.SoSwitch() self.symbol = gui_utils.dim_symbol() textdrawstyle = coin.SoDrawStyle() textdrawstyle.style = coin.SoDrawStyle.FILLED # The text string needs to be initialized to something, # otherwise it crashes self.text2d.string = self.text3d.string = "Label" self.text2d.justification = coin.SoText2.RIGHT self.text3d.justification = coin.SoAsciiText.RIGHT self.font.name = utils.get_param("textfont") switchnode = coin.SoSeparator() switchnode.addChild(self.line) self.lineswitch.addChild(switchnode) self.lineswitch.whichChild = 0 self.node2dtxt = coin.SoGroup() self.node2dtxt.addChild(self.font) self.node2dtxt.addChild(self.text2d) self.node2d = coin.SoGroup() self.node2d.addChild(self.matline) self.node2d.addChild(self.arrow) self.node2d.addChild(self.drawstyle) self.node2d.addChild(self.lcoords) self.node2d.addChild(self.lineswitch) self.node2d.addChild(self.mattext) self.node2d.addChild(textdrawstyle) self.node2d.addChild(self.textpos) self.node2d.addChild(self.node2dtxt) self.node2d.addChild(self.matline) self.node2d.addChild(self.drawstyle) self.node2d.addChild(self.fcoords) self.node2d.addChild(self.frame) self.node3dtxt = coin.SoGroup() self.node3dtxt.addChild(self.font) self.node3dtxt.addChild(self.text3d) self.node3d = coin.SoGroup() self.node3d.addChild(self.matline) self.node3d.addChild(self.arrow) self.node3d.addChild(self.drawstyle) self.node3d.addChild(self.lcoords) self.node3d.addChild(self.lineswitch) self.node3d.addChild(self.mattext) self.node3d.addChild(textdrawstyle) self.node3d.addChild(self.textpos) self.node3d.addChild(self.node3dtxt) self.node3d.addChild(self.matline) self.node3d.addChild(self.drawstyle) self.node3d.addChild(self.fcoords) self.node3d.addChild(self.frame) vobj.addDisplayMode(self.node2d, "2D text") vobj.addDisplayMode(self.node3d, "3D text") self.onChanged(vobj, "LineColor") self.onChanged(vobj, "TextColor") self.onChanged(vobj, "LineWidth") self.onChanged(vobj, "ArrowSize") self.onChanged(vobj, "Line")
def onChanged(self, vobj, prop): if prop == "LineColor": l = vobj.LineColor self.mat.diffuseColor.setValue([l[0], l[1], l[2]]) elif prop == "DrawStyle": if vobj.DrawStyle == "Solid": self.linestyle.linePattern = 0xffff elif vobj.DrawStyle == "Dashed": self.linestyle.linePattern = 0xf00f elif vobj.DrawStyle == "Dotted": self.linestyle.linePattern = 0x0f0f else: self.linestyle.linePattern = 0xff88 elif prop == "LineWidth": self.linestyle.lineWidth = vobj.LineWidth elif prop == "BubbleSize": if hasattr(self, "bubbleset"): if self.bubbles: self.bubbleset.removeChild(self.bubbles) self.bubbles = None if vobj.Object.Shape: if vobj.Object.Shape.Edges: self.bubbles = coin.SoSeparator() self.bubblestyle = coin.SoDrawStyle() self.bubblestyle.linePattern = 0xffff self.bubbles.addChild(self.bubblestyle) import Part, Draft self.bubbletexts = [] for i in range(len(vobj.Object.Shape.Edges)): verts = vobj.Object.Shape.Edges[i].Vertexes p1 = verts[0].Point p2 = verts[1].Point dv = p2.sub(p1) dv.normalize() rad = vobj.BubbleSize center = p2.add(dv.scale(rad, rad, rad)) buf = Part.makeCircle(rad, center).writeInventor() try: cin = coin.SoInput() cin.setBuffer(buf) cob = coin.SoDB.readAll(cin) except: import re # workaround for pivy SoInput.setBuffer() bug buf = buf.replace("\n", "") pts = re.findall("point \[(.*?)\]", buf)[0] pts = pts.split(",") pc = [] for p in pts: v = p.strip().split() pc.append([ float(v[0]), float(v[1]), float(v[2]) ]) coords = coin.SoCoordinate3() coords.point.setValues(0, len(pc), pc) line = coin.SoLineSet() line.numVertices.setValue(-1) else: coords = cob.getChild(1).getChild(0).getChild( 2) line = cob.getChild(1).getChild(0).getChild(3) self.bubbles.addChild(coords) self.bubbles.addChild(line) st = coin.SoSeparator() tr = coin.SoTransform() tr.translation.setValue( (center.x, center.y - rad / 4, center.z)) fo = coin.SoFont() fo.name = Draft.getParam("textfont", "Arial,Sans") fo.size = rad * 100 tx = coin.SoText2() tx.justification = coin.SoText2.CENTER self.bubbletexts.append(tx) st.addChild(tr) st.addChild(fo) st.addChild(tx) self.bubbles.addChild(st) self.bubbleset.addChild(self.bubbles) self.onChanged(vobj, "NumberingStyle") elif prop == "NumberingStyle": if hasattr(self, "bubbletexts"): chars = "abcdefghijklmnopqrstuvwxyz" roman = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1)) num = 0 for t in self.bubbletexts: if vobj.NumberingStyle == "1,2,3": t.string = str(num + 1) elif vobj.NumberingStyle == "01,02,03": t.string = str(num + 1).zfill(2) elif vobj.NumberingStyle == "001,002,003": t.string = str(num + 1).zfill(3) elif vobj.NumberingStyle == "A,B,C": result = "" base = num / 26 if base: result += chars[base].upper() remainder = num % 26 result += chars[remainder].upper() t.string = result elif vobj.NumberingStyle == "a,b,c": result = "" base = num / 26 if base: result += chars[base] remainder = num % 26 result += chars[remainder] t.string = result elif vobj.NumberingStyle == "I,II,III": result = "" num += 1 for numeral, integer in roman: while num >= integer: result += numeral num -= integer t.string = result elif vobj.NumberingStyle == "L0,L1,L2": t.string = "L" + str(num) num += 1