本文整理汇总了Python中vtk.vtkProperty函数的典型用法代码示例。如果您正苦于以下问题:Python vtkProperty函数的具体用法?Python vtkProperty怎么用?Python vtkProperty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkProperty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
ActorFactory.ActorFactory.__init__(self)
colors = ((1, 0, 0), (0, 1, 0), (0, 0, 1))
self._Properties = []
for i in range(3):
property = vtk.vtkProperty()
property.SetColor(colors[i])
property.SetAmbient(1.0)
property.SetOpacity(0.3)
self._Properties.append(property)
self._ConeProperties = []
for i in range(3):
property = vtk.vtkProperty()
property.SetColor(colors[i])
property.SetAmbient(1.0)
# property.SetOpacity(0.3)
self._ConeProperties.append(property)
self._Planes = []
self._Cutters = []
self._LineActorsIndex = []
self._ConeActorsIndex = []
self._ConeSize = 24.0
self._Cones = []
for i in range(6):
cone = vtk.vtkConeSource()
cone.SetResolution(2)
cone.SetHeight(self._ConeSize)
cone.SetRadius(self._ConeSize)
self._Cones.append(cone)
示例2: build_constelation
def build_constelation(self,mol):
if mol.acteur == None :
MB.showwarning('Info','Select a molecule in the list')
return
if mol.symobs !=None:
mol.acteur.RemoveObserver(mol.symobs)
if mol.lsm!=[]:
for sm in mol.lsm:
self.gfx.renderer.RemoveActor(sm)
mol.lsm=[]
(xmin, xmax, ymin, ymax, zmin, zmax)= self.bounds
sym=open(self.symlistfile,'r')
for l in sym:
ms = l.split()
nbl = int(ms[6][1:])
if nbl not in mol.lnbsm:
continue
ang = [float(ms[0]),float(ms[1]),float(ms[2])]
tra = array([float(ms[3]),float(ms[4]),float(ms[5])])
sm=symmate() #on cree un symmate vide
sm.SetPosition(mol.acteur.GetPosition()) #on assigne la partie translationelle des pv
sm.SetOrientation(mol.acteur.GetOrientation()) #on assigne la partie rotationelle des pv
self.RotaEuler(sm.ut,ang[0],ang[1],ang[2]) #on defini la partie rotationelle de la transformation
sm.ut.Translate(tra[0],tra[1],tra[2]) #on defini la partie translationelle de la transformation
sm.SetUserTransform(sm.ut) #on assigne la transformation a notre symmate
pip = [sm.GetMatrix().GetElement(0,3),sm.GetMatrix().GetElement(1,3),sm.GetMatrix().GetElement(2,3)]#on recupere la partie translationelle de la combinaison de pv et de la transformation (ut)
if (xmin + self.mdbe < pip[0]) and (pip[0] < xmax - self.mdbe) and (ymin + self.mdbe < pip[1]) and (pip[1] < ymax - self.mdbe) and (zmin + self.mdbe < pip[2]) and (pip[2] < zmax - self.mdbe):# on test si pip est dans la boite
sm.nbsym=nbl
if mol.acteur.GetClassName()=='vtkAssembly':# dans le cas ou la molecule independante est un assembly
for i in range(mol.acteur.GetNumberOfPaths()):
tmp=vtk.vtkActor()
tmp.SetMapper(mol.acteur.GetParts().GetItemAsObject(i).GetMapper())
p=vtk.vtkProperty()
#p.SetColor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor())
p.SetColor(Map.invcolor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor()))
tmp.SetProperty(p)
if mol.mod.type=='mol':
tmp.GetProperty().SetLineWidth(4)
tmp.DragableOff()
tmp.PickableOff()
sm.AddPart(tmp)
else:#cas simple ou la mol ind est composer d un seul objet
tmp=vtk.vtkActor()
tmp.SetMapper(mol.acteur.GetMapper())
p=vtk.vtkProperty()
#p.SetColor(mol.acteur.GetParts().GetItemAsObject(i).GetProperty().GetColor())
p.SetColor(Map.invcolor(mol.acteur.GetProperty().GetColor()))
tmp.SetProperty(p)
if mol.mod.type=='mol':
tmp.GetProperty().SetLineWidth(4)
tmp.DragableOff()
tmp.PickableOff()
sm.AddPart(tmp)
mol.lsm+=[sm]# on ajoute le symmate a la liste des symmate
sym.close()
self.move_sym(mol)
示例3: __init__
def __init__(self):
ActorFactory.__init__(self)
self._Property = vtk.vtkProperty()
self._Plane = None
self._Line = []
for i in range(4):
self._Line.append(vtk.vtkLineSource())
示例4: SetPlanes
def SetPlanes(self, planes):
"""Set a set of SlicePlaneFactory."""
self._Planes = planes
self._properties = []
for i in range(len(self._Planes)):
self._properties.append(vtk.vtkProperty())
self._UpdateIntersections()
示例5: __init__
def __init__(self, *args, **kwargs):
VtkRenderArea.__init__(self, *args, **kwargs)
self._CurrentRenderer = None
self._CurrentCamera = None
self._CurrentZoom = 1.0
self._CurrentLight = None
self._ViewportCenterX = 0
self._ViewportCenterY = 0
self._Picker = vtk.vtkCellPicker()
self._PickedAssembly = None
self._PickedProperty = vtk.vtkProperty()
self._PickedProperty.SetColor(1, 0, 0)
self._PrePickedProperty = None
self._OldFocus = None
# need this to be able to handle key_press events.
self.set_flags(gtk.CAN_FOCUS)
# these record the previous mouse position
self._LastX = 0
self._LastY = 0
self.connect('button_press_event', self.OnButtonDown)
self.connect('button_release_event', self.OnButtonUp)
self.connect('motion_notify_event', self.OnMouseMove)
self.connect('key_press_event', self.OnKeyPress)
self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
gtk.gdk.BUTTON_RELEASE_MASK |
gtk.gdk.KEY_PRESS_MASK |
gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.POINTER_MOTION_HINT_MASK)
示例6: CreateSphereMarkers
def CreateSphereMarkers(self, pubsub_evt):
ball_id = pubsub_evt.data[0]
ballsize = pubsub_evt.data[1]
ballcolour = pubsub_evt.data[2]
coord = pubsub_evt.data[3]
x, y, z = bases.flip_x(coord)
ball_ref = vtk.vtkSphereSource()
ball_ref.SetRadius(ballsize)
ball_ref.SetCenter(x, y, z)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(ball_ref.GetOutput())
prop = vtk.vtkProperty()
prop.SetColor(ballcolour)
#adding a new actor for the present ball
self.staticballs.append(vtk.vtkActor())
self.staticballs[ball_id].SetMapper(mapper)
self.staticballs[ball_id].SetProperty(prop)
self.ren.AddActor(self.staticballs[ball_id])
ball_id = ball_id + 1
self.UpdateRender()
示例7: SetElectrodeColor
def SetElectrodeColor(self, r, g, b):
"""
Set the color for a channel actor
"""
tempProperty = vtk.vtkProperty()
tempProperty.SetColor(r, g, b)
self.channelActors.ApplyProperty(tempProperty)
示例8: __init__
def __init__(self):
ActorFactory.ActorFactory.__init__(self)
# Create a green line
self._Points = vtk.vtkPoints()
self._Lines = vtk.vtkCellArray()
self._Poly = vtk.vtkPolyData()
self._Poly.SetPoints(self._Points)
self._Poly.SetLines(self._Lines)
self._PathProperty = vtk.vtkProperty()
self._PathProperty.SetColor(0, 1, 0)
self._PathProperty.SetOpacity(0.0)
# turn the line into a cylinder
self._tube = vtk.vtkTubeFilter()
# VTK-6
if vtk.vtkVersion().GetVTKMajorVersion() > 5:
self._tube.SetInputData(self._Poly)
else:
self._tube.SetInput(self._Poly)
self._tube.SetNumberOfSides(3)
self._tube.SetRadius(2.5)
示例9: __addNucleiToScene
def __addNucleiToScene(self, reader):
av = self.active_vol
self.mapper = vtk.vtkPolyDataMapper()
self.mapper.SetInputConnection( reader.GetOutputPort() )
# Create an actor
self.actor = vtk.vtkActor()
self.actor.SetMapper(self.mapper)
#center = self.actor.GetCenter()
#cent = self._vdata[av]._electrodes[1].centroid
#self._cameras[av].SetFocalPoint(cent)
self.prop = vtk.vtkProperty()
self.prop.ShadingOn()
self.prop.SetInterpolationToGouraud()
self.prop.EdgeVisibilityOff()
#self.prop.EdgeVisibilityOn()
self.prop.SetDiffuse(0.7)
self.prop.SetSpecular(0.4)
self.prop.SetSpecularPower(20)
self.prop.SetColor(1.0, 1.0, 0)
self.actor.SetProperty(self.prop)
self._renderers[av].AddActor(self.actor)
actv = self.active_vol
self.vol_qvtk_widgets[actv].update()
示例10: __init__
def __init__(self, brain_data, isoval=34):
# Setup Surface Rendering
# Gaussian smoothing of surface rendering for aesthetics
# Adds significant delay to rendering
self.cortexSmoother = vtk.vtkImageGaussianSmooth()
self.cortexSmoother.SetDimensionality(3)
self.cortexSmoother.SetRadiusFactors(0.5, 0.5, 0.5)
self.cortexSmoother.SetInput(brain_data.GetOutput())
# Apply a marching cubes algorithm to extract surface contour with
# isovalue of 30 (can change to adjust proper rendering of tissue
self.cortexExtractor = vtk.vtkMarchingCubes()
self.cortexExtractor.SetInput(self.cortexSmoother.GetOutput())
self.cortexExtractor.SetValue(0, isoval)
self.cortexExtractor.ComputeNormalsOn()
# Map/Paint the polydata associated with the surface rendering
self.cortexMapper = vtk.vtkPolyDataMapper()
self.cortexMapper.SetInput(self.cortexExtractor.GetOutput())
self.cortexMapper.ScalarVisibilityOff()
# Color the cortex (RGB)
self.cortexProperty = vtk.vtkProperty()
self.cortexProperty.SetColor(1, 1, 1)
self.cortexProperty.SetOpacity(1);
# Set the actor to adhere to mapped surface and inherit properties
self.SetMapper(self.cortexMapper)
self.SetProperty(self.cortexProperty)
self.cortexExtractor.Update()
示例11: __build_cross_lines
def __build_cross_lines(self):
renderer = self.slice_data.overlay_renderer
cross = vtk.vtkCursor3D()
cross.AllOff()
cross.AxesOn()
self.cross = cross
c = vtk.vtkCoordinate()
c.SetCoordinateSystemToWorld()
cross_mapper = vtk.vtkPolyDataMapper()
cross_mapper.SetInput(cross.GetOutput())
#cross_mapper.SetTransformCoordinate(c)
p = vtk.vtkProperty()
p.SetColor(1, 0, 0)
cross_actor = vtk.vtkActor()
cross_actor.SetMapper(cross_mapper)
cross_actor.SetProperty(p)
cross_actor.VisibilityOff()
# Only the slices are pickable
cross_actor.PickableOff()
self.cross_actor = cross_actor
renderer.AddActor(cross_actor)
示例12: __init__
def __init__(self):
ActorFactory.ActorFactory.__init__(self)
self.SetName("RectROI")
# colors
self._ActiveColor = (0, 1, 0)
self._HandleColor = tomato
self._LineColor = banana
# Mode 0: Click and Drag to set ROI;
# 1: Control-Click and drag to set ROI
self._Mode = 1
# 4 corner squares
self._Corners = []
for i in range(4):
corner = RectangleSource()
self._Corners.append(corner)
self._CornerProperty = vtk.vtkProperty()
self._CornerProperty.SetOpacity(0)
self._CornerProperty.SetColor(self._HandleColor)
# center cross
self._Center = CrossSource()
self._CenterProperty = vtk.vtkProperty()
self._CenterProperty.SetColor(self._HandleColor)
self._CenterProperty.SetOpacity(0)
# rectangle ROI
self._ROI = RectangleSource()
self._ROIProperty = vtk.vtkProperty()
self._ROIProperty.SetColor(self._LineColor)
self._ROIProperty.SetOpacity(0)
# hack for VCT project: we need to pick the active viewport
self._viewportManager = None
# listener method
self._listenerMethods = []
# x or y translate only for fixed size ROI, used by VCT scanner
self._XOnly = False
self._YOnly = False
self._clearROI = False
示例13: vtkKWSurfaceMaterialPropertyWidgetEntryPoint
def vtkKWSurfaceMaterialPropertyWidgetEntryPoint(parent, win):
app = parent.GetApplication()
# -----------------------------------------------------------------------
# Create the surface property that will be modified by the widget
sprop1 = vtkProperty()
# -----------------------------------------------------------------------
# Create the material widget
# Assign our surface property to the editor
sprop1_widget = vtkKWSurfaceMaterialPropertyWidget()
sprop1_widget.SetParent(parent)
sprop1_widget.Create()
sprop1_widget.SetBalloonHelpString(
"A surface material property widget.")
sprop1_widget.SetProperty(sprop1)
app.Script(
"pack %s -side top -anchor nw -expand n -padx 2 -pady 2",
sprop1_widget.GetWidgetName())
# -----------------------------------------------------------------------
# Create another material widget, in popup mode
# Assign our surface property to the editor
sprop2_widget = vtkKWSurfaceMaterialPropertyWidget()
sprop2_widget.SetParent(parent)
sprop2_widget.PopupModeOn()
sprop2_widget.Create()
sprop2_widget.SetBalloonHelpString(
"A surface material property widget, created in popup mode. Note that "
"it edits the same surface property object as the first widget.")
sprop2_widget.SetProperty(sprop1)
app.Script(
"pack %s -side top -anchor nw -expand n -padx 2 -pady 15",
sprop2_widget.GetWidgetName())
# Both editor are linked to the same surface prop, so they should notify
# each other of any changes to refresh the preview nicely
sprop2_widget.SetPropertyChangingCommand(sprop1_widget, "Update")
sprop2_widget.SetPropertyChangedCommand(sprop1_widget, "Update")
sprop1_widget.SetPropertyChangingCommand(sprop2_widget, "Update")
sprop1_widget.SetPropertyChangedCommand(sprop2_widget, "Update")
return "TypeVTK"
示例14: test_method_signature
def test_method_signature(self):
"""Check if VTK method signatures are parsed correctly."""
p = self.p
# Simple tests.
o = vtk.vtkProperty()
self.assertEqual([(['string'], None)],
p.get_method_signature(o.GetClassName))
if hasattr(vtk, 'vtkArrayCoordinates'):
self.assertEqual([([('float', 'float', 'float')], None),
([None], (['float', 'float', 'float'],)),
([None], ('float', 'float', 'float'))],
p.get_method_signature(o.GetColor))
else:
self.assertEqual([([('float', 'float', 'float')], None),
([None], (('float', 'float', 'float'),))],
p.get_method_signature(o.GetColor))
if hasattr(vtk, 'vtkArrayCoordinates'):
self.assertEqual([([None], ('float', 'float', 'float')),
([None], (['float', 'float', 'float'],))],
p.get_method_signature(o.SetColor))
else:
self.assertEqual([([None], ('float', 'float', 'float')),
([None], (('float', 'float', 'float'),))],
p.get_method_signature(o.SetColor))
# Get VTK version to handle changed APIs.
vtk_ver = vtk.vtkVersion().GetVTKVersion()
# Test vtkObjects args.
o = vtk.vtkContourFilter()
sig = p.get_method_signature(o.SetInput)
if len(sig) == 1:
self.assertEqual([([None], ['vtkDataSet'])],
sig)
elif vtk_ver[:3] in ['4.2', '4.4']:
self.assertEqual([([None], ['vtkDataObject']),
([None], ('int', 'vtkDataObject')),
([None], ['vtkDataSet']),
([None], ('int', 'vtkDataSet'))
], sig)
elif vtk_ver[:2] == '5.' or vtk_ver[:3] == '4.5':
self.assertEqual([([None], ['vtkDataObject']),
([None], ('int', 'vtkDataObject')),
], sig)
self.assertEqual([(['vtkPolyData'], None),
(['vtkPolyData'], ['int'])],
p.get_method_signature(o.GetOutput))
# Test if function arguments work.
self.assertEqual([(['int'], ('int', 'function'))],
p.get_method_signature(o.AddObserver))
# This one's for completeness.
self.assertEqual([([None], ['int'])],
p.get_method_signature(o.RemoveObserver))
示例15: __init__
def __init__(self):
self.AddObserver('LeftButtonPressEvent', self.onLeftButtonPressEvent)
self.AddObserver('MouseMoveEvent', self.onMouseMoveEvent)
self.AddObserver('LeftButtonReleaseEvent', self.onLeftButtonReleaseEvent)
self._lastPickedActor = None
self._lastPickedProperty = vtk.vtkProperty()
self._mouseMoved = False