本文整理汇总了Python中vtk.vtkOrientationMarkerWidget函数的典型用法代码示例。如果您正苦于以下问题:Python vtkOrientationMarkerWidget函数的具体用法?Python vtkOrientationMarkerWidget怎么用?Python vtkOrientationMarkerWidget使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkOrientationMarkerWidget函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: renderthis
def renderthis(self):
# open a window and create a renderer
self.ren = vtk.vtkRenderer()
self.widget.GetRenderWindow().AddRenderer(self.ren)
# Background colour lightgrey
self.ren.SetBackground(0.9,0.9,0.9)
#create a X,Y,Z axes to show 3d position:
# create axes variable and load vtk axes actor
self.axes = vtk.vtkAxesActor()
self.marker = vtk.vtkOrientationMarkerWidget()
# set the interactor. self.widget._Iren is inbuilt python mechanism for current renderer window.
self.marker.SetInteractor(self.widget._Iren )
self.marker.SetOrientationMarker(self.axes )
# set size and position of window (Xmin,Ymin,Xmax,Ymax)
self.marker.SetViewport(0.75,0,1,0.25)
#Allow user input
self.marker.SetEnabled(1)
# #settings for renderer window
self.ren.ResetCamera()
self.ren.ResetCameraClippingRange()
self.isplotted = True
self.p=0
示例2: renderthis
def renderthis(self):
# open a window and create a renderer
ren = vtk.vtkRenderer()
self.widget.GetRenderWindow().AddRenderer(ren)
# o take the polygonal data from the vtkConeSource and
# create a rendering for the renderer.
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(self.reader.GetOutputPort())
#SetInputConnection(reader.GetOutputPort())
# create an actor for our scene
actor = vtk.vtkActor()
actor.SetMapper(mapper)
# Add actor
ren.AddActor(actor)
axes = vtk.vtkAxesActor()
self.marker = vtk.vtkOrientationMarkerWidget()
self.marker.SetInteractor( self.widget._Iren )
self.marker.SetOrientationMarker( axes )
self.marker.SetViewport(0.75,0,1,0.25)
self.marker.SetEnabled(1)
ren.ResetCamera()
ren.ResetCameraClippingRange()
cam = ren.GetActiveCamera()
cam.Elevation(10)
cam.Azimuth(70)
self.isploted = True
示例3: __init__
def __init__(self, vtk_filename=None, vtk_data=None):
"""
Initiate Viwer
Parameters
----------
vtk_filename : str
Input VTK filename
"""
QDialog.__init__(self)
self.initUI()
ren = vtk.vtkRenderer()
self.vtkWidget.GetRenderWindow().AddRenderer(ren)
iren = self.vtkWidget.GetRenderWindow().GetInteractor()
if vtk_filename is not None:
# VTK file
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(vtk_filename)
reader.Update()
vtkdata = reader.GetOutput()
if vtk_data is not None:
vtkdata = vtk_data
# VTK surface
surface = vtk.vtkDataSetSurfaceFilter()
surface.SetInput(vtkdata)
surface.Update()
mapper = vtk.vtkDataSetMapper()
mapper.SetInput(surface.GetOutput())
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().EdgeVisibilityOff()
# actor.GetProperty().SetEdgeColor(1,1,1)
# actor.GetProperty().SetLineWidth(0.1)
ren.AddActor(actor)
# annot. cube
axesActor = vtk.vtkAnnotatedCubeActor()
axesActor.SetXPlusFaceText('R')
axesActor.SetXMinusFaceText('L')
axesActor.SetYMinusFaceText('H')
axesActor.SetYPlusFaceText('F')
axesActor.SetZMinusFaceText('A')
axesActor.SetZPlusFaceText('P')
axesActor.GetTextEdgesProperty().SetColor(1, 1, 0)
axesActor.GetCubeProperty().SetColor(0, 0, 1)
self.axes = vtk.vtkOrientationMarkerWidget()
self.axes.SetOrientationMarker(axesActor)
self.axes.SetInteractor(iren)
self.axes.EnabledOn()
self.axes.InteractiveOn()
ren.ResetCamera()
iren.Initialize()
示例4: ShowOrientationCube
def ShowOrientationCube(self):
cube = vtk.vtkAnnotatedCubeActor()
cube.GetXMinusFaceProperty().SetColor(1,0,0)
cube.GetXPlusFaceProperty().SetColor(1,0,0)
cube.GetYMinusFaceProperty().SetColor(0,1,0)
cube.GetYPlusFaceProperty().SetColor(0,1,0)
cube.GetZMinusFaceProperty().SetColor(0,0,1)
cube.GetZPlusFaceProperty().SetColor(0,0,1)
cube.GetTextEdgesProperty().SetColor(0,0,0)
# anatomic labelling
cube.SetXPlusFaceText ("A")
cube.SetXMinusFaceText("P")
cube.SetYPlusFaceText ("L")
cube.SetYMinusFaceText("R")
cube.SetZPlusFaceText ("S")
cube.SetZMinusFaceText("I")
axes = vtk.vtkAxesActor()
axes.SetShaftTypeToCylinder()
axes.SetTipTypeToCone()
axes.SetXAxisLabelText("X")
axes.SetYAxisLabelText("Y")
axes.SetZAxisLabelText("Z")
#axes.SetNormalizedLabelPosition(.5, .5, .5)
orientation_widget = vtk.vtkOrientationMarkerWidget()
orientation_widget.SetOrientationMarker(cube)
orientation_widget.SetViewport(0.85,0.85,1.0,1.0)
#orientation_widget.SetOrientationMarker(axes)
orientation_widget.SetInteractor(self.interactor)
orientation_widget.SetEnabled(1)
orientation_widget.On()
orientation_widget.InteractiveOff()
示例5: adicionaeixos
def adicionaeixos(self):
axes = vtk.vtkAxesActor()
self.marker = vtk.vtkOrientationMarkerWidget()
self.marker.SetInteractor( self.Interactor )
self.marker.SetOrientationMarker( axes )
self.marker.SetViewport(0.75,0,1,0.25)
self.marker.SetEnabled(1)
示例6: add_widgets
def add_widgets(self):
# axes
axes = vtk.vtkAxesActor()
self.marker_widget = vtk.vtkOrientationMarkerWidget()
self.marker_widget.SetInteractor(self.iren)
self.marker_widget.SetOrientationMarker(axes)
self.marker_widget.SetViewport(0.0, 0.0, 0.25, 0.25)
# scalar bar
self.scalarbar_actor = vtk.vtkScalarBarActor()
self.scalarbar_actor.SetLookupTable(self.lut)
self.scalarbar_widget = vtk.vtkScalarBarWidget()
self.scalarbar_widget.SetInteractor(self.iren)
self.scalarbar_widget.SetScalarBarActor(self.scalarbar_actor)
# contour slider
self.slider_rep = vtk.vtkSliderRepresentation2D()
self.slider_rep.SetTitleText("contour")
self.slider_rep.GetPoint1Coordinate().SetCoordinateSystemToNormalizedViewport()
self.slider_rep.GetPoint1Coordinate().SetValue(0.65, 0.1)
self.slider_rep.GetPoint2Coordinate().SetCoordinateSystemToNormalizedViewport()
self.slider_rep.GetPoint2Coordinate().SetValue(0.95, 0.1)
self.slider_widget = vtk.vtkSliderWidget()
self.slider_widget.SetInteractor(self.iren)
self.slider_widget.SetRepresentation(self.slider_rep)
self.slider_widget.SetAnimationModeToAnimate()
self.slider_widget.AddObserver(vtk.vtkCommand.InteractionEvent,
self.update_contour);
示例7: __init__
def __init__(self, parent = None):
QtGui.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ren = vtk.vtkRenderer()
self.ui.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
self.iren = self.ui.vtkWidget.GetRenderWindow().GetInteractor()
cube = vtk.vtkCubeSource()
cube.SetXLength(200)
cube.SetYLength(200)
cube.SetZLength(200)
cube.Update()
cm = vtk.vtkPolyDataMapper()
cm.SetInputConnection(cube.GetOutputPort())
ca = vtk.vtkActor()
ca.SetMapper(cm)
self.ren.AddActor(ca)
self.axesActor = vtk.vtkAnnotatedCubeActor();
self.axesActor.SetXPlusFaceText('R')
self.axesActor.SetXMinusFaceText('L')
self.axesActor.SetYMinusFaceText('H')
self.axesActor.SetYPlusFaceText('F')
self.axesActor.SetZMinusFaceText('P')
self.axesActor.SetZPlusFaceText('A')
self.axesActor.GetTextEdgesProperty().SetColor(1,1,0)
self.axesActor.GetTextEdgesProperty().SetLineWidth(2)
self.axesActor.GetCubeProperty().SetColor(0,0,1)
self.axes = vtk.vtkOrientationMarkerWidget()
self.axes.SetOrientationMarker(self.axesActor)
self.axes.SetInteractor(self.iren)
self.axes.EnabledOn()
self.axes.InteractiveOn()
self.ren.ResetCamera()
示例8: PlotGrids_wFEM
def PlotGrids_wFEM(grids):
""" Plots CFD structured grids with a single FEM """
N = len(grids)
HSV_tuples = [(x*1.0/N, 0.5, 0.5) for x in range(N)]
RGB_tuples = map(lambda x: colorsys.hsv_to_rgb(*x), HSV_tuples)
actors = []
for i in range(len(grids)):
# Create mapper
mapper = vtk.vtkDataSetMapper()
if vtk.vtkVersion().GetVTKMajorVersion() >5:
mapper.SetInput(grids[i])
else:
mapper.SetInputData(grids[i])
# Create actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().EdgeVisibilityOn()
if i != 0:
actor.GetProperty().SetRepresentationToWireframe()
actor.GetProperty().SetColor(RGB_tuples[i])
actor.GetProperty().LightingOff()
actors.append(actor)
# Add FEM Actor to renderer window
ren = vtk.vtkRenderer()
# ren.SetBackground(0.3, 0.3, 0.3)
ren.SetBackground(0.8, 0.8, 0.8)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Allow user to interact
istyle = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(istyle)
# Add actor
for actor in actors:
ren.AddActor(actor)
axes = vtk.vtkAxesActor()
widget = vtk.vtkOrientationMarkerWidget()
# widget.SetOutlineColor( 0.9300, 0.5700, 0.1300 )
widget.SetOrientationMarker( axes )
widget.SetInteractor( iren )
widget.SetViewport( 0.0, 0.0, 0.4, 0.4 )
widget.SetEnabled( 1 )
widget.InteractiveOn()
# Render
iren.Initialize()
renWin.Render()
iren.Start()
示例9: vtk_visualize
def vtk_visualize(point_list, view_thresh):
point_cloud = VtkPointCloud()
x_thresh = view_thresh[0]
y_thresh = view_thresh[1]
z_thresh = view_thresh[2]
for i in range(len(point_list)):
point_coords = point_list[i]
if (point_coords[0] > x_thresh[0]) and (point_coords[0] < x_thresh[1]) and \
(point_coords[1] > y_thresh[0]) and (point_coords[1] < y_thresh[1]) and \
(point_coords[2] > z_thresh[0]) and (point_coords[2] < z_thresh[1]):
color_num = 0.7
else:
color_num = -1
point_cloud.addPoint(point_list[i], color_num)
# Add the velodyne plane
for x in np.linspace(-4, 4, 100):
for y in np.linspace(0, 2, 25):
tmp_coords = np.array([x, 0, y])
point_cloud.addPoint(tmp_coords, 1)
# Add the floor plane
plane_center = (-4, -4, -0.55)
normal = (0, 0, 1)
point1 = ([-4, 10, -0.55])
point2 = ([4, -4, -0.55])
point_cloud.addPlane(plane_center, normal, point1, point2)
# Renderer
renderer = vtk.vtkRenderer()
renderer.AddActor(point_cloud.point_vtkActor)
renderer.AddActor(point_cloud.plane_vtkActor)
renderer.SetBackground(0.0, 0.0, 0.0)
renderer.ResetCamera()
# Render Window
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
# Interactor
render_window_interactor = vtk.vtkRenderWindowInteractor()
render_window_interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
render_window_interactor.SetRenderWindow(render_window)
'''Add camera coordinates'''
axes = vtk.vtkAxesActor()
widget = vtk.vtkOrientationMarkerWidget()
widget.SetOutlineColor(0.9300, 0.5700, 0.1300)
widget.SetOrientationMarker(axes)
widget.SetInteractor(render_window_interactor)
widget.SetViewport(0.0, 0.0, 0.4, 0.4)
widget.SetEnabled(1)
widget.InteractiveOn()
render_window.Render()
render_window_interactor.Start()
示例10: _create_orientation_widget
def _create_orientation_widget(self, view3d):
"""setup orientation widget stuff, the axes in the bottom
"""
view3d._orientation_widget = vtk.vtkOrientationMarkerWidget()
view3d._axes_actor = vtk.vtkAxesActor()
view3d._orientation_widget.SetOrientationMarker(view3d._axes_actor)
view3d._orientation_widget.SetInteractor(view3d)
开发者ID:RalfNieuwenhuizen,项目名称:DeViDe-multiVWR,代码行数:9,代码来源:multiDirectionalSlicedViewSegmentation3dVieWeRFrame.py
示例11: attach_pos
def attach_pos(self):
pos = self._pos
rad = self._rad
if pos is not None and rad is not None:
positions_vtk = numpy_support.numpy_to_vtk(num_array=pos.ravel(), deep=True, array_type=vtk.VTK_FLOAT)
positions_vtk.SetName("positions")
radius_vtk = numpy_support.numpy_to_vtk(num_array=rad.ravel(), deep=True, array_type=vtk.VTK_FLOAT)
radius_vtk.SetName("radius")
sphere = vtk.vtkSphereSource()
sphere.SetRadius(1.0)
ballGlyph = vtk.vtkGlyph3D()
if vtk.VTK_MAJOR_VERSION <= 5:
ballGlyph.SetSource(sphere.GetOutput())
else:
ballGlyph.SetSourceConnection(sphere.GetOutputPort())
polydata = vtk.vtkPolyData()
polydata.SetPoints(self._points)
polydata.GetPointData().AddArray(radius_vtk)
polydata.GetPointData().SetActiveScalars("radius") # this scales the source (sphere) radius (1.0)
ballGlyph.SetInputData(polydata)
#ballGlyph.SetScaleModeToDataScalingOn()
mapper = vtk.vtkPolyDataMapper()
if vtk.VTK_MAJOR_VERSION <= 5:
mapper.SetInput(ballGlyph.GetOutput())
else:
mapper.SetInputConnection(ballGlyph.GetOutputPort())
# Set colors depending on the color transfer functions
# mapper.SetLookupTable(self.colorTransferFunction)
# actor
ballActor = vtk.vtkActor()
ballActor.GetProperty().SetColor(0,0,1)
ballActor.SetMapper(mapper)
#self._ren.AddActor(ballActor)
self._marker2 = vtk.vtkOrientationMarkerWidget()
self._marker2.SetInteractor( self.widget._Iren )
self._marker2.SetOrientationMarker( ballActor )
self._marker2.SetViewport(0.75,0,1,0.25)
self._marker2.SetEnabled(1)
else:
print("No particles found. Make sure the particles loaded have positions and radii.")
示例12: createCubeOrientation
def createCubeOrientation(self):
self._cubeOrientationActor = vtk.vtkAnnotatedCubeActor()
self._cubeOrientationActor.SetXPlusFaceText(QtGui.QApplication.translate("ImagePlane",
"L",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetXMinusFaceText(QtGui.QApplication.translate("ImagePlane",
"R",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetYPlusFaceText(QtGui.QApplication.translate("ImagePlane",
"P",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetYMinusFaceText(QtGui.QApplication.translate("ImagePlane",
"A",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetZPlusFaceText(QtGui.QApplication.translate("ImagePlane",
"S",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetZMinusFaceText(QtGui.QApplication.translate("ImagePlane",
"I",
None,
QtGui.QApplication.UnicodeUTF8))
self._cubeOrientationActor.SetZFaceTextRotation(90)
self._cubeOrientationActor.SetFaceTextScale(0.67)
property = self._cubeOrientationActor.GetXPlusFaceProperty()
property.SetColor(0, 0, 1)
property = self._cubeOrientationActor.GetXMinusFaceProperty()
property.SetColor(0, 0, 1)
property = self._cubeOrientationActor.GetYPlusFaceProperty()
property.SetColor(0, 1, 0)
property = self._cubeOrientationActor.GetYMinusFaceProperty()
property.SetColor(0, 1, 0)
property = self._cubeOrientationActor.GetZPlusFaceProperty()
property.SetColor(1, 0, 0)
property = self._cubeOrientationActor.GetZMinusFaceProperty()
property.SetColor(1, 0, 0)
self._cubeOrientationActor.SetTextEdgesVisibility(1)
self._cubeOrientationActor.SetCubeVisibility(1)
self._cubeOrientationActor.SetFaceTextVisibility(1)
self.orientationWidget = vtk.vtkOrientationMarkerWidget()
self.orientationWidget.SetInteractor(self._interactor)
self.orientationWidget.SetViewport(0.85, 0.85, 1, 1)
self.orientationWidget.SetOrientationMarker(self._cubeOrientationActor)
self.orientationWidget.SetEnabled(1)
self.orientationWidget.InteractiveOff()
self.orientationWidget.On();
示例13: run
def run(self):
if self.displayAxes:
axesActor = vtk.vtkAxesActor()
axesActor.SetShaftTypeToLine()
axes = vtk.vtkOrientationMarkerWidget()
axes.SetOrientationMarker(axesActor);
axes.SetInteractor(self.interactor);
axes.EnabledOn();
axes.InteractiveOn();
self.window.Render()
self.window.SetWindowName(self.windowTitle)
self.interactor.Start()
示例14: addAxes
def addAxes(self):
self.widget = vtkOrientationMarkerWidget()
axes = vtkAxesActor()
axes.SetShaftTypeToLine()
axes.SetTotalLength(0.5, 0.5, 0.5)
self.widget.SetOutlineColor(0.9300,0.5700,0.1300)
self.widget.SetOrientationMarker(axes)
self.widget.SetInteractor(self._Iren)
self.widget.SetViewport(0.80, 0.0, 1.0,0.25)
self._widgetState = True
self.widget.SetEnabled(self._widgetState)
self.widget.InteractiveOff()
示例15: renderthis
def renderthis(self):
# open a window and create a renderer
self.ren = vtk.vtkRenderer()
self.widget.GetRenderWindow().AddRenderer(self.ren)
# to generate polygonal data for a arrow.
Arrow = vtk.vtkArrowSource()
Arrow.SetShaftResolution(100)
Arrow.SetTipResolution(100)
#invert arrow so the point which is referenced is the top of the point
Arrow.InvertOn()
# take the polygonal data from the vtkArrowSource and assign to variable arrowmapper
ArrowMapper = vtk.vtkPolyDataMapper()
ArrowMapper.SetInputConnection(Arrow.GetOutputPort())
# create an actor for our scene (arrowactor)
self.ArrowActor = vtk.vtkActor()
self.ArrowActor.SetMapper(ArrowMapper)
self.ArrowActor.GetProperty().SetColor(1,1,0)
self.ArrowActor.GetProperty().SetOpacity(0.60)
self.ArrowActor.GetProperty().EdgeVisibilityOn()
self.ArrowActor.GetProperty().SetColor(0.1,0.1,0.1)
# set tip position to (0,0,0)
self.position=(0,0,0)
self.ArrowActor.SetPosition(self.position)
# get and print arrow position
self.ArrowPos = self.ArrowActor.GetPosition()
#print self.ArrowPos
# Add actor to renderer window
#self.ren.AddActor(self.ArrowActor)
# Background colour lightgrey
self.ren.SetBackground(0.9,0.9,0.9)
#create a X,Y,Z axes to show 3d position:
# create axes variable and load vtk axes actor
self.axes = vtk.vtkAxesActor()
self.marker = vtk.vtkOrientationMarkerWidget()
# set the interactor. self.widget._Iren is inbuilt python mechanism for current renderer window.
self.marker.SetInteractor(self.widget._Iren )
self.marker.SetOrientationMarker(self.axes )
# set size and position of window (Xmin,Ymin,Xmax,Ymax)
self.marker.SetViewport(0.75,0,1,0.25)
#Allow user input
self.marker.SetEnabled(1)
# #settings for renderer window
self.ren.ResetCamera()
self.ren.ResetCameraClippingRange()
self.isplotted = True
self.p=0