Python pivy.coin.SoBaseColor() Examples

The following are 9 code examples of pivy.coin.SoBaseColor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pivy.coin , or try the search function .
Example #1
Source File: HUD.py    From CurvesWB with GNU Lesser General Public License v2.1 6 votes vote down vote up
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) 
Example #2
Source File: cointools.py    From NodeEditor with MIT License 6 votes vote down vote up
def displaysphere(self,point,radius=5,color=(1,1,1)):
    
    try:
        sg=self._sg
    except:
        sg    = SoSeparator()
        self._sg= sg

        root=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
        root.addChild(sg)

    p=point
    #say(point,color,"##########")

    trans = coin.SoTranslation()
    trans.translation.setValue(p.x,p.y,p.z)
    cub = coin.SoSphere()
    cub.radius.setValue(radius)
    col = coin.SoBaseColor()
    col.rgb=color
    myCustomNode = coin.SoSeparator()
    myCustomNode.addChild(col)
    myCustomNode.addChild(trans)
    myCustomNode.addChild(cub)
    sg.addChild(myCustomNode) 
Example #3
Source File: polarUtilsCmd.py    From flamingo with GNU Lesser General Public License v3.0 6 votes vote down vote up
def __init__(self,pl=None, scale=[100,100,20],offset=100,name='ARROW'):
    # define main properties
    self.view=FreeCADGui.ActiveDocument.ActiveView
    self.sg=self.view.getSceneGraph()
    self.cb=self.view.addEventCallbackPivy(coin.SoMouseButtonEvent.getClassTypeId(), self.pickCB)
    # define OpenInventor properties
    self.node=coin.SoSeparator() #self.node=coin.SoSelection()
    self.name=name
    self.node.setName(self.name)
    self.color=coin.SoBaseColor(); self.color.rgb=0,0.8,0
    self.transform=coin.SoTransform(); self.transform.scaleFactor.setValue(scale)
    self.cone=coin.SoCone()
    # create children of node
    self.node.addChild(self.color)
    self.node.addChild(self.transform)
    self.node.addChild(self.cone)
    # draw the arrow and move it to its Placement with the specified offset
    self.sg.addChild(self.node)
    self.offset=offset
    if not pl:
      pl=FreeCAD.Placement()
    self.moveto(pl) 
Example #4
Source File: polarUtilsCmd.py    From flamingo with GNU Lesser General Public License v3.0 6 votes vote down vote up
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) 
Example #5
Source File: ParametricComb.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
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")
        #self.onChanged(obj,"Color") 
Example #6
Source File: loooMarkers.py    From CurvesWB with GNU Lesser General Public License v2.1 5 votes vote down vote up
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 
Example #7
Source File: minimal.py    From pivy with ISC License 5 votes vote down vote up
def main():
    app = QApplication(sys.argv)

    root = SoSeparator()
    col = SoBaseColor()
    col.rgb = SbColor(1, 1, 0)
    root.addChild(col)
    root.addChild(SoCone())

    viewer = QuarterWidget()
    viewer.setSceneGraph(root)

    viewer.setWindowTitle("minimal")
    viewer.show()
    sys.exit(app.exec_()) 
Example #8
Source File: SurfaceEdit.py    From CurvesWB with GNU Lesser General Public License v2.1 4 votes vote down vote up
def __init__(self, mlist):
        self.colorRed = coin.SoBaseColor()
        self.colorRed.rgb=(1,0,0)
        self.colorGreen = coin.SoBaseColor()
        self.colorGreen.rgb=(0,1,0)
        self.colorBlue = coin.SoBaseColor()
        self.colorBlue.rgb=(0,0,1)
        self.colorYellow = coin.SoBaseColor()
        self.colorYellow.rgb=(1,1,0)
        self.colorPurple = coin.SoBaseColor()
        self.colorPurple.rgb=(1,0,1)
        self.colorCyan = coin.SoBaseColor()
        self.colorCyan.rgb=(0,1,1)
        self.colorWhite = coin.SoBaseColor()
        self.colorWhite.rgb=(1,1,1)
        self.colorBlack = coin.SoBaseColor()
        self.colorBlack.rgb=(0,0,0)
        self.Ulen = len(mlist)
        self.Vlen = len(mlist[0])
        self.pts = []
        for row in mlist:
            for pt in row:
                self.pts.append(pt.points[0])
        num = []
        for u in range(self.Ulen):
            for v in range(self.Vlen):
                num.append(u*self.Vlen+v)
            num.append(-1)
        num2 = []
        for v in range(self.Vlen):
            for u in range(self.Ulen):
                num2.append(u*self.Vlen+v)
            num2.append(-1)
        print(str(num))
        print(str(num2))
        self.gridSep = coin.SoSeparator()
        #self.coords = coin.SoCoordinate3()
        #self.coords.point.setValues(0,len(self.pts),self.pts)

        self.Line = coin.SoIndexedLineSet()
        self.Line.coordIndex.setValues(0,len(num),num)
        self.Node = coin.SoSeparator()
        #self.Node.addChild(self.coords)
        self.Node.addChild(self.colorBlue)
        self.Node.addChild(self.Line)

        self.Line2 = coin.SoIndexedLineSet()
        self.Line2.coordIndex.setValues(0,len(num2),num2)
        self.Node2 = coin.SoSeparator()
        #self.Node2.addChild(self.coords)
        self.Node2.addChild(self.colorPurple)
        self.Node2.addChild(self.Line2)
        
        self.gridSep.addChild(self.Node)
        self.gridSep.addChild(self.Node2) 
Example #9
Source File: hooks.py    From CurvesWB with GNU Lesser General Public License v2.1 4 votes vote down vote up
def attach(self, vobj):
        self.ViewObject = vobj
        self.Object = vobj.Object
        
        #self.selectionNode = coin.SoType.fromName("SoFCSelection").createInstance()
        #self.selectionNode.documentName.setValue(FreeCAD.ActiveDocument.Name)
        #self.selectionNode.objectName.setValue(vobj.Object.Name) # here obj is the ViewObject, we need its associated App Object
        #self.selectionNode.subElementName.setValue("Vertex")
        
        
        #self.node = coin.SoSeparator()
        #self.node.setName("Hook")
        #self.coord = coin.SoCoordinate3()
        #self.marker = coin.SoSphere() #coin.SoMarkerSet() #((1,0,0),coin.SoMarkerSet.DIAMOND_FILLED_9_9)
        ##self.marker.markerIndex = coin.SoMarkerSet.DIAMOND_FILLED_9_9
        #self.color = coin.SoBaseColor()
        #self.color.rgb = (1,0,0)
        
        
        ##self.node.addChild(self.color)
        ##self.node.addChild(self.coord)
        ##self.node.addChild(self.marker)
        #self.selectionNode.addChild(self.color)
        #self.selectionNode.addChild(self.coord)
        #self.selectionNode.addChild(self.marker)
        
        #vobj.addDisplayMode(self.selectionNode,"Wireframe")

    #def updateData(self, fp, prop):
        #if prop == "Center":
            #vec = coin.SbVec3f(fp.Center.x, fp.Center.y, fp.Center.z)
            #self.coord.point.setValue(vec)
            ##self.coord.point.setValues(0,len([vec]),[vec])

    #def getDisplayModes(self,obj):
         #"Return a list of display modes."
         #modes=[]
         #modes.append("Wireframe")
         #return modes

    #def getDefaultDisplayMode(self):
         #'''Return the name of the default display mode. It must be defined in getDisplayModes.'''
         #return "Wireframe"

    #def setDisplayMode(self,mode):
         #return mode