def attach(self, vobj): from pivy import coin self.centerlinegroup = coin.SoSeparator() self.centerlinegroup.setName("Centerline") self.centerlinecolor = coin.SoBaseColor() self.centerlinestyle = coin.SoDrawStyle() self.centerlinegroup.addChild(self.centerlinecolor) self.centerlinegroup.addChild(self.centerlinestyle) vobj.addDisplayMode(self.centerlinegroup, "Centerline") ArchComponent.ViewProviderComponent.attach(self, vobj)
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")
def __init__(self): color = coin.SoBaseColor() color.rgb = FreeCADGui.DDADockWidget.getDefaultColor("snap") self.marker = coin.SoMarkerSet() # this is the marker symbol self.marker.markerIndex = coin.SoMarkerSet.CIRCLE_FILLED_9_9 self.coords = coin.SoCoordinate3() # this is the coordinate self.coords.point.setValue((0, 0, 0)) node = coin.SoAnnotation() node.addChild(self.coords) node.addChild(color) node.addChild(self.marker) Tracker.__init__(self, children=[node])
def __init__(self): color = coin.SoBaseColor() color.rgb = FreeCADGui.draftToolBar.getDefaultColor("snap") self.marker = coin.SoMarkerSet() # this is the marker symbol self.marker.markerIndex = FreeCADGui.getMarkerIndex("", 9) self.coords = coin.SoCoordinate3() # this is the coordinate self.coords.point.setValue((0,0,0)) node = coin.SoAnnotation() node.addChild(self.coords) node.addChild(color) node.addChild(self.marker) Tracker.__init__(self,children=[node],name="snapTracker")
def attach(self, vobj): ArchFloor._ViewProviderFloor.attach(self, vobj) from pivy import coin self.diagramsep = coin.SoSeparator() self.color = coin.SoBaseColor() self.coords = coin.SoTransform() self.diagramswitch = coin.SoSwitch() self.diagramswitch.whichChild = -1 self.diagramswitch.addChild(self.diagramsep) self.diagramsep.addChild(self.coords) self.diagramsep.addChild(self.color) vobj.Annotation.addChild(self.diagramswitch)
def attach(self, vobj): self.Object = vobj.Object col = coin.SoBaseColor() col.rgb.setValue(vobj.LineColor[0],vobj.LineColor[1],vobj.LineColor[2]) self.coords = coin.SoTransform() self.pt = coin.SoSeparator() self.pt.addChild(col) self.pt.addChild(self.coords) self.symbol = gui_utils.dim_symbol() self.pt.addChild(self.symbol) super(ViewProviderWire, self).attach(vobj) self.onChanged(vobj,"EndArrow")
def __init__(self): super(Axis, self).__init__() self.xAxisSep = coin.SoSeparator() self.yAxisSep = coin.SoSeparator() self.zAxisSep = coin.SoSeparator() self.xaxisColor = coin.SoBaseColor() self.yaxisColor = coin.SoBaseColor() self.zaxisColor = coin.SoBaseColor() self.xaxisColor.rgb = (0.8,0,0) self.xpts = [] #[[p[0]-1000,p[1],p[2]],[p[0]+1000,p[1],p[2]]] self.yaxisColor.rgb = (0,0.8,0) self.ypts = [] #[[p[0],p[1]-1000,p[2]],[p[0],p[1]+1000,p[2]]] self.zaxisColor.rgb = (0,0,0.8) self.zpts = [] #[[p[0],p[1],p[2]-1000],[p[0],p[1],p[2]+1000]] self.xaxis = coin.SoLineSet() self.xaxisPoints = coin.SoCoordinate3() self.xaxisPoints.point.setValue(0,0,0) self.xaxisPoints.point.setValues(0,len(self.xpts),self.xpts) self.xAxisSep.addChild(self.xaxisColor) self.xAxisSep.addChild(self.xaxisPoints) self.xAxisSep.addChild(self.xaxis) self.yaxis = coin.SoLineSet() self.yaxisPoints = coin.SoCoordinate3() self.yaxisPoints.point.setValue(0,0,0) self.yaxisPoints.point.setValues(0,len(self.ypts),self.ypts) self.yAxisSep.addChild(self.yaxisColor) self.yAxisSep.addChild(self.yaxisPoints) self.yAxisSep.addChild(self.yaxis) self.zaxis = coin.SoLineSet() self.zaxisPoints = coin.SoCoordinate3() self.zaxisPoints.point.setValue(0,0,0) self.zaxisPoints.point.setValues(0,len(self.zpts),self.zpts) self.zAxisSep.addChild(self.zaxisColor) self.zAxisSep.addChild(self.zaxisPoints) self.zAxisSep.addChild(self.zaxis) self.xState = False self.yState = False self.zState = False
def drawXYPlane(self): col = coin.SoBaseColor() #col.rgb = FR_COLOR.FR_BLUEG col.rgb = FR_COLOR.FR_SPECIAL_BLUE LengthOfGrid = 1000 # mm bothSideLength = LengthOfGrid / 2 counter = LengthOfGrid try: line = [] count5Cells = 0 lineSize = 1 for i in range(0, counter, self.GridSize): # X direction P1x = -bothSideLength P1y = -bothSideLength + i # y direction P3x = -bothSideLength + i P3y = -bothSideLength if count5Cells == 0: lineSize = 2 else: lineSize = 1 # don't draw line at 0,±y and ±x,0 # TODO: Draw x, y using correct color if P1y != 0: line.append(dim_dash((P1x, P1y, 0.0), (-P1x, P1y, 0.0), col, lineSize)) # x if P3x != 0: line.append(dim_dash((P3x, P3y, 0.0), (P3x, -P3y, 0.0), col, lineSize)) # y count5Cells = count5Cells + 1 if count5Cells == 5: count5Cells = 0 for i in line: self.sg.addChild(i) self.collectGarbage.append(i) except Exception as err: App.Console.PrintError("'Plane' 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 makeSnapshotWithoutGui(): from pivy import coin # create a test geometry and create an IV representation as string box = Part.makeCone(10, 8, 10) iv = box.writeInventor() # load it into a buffer inp = coin.SoInput() try: inp.setBuffer(iv) except Exception: tempPath = tempfile.gettempdir() fileName = tempPath + os.sep + "cone.iv" file = open(fileName, "w") file.write(iv) file.close() inp.openFile(fileName) # and create a scenegraph data = coin.SoDB.readAll(inp) base = coin.SoBaseColor() base.rgb.setValue(0.6, 0.7, 1.0) data.insertChild(base, 0) # add light and camera so that the rendered geometry is visible root = coin.SoSeparator() light = coin.SoDirectionalLight() cam = coin.SoOrthographicCamera() root.addChild(cam) root.addChild(light) root.addChild(data) # do the rendering now axo = coin.SbRotation(-0.353553, -0.146447, -0.353553, -0.853553) viewport = coin.SbViewportRegion(400, 400) cam.orientation.setValue(axo) cam.viewAll(root, viewport) off = coin.SoOffscreenRenderer(viewport) root.ref() off.render(root) root.unref() # export the image, PS is always available off.writeToPostScript("crystal.ps") # Other formats are only available if simage package is installed if off.isWriteSupported("PNG"): print("Save as PNG") off.writeToFile("crystal.png", "PNG")
def onChanged(self, vobj, prop): if prop == "ShowLimits": self.extentsBox.removeAllChildren() if vobj.ShowLimits and hasattr(vobj, "Object"): from pivy import coin parent = coin.SoType.fromName( "SoSkipBoundingGroup").createInstance() self.extentsBox.addChild(parent) # set pattern pattern = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/Part").GetInt( "GridLinePattern", 0x0f0f) defStyle = coin.SoDrawStyle() defStyle.lineWidth = 1 defStyle.linePattern = pattern parent.addChild(defStyle) # set color c = FreeCAD.ParamGet( "User parameter:BaseApp/Preferences/Mod/Path").GetUnsigned( "DefaultExtentsColor", 3418866943) r = float((c >> 24) & 0xFF) / 255.0 g = float((c >> 16) & 0xFF) / 255.0 b = float((c >> 8) & 0xFF) / 255.0 color = coin.SoBaseColor() parent.addChild(color) # set boundbox extents = coin.SoType.fromName( "SoFCBoundingBox").createInstance() extents.coordsOn.setValue(False) extents.dimensionsOn.setValue(False) XMax, YMax, ZMax = vobj.Object.X_Max.Value, vobj.Object.Y_Max.Value, vobj.Object.Z_Max.Value XMin, YMin, ZMin = vobj.Object.X_Min.Value, vobj.Object.Y_Min.Value, vobj.Object.Z_Min.Value # UnitParams = FreeCAD.ParamGet( # "User parameter:BaseApp/Preferences/Units") extents.minBounds.setValue(XMax, YMax, ZMax) extents.maxBounds.setValue(XMin, YMin, ZMin) parent.addChild(extents) mode = 2 vobj.setEditorMode('LineWidth', mode) vobj.setEditorMode('MarkerColor', mode) vobj.setEditorMode('NormalColor', mode) vobj.setEditorMode('ShowFirstRapid', 0) vobj.setEditorMode('DisplayMode', mode) vobj.setEditorMode('BoundingBox', mode) vobj.setEditorMode('Selectable', mode)
def createAButton(self, _vector, _color, _rotation): color = coin.SoBaseColor() color.rgb = _color transform = coin.SoTransform() tempR = coin.SbVec3f() tempR.setValue(_rotation[0], _rotation[1], _rotation[2]) transform.rotation.setValue(tempR, math.radians(_rotation[3])) sphere = coin.SoSphere() sphere.radius = self.ButtonRadius transBar = coin.SoTranslation() transBar.translation.setValue(_vector) barLine = coin.SoSeparator() barLine.addChild(color) barLine.addChild(transBar) barLine.addChild(transform) barLine.addChild(sphere) return barLine
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 attach(self, vobj): self.Object = vobj.Object from pivy import coin sep = coin.SoSeparator() self.coords = coin.SoCoordinate3() sep.addChild(self.coords) self.coords.point.deleteValues(0) symbol = coin.SoMarkerSet() symbol.markerIndex = coin.SoMarkerSet.CIRCLE_FILLED_5_5 sep.addChild(symbol) rn = vobj.RootNode rn.addChild(sep) self.hiresgroup = coin.SoGroup() self.meshcolor = coin.SoBaseColor() self.hiresgroup.addChild(self.meshcolor) vobj.addDisplayMode(self.hiresgroup, "Mesh") ArchComponent.ViewProviderComponent.attach(self, vobj)
def attach(self, vobj): self.Object = vobj.Object from pivy import coin self.diagramsep = coin.SoSeparator() self.color = coin.SoBaseColor() self.coords = coin.SoTransform() self.diagramswitch = coin.SoSwitch() self.diagramswitch.whichChild = -1 self.diagramswitch.addChild(self.diagramsep) self.diagramsep.addChild(self.coords) self.diagramsep.addChild(self.color) vobj.Annotation.addChild(self.diagramswitch) self.compass = Compass() self.updateCompassVisibility(vobj) self.updateCompassScale(vobj) self.rotateCompass(vobj) vobj.Annotation.addChild(self.compass.rootNode)
def sceneDrawPath(path, color=(0, 0, 1)): coPoint = coin.SoCoordinate3() pts = [] for pt in path: pts.append([pt[0], pt[1], topZ]) coPoint.point.setValues(0, len(pts), pts) ma = coin.SoBaseColor() ma.rgb = color li = coin.SoLineSet() li.numVertices.setValue(len(pts)) pathNode = coin.SoSeparator() pathNode.addChild(coPoint) pathNode.addChild(ma) pathNode.addChild(li) sceneGraph.addChild(pathNode) scenePathNodes.append(pathNode) #for scene cleanup afterwards
def createABar(self, _vector, _color, _length, _rotation): color = coin.SoBaseColor() transform = coin.SoTransform() tempR = coin.SbVec3f() tempR.setValue(_rotation[0], _rotation[1], _rotation[2]) transform.rotation.setValue(tempR, math.radians(_rotation[3])) color.rgb = _color cylinder = coin.SoCylinder() cylinder.height = _length cylinder.radius = self.barRadius transBar = coin.SoTranslation() transBar.translation.setValue(_vector) barLine = coin.SoSeparator() barLine.addChild(color) barLine.addChild(transBar) barLine.addChild(transform) barLine.addChild(cylinder) return barLine
def attach(self,vobj): self.Object = vobj.Object # adding arrows rn = vobj.RootNode self.col = coin.SoBaseColor() self.setColor() ds = coin.SoDrawStyle() ds.style = coin.SoDrawStyle.LINES self.lcoords = coin.SoCoordinate3() ls = coin.SoLineSet() ls.numVertices.setValues([2,4,4,2,4,4,2,4,4,2,4,4]) pt = coin.SoAnnotation() pt.addChild(self.col) pt.addChild(ds) pt.addChild(self.lcoords) pt.addChild(ls) rn.addChild(pt) self.setVerts()
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, dotted=False, scolor=None, swidth=None, children=[], ontop=False): self.ontop = ontop color = coin.SoBaseColor() color.rgb = scolor or FreeCADGui.DDADockWidget.getDefaultColor("ui") drawstyle = coin.SoDrawStyle() if swidth: drawstyle.lineWidth = swidth if dotted: drawstyle.style = coin.SoDrawStyle.LINES drawstyle.lineWeight = 3 drawstyle.linePattern = 0x0f0f # 0xaa , 虚线的具体样式 node = coin.SoSeparator() for c in [drawstyle, color] + children: # openInventor的处理方式,前两决定后续children的样式 node.addChild(c) self.switch = coin.SoSwitch() # this is the on/off switch self.switch.addChild(node) self.switch.whichChild = -1 self.Visible = False todo.delay(self._insertSwitch, self.switch)
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 attach(self, vobj): ''' Create Object visuals in 3D view. ''' # GeoCoord Node. self.geo_coords = coin.SoGeoCoordinate() # Point group features. points = coin.SoPointSet() self.markers = coin.SoMarkerSet() self.color_mat = coin.SoMaterial() self.point_normal = coin.SoNormal() self.point_style = coin.SoDrawStyle() self.point_style.style = coin.SoDrawStyle.POINTS # Highlight for selection. highlight = coin.SoType.fromName('SoFCSelection').createInstance() #highlight.documentName.setValue(FreeCAD.ActiveDocument.Name) #highlight.objectName.setValue(vobj.Object.Name) #highlight.subElementName.setValue("Main") highlight.addChild(self.geo_coords) highlight.addChild(points) highlight.addChild(self.markers) # Point labels features. color =coin.SoBaseColor() self.point_labels = coin.SoSeparator() self.point_labels.addChild(color) # Point group root. point_root = coin.SoSeparator() point_root.addChild(self.point_labels) point_root.addChild(self.point_style) point_root.addChild(self.point_normal) point_root.addChild(self.color_mat) point_root.addChild(highlight) vobj.addDisplayMode(point_root,"Point") # Take features from properties. if vobj.Object.Points: self.onChanged(vobj,"Elevation") self.onChanged(vobj,"PointSize") self.onChanged(vobj,"PointColor")
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 __init__(self, marker=False, line=False, color=False, style=False): """ Constructor """ self.group = coin.SoGroup() self.coord = coin.SoCoordinate3() self.marker = coin.SoMarkerSet() self.line = coin.SoLineSet() self.color = coin.SoBaseColor() self.style = CoinStyles.DEFAULT self.group.addChild(self.coord) self.group.addChild(self.color) if marker: self.group.addChild(self.marker) self.group.addChild(self.line)
def onChanged(self, vobj, prop): if prop == "Positions": if not vobj.Draw: return if vobj.Proxy.indexPosition: po = list(vobj.Positions[vobj.Proxy.indexPosition-1:]) else: po = list(vobj.Positions[vobj.Proxy.indexPosition:]) vobj.Proxy.indexPosition = len(vobj.Positions) co = coin.SoCoordinate3() co.point.setValues(0, len(po), po) ma = coin.SoBaseColor() ma.rgb = vobj.Color[0:3] li = coin.SoLineSet() li.numVertices.setValue(len(po)) no = coin.SoSeparator() no.addChild(co) no.addChild(ma) no.addChild(li) vobj.RootNode.addChild(no)
def attach(self, obj): '''Setup the scene sub-graph of the view provider, this method is mandatory''' self.shaded = coin.SoGroup() self.wireframe = coin.SoGroup() self.scale = coin.SoScale() self.color = coin.SoBaseColor() data=coin.SoCube() self.shaded.addChild(self.scale) self.shaded.addChild(self.color) self.shaded.addChild(data) obj.addDisplayMode(self.shaded,"Shaded"); style=coin.SoDrawStyle() style.style = coin.SoDrawStyle.LINES self.wireframe.addChild(style) self.wireframe.addChild(self.scale) self.wireframe.addChild(self.color) self.wireframe.addChild(data) obj.addDisplayMode(self.wireframe,"Wireframe"); self.onChanged(obj,"Color")
def draw_snap(self, sel, sensor): """Method that draw the current snap point""" if self.snap_point != sel: if self.snap_point is not None: self.root.removeChild(self.SnapNode) self.snap_point = sel if sel is not None: col = coin.SoBaseColor() col.rgb = (0, 1, 0) trans = coin.SoTranslation() trans.translation.setValue(sel) snap = coin.SoMarkerSet() # this is the marker symbol snap.markerIndex = FreeCADGui.getMarkerIndex("", 9) # cub = coin.SoSphere() self.SnapNode = coin.SoSeparator() self.SnapNode.addChild(col) self.SnapNode.addChild(trans) self.SnapNode.addChild(snap) self.root.addChild(self.SnapNode)
def attach(self, vobj): Draft._ViewProviderDraft.attach(self, vobj) from pivy import coin self.coords = coin.SoCoordinate3() self.lineset = coin.SoLineSet() self.lineset.numVertices.setValue(-1) lineStyle = coin.SoDrawStyle() lineStyle.linePattern = 0x0f0f self.color = coin.SoBaseColor() self.switch = coin.SoSwitch() sep = coin.SoSeparator() self.switch.whichChild = -1 sep.addChild(self.color) sep.addChild(lineStyle) sep.addChild(self.coords) sep.addChild(self.lineset) self.switch.addChild(sep) vobj.Annotation.addChild(self.switch) self.onChanged(vobj, "ShowMargin") self.onChanged(vobj, "LineColor")
def __init__(self, pos, object_name, node_name, marker_type, marker_size): self.pos = pos self.name = node_name self.inactive = False self.color = coin.SoBaseColor() self.marker = coin.SoMarkerSet() self.marker.markerIndex = Gui.getMarkerIndex(marker_type, marker_size) self.coords = coin.SoCoordinate3() self.coords.point.setValue((pos.x, pos.y, pos.z)) selnode = None if self.inactive: selnode = coin.SoSeparator() else: selnode = coin.SoType.fromName("SoFCSelection").createInstance() selnode.documentName.setValue(App.ActiveDocument.Name) selnode.objectName.setValue(object_name) selnode.subElementName.setValue(node_name) node = coin.SoAnnotation() selnode.addChild(self.coords) selnode.addChild(self.color) selnode.addChild(self.marker) node.addChild(selnode) ontop = not self.inactive Tracker.__init__( self, children=[node], ontop=ontop, name="EditTracker") self.on()
def attach(self, obj): self.shaded = coin.SoGroup() self.wireframe = coin.SoGroup() self.color = coin.SoBaseColor() self.trans = coin.SoTranslation() self.box = coin.SoCube() self.shaded.addChild(self.color) self.shaded.addChild(self.trans) self.shaded.addChild(self.box) obj.addDisplayMode(self.shaded, "Shaded") style = coin.SoDrawStyle() style.style = coin.SoDrawStyle.LINES self.wireframe.addChild(style) self.wireframe.addChild(self.color) self.wireframe.addChild(self.trans) self.wireframe.addChild(self.box) obj.addDisplayMode(self.wireframe, "Wireframe") self.onChanged(obj, "Color") return