コード例 #1
0
ファイル: troupe.py プロジェクト: zsmith3/autodiff
    def __init__(self, **kwargs):
        text_rep = vtk.vtkTextRepresentation()
        text_rep.GetPositionCoordinate().SetValue(0.01, 0.02)
        text_rep.GetPosition2Coordinate().SetValue(.3, .96)

        text_widget = vtk.vtkTextWidget()

        text_widget.SetRepresentation(text_rep)

        text_actor = text_widget.GetTextActor()
        text_actor.SetTextScaleModeToNone()
        text_actor.UseBorderAlignOn()
        text_actor.SetMaximumLineHeight(0.03)

        text_prop = text_rep.GetTextActor().GetTextProperty()
        text_prop.SetColor(0., 0, 0)
        text_prop.SetFontSize(12)
        text_prop.SetJustificationToLeft()
        text_prop.SetVerticalJustificationToTop()

        self.text_widget = text_widget
        self.text_rep = text_rep
        self.text_prop = text_prop

        self._process_kwargs(**kwargs)
コード例 #2
0
ファイル: troupe.py プロジェクト: gbaydin/autodiff
    def __init__(self, **kwargs):
        text_rep = vtk.vtkTextRepresentation();
        text_rep.GetPositionCoordinate().SetValue(0.01, 0.02)
        text_rep.GetPosition2Coordinate().SetValue(.3, .96)

        text_widget = vtk.vtkTextWidget()

        text_widget.SetRepresentation(text_rep)

        text_actor = text_widget.GetTextActor()
        text_actor.SetTextScaleModeToNone()
        text_actor.UseBorderAlignOn()
        text_actor.SetMaximumLineHeight(0.03)

        text_prop = text_rep.GetTextActor().GetTextProperty()
        text_prop.SetColor(0., 0, 0)
        text_prop.SetFontSize(12)
        text_prop.SetJustificationToLeft()
        text_prop.SetVerticalJustificationToTop()

        self.text_widget = text_widget
        self.text_rep = text_rep
        self.text_prop = text_prop

        self._process_kwargs(**kwargs)
コード例 #3
0
 def do_test(self):
     vw = vtk.vtkTextWidget()
     vr = vtk.vtkTextRepresentation()
     vw.SetRepresentation(vr)
     w = vcs.vtk_ui.widget.Widget(self.inter, vw)
     assert w.repr == vr, "Representation improperly set"
     assert w.interactor == self.inter, "Interactor improperly set"
     assert w.manager == vcs.vtk_ui.manager.get_manager(self.inter), "Manager improperly set"
     assert w in w.manager.widgets, "Widget improperly registered"
     self.passed = 0
コード例 #4
0
def main():
    colors = vtk.vtkNamedColors()

    # colors.SetColor('bkg', [0.1, 0.2, 0.4, 1.0])

    source = vtk.vtkSphereSource()

    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInputConnection(source.GetOutputPort())

    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    actor.GetProperty().SetColor(colors.GetColor3d('MistyRose'))

    renderer = vtk.vtkRenderer()
    render_window = vtk.vtkRenderWindow()
    render_window.AddRenderer(renderer)

    interactor = vtk.vtkRenderWindowInteractor()
    interactor.SetRenderWindow(render_window)

    # Create the TextActor
    text_actor = vtk.vtkTextActor()
    text_actor.SetInput('This is a test')
    text_actor.GetTextProperty().SetColor(colors.GetColor3d('Lime'))

    # Create the text representation. Used for positioning the text_actor
    text_representation = vtk.vtkTextRepresentation()
    text_representation.GetPositionCoordinate().SetValue(0.15, 0.15)
    text_representation.GetPosition2Coordinate().SetValue(0.7, 0.2)

    # Create the TextWidget
    # Note that the SelectableOff method MUST be invoked!
    # According to the documentation :
    #
    # SelectableOn/Off indicates whether the interior region of the widget can be
    # selected or not. If not, then events (such as left mouse down) allow the user
    # to 'move' the widget, and no selection is possible. Otherwise the
    # SelectRegion() method is invoked.
    text_widget = vtk.vtkTextWidget()
    text_widget.SetRepresentation(text_representation)

    text_widget.SetInteractor(interactor)
    text_widget.SetTextActor(text_actor)
    text_widget.SelectableOff()

    renderer.AddActor(actor)
    renderer.SetBackground(colors.GetColor3d('MidnightBLue'))
    render_window.SetSize(300, 300)
    render_window.SetWindowName('TextWidget')

    interactor.Initialize()
    render_window.Render()
    text_widget.On()
    interactor.Start()
