def attach(self, vobj): # self.ViewObject = vobj self.Object = vobj.Object self.gridDM = coin.SoGroup() self.pointsDM = coin.SoGroup() self.ProfDM = coin.SoGroup() self.railDM = coin.SoGroup() self.coord = CoinNodes.coordinate3Node(self.Object.Points) self.row = CoinNodes.rowNode((0.8, 0.4, 0.4), 1.0) self.col = CoinNodes.colNode((0.4, 0.4, 0.8), 1.0) self.pointSet = coin.SoPointSet() self.style = CoinNodes.styleNode((0, 0, 0), 1.0, 2.0) self.style.addChild(self.pointSet) # vobj.addChild(self.coord) self.ProfDM.addChild(self.coord) self.ProfDM.addChild(self.row) self.railDM.addChild(self.coord) self.railDM.addChild(self.col) self.gridDM.addChild(self.coord) self.gridDM.addChild(self.row) self.gridDM.addChild(self.col) self.pointsDM.addChild(self.coord) self.pointsDM.addChild(self.style) # self.points.addChild(self.pointSet) vobj.addDisplayMode(self.gridDM, "Wireframe") vobj.addDisplayMode(self.pointsDM, "Points") vobj.addDisplayMode(self.ProfDM, "Profiles") vobj.addDisplayMode(self.railDM, "Rails")
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 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 attach(self, obj): material = coin.SoMaterial() material.diffuseColor = (1.0, 0.0, 0.0) material.emissiveColor = (1.0, 0.0, 0.0) drawStyle = coin.SoDrawStyle() drawStyle.pointSize.setValue(10) drawStyle.style = coin.SoDrawStyle.LINES wireframe = coin.SoGroup() shaded = coin.SoGroup() self.wireframe = wireframe self.shaded = shaded self.coords = coin.SoCoordinate3() self.coords.point.setValues(0, 2, [FreeCAD.Vector(0, 0, 0), FreeCAD.Vector(1, 0, 0)]) wireframe += self.coords wireframe += drawStyle wireframe += material shaded += self.coords shaded += drawStyle shaded += material g = coin.SoGroup() sel1 = coin.SoType.fromName('SoFCSelection').createInstance() sel1.style = 'EMISSIVE_DIFFUSE' p1 = coin.SoType.fromName('SoIndexedPointSet').createInstance() p1.coordIndex.set1Value(0, 0) sel1 += p1 g += sel1 wireframe += g shaded += g g = coin.SoGroup() sel2 = coin.SoType.fromName('SoFCSelection').createInstance() sel2.style = 'EMISSIVE_DIFFUSE' p2 = coin.SoType.fromName('SoIndexedPointSet').createInstance() p2.coordIndex.set1Value(0, 1) sel2 += p2 g += sel2 wireframe += g shaded += g g = coin.SoGroup() sel3 = coin.SoType.fromName('SoFCSelection').createInstance() sel3.style = 'EMISSIVE_DIFFUSE' p3 = coin.SoType.fromName('SoIndexedLineSet').createInstance() p3.coordIndex.setValues(0, 2, [0, 1]) sel3 += p3 g += sel3 wireframe += g shaded += g obj.addDisplayMode(wireframe, 'Wireframe') obj.addDisplayMode(shaded, 'Shaded') self.sel1 = sel1 self.sel2 = sel2 self.sel3 = sel3 self.constructed = True self.updateData(obj.Object, 'p2')
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 attach(self, obj): # Property view of object self.modes = [] self.modes.append("Flat Lines") self.modes.append("Shaded") self.modes.append("Wireframe") self.modes.append("Points") obj.addDisplayMode( coin.SoGroup(),"Flat Lines" ) # Display Mode obj.addDisplayMode( coin.SoGroup(),"Shaded" ) obj.addDisplayMode( coin.SoGroup(),"Wireframe" ) obj.addDisplayMode( coin.SoGroup(),"Points" ) return self.modes
def get_drag_connection(self): """ Return a SoGroup() object of trackers which connect to the drag select """ _trackers = self.trackers['NODE'] #get list of sorted trackers _selected = [ _trackers[_k] for _k in sorted(self.gui_action['selected']) ] #get index values for first and last selected elements _idx = [int(_selected[_i].name.split('-')[1]) for _i in [0, -1]] _conn = [] self.connect_idx = 0 #if our starting node isn't the first, add the previous node if _idx[0] > 0: _conn.append(_trackers['NODE-' + str(_idx[0] - 1)]) self.connect_idx = 1 _conn.append(_selected[0]) self.drag_start = _selected[0].get() #if our ending node isn't the last, add the next node if _idx[-1] < len(_trackers) - 1: _conn.append(_trackers['NODE-' + str(_idx[-1] + 1)]) _result = coin.SoGroup() _coord = coin.SoCoordinate3() for _i, _v in enumerate(_conn): _coord.point.set1Value(_i, list(_v.get())) _marker = coin.SoMarkerSet() _line = coin.SoLineSet() _line.numVertices.setValue(_coord.point.getNum()) _node = coin.SoGroup() _node.addChild(_coord) _node.addChild(_marker) _node.addChild(_line) _result.addChild(_node) self.connect_coord = _coord return _result
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object #self.wireframeDM = coin.SoGroup() self.normalDM = coin.SoGroup() self.binormalDM = coin.SoGroup() self.bothDM = coin.SoGroup() self.normCoords = CoinNodes.coordinate3Node() self.binormCoords = CoinNodes.coordinate3Node() self.curveCoords = CoinNodes.coordinate3Node() self.normComb = CoinNodes.combComb(color=(0., 0.3, 0.), lineWidth=1.0) self.normCurve = CoinNodes.combCurve(color=(0., 0.7, 0.), lineWidth=1.0) self.binormComb = CoinNodes.combComb(color=(0., 0., 0.3), lineWidth=1.0) self.binormCurve = CoinNodes.combCurve(color=(0., 0., 0.7), lineWidth=1.0) self.curve = CoinNodes.polygonNode(color=(0., 0., 0.), lineWidth=1.0) self.normComb.linkTo(self.normCoords) self.normCurve.linkTo(self.normCoords) self.binormComb.linkTo(self.binormCoords) self.binormCurve.linkTo(self.binormCoords) #self.wireframeDM.addChild(self.curveCoords) #self.wireframeDM.addChild(self.curve) self.normalDM.addChild(self.curveCoords) self.normalDM.addChild(self.curve) self.binormalDM.addChild(self.curveCoords) self.binormalDM.addChild(self.curve) self.normalDM.addChild(self.normCoords) self.normalDM.addChild(self.normComb) self.normalDM.addChild(self.normCurve) self.binormalDM.addChild(self.binormCoords) self.binormalDM.addChild(self.binormComb) self.binormalDM.addChild(self.binormCurve) self.bothDM.addChild(self.normalDM) self.bothDM.addChild(self.binormalDM) #vobj.addDisplayMode(self.wireframeDM,"Wireframe") vobj.addDisplayMode(self.normalDM, "Normal") vobj.addDisplayMode(self.binormalDM, "Binormal") vobj.addDisplayMode(self.bothDM, "Normal Binormal")
def __init__(self, names, children=None, select=True, group=False): """ Constructor """ self.visible = False self.select = select self.color = coin.SoBaseColor() self.draw_style = coin.SoDrawStyle() self.names = names self.node = coin.SoSeparator() self.parent = None if not children: children = [] if group: self.node = coin.SoGroup() if self.select: self.node = \ coin.SoType.fromName("SoFCSelection").createInstance() self.node.documentName.setValue(self.names[0]) self.node.objectName.setValue(self.names[1]) self.node.subElementName.setValue(self.names[2]) for child in [self.draw_style, self.color] + children: self.node.addChild(child)
def create_rollover(self, names): """ Create the rollover node tracker """ group = coin.SoGroup() for style in [self.STYLE.ROLL_INNER, self.STYLE.ROLL_OUTER]: marker = coin.SoMarkerSet() marker.markerIndex = \ Gui.getMarkerIndex(style['shape'], style['size']) nam = names[:] nam[2] += '.' + style['id'] child = BaseTracker(nam, [self.coord, marker], style['select']) child.color.rgb = style['color'] group.addChild(child.node) self.groups['rollover'].append(child) return group
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object self.report = self.Object.Proxy self.coinNode = coin.SoGroup() vobj.addDisplayMode(self.coinNode, "Standard")
def attach(self, obj): #debug("Comb : ViewProviderComb.attach ") self.oldx = 0 self.oldy = 0 self.wireframe = coin.SoGroup() self.combColor = coin.SoBaseColor() self.curveColor = coin.SoBaseColor() self.combColor.rgb = (obj.CombColor[0], obj.CombColor[1], obj.CombColor[2]) self.curveColor.rgb = (obj.CurveColor[0], obj.CurveColor[1], obj.CurveColor[2]) self.points = coin.SoCoordinate3() self.combLines = coin.SoIndexedLineSet() self.curveLines = coin.SoIndexedLineSet() self.wireframe.addChild(self.points) self.wireframe.addChild(self.combColor) self.wireframe.addChild(self.combLines) self.wireframe.addChild(self.curveColor) self.wireframe.addChild(self.curveLines) #self.selectionNode = coin.SoType.fromName("SoFCSelection").createInstance() #self.selectionNode.documentName.setValue(FreeCAD.ActiveDocument.Name) #self.selectionNode.objectName.setValue(obj.Object.Name) # here obj is the ViewObject, we need its associated App Object #self.selectionNode.subElementName.setValue("Comb") #self.selectionNode.addChild(self.curveLines) #self.wireframe.addChild(self.selectionNode) obj.addDisplayMode(self.wireframe, "Wireframe")
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object self.coinNode = coin.SoGroup() self.material = coin.SoMaterial() self.material.transparency.setValue(0.7) self.material.diffuseColor.setValue([0.66, 0, 0.5]) self.plane_coords = coin.SoCoordinate3() self.updatePlaneCoordinates(vobj) fs = coin.SoIndexedFaceSet() fs.coordIndex.setValues(0, 7, [0, 1, 2, -1, 0, 2, 3]) # self.drawstyle = coin.SoDrawStyle() # self.drawstyle.style = coin.SoDrawStyle.LINES sep = coin.SoSeparator() sep.addChild(self.plane_coords) sep.addChild(self.material) sep.addChild(fs) self.coinNode.addChild(sep) vobj.addDisplayMode(self.coinNode, "Standard")
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object self.standard = coin.SoGroup() vobj.addDisplayMode(self.standard, "Standard") #self.ViewObject.Transparency = 95 return
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 get_drag_selection(self): """ Return a SoGroup() object of trackers to be transformed by draf """ #coordinates, markers, lines, draw-styles, transforms, etc. to be #rendered in a single SoGroup() _result = coin.SoGroup() _result.setName('PI_TRACKER') _c = [list(_v.get()) for _v in self.gui_action['selected'].values()] _count = len(_c) _coord = coin.SoCoordinate3() _coord.point.setValues(0, _count, _c) _result.addChild(_coord) _result.addChild(coin.SoMarkerSet()) if _count > 1: _line = coin.SoLineSet() _line.numVertices.setValue(_count) _result.addChild(_line) return _result
def _build_drag_line(self): """ Build the drag line for drag operations """ _m = coin.SoMarkerSet() _l = coin.SoLineSet() _l.numVertices.setValue(2) _d = coin.SoDrawStyle() _d.linePattern = 0x0f0f _d.lineWeight = 2 _c = coin.SoBaseColor() _c.rgb = (0.8, 0.8, 1.0) _g = coin.SoGroup() _g.addChild(_d) _g.addChild(_c) _g.addChild(self.drag_line_coord) _g.addChild(_m) _g.addChild(_l) self.root.addChild(_g)
def attach(self, vobj): self.Object = vobj.Object from pivy import coin sep = coin.SoGroup() vobj.addDisplayMode(sep, "Default") return
def __init__(self, view, names, base_node): """ Constructor """ self.base_node = base_node self.viewport = \ view.getViewer().getSoRenderManager().getViewportRegion() self.nodes = { 'connector': coin.SoGroup(), 'selected': coin.SoGroup(), 'switch': coin.SoSwitch(), 'transform': coin.SoTransform(), } self.view = view self.start_path = None self.gui_callbacks = { 'SoLocation2Event': \ view.addEventCallback('SoLocation2Event', self.mouse_action) } self.callbacks = [] self.datums = { _k: None for _k in ['origin', 'picked', 'start', 'drag_start'] } self.datums['rotation'] = { 'center': None, 'ref_vec': Vector(), 'angle': 0.0 } names.append('DRAG TRACKER') super().__init__(names, [ self.nodes['connector'], self.nodes['selected'] ], False) self.nodes['selected'].addChild(self.nodes['transform']) self.nodes['switch'].addChild(self.node) self.on(self.nodes['switch']) self.insert_node(self.nodes['switch'], self.base_node)
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object from pivy import coin self.coinNode = coin.SoGroup() vobj.addDisplayMode(self.coinNode, "Standard")
def attach(self, obj): self.wireframe = coin.SoGroup() self.shaded = coin.SoSeparator() self.drawStyle = coin.SoDrawStyle() self.drawStyle.pointSize.setValue(10) self.drawStyle.style = coin.SoDrawStyle.LINES self.pointMaterial = coin.SoMaterial() self.pointMaterial.diffuseColor = (1.0, 0.0, 0.0) self.shaded += self.drawStyle self.shaded += self.pointMaterial self.wireframe += self.drawStyle self.wireframe += self.pointMaterial vertex_data = obj.Object.getPropertyByName('Points') n = obj.Object.getPropertyByName('NetWidth') m = obj.Object.getPropertyByName('NetLength') coord = coin.SoCoordinate3() coord.point.setValues(0, len(vertex_data), vertex_data) for ii in range(n): for jj in range(m): sep = coin.SoSeparator() sep += self.pointMaterial p = vertex_data[ii * m + jj] co = coin.SoCoordinate3() co.point.setValue(p[0], p[1], p[2]) sep += co s = coin.SoType.fromName('SoPointSet').createInstance() s.numPoints.setValue(1) sep += s self.shaded += sep stations = coin.SoSeparator() stations += coord for ii in range(n): sep = coin.SoSeparator() indices = [ii + jj * n for jj in range(m)] lineSet = coin.SoType.fromName('SoBrepEdgeSet').createInstance() lineSet.coordIndex.setValues(0, len(indices), indices) sep += lineSet stations += sep self.shaded += stations self.wireframe += stations lines = coin.SoSeparator() lines += coord for jj in range(m): indices = [ii + jj * n for ii in range(n)] lineSet = coin.SoType.fromName('SoBrepEdgeSet').createInstance() lineSet.coordIndex.setValues(0, len(indices), indices) lines += lineSet self.shaded += lines self.wireframe += lines obj.addDisplayMode(self.wireframe, 'Wireframe') obj.addDisplayMode(self.shaded, 'Shaded')
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object #try: #self.ViewObject.ShapeColor = (0.5,0.0,1.0) #self.ViewObject.Transparency = 70 #except: #pass self.standard = coin.SoGroup() vobj.addDisplayMode(self.standard, "Standard")
def attach(self, vobj): self.ViewObject = vobj self.Object = vobj.Object self.textureConfig = self.Object.Proxy self.textureConfig.showTextures = vobj.Visibility self.coinNode = coin.SoGroup() vobj.addDisplayMode(self.coinNode, "Standard") vobj.Visibility = False
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 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 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
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.color = coin.SoBaseColor() self.data = coin.SoCoordinate3() self.face = coin.SoIndexedFaceSet() self.shaded.addChild(self.color) self.shaded.addChild(self.data) self.shaded.addChild(self.face) 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.data) self.wireframe.addChild(self.face) obj.addDisplayMode(self.wireframe, "Wireframe") self.onChanged(obj, "Color")
def rot2trans(obj): tot = coin.SoGroup() for ang, axis in [(obj.x.to('radian').magnitude, coin.SoRotationXYZ.X), (obj.y.to('radian').magnitude, coin.SoRotationXYZ.Y), (obj.z.to('radian').magnitude, coin.SoRotationXYZ.Z)]: if ang == 0.0: continue r = coin.SoRotationXYZ() r.axis = axis r.angle = ang tot.addChild(r) assert len(tot), 'Failed to add any rotations for %s' % str(obj.name) return tot
def attach(self, obj): self.trans = coin.SoTransform() self.xy = gridNode() self.xy.vector1dir = (1, 0, 0) self.xy.vector1color = (0.827, 0.149, 0.149) # red (X) self.xy.vector2dir = (0, 1, 0) self.xy.vector2color = (0.400, 0.590, 0.200) # green (Y) self.xy.mainDim = 100 self.xy.subDim = 10 self.xy.maxviz = 1.0 self.xz = gridNode() self.xz.vector1dir = (1, 0, 0) self.xz.vector1color = (0.827, 0.149, 0.149) # red (X) self.xz.vector2dir = (0, 0, 1) self.xz.vector2color = (0.133, 0.490, 0.882) # blue (Z) self.xz.mainDim = 100 self.xz.subDim = 10 self.xz.maxviz = 0.5 self.yz = gridNode() self.yz.vector1dir = (0, 1, 0) self.yz.vector1color = (0.400, 0.590, 0.200) # green (Y) self.yz.vector2dir = (0, 0, 1) self.yz.vector2color = (0.133, 0.490, 0.882) # blue (Z) self.yz.mainDim = 100 self.yz.subDim = 10 self.yz.maxviz = 0.5 self.sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() self.cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode() self.xy.linkTo(self.cam) self.xy.factor = 1. self.xz.linkTo(self.cam) self.xz.factor = 50. self.yz.linkTo(self.cam) self.yz.factor = 50. self.grid = coin.SoGroup() self.grid.addChild(self.trans) self.grid.addChild(self.xy) self.grid.addChild(self.xz) self.grid.addChild(self.yz) obj.addDisplayMode(self.grid, "Wireframe") self.ViewObject = obj self.Object = obj.Object
def __init__(self, view, names): """ Constructor """ self.viewport = \ view.getViewer().getSoRenderManager().getViewportRegion() self.nodes = { 'connector': coin.SoGroup(), 'selected': coin.SoGroup(), 'switch': coin.SoSwitch(), 'transform': coin.SoTransform(), } self.start_path = None self.trackers = None self.datums = { _k: None for _k in ['origin', 'picked', 'start', 'trans_start'] } self.datums['rotation'] = { 'center': None, 'ref_vec': None, 'angle': 0.0 } names.append('DRAG TRACKER') super().__init__(names, [self.nodes['connector'], self.nodes['selected']], False) self.nodes['switch'].addChild(self.node) self.on(self.nodes['switch'])