示例#1
0
 def attach(self,vobj):
     self.mat1 = coin.SoMaterial()
     self.mat2 = coin.SoMaterial()
     self.fcoords = coin.SoCoordinate3()
     #fs = coin.SoType.fromName("SoBrepFaceSet").createInstance() # this causes a FreeCAD freeze for me
     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
     self.lcoords = coin.SoCoordinate3()
     ls = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
     ls.coordIndex.setValues(0,57,[0,1,-1,2,3,4,5,-1,6,7,8,9,-1,10,11,-1,12,13,14,15,-1,16,17,18,19,-1,20,21,-1,22,23,24,25,-1,26,27,28,29,-1,30,31,-1,32,33,34,35,-1,36,37,38,39,-1,40,41,42,43,44])
     sep = coin.SoSeparator()
     psep = coin.SoSeparator()
     fsep = coin.SoSeparator()
     fsep.addChild(self.mat2)
     fsep.addChild(self.fcoords)
     fsep.addChild(fs)
     psep.addChild(self.mat1)
     psep.addChild(self.drawstyle)
     psep.addChild(self.lcoords)
     psep.addChild(ls)
     sep.addChild(fsep)
     sep.addChild(psep)
     vobj.addDisplayMode(sep,"Default")
     self.onChanged(vobj,"DisplaySize")
     self.onChanged(vobj,"LineColor")
     self.onChanged(vobj,"Transparency")
示例#2
0
def mesh_sep(vertices, polygons, color=(1,1,0), draw_lines=False):
    _vertices = vertices
    _polygons = []
    _lines = []
    for i in polygons:
        _polygons += i
        _lines += i
        _lines.append(i[0])
        _polygons.append(-1)
        _lines.append(-1)

    sep = coin.SoSeparator()
    vertex_property = coin.SoVertexProperty()
    face_set = coin.SoIndexedFaceSet()
    shape_hint = coin.SoShapeHints()
    shape_hint.vertexOrdering = coin.SoShapeHints.COUNTERCLOCKWISE
    shape_hint.creaseAngle = coin.M_PI / 3
    face_mat = coin.SoMaterial()
    face_mat.diffuseColor = color
    vertex_property.vertex.setValues(0, len(_vertices), _vertices)
    face_set.coordIndex.setValues(0, len(_polygons), list(_polygons))
    vertex_property.materialBinding = coin.SoMaterialBinding.PER_VERTEX_INDEXED
    sep += shape_hint, vertex_property, face_mat, face_set

    if draw_lines:
        line_set = coin.SoIndexedLineSet()
        line_set.coordIndex.setValues(0, len(_lines), list(_lines))
        line_mat = coin.SoMaterial()
        line_mat.diffuseColor = (.0, .0, .0)
        sep += line_mat, line_set
    return sep
示例#3
0
 def __init__(self, dotted=False, scolor=None, swidth=None, face=False):
     self.origin = Vector(0, 0, 0)
     line = coin.SoLineSet()
     line.numVertices.setValue(5)
     self.coords = coin.SoCoordinate3()  # this is the coordinate
     self.coords.point.setValues(
         0, 50, [[0, 0, 0], [2, 0, 0], [2, 2, 0], [0, 2, 0], [0, 0, 0]])
     if face:
         m1 = coin.SoMaterial()
         m1.transparency.setValue(0.5)
         m1.diffuseColor.setValue([0.5, 0.5, 1.0])
         f = coin.SoIndexedFaceSet()
         f.coordIndex.setValues([0, 1, 2, 3])
         Tracker.__init__(self,
                          dotted,
                          scolor,
                          swidth, [self.coords, line, m1, f],
                          name="rectangleTracker")
     else:
         Tracker.__init__(self,
                          dotted,
                          scolor,
                          swidth, [self.coords, line],
                          name="rectangleTracker")
     self.u = FreeCAD.DraftWorkingPlane.u
     self.v = FreeCAD.DraftWorkingPlane.v
示例#4
0
 def __init__(self):
     # getting screen distance
     p1 = Draft.get3DView().getPoint((100,100))
     p2 = Draft.get3DView().getPoint((110,100))
     bl = (p2.sub(p1)).Length * (Draft.getParam("snapRange", 8)/2)
     pick = coin.SoPickStyle()
     pick.style.setValue(coin.SoPickStyle.UNPICKABLE)
     self.trans = coin.SoTransform()
     self.trans.translation.setValue([0,0,0])
     m1 = coin.SoMaterial()
     m1.transparency.setValue(0.8)
     m1.diffuseColor.setValue([0.4,0.4,0.6])
     c1 = coin.SoCoordinate3()
     c1.point.setValues([[-bl,-bl,0],[bl,-bl,0],[bl,bl,0],[-bl,bl,0]])
     f = coin.SoIndexedFaceSet()
     f.coordIndex.setValues([0,1,2,3])
     m2 = coin.SoMaterial()
     m2.transparency.setValue(0.7)
     m2.diffuseColor.setValue([0.2,0.2,0.3])
     c2 = coin.SoCoordinate3()
     c2.point.setValues([[0,bl,0],[0,0,0],[bl,0,0],[-.05*bl,.95*bl,0],[0,bl,0],
                         [.05*bl,.95*bl,0],[.95*bl,.05*bl,0],[bl,0,0],[.95*bl,-.05*bl,0]])
     l = coin.SoLineSet()
     l.numVertices.setValues([3,3,3])
     s = coin.SoSeparator()
     s.addChild(pick)
     s.addChild(self.trans)
     s.addChild(m1)
     s.addChild(c1)
     s.addChild(f)
     s.addChild(m2)
     s.addChild(c2)
     s.addChild(l)
     Tracker.__init__(self,children=[s],name="planeTracker")
