vtkInteractor 几种模式

来源:互联网 发布:网络工程师 知乎 编辑:程序博客网 时间:2024/05/17 00:56

provide event-driven interface to the rendering window (defines trackball mode)

vtkInteractorStyle is a base class implementing the majority of motion control routines and defines an event driven interface to support vtkRenderWindowInteractor. vtkRenderWindowInteractor implements platform dependent key/mouse routing and timer control, which forwards events in a neutral form to vtkInteractorStyle.

vtkInteractorStyle implements the "joystick" style of interaction. That is, holding down the mouse keys generates a stream of events that cause continuous actions (e.g., rotate, translate, pan, zoom). (The class vtkInteractorStyleTrackballimplements a grab and move style.) The event bindings for this class include the following:

  • Keypress j / Keypress t: toggle between joystick (position sensitive) and trackball (motion sensitive) styles. In joystick style, motion occurs continuously as long as a mouse button is pressed. In trackball style, motion occurs when the mouse button is pressed and the mouse pointer moves.
  • Keypress c / Keypress a: toggle between camera and actor modes. In camera mode, mouse events affect the camera position and focal point. In actor mode, mouse events affect the actor that is under the mouse pointer.
  • Button 1: rotate the camera around its focal point (if camera mode) or rotate the actor around its origin (if actor mode). The rotation is in the direction defined from the center of the renderer's viewport towards the mouse position. In joystick mode, the magnitude of the rotation is determined by the distance the mouse is from the center of the render window.
  • Button 2: pan the camera (if camera mode) or translate the actor (if actor mode). In joystick mode, the direction of pan or translation is from the center of the viewport towards the mouse position. In trackball mode, the direction of motion is the direction the mouse moves. (Note: with 2-button mice, pan is defined as <Shift>-Button 1.)
  • Button 3: zoom the camera (if camera mode) or scale the actor (if actor mode). Zoom in/increase scale if the mouse position is in the top half of the viewport; zoom out/decrease scale if the mouse position is in the bottom half. In joystick mode, the amount of zoom is controlled by the distance of the mouse pointer from the horizontal centerline of the window.
  • Keypress 3: toggle the render window into and out of stereo mode. By default, red-blue stereo pairs are created. Some systems support Crystal Eyes LCD stereo glasses; you have to invoke SetStereoTypeToCrystalEyes() on the rendering window.
  • Keypress e: exit the application.
  • Keypress f: fly to the picked point
  • Keypress p: perform a pick operation. The render window interactor has an internal instance of vtkCellPicker that it uses to pick.
  • Keypress r: reset the camera view along the current view direction. Centers the actors and moves the camera so that all actors are visible.
  • Keypress s: modify the representation of all actors so that they are surfaces.
  • Keypress u: invoke the user-defined function. Typically, this keypress will bring up an interactor that you can type commands in. Typing u calls UserCallBack() on the vtkRenderWindowInteractor, which invokes a vtkCommand::UserEvent. In other words, to define a user-defined callback, just add an observer to the vtkCommand::UserEvent on the vtkRenderWindowInteractor object.
  • Keypress w: modify the representation of all actors so that they are wireframe.


vtkInteractorStyleSwitch Class

class to swap between interactory styles

The class vtkInteractorStyleSwitch allows handles interactively switching between four interactor styles – joystick actor, joystick camera, trackball actor, and trackball camera. Type 'j' or 't' to select joystick or trackball, and type 'c' or 'a' to select camera or actor. The default interactor style is joystick camera.


vtkInteractorStyleTrackballCamera Class

interactive manipulation of the camera

vtkInteractorStyleTrackballCamera allows the user to interactively manipulate (rotate, pan, etc.) the camera, the viewpoint of the scene. In trackball interaction, the magnitude of the mouse motion is proportional to the camera motion associated with a particular mouse binding. For example, small left-button motions cause small changes in the rotation of the camera around its focal point. For a 3-button mouse, the left button is for rotation, the right button for zooming, the middle button for panning, and ctrl + left button for spinning. (With fewer mouse buttons, ctrl + shift + left button is for zooming, and shift + left button is for panning.)


vtkInteractorStyleTrackballActor Class 

manipulate objects in the scene independent of each other

vtkInteractorStyleTrackballActor allows the user to interact with (rotate, pan, etc.) objects in the scene indendent of each other. In trackball interaction, the magnitude of the mouse motion is proportional to the actor motion associated with a particular mouse binding. For example, small left-button motions cause small changes in the rotation of the actor around its center point.

The mouse bindings are as follows. For a 3-button mouse, the left button is for rotation, the right button for zooming, the middle button for panning, and ctrl + left button for spinning. (With fewer mouse buttons, ctrl + shift + left button is for zooming, and shift + left button is for panning.)




vtkInteractorStyleImage Class

interactive manipulation of the camera specialized for images

vtkInteractorStyleImage allows the user to interactively manipulate (rotate, pan, zoom etc.) the camera. vtkInteractorStyleImage is specially designed to work with images that are being rendered with vtkImageActor. Several events are overloaded from its superclass vtkInteractorStyle, hence the mouse bindings are different. (The bindings keep the camera's view plane normal perpendicular to the x-y plane.) In summary the mouse events for 2D image interaction are as follows:

  • Left Mouse button triggers window level events
  • CTRL Left Mouse spins the camera around its view plane normal
  • SHIFT Left Mouse pans the camera
  • CTRL SHIFT Left Mouse dollys (a positional zoom) the camera
  • Middle mouse button pans the camera
  • Right mouse button dollys the camera.
  • SHIFT Right Mouse triggers pick events

If SetInteractionModeToImageSlicing() is called, then some of the mouse events are changed as follows:

  • CTRL Left Mouse slices through the image
  • SHIFT Middle Mouse slices through the image
  • CTRL Right Mouse spins the camera

If SetInteractionModeToImage3D() is called, then some of the mouse events are changed as follows:

  • SHIFT Left Mouse rotates the camera for oblique slicing
  • SHIFT Middle Mouse slices through the image
  • CTRL Right Mouse also slices through the image

In all modes, the following key bindings are in effect:

  • R Reset the Window/Level
  • X Reset to a sagittal view
  • Y Reset to a coronal view
  • Z Reset to an axial view

Note that the renderer's actors are not moved; instead the camera is moved.