コード例 #5
0
 def do_test(self):
     vw = vtk.vtkTextWidget()
     vr = vtk.vtkTextRepresentation()
     vw.SetRepresentation(vr)
     w = vcs.vtk_ui.widget.Widget(self.inter, vw)
     assert w.repr == vr, "Representation improperly set"
     assert w.interactor == self.inter, "Interactor improperly set"
     assert w.manager == vcs.vtk_ui.manager.get_manager(
         self.inter), "Manager improperly set"
     assert w in w.manager.widgets, "Widget improperly registered"
     self.passed = 0
コード例 #6
0
    def draw(self):
        self._renderWindowInteractor.Initialize()
        self._renderWindowInteractor.SetInteractorStyle(self._interactorStyle)

        axes = vtk.vtkAxesActor()
        widget = vtk.vtkOrientationMarkerWidget()
        widget.SetOutlineColor(0.9300, 0.5700, 0.1300)
        widget.SetOrientationMarker(axes)
        widget.SetInteractor(self._renderWindowInteractor)
        #widget.SetViewport(0.0, 0.0, 0.1, 0.1)
        widget.SetViewport(0.0, 0.0, 0.2, 0.4)
        widget.SetEnabled(True)
        widget.InteractiveOn()

        textWidget = vtk.vtkTextWidget()

        textRepresentation = vtk.vtkTextRepresentation()
        textRepresentation.GetPositionCoordinate().SetValue(.0, .0)
        textRepresentation.GetPosition2Coordinate().SetValue(.3, .04)
        textWidget.SetRepresentation(textRepresentation)

        textWidget.SetInteractor(self._renderWindowInteractor)
        textWidget.SetTextActor(self._textActor)
        textWidget.SelectableOff()
        textWidget.On()

        self._rendererScene.ResetCamera()
        camPos = self._rendererScene.GetActiveCamera().GetPosition()
        self._rendererScene.GetActiveCamera().SetPosition(
            (camPos[2], camPos[1], camPos[0]))
        self._rendererScene.GetActiveCamera().SetViewUp((0.0, 0.0, 1.0))
        self._rendererScene.GetActiveCamera().Zoom(1.4)

        self._renderWindowScene.Render()

        if self._addedBSpline:
            self._contextViewPlotCurv.GetRenderWindow().SetMultiSamples(0)
            self._contextViewPlotCurv.GetInteractor().Initialize()
            self._contextViewPlotCurv.GetInteractor().SetInteractorStyle(
                self._contextInteractorStyleCurv)
            #self._contextViewPlotCurv.GetInteractor().Start()

            self._contextViewPlotTors.GetRenderWindow().SetMultiSamples(0)
            self._contextViewPlotTors.GetInteractor().Initialize()
            self._contextViewPlotTors.GetInteractor().SetInteractorStyle(
                self._contextInteractorStyleTors)
            self._contextViewPlotTors.GetInteractor().Start()
        else:
            self._renderWindowInteractor.Start()