示例#5
0
 def attach(self,vobj):
     self.clip = None
     self.mat1 = coin.SoMaterial()
     self.mat2 = coin.SoMaterial()
     self.fcoords = coin.SoCoordinate3()
     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
     self.lcoords = coin.SoCoordinate3()
     ls = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
     ls.coordIndex.setValues(0,28,[0,1,-1,2,3,4,5,-1,6,7,-1,8,9,10,11,-1,12,13,-1,14,15,16,17,-1,18,19,20,21])
     sep = coin.SoSeparator()
     psep = coin.SoSeparator()
     fsep = coin.SoSeparator()
     fsep.addChild(self.mat2)
     fsep.addChild(self.fcoords)
     fsep.addChild(fs)
     psep.addChild(self.mat1)
     psep.addChild(self.drawstyle)
     psep.addChild(self.lcoords)
     psep.addChild(ls)
     sep.addChild(fsep)
     sep.addChild(psep)
     vobj.addDisplayMode(sep,"Default")
     self.onChanged(vobj,"DisplaySize")
     self.onChanged(vobj,"LineColor")
     self.onChanged(vobj,"Transparency")
     self.Object = vobj.Object
示例#6
0
 def __init__(self):
     # getting screen distance
     p1 = FreeCADGui.ActiveDocument.ActiveView.getPoint((100, 100))
     p2 = FreeCADGui.ActiveDocument.ActiveView.getPoint((110, 100))
     bl = (p2.sub(p1)).Length * (Base.getParam("snapRange") / 2)
     self.trans = coin.SoTransform()
     self.trans.translation.setValue([0, 0, 0])
     m1 = coin.SoMaterial()
     m1.transparency.setValue(0.8)
     m1.diffuseColor.setValue([0.4, 0.4, 0.6])
     c1 = coin.SoCoordinate3()
     c1.point.setValues([[-bl, -bl, 0], [bl, -bl, 0], [bl, bl, 0], [-bl, bl, 0]])
     f = coin.SoIndexedFaceSet()
     f.coordIndex.setValues([0, 1, 2, 3])
     m2 = coin.SoMaterial()
     m2.transparency.setValue(0.7)
     m2.diffuseColor.setValue([0.2, 0.2, 0.3])
     c2 = coin.SoCoordinate3()
     c2.point.setValues([[0, bl, 0], [0, 0, 0], [bl, 0, 0], [-.05 * bl, .95 * bl, 0], [0, bl, 0],
                         [.05 * bl, .95 * bl, 0], [.95 * bl, .05 * bl, 0], [bl, 0, 0], [.95 * bl, -.05 * bl, 0]])
     l = coin.SoLineSet()
     l.numVertices.setValues([3, 3, 3])
     s = coin.SoSeparator()
     s.addChild(self.trans)
     s.addChild(m1)
     s.addChild(c1)
     s.addChild(f)
     s.addChild(m2)
     s.addChild(c2)
     s.addChild(l)
     Tracker.__init__(self, children=[s])
示例#7
0
def draw_polygon(vertices, color, LineWidth):
    """
        Draw any polygon. This will be the base of all multi-point drawing.
        Curves, and arc is not here.
    """
    if len(vertices) < 4:
        raise ValueError('Vertices must be 4')
    _polygon = coin.SoSeparator()
    col = coin.SoBaseColor()
    col.rgb = color
    coords = coin.SoTransform()
    data = coin.SoCoordinate3()
    face = coin.SoIndexedFaceSet()
    style = coin.SoDrawStyle()
    style.lineWidth = LineWidth
    _polygon.addChild(style)
    _polygon.addChild(col)
    _polygon.addChild(coords)
    _polygon.addChild(data)
    _polygon.addChild(face)

    i = 0
    for vr in vertices:
        data.point.set1Value(i, vr[0], vr[1], vr[2])
    i += 1
    polygons = [
        0, 1, 2, 3, -1
    ]  # -1 means that the n-gon is terminated and a new one can be created with the next points

    i = 0
    for p in polygons:
        face.coordIndex.set1Value(i, p)
    i += 1
    return _polygon
def sceneDrawFilledPaths(grpName, paths, scale_factor, color=(0, 0, 1)):
    global sg
    global topZ
    global scenePathNodes

    for i in range(0, len(paths)):
        path = paths[i]
        pts = []
        for pt in path:
            pts.append(
                [1.0 * pt[0] / scale_factor, 1.0 * pt[1] / scale_factor, topZ])
        coPoint = coin.SoCoordinate3()
        coPoint.point.setValues(0, len(pts), pts)
        ma = coin.SoMaterial()
        ma.diffuseColor = color
        if i == 0:
            ma.transparency.setValue(0.9)
        else:
            ma.transparency.setValue(0.8)

        hints = coin.SoShapeHints()
        hints.faceType = coin.SoShapeHints.UNKNOWN_FACE_TYPE
        #hints.vertexOrdering = coin.SoShapeHints.CLOCKWISE

        li = coin.SoIndexedFaceSet()
        li.coordIndex.setValues(range(0, len(pts)))
        pathNode = coin.SoSeparator()
        pathNode.addChild(hints)
        pathNode.addChild(coPoint)
        pathNode.addChild(ma)
        pathNode.addChild(li)
        sg.addChild(pathNode)
        if not scenePathNodes.has_key(grpName):
            scenePathNodes[grpName] = []
        scenePathNodes[grpName].append(pathNode)
    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")
