Python vtk.vtkAxesActor() Examples

The following are 14 code examples of vtk.vtkAxesActor(). 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 vtk , or try the search function .
Example #1
Source File: pose.py    From robopy with MIT License 6 votes vote down vote up
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() 
Example #2
Source File: renderer.py    From pyvista with MIT License 6 votes vote down vote up
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 
Example #3
Source File: tools.py    From pyvista with MIT License 6 votes vote down vote up
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 
Example #4
Source File: vtkVisualization.py    From MOTSFusion with MIT License 5 votes vote down vote up
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) 
Example #5
Source File: QVTKWidget.py    From pcloudpy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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() 
Example #6
Source File: pose.py    From robopy with MIT License 5 votes vote down vote up
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() 
Example #7
Source File: graphics.py    From robopy with MIT License 5 votes vote down vote up
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 
Example #8
Source File: graphics.py    From robopy with MIT License 5 votes vote down vote up
def axesActor2d():
    axes = vtk.vtkAxesActor()
    axes.SetTotalLength(1, 1, 0)
    axes.SetZAxisLabelText("")

    return axes 
Example #9
Source File: tools.py    From pyvista with MIT License 5 votes vote down vote up
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 
Example #10
Source File: show_vtk.py    From pyrealsense with Apache License 2.0 5 votes vote down vote up
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) 
Example #11
Source File: visualizer_3d.py    From sanet_relocal_demo with GNU General Public License v3.0 5 votes vote down vote up
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 = [] 
Example #12
Source File: pointobject.py    From Det3D with Apache License 2.0 5 votes vote down vote up
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 
Example #13
Source File: utility.py    From ILCC with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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() 
Example #14
Source File: wvtk.py    From pyCGNS with GNU Lesser General Public License v2.1 4 votes vote down vote up
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