コード例 #7
0
ファイル: plotter.py プロジェクト: trianam/voropath
    def draw(self):
        self._renderWindowInteractor.Initialize()
        self._renderWindowInteractor.SetInteractorStyle(self._interactorStyle)

        axes = vtk.vtkAxesActor()
        widget = vtk.vtkOrientationMarkerWidget()
        widget.SetOutlineColor(0.9300, 0.5700, 0.1300)
        widget.SetOrientationMarker(axes)
        widget.SetInteractor(self._renderWindowInteractor)
        #widget.SetViewport(0.0, 0.0, 0.1, 0.1)
        widget.SetViewport(0.0, 0.0, 0.2, 0.4)
        widget.SetEnabled(True)
        widget.InteractiveOn()

        textWidget = vtk.vtkTextWidget()
 
        textRepresentation = vtk.vtkTextRepresentation()
        textRepresentation.GetPositionCoordinate().SetValue(.0,.0 )
        textRepresentation.GetPosition2Coordinate().SetValue(.3,.04 )
        textWidget.SetRepresentation(textRepresentation)
 
        textWidget.SetInteractor(self._renderWindowInteractor)
        textWidget.SetTextActor(self._textActor)
        textWidget.SelectableOff()
        textWidget.On()

        self._rendererScene.ResetCamera()
        camPos = self._rendererScene.GetActiveCamera().GetPosition()
        self._rendererScene.GetActiveCamera().SetPosition((camPos[2],camPos[1],camPos[0]))
        self._rendererScene.GetActiveCamera().SetViewUp((0.0,0.0,1.0))
        self._rendererScene.GetActiveCamera().Zoom(1.4)

        self._renderWindowScene.Render()

        if self._addedBSpline:
            self._contextViewPlotCurv.GetRenderWindow().SetMultiSamples(0)
            self._contextViewPlotCurv.GetInteractor().Initialize()
            self._contextViewPlotCurv.GetInteractor().SetInteractorStyle(self._contextInteractorStyleCurv)
            #self._contextViewPlotCurv.GetInteractor().Start()

            self._contextViewPlotTors.GetRenderWindow().SetMultiSamples(0)
            self._contextViewPlotTors.GetInteractor().Initialize()
            self._contextViewPlotTors.GetInteractor().SetInteractorStyle(self._contextInteractorStyleTors)
            self._contextViewPlotTors.GetInteractor().Start()
        else:
            self._renderWindowInteractor.Start()
コード例 #8
0
def points_render(points, dirpath=None, vertice_number=None):
    colors = vtk.vtkNamedColors()
    points_actor = create_points_actor(points)

    # Create a renderer, render window, and interactor
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    if dirpath is not None and vertice_number is not None:
        # Create the widget
        textActor = vtk.vtkTextActor()
        textActor.SetInput("KeyPress 'F5' to Refresh")
        textActor.GetTextProperty().SetColor(0.0, 1.0, 0.0)
        textWidget = vtk.vtkTextWidget()

        textRepresentation = vtk.vtkTextRepresentation()
        textRepresentation.GetPositionCoordinate().SetValue(.05, .05)
        textRepresentation.GetPosition2Coordinate().SetValue(.1, .1)
        textWidget.SetRepresentation(textRepresentation)
        textWidget.SetInteractor(renderWindowInteractor)
        textWidget.SetTextActor(textActor)
        textWidget.SelectableOff()
        textWidget.EnabledOn()

        # callback = UpdateObserver(points, dirpath, renderer)
        # renderWindowInteractor.AddObserver('KeyPressEvent', callback)

        style = KeyPressInteractorStyle(points, dirpath,
                                        renderWindowInteractor, vertice_number,
                                        points_actor)
        renderWindowInteractor.SetInteractorStyle(style)

    # Add the actor to the scene
    renderer.AddActor(points_actor)

    renderer.SetBackground(
        colors.GetColor3d("Green"))  # Background color green

    # Render and interact
    renderWindow.Render()
    renderWindowInteractor.Initialize()
    renderWindowInteractor.CreateRepeatingTimer(5000)
    renderWindowInteractor.Start()