示例#10
0
 def setup_default_display_mode(self, vobj):
     """Setup the coin nodes of the placeholder representation of the Section Plane."""
     self.clip = None
     self.mat1 = coin.SoMaterial()
     self.mat2 = coin.SoMaterial()
     self.fcoords = coin.SoCoordinate3()
     #fs = coin.SoType.fromName("SoBrepFaceSet").createInstance() # this causes a FreeCAD freeze for me
     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
     self.lcoords = coin.SoCoordinate3()
     ls = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
     ls.coordIndex.setValues(0, 57, [
         0, 1, -1, 2, 3, 4, 5, -1, 6, 7, 8, 9, -1, 10, 11, -1, 12, 13, 14,
         15, -1, 16, 17, 18, 19, -1, 20, 21, -1, 22, 23, 24, 25, -1, 26, 27,
         28, 29, -1, 30, 31, -1, 32, 33, 34, 35, -1, 36, 37, 38, 39, -1, 40,
         41, 42, 43, 44
     ])
     sep = coin.SoSeparator()
     psep = coin.SoSeparator()
     fsep = coin.SoSeparator()
     fsep.addChild(self.mat2)
     fsep.addChild(self.fcoords)
     fsep.addChild(fs)
     psep.addChild(self.mat1)
     psep.addChild(self.drawstyle)
     psep.addChild(self.lcoords)
     psep.addChild(ls)
     sep.addChild(fsep)
     sep.addChild(psep)
     vobj.addDisplayMode(sep, "Default")
示例#11
0
    def onChanged(self,vobj,prop):

        if prop == "ShowNodes":
            if hasattr(self,"nodes"):
                vobj.Annotation.removeChild(self.nodes)
                del self.nodes
            if vobj.ShowNodes:
                from pivy import coin
                self.nodes = coin.SoAnnotation()
                self.coords = coin.SoCoordinate3()
                self.mat = coin.SoMaterial()
                self.pointstyle = coin.SoDrawStyle()
                self.pointstyle.style = coin.SoDrawStyle.POINTS
                self.pointset = coin.SoType.fromName("SoBrepPointSet").createInstance()
                self.linestyle = coin.SoDrawStyle()
                self.linestyle.style = coin.SoDrawStyle.LINES
                self.lineset = coin.SoType.fromName("SoBrepEdgeSet").createInstance()
                self.facestyle = coin.SoDrawStyle()
                self.facestyle.style = coin.SoDrawStyle.FILLED
                self.shapehints = coin.SoShapeHints()
                self.shapehints.faceType = coin.SoShapeHints.UNKNOWN_FACE_TYPE
                self.fmat = coin.SoMaterial()
                self.fmat.transparency.setValue(0.75)
                self.faceset = coin.SoIndexedFaceSet()
                self.nodes.addChild(self.coords)
                self.nodes.addChild(self.mat)
                self.nodes.addChild(self.pointstyle)
                self.nodes.addChild(self.pointset)
                self.nodes.addChild(self.linestyle)
                self.nodes.addChild(self.lineset)
                self.nodes.addChild(self.facestyle)
                self.nodes.addChild(self.shapehints)
                self.nodes.addChild(self.fmat)
                self.nodes.addChild(self.faceset)
                vobj.Annotation.addChild(self.nodes)
                self.updateData(vobj.Object,"Nodes")
                self.onChanged(vobj,"NodeColor")
                self.onChanged(vobj,"NodeLine")
                self.onChanged(vobj,"NodeSize")

        elif prop == "NodeColor":
            if hasattr(self,"mat"):
                l = vobj.NodeColor
                self.mat.diffuseColor.setValue([l[0],l[1],l[2]])
                self.fmat.diffuseColor.setValue([l[0],l[1],l[2]])

        elif prop == "NodeLine":
            if hasattr(self,"linestyle"):
                self.linestyle.lineWidth = vobj.NodeLine

        elif prop == "NodeSize":
            if hasattr(self,"pointstyle"):
                self.pointstyle.pointSize = vobj.NodeSize

        elif prop == "NodeType":
            self.updateData(vobj.Object,"Nodes")

        else:
            ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
示例#12
0
 def attach(self,vobj):
     self.Object = vobj.Object
     from pivy import coin
     tex = coin.SoTexture2()
     tex.image = Draft.loadTexture(Draft.svgpatterns()['simple'][1], 128)
     texcoords = coin.SoTextureCoordinatePlane()
     s = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("patternScale",0.01)
     texcoords.directionS.setValue(s,0,0)
     texcoords.directionT.setValue(0,s,0)
     self.fcoords = coin.SoCoordinate3()
     self.fset = coin.SoIndexedFaceSet()
     sep = coin.SoSeparator()
     sep.addChild(tex)
     sep.addChild(texcoords)
     sep.addChild(self.fcoords)
     sep.addChild(self.fset)
     vobj.RootNode.addChild(sep)
     ArchComponent.ViewProviderComponent.attach(self,vobj)
示例#13
0
def simple_poly_mesh(verts, poly, color=None):
    color = color or COLORS["grey"]
    _vertices = [list(v) for v in verts]
    _polygons = []
    for pol in poly:
        _polygons += list(pol) + [-1]
    sep = coin.SoSeparator()
    vertex_property = coin.SoVertexProperty()
    face_set = coin.SoIndexedFaceSet()
    shape_hint = coin.SoShapeHints()
    shape_hint.vertexOrdering = coin.SoShapeHints.COUNTERCLOCKWISE
    shape_hint.creaseAngle = np.pi / 3
    face_mat = coin.SoMaterial()
    face_mat.diffuseColor = color
    vertex_property.vertex.setValues(0, len(_vertices), _vertices)
    face_set.coordIndex.setValues(0, len(_polygons), list(_polygons))
    vertex_property.materialBinding = coin.SoMaterialBinding.PER_VERTEX_INDEXED
    sep += [shape_hint, vertex_property, face_mat, face_set]
    return sep
示例#14
0
    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)
示例#15
0
    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")
