本文整理汇总了Python中vtk.vtkAxesActor方法的典型用法代码示例。如果您正苦于以下问题:Python vtk.vtkAxesActor方法的具体用法?Python vtk.vtkAxesActor怎么用?Python vtk.vtkAxesActor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtk
的用法示例。
在下文中一共展示了vtk.vtkAxesActor方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def __init__(self):
self.renderer = vtk.vtkRenderer()
self.renderer.SetBackground(0.5, 0.5, 0.5)
self.renderer.ResetCamera()
axes_actor = vtk.vtkAxesActor()
axes_actor.AxisLabelsOff()
self.renderer.AddActor(axes_actor)
self.window = vtk.vtkRenderWindow()
self.window.AddRenderer(self.renderer)
self.interactor = vtk.vtkRenderWindowInteractor()
self.interactor.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
self.interactor.SetRenderWindow(self.window)
self.camera = vtk.vtkCamera()
self.camera.SetViewUp(0.0, -1.0, 0.0)
self.camera.SetPosition(0.0, 0.0, -5)
self.camera.SetFocalPoint(0.0, 0.0, 0.0)
# self.camera.SetClippingRange(0.0, 100000)
self.renderer.SetActiveCamera(self.camera)
示例2: plot
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def plot(self):
pose_se3 = self
if type(self) is SO3:
pose_se3 = self.to_se3()
pipeline = VtkPipeline()
axes = [vtk.vtkAxesActor() for i in range(self.length)]
vtk_mat = [transforms.np2vtk(each) for each in pose_se3]
for i in range(len(axes)):
axes[i].SetUserMatrix(vtk_mat[i])
axes[i].SetAxisLabels(0)
pipeline.add_actor(axes[i])
pipeline.add_actor(graphics.axesCube(pipeline.ren))
pipeline.render(ui=False)
pipeline.screenshot()
pipeline.iren.Initialize()
pipeline.iren.Start()
示例3: add_axes_at_origin
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def add_axes_at_origin(self, x_color=None, y_color=None, z_color=None,
xlabel='X', ylabel='Y', zlabel='Z', line_width=2,
labels_off=False):
"""Add axes actor at origin.
Return
------
marker_actor : vtk.vtkAxesActor
vtkAxesActor actor
"""
self.marker_actor = create_axes_marker(line_width=line_width,
x_color=x_color, y_color=y_color, z_color=z_color,
xlabel=xlabel, ylabel=ylabel, zlabel=zlabel, labels_off=labels_off)
self.AddActor(self.marker_actor)
memory_address = self.marker_actor.GetAddressAsString("")
self._actors[memory_address] = self.marker_actor
self.Modified()
return self.marker_actor
示例4: update_axes_label_color
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def update_axes_label_color(axes_actor, color=None):
"""Set the axes label color (internale helper)."""
if color is None:
color = rcParams['font']['color']
color = parse_color(color)
if isinstance(axes_actor, vtk.vtkAxesActor):
prop_x = axes_actor.GetXAxisCaptionActor2D().GetCaptionTextProperty()
prop_y = axes_actor.GetYAxisCaptionActor2D().GetCaptionTextProperty()
prop_z = axes_actor.GetZAxisCaptionActor2D().GetCaptionTextProperty()
for prop in [prop_x, prop_y, prop_z]:
prop.SetColor(color[0], color[1], color[2])
prop.SetShadow(False)
elif isinstance(axes_actor, vtk.vtkAnnotatedCubeActor):
axes_actor.GetTextEdgesProperty().SetColor(color)
return
示例5: add_axes
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def add_axes(self):
self.axis_widget = vtkOrientationMarkerWidget()
axes = vtkAxesActor()
axes.SetShaftTypeToLine()
axes.SetTotalLength(0.5, 0.5, 0.5)
self.axis_widget.SetOutlineColor(0.9300,0.5700,0.1300)
self.axis_widget.SetOrientationMarker(axes)
self.axis_widget.SetInteractor(self._Iren)
self.axis_widget.SetViewport(0.80, 0.0, 1.0,0.25)
self._enable_axis = True
self.axis_widget.SetEnabled(self._enable_axis)
self.axis_widget.InteractiveOff()
示例6: animate
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def animate(self, other=None, duration=5, gif=None):
from .quaternion import UnitQuaternion
assert duration > 0
q1 = []
q2 = []
if other is not None:
assert type(other) is SO3
assert self.length == other.length
for i in range(self.length):
q1.append(UnitQuaternion.rot(self.data[i]))
q2.append(UnitQuaternion.rot(other.data[i]))
else:
for i in range(self.length):
q1.append(UnitQuaternion())
q2.append(UnitQuaternion.rot(self.data[i]))
self.pipeline = VtkPipeline(total_time_steps=duration*60, gif_file=gif)
axis_list = []
for i in range(self.length):
axis_list.append(vtk.vtkAxesActor())
axis_list[i].SetAxisLabels(0)
axis_list[i].SetUserMatrix(transforms.np2vtk(q1[i].q2tr()))
self.pipeline.add_actor(axis_list[i])
cube_axes = graphics.axesCube(self.pipeline.ren)
self.pipeline.add_actor(cube_axes)
def execute(obj, event):
nonlocal axis_list
self.pipeline.timer_tick()
print(self.pipeline.timer_count)
for i in range(len(axis_list)):
axis_list[i].SetUserMatrix(
transforms.np2vtk(
q1[i].interp(
q2[i], r=1 / self.pipeline.total_time_steps * self.pipeline.timer_count).q2tr()))
self.pipeline.iren.GetRenderWindow().Render()
self.pipeline.iren.AddObserver('TimerEvent', execute)
self.pipeline.animate()
示例7: axesUniversal
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def axesUniversal():
axes_uni = vtk.vtkAxesActor()
axes_uni.SetXAxisLabelText("x'")
axes_uni.SetYAxisLabelText("y'")
axes_uni.SetZAxisLabelText("z'")
axes_uni.SetTipTypeToSphere()
axes_uni.SetShaftTypeToCylinder()
axes_uni.SetTotalLength(2, 2, 2)
axes_uni.SetCylinderRadius(0.02)
axes_uni.SetAxisLabels(0)
return axes_uni
示例8: axesActor2d
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def axesActor2d():
axes = vtk.vtkAxesActor()
axes.SetTotalLength(1, 1, 0)
axes.SetZAxisLabelText("")
return axes
示例9: create_axes_marker
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def create_axes_marker(label_color=None, x_color=None, y_color=None,
z_color=None, xlabel='X', ylabel='Y', zlabel='Z',
labels_off=False, line_width=2):
"""Return an axis actor to add in the scene."""
if x_color is None:
x_color = rcParams['axes']['x_color']
if y_color is None:
y_color = rcParams['axes']['y_color']
if z_color is None:
z_color = rcParams['axes']['z_color']
axes_actor = vtk.vtkAxesActor()
axes_actor.GetXAxisShaftProperty().SetColor(parse_color(x_color))
axes_actor.GetXAxisTipProperty().SetColor(parse_color(x_color))
axes_actor.GetYAxisShaftProperty().SetColor(parse_color(y_color))
axes_actor.GetYAxisTipProperty().SetColor(parse_color(y_color))
axes_actor.GetZAxisShaftProperty().SetColor(parse_color(z_color))
axes_actor.GetZAxisTipProperty().SetColor(parse_color(z_color))
# Set labels
axes_actor.SetXAxisLabelText(xlabel)
axes_actor.SetYAxisLabelText(ylabel)
axes_actor.SetZAxisLabelText(zlabel)
if labels_off:
axes_actor.AxisLabelsOff()
# Set Line width
axes_actor.GetXAxisShaftProperty().SetLineWidth(line_width)
axes_actor.GetYAxisShaftProperty().SetLineWidth(line_width)
axes_actor.GetZAxisShaftProperty().SetLineWidth(line_width)
update_axes_label_color(axes_actor, label_color)
return axes_actor
示例10: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def __init__(self, threadLock, actorWrapper, axis=True,):
super(VTKVisualisation, self).__init__()
self.threadLock = threadLock
self.ren = vtk.vtkRenderer()
self.ren.AddActor(actorWrapper.actor)
self.axesActor = vtk.vtkAxesActor()
self.axesActor.AxisLabelsOff()
self.axesActor.SetTotalLength(1, 1, 1)
self.ren.AddActor(self.axesActor)
self.renWin = vtk.vtkRenderWindow()
self.renWin.AddRenderer(self.ren)
## IREN
self.iren = vtk.vtkRenderWindowInteractor()
self.iren.SetRenderWindow(self.renWin)
self.iren.Initialize()
self.style = vtk.vtkInteractorStyleTrackballCamera()
self.iren.SetInteractorStyle(self.style)
self.iren.AddObserver("TimerEvent", self.update_visualisation)
dt = 30 # ms
timer_id = self.iren.CreateRepeatingTimer(dt)
示例11: __init__
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def __init__(self, h=800, w=600):
self.renderer = vtk.vtkRenderer()
self.renderer.SetBackground(0.1, 0.1, 0.1)
# Add axes
axes = vtk.vtkAxesActor()
axes.GetXAxisCaptionActor2D().SetHeight(0.05)
axes.GetYAxisCaptionActor2D().SetHeight(0.05)
axes.GetZAxisCaptionActor2D().SetHeight(0.05)
axes.SetCylinderRadius(0.03)
axes.SetShaftTypeToCylinder()
self.renderer.AddActor(axes)
# Add render window
self.renwin = vtk.vtkRenderWindow()
self.renwin.SetWindowName("Point Cloud Viewer")
self.renwin.SetSize(h, w)
self.renwin.AddRenderer(self.renderer)
# An interactor
self.interactor = vtk.vtkRenderWindowInteractor()
interstyle = vtk.vtkInteractorStyleTrackballCamera()
self.interactor.SetInteractorStyle(interstyle)
self.interactor.SetRenderWindow(self.renwin)
self.camera_actors = []
示例12: CreateAxes
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def CreateAxes(self, length):
"Create a coordinate axes system with a given length of the axes"
axesActor = vtk.vtkAxesActor()
axesActor.AxisLabelsOff()
axesActor.SetTotalLength(length, length, length)
self.actor = axesActor
示例13: vis_with_renderer
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def vis_with_renderer(renderer):
# Renderer
# renderer.SetBackground(.2, .3, .4)
renderer.SetBackground(1, 1, 1)
renderer.ResetCamera()
transform = vtk.vtkTransform()
transform.Translate(1.0, 0.0, 0.0)
axes = vtk.vtkAxesActor()
renderer.AddActor(axes)
# Render Window
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
# Interactor
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
def get_camera_info(obj, ev):
if renderWindowInteractor.GetKeyCode() == "s":
w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(renderWindow)
w2if.Update()
writer = vtk.vtkPNGWriter()
writer.SetFileName("screenshot.png")
if vtk.VTK_MAJOR_VERSION == 5:
writer.SetInput(w2if.GetOutput())
else:
writer.SetInputData(w2if.GetOutput())
writer.Write()
print "screenshot saved"
style = vtk.vtkInteractorStyleSwitch()
renderWindowInteractor.SetInteractorStyle(style)
# style.SetCurrentStyleToTrackballActor()
style.SetCurrentStyleToTrackballCamera()
# Begin Interaction
renderWindowInteractor.AddObserver(vtk.vtkCommand.KeyPressEvent, get_camera_info, 1)
renderWindow.Render()
renderWindowInteractor.Start()
示例14: addMarker
# 需要导入模块: import vtk [as 别名]
# 或者: from vtk import vtkAxesActor [as 别名]
def addMarker(self):
axes = vtk.vtkAxesActor()
axes.SetShaftTypeToLine()
axes.SetTotalLength(1, 1, 1)
self.widget = vtk.vtkOrientationMarkerWidget()
self.widget.SetOutlineColor(0.93, 0.57, 0.13)
self.widget.SetOrientationMarker(axes)
self.widget.SetViewport(0, 0, 0.25, 0.25)
xLabel = axes.GetXAxisCaptionActor2D()
xLabel.SetCaption("X")
xprop = vtk.vtkTextProperty()
xprop.SetFontSize(3)
xLabel.SetCaptionTextProperty(xprop)
xLabel.SetAttachmentPoint(0.75, 0.2, 0)
xLabel.LeaderOff()
xLabel.BorderOff()
xLabel.GetProperty().SetColor(self.color)
xLabel.SetPosition(0, 0)
yLabel = axes.GetYAxisCaptionActor2D()
yLabel.SetCaption("Y")
yprop = vtk.vtkTextProperty()
yprop.SetFontSize(3)
yLabel.SetCaptionTextProperty(yprop)
yLabel.SetAttachmentPoint(0.2, 0.75, 0)
yLabel.LeaderOff()
yLabel.BorderOff()
yLabel.GetProperty().SetColor(self.color)
yLabel.SetPosition(0, 0)
zLabel = axes.GetZAxisCaptionActor2D()
zLabel.SetCaption("Z")
zprop = vtk.vtkTextProperty()
zprop.SetFontSize(3)
zLabel.SetCaptionTextProperty(zprop)
zLabel.SetAttachmentPoint(0, 0.2, 0.75)
zLabel.LeaderOff()
zLabel.BorderOff()
zLabel.GetProperty().SetColor(self.color)
zLabel.SetPosition(0, 0)
self.xLabel = xLabel
self.yLabel = yLabel
self.zLabel = zLabel