コード例 #9
0
def poly_render(points, faces, fresh_time, interval):
    '''
    points:vtkPoints
    faces:array
    '''
    colors = vtk.vtkNamedColors()
    actor = create_points_actor(points)
    # Create the widget
    textActor = vtk.vtkTextActor()
    textActor.SetInput("Refresh: Once every second")
    textActor.GetTextProperty().SetColor(0.0, 1.0, 0.0)
    textWidget = vtk.vtkTextWidget()

    textRepresentation = vtk.vtkTextRepresentation()
    textRepresentation.GetPositionCoordinate().SetValue(.1, .1)
    textRepresentation.GetPosition2Coordinate().SetValue(.1, .1)
    textWidget.SetRepresentation(textRepresentation)

    # Create a renderer, render window, and interactor
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    textWidget.SetInteractor(renderWindowInteractor)
    textWidget.SetTextActor(textActor)
    textWidget.SelectableOff()
    textWidget.EnabledOn()

    style = KeyPressInteractorStyle(points, faces, renderWindowInteractor,
                                    actor, interval)
    renderWindowInteractor.SetInteractorStyle(style)

    # Add the actor to the scene
    renderer.AddActor(actor)

    renderer.SetBackground(
        colors.GetColor3d("Green"))  # Background color green

    # Render and interact
    renderWindow.Render()
    renderWindowInteractor.Initialize()
    renderWindowInteractor.CreateRepeatingTimer(fresh_time)
    renderWindowInteractor.Start()
コード例 #10
0
def points_render(points, steamfile, vertice_number):
    colors = vtk.vtkNamedColors()
    actor = create_points_actor(points)
    # Create the widget
    textActor = vtk.vtkTextActor()
    textActor.SetInput("Refresh: Once every 5 seconds")
    textActor.GetTextProperty().SetColor(0.0, 1.0, 0.0)
    textWidget = vtk.vtkTextWidget()

    textRepresentation = vtk.vtkTextRepresentation()
    textRepresentation.GetPositionCoordinate().SetValue(.05, .05)
    textRepresentation.GetPosition2Coordinate().SetValue(.1, .1)
    textWidget.SetRepresentation(textRepresentation)

    # Create a renderer, render window, and interactor
    renderer = vtk.vtkRenderer()
    renderWindow = vtk.vtkRenderWindow()
    renderWindow.AddRenderer(renderer)
    renderWindowInteractor = vtk.vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    textWidget.SetInteractor(renderWindowInteractor)
    textWidget.SetTextActor(textActor)
    textWidget.SelectableOff()
    textWidget.EnabledOn()

    style = KeyPressInteractorStyle(points, steamfile, renderWindowInteractor,
                                    vertice_number, actor)
    renderWindowInteractor.SetInteractorStyle(style)

    # Add the actor to the scene
    renderer.AddActor(actor)

    renderer.SetBackground(
        colors.GetColor3d("Green"))  # Background color green

    # Render and interact
    renderWindow.Render()
    renderWindowInteractor.Initialize()
    renderWindowInteractor.CreateRepeatingTimer(5000)
    renderWindowInteractor.Start()
