def __init__(self,sel,dotted=False,scolor=None,swidth=None): self.trans = coin.SoTransform() self.trans.translation.setValue([0,0,0]) self.children = [self.trans] rootsep = coin.SoSeparator() if not isinstance(sel,list): sel = [sel] for obj in sel: import Part if not isinstance(obj, Part.Vertex): rootsep.addChild(self.getNode(obj)) else: self.coords = coin.SoCoordinate3() self.coords.point.setValue((obj.X,obj.Y,obj.Z)) color = coin.SoBaseColor() color.rgb = FreeCADGui.draftToolBar.getDefaultColor("snap") self.marker = coin.SoMarkerSet() # this is the marker symbol self.marker.markerIndex = FreeCADGui.getMarkerIndex("quad", 9) node = coin.SoAnnotation() selnode = coin.SoSeparator() selnode.addChild(self.coords) selnode.addChild(color) selnode.addChild(self.marker) node.addChild(selnode) rootsep.addChild(node) self.children.append(rootsep) Tracker.__init__(self,dotted,scolor,swidth,children=self.children,name="ghostTracker")
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 __init__(self,pos=Vector(0,0,0),name=None,idx=0,objcol=None,\ marker=FreeCADGui.getMarkerIndex("quad", 9),inactive=False): color = coin.SoBaseColor() if objcol: color.rgb = objcol[:3] else: color.rgb = FreeCADGui.draftToolBar.getDefaultColor("snap") self.marker = coin.SoMarkerSet() # this is the marker symbol self.marker.markerIndex = marker self.coords = coin.SoCoordinate3() # this is the coordinate self.coords.point.setValue((pos.x,pos.y,pos.z)) if inactive: selnode = coin.SoSeparator() else: selnode = coin.SoType.fromName("SoFCSelection").createInstance() if name: selnode.documentName.setValue(FreeCAD.ActiveDocument.Name) selnode.objectName.setValue(name) selnode.subElementName.setValue("EditNode"+str(idx)) node = coin.SoAnnotation() selnode.addChild(self.coords) selnode.addChild(color) selnode.addChild(self.marker) node.addChild(selnode) ontop = not inactive Tracker.__init__(self,children=[node],ontop=ontop,name="editTracker") self.on()
def set_style(self, style=None, draw=None, color=None): """ Update the tracker style """ #pylint: disable=no-member if self.active_style == style: return if not draw: draw = self.draw_style if not color: color = self.color if not style: style = self.coin_style draw.lineWidth = style.line_width draw.style = style.style draw.linePattern = style.line_pattern color.rgb = style.color if hasattr(self, 'marker'): self.marker.markerIndex = \ Gui.getMarkerIndex(style.shape, style.size) self.active_style = style
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): 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 = FreeCADGui.getMarkerIndex("", 5) sep.addChild(symbol) rn = vobj.RootNode rn.addChild(sep) ArchComponent.ViewProviderComponent.attach(self, vobj)
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 = FreeCADGui.getMarkerIndex("", 5) sep.addChild(symbol) rn = vobj.RootNode rn.addChild(sep) ArchComponent.ViewProviderComponent.attach(self,vobj)
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 __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 create_default(self, names): """ Create the default node tracker """ style = self.STYLE.DEFAULT 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 = coin.SoGroup() group.addChild(child.node) self.groups['default'].append(child) return group
def dim_symbol(symbol=None, invert=False): """Return the specified dimension symbol. Parameters ---------- symbol: int, optional It defaults to `None`, in which it gets the value from the parameter database, `get_param("dimsymbol", 0)`. A numerical value defines different markers * 0, `SoSphere` * 1, `SoMarkerSet` with a circle * 2, `SoSeparator` with a `soCone` * 3, `SoSeparator` with a `SoFaceSet` * 4, `SoSeparator` with a `SoLineSet`, calling `dim_dash` * Otherwise, `SoSphere` invert: bool, optional It defaults to `False`. If it is `True` and `symbol=2`, the cone will be rotated -90 degrees around the Z axis, otherwise the rotation is positive, +90 degrees. Returns ------- Coin.SoNode A `Coin.SoSphere`, or `Coin.SoMarkerSet` (circle), or `Coin.SoSeparator` (cone, face, line) that will be used as a dimension symbol. """ if symbol is None: symbol = utils.get_param("dimsymbol", 0) if symbol == 0: # marker = coin.SoMarkerSet() # marker.markerIndex = 80 # Returning a sphere means that the bounding box will # be 3-dimensional; a marker will always be planar seen from any # orientation but it currently doesn't work correctly marker = coin.SoSphere() return marker elif symbol == 1: marker = coin.SoMarkerSet() # Should be the same as # marker.markerIndex = 10 marker.markerIndex = Gui.getMarkerIndex("circle", 9) return marker elif symbol == 2: marker = coin.SoSeparator() t = coin.SoTransform() t.translation.setValue((0, -2, 0)) t.center.setValue((0, 2, 0)) if invert: t.rotation.setValue(coin.SbVec3f((0, 0, 1)), -math.pi/2) else: t.rotation.setValue(coin.SbVec3f((0, 0, 1)), math.pi/2) c = coin.SoCone() c.height.setValue(4) marker.addChild(t) marker.addChild(c) return marker elif symbol == 3: marker = coin.SoSeparator() c = coin.SoCoordinate3() c.point.setValues([(-1, -2, 0), (0, 2, 0), (1, 2, 0), (0, -2, 0)]) f = coin.SoFaceSet() marker.addChild(c) marker.addChild(f) return marker elif symbol == 4: return dimDash((-1.5, -1.5, 0), (1.5, 1.5, 0)) else: _wrn(_tr("Symbol not implemented. Use a default symbol.")) return coin.SoSphere()
def setMarker(self,style): self.marker.markerIndex = FreeCADGui.getMarkerIndex(style, 9)
def setMarker(self, style): """Set the marker index.""" self.marker.markerIndex = FreeCADGui.getMarkerIndex(style, 9)