示例#16
0
def draw_RotationPad(p1=App.Vector(0.0, 0.0, 0.0),
                     color=FR_COLOR.FR_GOLD,
                     scale=(1, 1, 1),
                     opacity=0,
                     _rotation=[0.0, 0.0, 0.0]):
    try:
        root = coin.SoSeparator()

        separatorX = coin.SoSeparator()
        separatorY = coin.SoSeparator()
        separatorZ = coin.SoSeparator()

        tempRX = coin.SbVec3f()
        tempRX.setValue(1, 0, 0)

        tempRY = coin.SbVec3f()
        tempRY.setValue(0, 1, 0)

        tempRZ = coin.SbVec3f()
        tempRZ.setValue(0, 0, 1)

        transformX = coin.SoTransform()
        transformY = coin.SoTransform()
        transformZ = coin.SoTransform()

        transformX.rotation.setValue(tempRY, math.radians(_rotation[0]))
        transformY.rotation.setValue(tempRX, math.radians(_rotation[1]))
        transformZ.rotation.setValue(tempRZ, math.radians(_rotation[2]))

        material = coin.SoMaterial()
        material.transparency.setValue(opacity)
        material.diffuseColor.setValue(coin.SbColor(color))
        Shapehint = coin.SoShapeHints()
        Shapehint.shapeType = coin.SoShapeHints.UNKNOWN_FACE_TYPE
        Shapehint.vertexOrdering = coin.SoShapeHints.CLOCKWISE
        Shapehint.faceType = coin.SoShapeHints.UNKNOWN_FACE_TYPE

        soIndexFace = coin.SoIndexedFaceSet()
        cordinate = coin.SoCoordinate3()
        vertexPositions = [
            (0, 0, 0.5), (0.01, 0, 0.5), (0.02, 0, 0.5), (0.02, 0, 0.49),
            (0.03, 0, 0.49), (0.04, 0, 0.49), (0.04, 0, 0.48), (0.04, 0, 0.47),
            (0.05, 0, 0.47), (0.05, 0, 0.46), (0.05, 0, 0.45), (0, 0, 0.4),
            (-0.01, 0, 0.4), (-0.02, 0, 0.4),
            (-0.02, 0, 0.41), (-0.03, 0, 0.41), (-0.04, 0, 0.41),
            (-0.04, 0, 0.42), (-0.04, 0, 0.43), (-0.05, 0, 0.43),
            (-0.05, 0, 0.44), (-0.05, 0, 0.45), (-0.05, 0, 0.46),
            (-0.05, 0, 0.47), (-0.04, 0, 0.47), (-0.04, 0, 0.48),
            (-0.04, 0, 0.49), (-0.03, 0, 0.49), (-0.02, 0, 0.49),
            (-0.02, 0, 0.5), (-0.01, 0, 0.5), (0.05, 0, 0.44), (0.05, 0, 0.43),
            (0.04, 0, 0.43), (0.04, 0, 0.42), (0.04, 0, 0.41), (0.03, 0, 0.41),
            (0.02, 0, 0.41), (0.02, 0, 0.4), (0.01, 0, 0.4), (-0.09, 0, 0.49),
            (-0.17, 0, 0.47), (-0.24, 0, 0.44), (-0.31, 0, 0.39),
            (-0.37, 0, 0.34), (-0.42, 0, 0.27), (-0.46, 0, 0.2),
            (-0.48, 0, 0.13), (-0.5, 0, 0.05), (-0.5, 0, -0.03),
            (-0.49, 0, -0.11), (-0.46, 0, -0.19), (-0.43, 0, -0.26),
            (-0.38, 0, -0.33), (-0.32, 0, -0.38), (-0.25, 0, -0.43),
            (-0.18, 0, -0.47), (-0.1, 0, -0.49), (-0.02, 0, -0.5),
            (0.06, 0, -0.5), (0.14, 0, -0.48), (0.21, 0, -0.45),
            (0.28, 0, -0.41), (0.35, 0, -0.36), (0.4, 0, -0.3),
            (0.44, 0, -0.23), (0.47, 0, -0.16), (0.49, 0, -0.08), (0.5, 0, 0),
            (0.49, 0, 0.08), (0.48, 0, 0.15), (0.45, 0, 0.22), (0.41, 0, 0.29),
            (0.36, 0, 0.35), (0.3, 0, 0.4), (0.24, 0, 0.44), (0.17, 0, 0.47),
            (0.09, 0, 0.49), (0.1, 0, 0.48), (0.1, 0, 0.46), (0.1, 0, 0.45),
            (0.1, 0, 0.43), (0.09, 0, 0.41), (0.08, 0, 0.39), (0.4, 0, 0),
            (0.39, 0, 0.07), (0.38, 0, 0.13), (0.35, 0, 0.2), (0.31, 0, 0.25),
            (0.26, 0, 0.3), (0.21, 0, 0.34), (0.15, 0, 0.37), (-0.08, 0, 0.39),
            (-0.15, 0, 0.37), (-0.21, 0, 0.34), (-0.27, 0, 0.29),
            (-0.32, 0, 0.24), (-0.36, 0, 0.18), (-0.38, 0, 0.11),
            (-0.4, 0, 0.04), (-0.4, 0, -0.03), (-0.39, 0, -0.1),
            (-0.36, 0, -0.17), (-0.33, 0, -0.23), (-0.28, 0, -0.29),
            (-0.22, 0, -0.33), (-0.16, 0, -0.37), (-0.09, 0, -0.39),
            (-0.02, 0, -0.4), (0.05, 0, -0.4), (0.12, 0, -0.38),
            (0.19, 0, -0.35), (0.25, 0, -0.31), (0.3, 0, -0.26),
            (0.34, 0, -0.21), (0.37, 0, -0.14), (0.39, 0, -0.07),
            (-0.09, 0, 0.41), (-0.1, 0, 0.43), (-0.1, 0, 0.45),
            (-0.1, 0, 0.47), (0, 0, 0.5), (0.05, 0, 0.45), (0, 0, 0.4),
            (-0.09, 0, 0.49), (0.5, 0, 0), (-0.08, 0, 0.39), (0.4, 0, 0),
            (0.08, 0, 0.39), (0.1, 0, 0.45), (0.09, 0, 0.49)
        ]

        cordinate.point.setValues(0, 468, vertexPositions)
        indices = [
            5, 1, 0, -1, 5, 2, 1, -1, 5, 3, 2, -1, 5, 4, 3, -1, 5, 7, 6, -1, 5,
            8, 7, -1, 5, 9, 8, -1, 5, 10, 9, -1, 5, 12, 11, -1, 5, 13, 12, -1,
            5, 14, 13, -1, 5, 15, 14, -1, 5, 16, 15, -1, 5, 17, 16, -1, 5, 18,
            17, -1, 5, 19, 18, -1, 5, 20, 19, -1, 5, 21, 20, -1, 5, 22, 21, -1,
            5, 23, 22, -1, 5, 24, 23, -1, 5, 25, 24, -1, 5, 26, 25, -1, 5, 27,
            26, -1, 5, 28, 27, -1, 5, 29, 28, -1, 5, 30, 29, -1, 5, 0, 30, -1,
            5, 31, 10, -1, 5, 32, 31, -1, 5, 33, 32, -1, 5, 34, 33, -1, 5, 35,
            34, -1, 5, 36, 35, -1, 5, 37, 36, -1, 5, 38, 37, -1, 5, 39, 38, -1,
            5, 11, 39, -1, 104, 53, 54, -1, 103, 52, 53, -1, 103, 53, 104, -1,
            105, 54, 55, -1, 105, 104, 54, -1, 102, 52, 103, -1, 102, 51, 52,
            -1, 106, 55, 56, -1, 106, 105, 55, -1, 101, 51, 102, -1, 101, 50,
            51, -1, 107, 106, 56, -1, 107, 56, 57, -1, 100, 48, 49, -1, 100,
            49, 50, -1, 100, 50, 101, -1, 108, 107, 57, -1, 108, 57, 58, -1,
            108, 58, 59, -1, 99, 47, 48, -1, 99, 48, 100, -1, 109, 108, 59, -1,
            60, 109, 59, -1, 98, 47, 99, -1, 110, 109, 60, -1, 46, 47, 98, -1,
            61, 110, 60, -1, 97, 46, 98, -1, 111, 110, 61, -1, 45, 46, 97, -1,
            62, 111, 61, -1, 96, 45, 97, -1, 112, 111, 62, -1, 44, 45, 96, -1,
            63, 112, 62, -1, 95, 44, 96, -1, 113, 112, 63, -1, 43, 44, 95, -1,
            64, 113, 63, -1, 94, 43, 95, -1, 114, 113, 64, -1, 42, 43, 94, -1,
            65, 114, 64, -1, 93, 42, 94, -1, 115, 114, 65, -1, 41, 42, 93, -1,
            66, 115, 65, -1, 117, 93, 92, -1, 116, 115, 66, -1, 118, 41, 93,
            -1, 118, 93, 117, -1, 119, 41, 118, -1, 120, 41, 119, -1, 40, 41,
            120, -1, 67, 84, 116, -1, 67, 116, 66, -1, 68, 84, 67, -1, 91, 82,
            83, -1, 81, 82, 91, -1, 69, 84, 68, -1, 69, 85, 84, -1, 70, 85, 69,
            -1, 70, 86, 85, -1, 76, 81, 91, -1, 76, 77, 78, -1, 76, 78, 79, -1,
            76, 79, 80, -1, 76, 80, 81, -1, 71, 86, 70, -1, 71, 87, 86, -1, 75,
            76, 91, -1, 75, 91, 90, -1, 72, 87, 71, -1, 72, 88, 87, -1, 74, 75,
            90, -1, 74, 90, 89, -1, 73, 88, 72, -1, 73, 74, 89, -1, 73, 89, 88,
            -1
        ]
        soIndexFace.coordIndex.setValues(0, len(indices), indices)
        separatorX.addChild(transformX)
        separatorX.addChild(Shapehint)
        separatorX.addChild(cordinate)
        separatorX.addChild(soIndexFace)

        separatorY.addChild(transformY)
        separatorY.addChild(separatorX)

        separatorZ.addChild(transformZ)
        separatorZ.addChild(separatorY)

        transform = coin.SoTransform()  # for scale only
        trans = coin.SoTranslation()
        trans.translation.setValue(p1)
        # Only for scale
        transform.scaleFactor.setValue([scale[0], scale[1], scale[2]])

        root.addChild(trans)
        root.addChild(material)
        root.addChild(transform)
        root.addChild(separatorZ)
        return root
    except Exception as err:
        App.Console.PrintError("'draw draw_RotationPad' 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)
示例#17
0
def draw_DoubleSide2DdArrow(_Points=App.Vector(0, 0, 0),
                            color=FR_COLOR.FR_GOLD,
                            scale=[0.5, 0.5, 0.5],
                            opacity=0,
                            _rotation=[0.0, 0.0, 1.0, 0.0]):
    """[2D Arrow Double sided]

    Args:
        p1 ([App.Vector], optional): [Position of the arrow]. Defaults to App.Vector(0.0, 0.0, 0.0).
        color ((float,float,float)), optional): [RGB Value between 0 to 1]. Defaults to FR_COLOR.FR_GOLD.
        scale ((float,float,float)), optional): [Scale factor for each axis]. Defaults to (1,1,1).
        type (int, optional): [Arrow type. At the moment there are 2 types]. Defaults to 1.
        opacity (int, optional): [Opacity of the drawn arrow]. Defaults to 0.
        _rotation (list, optional): [Rotation of the arrow provided by three float and an angle (float) in degree]. Defaults to [1.0, 0.0, 0.0, 0.0].

    Returns:
        [SoSeparator]: [SoSeparator which hold the drawing. Add it to the scenegraph to show the arrow]
    """
    try:
        p1 = _Points
        root = coin.SoSeparator()
        transform = coin.SoTransform()

        trans = coin.SoTranslation()
        trans.translation.setValue(p1)

        transform.rotation.setValue(_rotation)
        transform.scaleFactor.setValue([scale[0], scale[1], scale[2]])
        tempR = coin.SbVec3f()
        tempR.setValue(_rotation[0], _rotation[1], _rotation[2])
        transform.rotation.setValue(tempR, math.radians(_rotation[3]))

        material = coin.SoMaterial()
        material.transparency.setValue(opacity)
        material.diffuseColor.setValue(coin.SbColor(color))
        material.ambientColor.setValue(coin.SbColor(color))
        material.emissiveColor.setValue(coin.SbColor(0.1, 0.1, 0.1))

        soSepArrow = coin.SoSeparator()  # drawing holder
        soIndexFace = coin.SoIndexedFaceSet()
        cordinate = coin.SoCoordinate3()
        vertexPositions = [(0.00, 8.68, 8.90), (0.00, 8.68, 8.90),
                           (0.00, 8.66, 9.16), (0.00, 7.89, 10.43),
                           (0.00, 8.21, 10.12), (0.00, 8.46, 9.73),
                           (0.00, 8.59, 9.45), (0.00, 5.49, 10.52),
                           (0.00, 5.88, 10.71), (0.00, 6.29, 10.83),
                           (0.00, 6.70, 10.85), (0.00, 7.12, 10.80),
                           (0.00, 7.52, 10.66), (0.00, 3.62, 8.71),
                           (0.00, 1.91, 7.01), (0.00, 1.91, 9.53),
                           (0.00, 1.91, 9.53), (0.00, 1.91, 9.95),
                           (0.00, 1.91, 9.95), (0.00, 1.91, 10.83),
                           (0.00, 1.91, 10.83), (0.00, 1.91, 40.41),
                           (0.00, 1.91, 40.67), (0.00, 3.61, 38.97),
                           (0.00, 5.47, 37.16), (0.00, 6.62, 36.81),
                           (0.00, 6.22, 36.85), (0.00, 5.84, 36.96),
                           (0.00, 8.58, 38.22), (0.00, 8.39, 37.82),
                           (0.00, 8.14, 37.48), (0.00, 7.83, 37.20),
                           (0.00, 7.46, 36.99), (0.00, 7.06, 36.86),
                           (0.00, 8.35, 39.97), (0.00, 8.57, 39.53),
                           (0.00, 8.67, 39.04), (0.00, 8.67, 38.63),
                           (0.00, 1.17, 47.25), (0.00, 0.51, 47.61),
                           (0.00, 0.82, 47.48), (0.00, 0.99, 47.38),
                           (0.00, -0.11, 47.69), (0.00, 0.25, 47.68),
                           (0.00, -0.72, 47.62), (0.00, -0.49, 47.67),
                           (0.00, -0.33, 47.69), (0.00, -4.96, 43.74),
                           (0.00, -1.75, 46.90), (0.00, -1.06, 47.48),
                           (0.00, -0.89, 47.56), (0.00, -8.86, 39.54),
                           (0.00, -8.75, 39.83), (0.00, -7.92, 40.78),
                           (0.00, -8.95, 38.92), (0.00, -8.92, 39.26),
                           (0.00, -8.96, 38.82), (0.00, -8.94, 38.56),
                           (0.00, -8.17, 37.29), (0.00, -8.49, 37.60),
                           (0.00, -8.74, 37.99), (0.00, -8.86, 38.27),
                           (0.00, -5.77, 37.20), (0.00, -6.16, 37.00),
                           (0.00, -6.57, 36.89), (0.00, -6.98, 36.86),
                           (0.00, -7.40, 36.92), (0.00, -7.79, 37.06),
                           (0.00, -3.89, 39.00), (0.00, -2.18, 40.69),
                           (0.00, -2.19, 38.17), (0.00, -2.18, 38.17),
                           (0.00, -2.18, 37.75), (0.00, -2.19, 37.75),
                           (0.00, -2.19, 36.87), (0.00, -2.18, 36.87),
                           (0.00, -2.18, 7.01), (0.00, -3.88, 8.71),
                           (0.00, -5.75, 10.51), (0.00, -6.90, 10.85),
                           (0.00, -6.50, 10.82), (0.00, -6.12, 10.70),
                           (0.00, -8.85, 9.44), (0.00, -8.67, 9.84),
                           (0.00, -8.42, 10.18), (0.00, -8.11, 10.46),
                           (0.00, -7.74, 10.67), (0.00, -7.34, 10.81),
                           (0.00, -8.62, 7.68), (0.00, -8.84, 8.13),
                           (0.00, -8.94, 8.61), (0.00, -8.94, 9.03),
                           (0.00, -1.41, 0.44), (0.00, -0.75, 0.08),
                           (0.00, -1.06, 0.21), (0.00, -1.23, 0.31),
                           (0.00, -0.13, 0.00), (0.00, -0.49, 0.01),
                           (0.00, 0.48, 0.08), (0.00, 0.25, 0.02),
                           (0.00, 0.09, 0.00), (0.00, 4.70, 3.97),
                           (0.00, 1.51, 0.80), (0.00, 0.82, 0.22),
                           (0.00, 0.65, 0.14), (0.00, 8.59, 8.18),
                           (0.00, 8.48, 7.89), (0.00, 7.65, 6.94),
                           (0.00, 8.68, 8.81), (0.00, 8.65, 8.47),
                           (0.00, 8.68, 8.90), (0.00, 8.68, 8.81),
                           (0.00, 8.59, 8.18), (0.00, 4.70, 3.97),
                           (0.00, 0.48, 0.08), (0.00, -0.13, 0.00),
                           (0.00, -0.75, 0.08), (0.00, -1.41, 0.44),
                           (0.00, -8.62, 7.68), (0.00, -8.85, 9.44),
                           (0.00, -6.90, 10.85), (0.00, -5.75, 10.51),
                           (0.00, -3.88, 8.71), (0.00, -2.18, 7.01),
                           (0.00, -2.18, 36.87), (0.00, -2.19, 36.87),
                           (0.00, -2.19, 37.75), (0.00, -2.18, 37.75),
                           (0.00, -2.18, 38.17), (0.00, -2.19, 38.17),
                           (0.00, -2.18, 40.69), (0.00, -3.89, 39.00),
                           (0.00, -5.77, 37.20), (0.00, -8.17, 37.29),
                           (0.00, -8.94, 38.56), (0.00, -8.96, 38.82),
                           (0.00, -8.95, 38.92), (0.00, -8.86, 39.54),
                           (0.00, -4.96, 43.74), (0.00, -0.72, 47.62),
                           (0.00, -0.11, 47.69), (0.00, 0.51, 47.61),
                           (0.00, 1.17, 47.25), (0.00, 8.35, 39.97),
                           (0.00, 8.58, 38.22), (0.00, 6.62, 36.81),
                           (0.00, 5.47, 37.16), (0.00, 3.61, 38.97),
                           (0.00, 1.91, 40.67), (0.00, 1.91, 40.41),
                           (0.00, 1.91, 10.83), (0.00, 1.91, 10.83),
                           (0.00, 1.91, 9.95), (0.00, 1.91, 9.95),
                           (0.00, 1.91, 9.53), (0.00, 1.91, 9.53),
                           (0.00, 1.91, 7.01), (0.00, 3.62, 8.71),
                           (0.00, 5.49, 10.52), (0.00, 7.89, 10.43),
                           (0.00, 8.66, 9.16), (0.00, 8.68, 8.90)]

        cordinate.point.setValues(0, 432, vertexPositions)
        indices = [
            104, 98, 103, -1, 99, 100, 98, -1, 103, 96, 102, -1, 98, 96, 103,
            -1, 100, 96, 98, -1, 1, 2, 0, -1, 97, 93, 96, -1, 108, 6, 1, -1, 1,
            6, 2, -1, 108, 5, 6, -1, 93, 94, 96, -1, 94, 95, 96, -1, 96, 92,
            102, -1, 95, 92, 96, -1, 108, 4, 5, -1, 4, 12, 3, -1, 109, 12, 108,
            -1, 108, 12, 4, -1, 109, 11, 12, -1, 11, 9, 10, -1, 109, 9, 11, -1,
            109, 8, 9, -1, 106, 7, 105, -1, 107, 7, 106, -1, 105, 7, 109, -1,
            109, 7, 8, -1, 101, 13, 107, -1, 107, 13, 7, -1, 102, 14, 101, -1,
            101, 14, 13, -1, 14, 16, 15, -1, 17, 20, 18, -1, 18, 20, 19, -1,
            16, 76, 17, -1, 92, 76, 102, -1, 102, 76, 14, -1, 14, 76, 16, -1,
            76, 88, 77, -1, 77, 88, 78, -1, 92, 88, 76, -1, 81, 79, 80, -1, 78,
            79, 81, -1, 89, 79, 88, -1, 88, 79, 78, -1, 91, 82, 90, -1, 89, 83,
            79, -1, 82, 83, 90, -1, 79, 83, 87, -1, 90, 83, 89, -1, 87, 85, 86,
            -1, 83, 84, 87, -1, 87, 84, 85, -1, 30, 33, 29, -1, 31, 33, 30, -1,
            32, 33, 31, -1, 33, 25, 29, -1, 29, 36, 28, -1, 28, 36, 37, -1, 25,
            35, 29, -1, 29, 35, 36, -1, 26, 27, 25, -1, 25, 34, 35, -1, 27, 24,
            25, -1, 25, 24, 34, -1, 24, 23, 34, -1, 23, 22, 34, -1, 75, 73, 72,
            -1, 74, 73, 75, -1, 72, 71, 21, -1, 21, 69, 22, -1, 71, 69, 21, -1,
            70, 69, 71, -1, 65, 66, 64, -1, 22, 38, 34, -1, 58, 59, 67, -1, 57,
            56, 61, -1, 40, 42, 39, -1, 41, 42, 40, -1, 38, 42, 41, -1, 39, 42,
            43, -1, 60, 54, 59, -1, 61, 54, 60, -1, 56, 54, 61, -1, 54, 55, 59,
            -1, 63, 55, 62, -1, 64, 55, 63, -1, 67, 55, 66, -1, 59, 55, 67, -1,
            66, 55, 64, -1, 46, 44, 45, -1, 42, 44, 46, -1, 55, 51, 62, -1, 42,
            49, 44, -1, 44, 49, 50, -1, 51, 52, 62, -1, 42, 48, 49, -1, 38, 48,
            42, -1, 22, 48, 38, -1, 69, 48, 22, -1, 69, 47, 48, -1, 68, 47, 69,
            -1, 52, 53, 62, -1, 68, 53, 47, -1, 62, 53, 68, -1, 21, 20, 72, -1,
            72, 20, 17, -1, 72, 17, 75, -1, 75, 17, 76, -1
        ]
        soIndexFace.coordIndex.setValues(0, len(indices), indices)
        soSepArrow.addChild(cordinate)
        soSepArrow.addChild(soIndexFace)

        # Finalize the drawing by adding color, pos, scale , opacity
        root.addChild(trans)
        root.addChild(transform)
        root.addChild(material)
        root.addChild(soSepArrow)
        return root

    except Exception as err:
        App.Console.PrintError("'draw_arrow2DDoublesided' 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)
示例#18
0
    def setupCoin(self):
        from pivy import coin

        compasssep = coin.SoSeparator()

        self.transform = coin.SoTransform()

        darkNorthMaterial = coin.SoMaterial()
        darkNorthMaterial.diffuseColor.set1Value(0, 0.5, 0,
                                                 0)  # north dark color

        lightNorthMaterial = coin.SoMaterial()
        lightNorthMaterial.diffuseColor.set1Value(0, 0.9, 0,
                                                  0)  # north light color

        darkGreyMaterial = coin.SoMaterial()
        darkGreyMaterial.diffuseColor.set1Value(0, 0.9, 0.9, 0.9)  # dark color

        lightGreyMaterial = coin.SoMaterial()
        lightGreyMaterial.diffuseColor.set1Value(0, 0.5, 0.5,
                                                 0.5)  # light color

        coords = self.buildCoordinates()

        # coordIndex = [0, 1, 2, -1, 2, 3, 0, -1]

        lightColorFaceset = coin.SoIndexedFaceSet()
        lightColorCoordinateIndex = [4, 5, 6, -1, 8, 9, 10, -1, 12, 13, 14, -1]
        lightColorFaceset.coordIndex.setValues(0,
                                               len(lightColorCoordinateIndex),
                                               lightColorCoordinateIndex)

        darkColorFaceset = coin.SoIndexedFaceSet()
        darkColorCoordinateIndex = [6, 7, 4, -1, 10, 11, 8, -1, 14, 15, 12, -1]
        darkColorFaceset.coordIndex.setValues(0, len(darkColorCoordinateIndex),
                                              darkColorCoordinateIndex)

        lightNorthFaceset = coin.SoIndexedFaceSet()
        lightNorthCoordinateIndex = [2, 3, 0, -1]
        lightNorthFaceset.coordIndex.setValues(0,
                                               len(lightNorthCoordinateIndex),
                                               lightNorthCoordinateIndex)

        darkNorthFaceset = coin.SoIndexedFaceSet()
        darkNorthCoordinateIndex = [0, 1, 2, -1]
        darkNorthFaceset.coordIndex.setValues(0, len(darkNorthCoordinateIndex),
                                              darkNorthCoordinateIndex)

        self.compassswitch = coin.SoSwitch()
        self.compassswitch.whichChild = coin.SO_SWITCH_NONE
        self.compassswitch.addChild(compasssep)

        lightGreySeparator = coin.SoSeparator()
        lightGreySeparator.addChild(lightGreyMaterial)
        lightGreySeparator.addChild(lightColorFaceset)

        darkGreySeparator = coin.SoSeparator()
        darkGreySeparator.addChild(darkGreyMaterial)
        darkGreySeparator.addChild(darkColorFaceset)

        lightNorthSeparator = coin.SoSeparator()
        lightNorthSeparator.addChild(lightNorthMaterial)
        lightNorthSeparator.addChild(lightNorthFaceset)

        darkNorthSeparator = coin.SoSeparator()
        darkNorthSeparator.addChild(darkNorthMaterial)
        darkNorthSeparator.addChild(darkNorthFaceset)

        compasssep.addChild(coords)
        compasssep.addChild(self.transform)
        compasssep.addChild(lightGreySeparator)
        compasssep.addChild(darkGreySeparator)
        compasssep.addChild(lightNorthSeparator)
        compasssep.addChild(darkNorthSeparator)

        return self.compassswitch
示例#19
0
    def attach(self, vobj):
        '''
        Create Object visuals in 3D view.
        '''
        # GeoCoords Node.
        self.geo_coords = coin.SoGeoCoordinate()

        # Surface features.
        self.triangles = coin.SoIndexedFaceSet()
        shape_hints = coin.SoShapeHints()
        shape_hints.vertex_ordering = coin.SoShapeHints.COUNTERCLOCKWISE
        self.mat_color = coin.SoMaterial()
        mat_binding = coin.SoMaterialBinding()
        mat_binding.value = coin.SoMaterialBinding.OVERALL
        edge_color = coin.SoBaseColor()
        edge_color.rgb = (0.5, 0.5, 0.5)
        offset = coin.SoPolygonOffset()

        # Line style.
        line_style = coin.SoDrawStyle()
        line_style.style = coin.SoDrawStyle.LINES
        line_style.lineWidth = 2

        # Contour features.
        cont_color = coin.SoBaseColor()
        cont_color.rgb = (1, 1, 0)
        self.cont_coords = coin.SoGeoCoordinate()
        self.cont_lines = coin.SoLineSet()

        # Contour root.
        contours = coin.SoSeparator()
        contours.addChild(cont_color)
        contours.addChild(line_style)
        contours.addChild(self.cont_coords)
        contours.addChild(self.cont_lines)

        # Face root.
        faces = coin.SoSeparator()
        faces.addChild(shape_hints)
        faces.addChild(self.mat_color)
        faces.addChild(mat_binding)
        faces.addChild(self.geo_coords)
        faces.addChild(self.triangles)

        # 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(edge_color)
        highlight.addChild(line_style)
        highlight.addChild(self.geo_coords)
        highlight.addChild(self.triangles)

        # Surface root.
        surface_root = coin.SoSeparator()
        surface_root.addChild(contours)
        surface_root.addChild(offset)
        surface_root.addChild(faces)
        surface_root.addChild(offset)
        surface_root.addChild(highlight)
        vobj.addDisplayMode(surface_root,"Surface")

        # Take features from properties.
        self.onChanged(vobj,"TriangleColor")