コード例 #11
0
def text(iren,
         ren,
         callback,
         message="FURY",
         left_down_pos=(0.8, 0.5),
         right_top_pos=(0.9, 0.5),
         color=(1., .5, .0),
         opacity=1.,
         border=False):
    """ 2D text that can be clicked and process events

    Parameters
    ----------
    iren : vtkRenderWindowInteractor
        Used to process events and handle them to the button. Can also be given
        by the attribute ``ShowManager.iren``.
    ren :  vtkRenderer or Renderer
        Used to update the slider's position when the window changes. Can also
        be given by the ``ShowManager.ren`` attribute.
    callback : function
        Function that has at least ``obj`` and ``event`` as parameters. It will
        be called when the button is pressed.
    message : str
        Message to be shown in the text widget
    left_down_pos : tuple
        Coordinates for left down corner of text. If float are provided,
        the normalized coordinate system is used, otherwise the coordinates
        represent pixel positions. Default is (0.8, 0.5).
    right_top_pos : tuple
        Coordinates for right top corner of text. If float are provided,
        the normalized coordinate system is used, otherwise the coordinates
        represent pixel positions. Default is (0.9, 0.5).
    color : tuple
        Foreground RGB color of text. Default is (1., .5, .0).
    opacity : float
        Takes values from 0 to 1. Default is 1.
    border : bool
        Show text border. Default is False.

    Returns
    -------
    text : TextWidget
        This object inherits from ``vtkTextWidget`` has an additional method
        called ``place`` which allows to update the position of the text if
        necessary.
    """

    # Create the TextActor
    text_actor = vtk.vtkTextActor()
    text_actor.SetInput(message)
    text_actor.GetTextProperty().SetColor(color)
    text_actor.GetTextProperty().SetOpacity(opacity)

    # Create the text representation. Used for positioning the text_actor
    text_rep = vtk.vtkTextRepresentation()
    text_rep.SetTextActor(text_actor)

    if border:
        text_rep.SetShowBorderToOn()
    else:
        text_rep.SetShowBorderToOff()

    class TextWidget(vtk.vtkTextWidget):
        def place(self, renderer):
            text_rep = self.GetRepresentation()

            position = text_rep.GetPositionCoordinate()
            position2 = text_rep.GetPosition2Coordinate()

            # The dtype of `left_down_pos` determines coordinate system type.
            if np.issubdtype(np.asarray(left_down_pos).dtype, np.integer):
                position.SetCoordinateSystemToDisplay()
            else:
                position.SetCoordinateSystemToNormalizedDisplay()

            # The dtype of `right_top_pos` determines coordinate system type.
            if np.issubdtype(np.asarray(right_top_pos).dtype, np.integer):
                position2.SetCoordinateSystemToDisplay()
            else:
                position2.SetCoordinateSystemToNormalizedDisplay()

            position.SetValue(*left_down_pos)
            position2.SetValue(*right_top_pos)

    text_widget = TextWidget()
    text_widget.SetRepresentation(text_rep)
    text_widget.SetInteractor(iren)
    text_widget.SelectableOn()
    text_widget.ResizableOff()

    text_widget.AddObserver(vtk.vtkCommand.WidgetActivateEvent, callback)

    # Place widget after window resizing.
    def _place_widget(obj, event):
        text_widget.place(ren)

    iren.GetRenderWindow().AddObserver(vtk.vtkCommand.StartEvent,
                                       _place_widget)
    iren.GetRenderWindow().AddObserver(vtk.vtkCommand.ModifiedEvent,
                                       _place_widget)

    text_widget.On()

    return text_widget
コード例 #12
0
ファイル: text_widget.py プロジェクト: Nibba2018/testing-fury
renderer.SetBackground(0.1, 0.2, 0.4)

render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetSize(400, 400)

interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)

# Create the TextActor
text_actor = vtk.vtkTextActor()
text_actor.SetInput("This is a test")
text_actor.GetTextProperty().SetColor((0, 1, 1))

# Create the text representation. Used for positioning the text_actor
text_representation = vtk.vtkTextRepresentation()

text_representation.GetPositionCoordinate().SetCoordinateSystemToDisplay()
text_representation.GetPosition2Coordinate().SetCoordinateSystemToDisplay()

text_representation.GetPositionCoordinate().SetValue(200, 200)
text_representation.GetPosition2Coordinate().SetValue(200, 200)

text_representation.SetShowBorderToOn()

text_actor.GetTextProperty().SetFontSize(0)

