本文整理汇总了Python中pivy.coin.SoTransform方法的典型用法代码示例。如果您正苦于以下问题:Python coin.SoTransform方法的具体用法?Python coin.SoTransform怎么用?Python coin.SoTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pivy.coin
的用法示例。
在下文中一共展示了coin.SoTransform方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
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)
示例2: setupAxis
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
def setupAxis(self):
vobj = getattr(self,'ViewObject', None)
if not vobj:
return
switch = getattr(self,'axisNode',None)
if not self.showCS():
if switch:
switch.whichChild = -1
return
if not switch:
parentSwitch = vobj.SwitchNode
if not parentSwitch.getNumChildren():
return
from pivy import coin
switch = coin.SoSwitch()
node = coin.SoType.fromName('SoFCSelectionRoot').createInstance()
switch.addChild(node)
trans = coin.SoTransform()
node.addChild(trans)
node.addChild(ViewProviderAsmElement.getAxis())
self.axisNode = switch
self.transNode = trans
for i in range(parentSwitch.getNumChildren()):
parentSwitch.getChild(i).addChild(switch)
switch.whichChild = 0
pla = vobj.Object.Placement.inverse().multiply(
utils.getElementPlacement(vobj.Object.Shape))
self.transNode.translation.setValue(pla.Base)
self.transNode.rotation.setValue(pla.Rotation.Q)
示例3: __init__
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
def __init__(self, color = (0.,0.,0.), font = 'sans', size = 16, trans = (0,0,0), text = ''):
super(text2dNode, self).__init__()
self.fontNode = coin.SoFont()
self.transNode = coin.SoTransform()
self.textNode = coin.SoText2()
self.addChild(self.fontNode)
self.addChild(self.transNode)
self.addChild(self.textNode)
self.color = color
self.font = font
self.size = size
self.trans = trans
self.text = text
示例4: data
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
def data(self, datarr):
if not ((len(self._data) == len(datarr[0])) & (len(self._data) == len(datarr[1]))): # lengths of the 2 arrays are different. Wipe the Separator and populate it.
self.nodeList = []
self._data = []
self.textSep.removeAllChildren()
for i in range(min(len(datarr[0]),len(datarr[1]))):
sep = coin.SoSeparator()
textpos = coin.SoTransform()
textpos.translation.setValue([datarr[0][i][0],datarr[0][i][1],datarr[0][i][2]])
text = coin.SoText2()
field = [""]*self.offset + [datarr[1][i]]
text.string.setValues(0,len(field),field)
sep.addChild(textpos)
sep.addChild(text)
self.textSep.addChild(sep)
self.nodeList.append((textpos,text))
self._data.append((datarr[0][i],datarr[1][i]))
else:
for i in range(min(len(datarr[0]),len(datarr[1]))):
print(range(min(len(datarr[0]),len(datarr[1]))))
print(self.nodeList[i][0])
self.nodeList[i][0].translation.setValue([datarr[0][i][0],datarr[0][i][1],datarr[0][i][2]])
field = [""]*self.offset + [datarr[1][i]]
self.nodeList[i][1].string.setValues(0,len(field),field)
self._data[i] = (datarr[0][i],datarr[1][i])
#c = coordinate3Node([(0,1,0),(1,1,0),(2,2,1)])
#p = polygonNode((0.5,0.9,0.1),2)
#m = markerSetNode((1,0.35,0.8),1)
#t = text2dNode((0.2,0.9,0.9),'osiFont',15,(10,15,20),'blabla')
#mt = multiTextNode((0.2,0.9,0.9),'osiFont',15,(10,15,20))
#mt.data = ([(1,2,3),(4,5,6)],['bla','blublu'])
示例5: __init__
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
def __init__(self, name = "GridView"):
super(gridView, self).__init__()
self.setName(name)
self._number_of_points = 50
self._center = (0,0)
self._scale = 1.0
self._axis = 0 # 1=X 2=Y 3=Z
self.transform = coin.SoTransform()
self.coord = coin.SoCoordinate3()
self.sep1 = coin.SoSeparator()
self.sep1.setName("Snap_Points")
self.sep2 = coin.SoSeparator()
self.sep2.setName("Grid")
self.sep3 = coin.SoSeparator()
self.sep3.setName("Axis")
self.addChild(self.transform)
self.addChild(self.coord)
self.addChild(self.sep1)
self.addChild(self.sep2)
self.addChild(self.sep3)
ps = coin.SoPointSet()
ds = coin.SoDrawStyle()
ds.pointSize = 1
self.sep1.addChild(ds)
self.sep1.addChild(ps)
self.color1 = (0.82, 0.15, 0.15) # red (X)
self.color2 = (0.40, 0.59, 0.20) # green (Y)
self.color3 = (0.13, 0.49, 0.88) # blue (Z)
示例6: displaytext
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
def displaytext(self,pos,color=(1,1,1),text=["aaa","bbb"]):
textpos = coin.SoTransform()
p=pos
textpos.translation.setValue(p.x+10,p.y+10,p.z+10)
font = coin.SoFont()
font.size = 20
text2d = coin.SoText2()
text3d = coin.SoAsciiText()
text2d.string.setValues([l.encode("utf8") for l in text if l])
text3d.string.setValues([l.encode("utf8") for l in text if l])
myMaterial = SoMaterial()
myMaterial.diffuseColor.set1Value(0, SbColor(*color))
try:
sg=self._sg
except:
sg = SoSeparator()
self._sg= sg
root=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()
root.addChild(sg)
node2d = SoSeparator()
node2d.addChild(textpos)
node2d.addChild(myMaterial)
node2d.addChild(font)
node2d.addChild(text2d)
#node2d.addChild(text3d)
sg.addChild(node2d)
示例7: attach
# 需要导入模块: from pivy import coin [as 别名]
# 或者: from pivy.coin import SoTransform [as 别名]
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 updateCam(self):
# self.cam = FreeCADGui.ActiveDocument.ActiveView.getCameraNode()
# self.xy.linkTo(self.cam)
# self.xz.linkTo(self.cam)
# self.yz.linkTo(self.cam)