# Create the TextWidget
# Note that the SelectableOff method MUST be invoked!
# According to the documentation :
#
コード例 #13
0
ファイル: ASDVTKGenActors.py プロジェクト: tamlovincy/UppASD
 def Add_GenActors(self,iren,renWin,method,lut,ren,window,current_Actors,flag2D):
     import vtk
     # Create the TextActor
     ASDGenActors.time_label = vtk.vtkTextActor()
     ASDGenActors.time_label.SetInput(str('{: 4.2f}'.format(0.00)+' ns'))
     ASDGenActors.time_label.GetTextProperty().SetColor((0, 0, 0))
     # Create the text representation. Used for positioning the text_actor
     ASDGenActors.time_label_rep = vtk.vtkTextRepresentation()
     ASDGenActors.time_label_rep.GetPositionCoordinate().SetValue(0.80, 0.90)
     ASDGenActors.time_label_rep.GetPosition2Coordinate().SetValue(0.10, 0.10)
     ########################################################################
     # Creating the actual widget
     ########################################################################
     ASDGenActors.time_label_widget = vtk.vtkTextWidget()
     ASDGenActors.time_label_widget.SetRepresentation(ASDGenActors.time_label_rep)
     ASDGenActors.time_label_widget.SetInteractor(iren)
     ASDGenActors.time_label_widget.SetTextActor(ASDGenActors.time_label)
     ASDGenActors.time_label_widget.SelectableOff()
     ASDGenActors.time_label_widget.Off()
     ########################################################################
     # Creation of the data structures for the data clipping
     ########################################################################
     # Right now this only can clip polydata, which is fine for 2D structures
     # however, for the 3d Delaunay tessellation, the output is an unstructured
     # grid, which means that annother type of clipper is required
     ########################################################################
     ASDGenActors.plane = vtk.vtkPlane()
     ASDGenActors.plane.SetOrigin(current_Actors.xmin, current_Actors.ymid, current_Actors.zmid)
     ASDGenActors.plane.SetNormal(1, 0, 0)
     ########################################################################
     # Check which kind of clipper must be used, as 2D and 3D data must be
     # treated differently
     ########################################################################
     if flag2D:
         ASDGenActors.clipper = vtk.vtkClipPolyData()
     else:
         ASDGenActors.clipper = vtk.vtkClipVolume()
     # Set the common variables for the clipper mapper
     ASDGenActors.clipper.SetInputConnection(method.GetOutputPort())
     ASDGenActors.clipper.SetClipFunction(ASDGenActors.plane)
     ASDGenActors.clipper.InsideOutOn()
     # Mapper of the clipper
     ASDGenActors.clipperMapper = vtk.vtkDataSetMapper()
     ASDGenActors.clipperMapper.SetScalarRange(method.GetInput().GetScalarRange())
     ASDGenActors.clipperMapper.SetInputConnection(ASDGenActors.clipper.GetOutputPort())
     ASDGenActors.clipperMapper.SetLookupTable(lut)
     # Creating the actor
     ASDGenActors.clipperActor = vtk.vtkLODActor()
     ASDGenActors.clipperActor.SetMapper(ASDGenActors.clipperMapper)
     ASDGenActors.clipperActor.VisibilityOff()
     # Adding the actor to the scene
     ren.AddActor(ASDGenActors.clipperActor)
     ########################################################################
     # Setting the information for the scalar bar widget
     ########################################################################
     # Create the scalar bar actor
     ASDGenActors.scalar_bar = vtk.vtkScalarBarActor()
     ASDGenActors.scalar_bar.SetLookupTable(lut)
     ASDGenActors.scalar_bar.GetLabelTextProperty().SetColor(0.0,0.0,0.0)
     ASDGenActors.scalar_bar.SetNumberOfLabels(5)
     ASDGenActors.scalar_bar.GetLabelTextProperty().ShadowOff()
     ASDGenActors.scalar_bar.GetLabelTextProperty().BoldOn()
     ASDGenActors.scalar_bar.GetLabelTextProperty().ItalicOff()
     ASDGenActors.scalar_bar.GetLabelTextProperty().SetFontSize(8)
     ASDGenActors.scalar_bar.SetLabelFormat("%-#6.1E")
     ASDGenActors.scalar_bar.SetBarRatio(0.5)
     ASDGenActors.scalar_bar.DrawBackgroundOn()
     ASDGenActors.scalar_bar.DrawTickLabelsOn()
     # Create the scalar bar widget
     ASDGenActors.scalar_bar_widget = vtk.vtkScalarBarWidget()
     ASDGenActors.scalar_bar_widget.SetScalarBarActor(ASDGenActors.scalar_bar)
     # Representation to actually control where the scalar bar is
     ASDGenActors.scalarBarRep = ASDGenActors.scalar_bar_widget.GetRepresentation()
     ASDGenActors.scalarBarRep.SetOrientation(0)  # 0 = Horizontal, 1 = Vertical
     ASDGenActors.scalarBarRep.GetPositionCoordinate().SetValue(0.30,0.05)
     ASDGenActors.scalarBarRep.GetPosition2Coordinate().SetValue(0.50,0.05)
     ASDGenActors.scalar_bar_widget.SetInteractor(iren)
     ASDGenActors.scalar_bar_widget.On()
     ########################################################################
     # Setting the information for the axes widget
     ########################################################################
     # Create the axes actor
     try:
         ASDGenActors.axes
     except:
         ASDGenActors.axes = vtk.vtkAxesActor()
         ASDGenActors.axes.SetShaftTypeToCylinder()
         ASDGenActors.axes.SetCylinderRadius(0.05)
         ASDGenActors.axes.SetNormalizedShaftLength(0.85,0.85,0.85)
         ASDGenActors.axes.SetNormalizedTipLength(0.40,0.40,0.40)
         ASDGenActors.axes.SetConeResolution(40)
         ASDGenActors.axes.SetCylinderResolution(40)
         # The properties of the text can be controlled independently
         ASDGenActors.axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0.0,0.0,0.0)
         ASDGenActors.axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0.0,0.0,0.0)
         ASDGenActors.axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0.0,0.0,0.0)
         ASDGenActors.axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().ShadowOff()
         ASDGenActors.axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().ShadowOff()
         ASDGenActors.axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().ShadowOff()
     else:
         pass
     ########################################################################
     # The axes actor is then used as an orientation marker widget, the advantage
     # of setting it up as a widget is that it is interactive and one can move it
     # and that it moves as the zoom changes
     # Must make sure that the widget is part of the main class so that it can
     # be actually rendered and no segfaults occur
     ########################################################################
     try:
         ASDGenActors.OrientMarker
     except:
         ASDGenActors.OrientMarker= vtk.vtkOrientationMarkerWidget()
         ASDGenActors.OrientMarker.SetOutlineColor(0.9300, 0.5700, 0.1300)
         ASDGenActors.OrientMarker.SetOrientationMarker(ASDGenActors.axes)
         ASDGenActors.OrientMarker.SetViewport(0.0, 0.0, 0.2, 0.2)
         ASDGenActors.OrientMarker.SetInteractor(iren)
         ASDGenActors.OrientMarker.EnabledOn() # <== application freeze-crash
         ASDGenActors.OrientMarker.InteractiveOn()
     else:
         pass
     iren.Start()
     renWin.Render()
     return
コード例 #14
0
ファイル: TextWidget.py プロジェクト: dlrdave/VTKWikiExamples
renderer.SetBackground(0.1, 0.2, 0.4)
 
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window.SetSize(300, 300)
 
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)
 
# Create the TextActor
text_actor = vtk.vtkTextActor()
text_actor.SetInput("This is a test")
text_actor.GetTextProperty().SetColor((0, 1, 1))
 
# Create the text representation. Used for positioning the text_actor
text_representation = vtk.vtkTextRepresentation()
text_representation.GetPositionCoordinate().SetValue(0.15, 0.15)
text_representation.GetPosition2Coordinate().SetValue(0.7, 0.2)
 
# Create the TextWidget
# Note that the SelectableOff method MUST be invoked!
# According to the documentation :
#
# SelectableOn/Off indicates whether the interior region of the widget can be
# selected or not. If not, then events (such as left mouse down) allow the user
# to "move" the widget, and no selection is possible. Otherwise the
# SelectRegion() method is invoked.
text_widget = vtk.vtkTextWidget()
text_widget.SetRepresentation(text_representation)
text_widget.SetInteractor(interactor)
text_widget.SetTextActor(text_actor)