FreeMat: vtkBoxWidget2

FreeMat

- Main Page
- Related Pages

vtkBoxWidget2

Section: Visualization Toolkit Widget Classes

# Usage

This 3D widget interacts with a vtkBoxRepresentation class (i.e., it handles the events that drive its corresponding representation). The representation is assumed to represent a region of interest that is represented by an arbitrarily oriented hexahedron (or box) with interior face angles of 90 degrees (i.e., orthogonal faces). The representation manifests seven handles that can be moused on and manipulated, plus the six faces can also be interacted with. The first six handles are placed on the six faces, the seventh is in the center of the box. In addition, a bounding box outline is shown, the "faces" of which can be selected for object rotation or scaling. A nice feature of vtkBoxWidget2, like any 3D widget, will work with the current interactor style. That is, if vtkBoxWidget2 does not handle an event, then all other registered observers (including the interactor style) have an opportunity to process the event. Otherwise, the vtkBoxWidget will terminate the processing of the event that it handles.

To use this widget, you generally pair it with a vtkBoxRepresentation (or a subclass). Variuos options are available in the representation for controlling how the widget appears, and how the widget functions.

.SECTION Event Bindings By default, the widget responds to the following VTK events (i.e., it watches the vtkRenderWindowInteractor for these events):

     If one of the seven handles are selected:
       LeftButtonPressEvent - select the appropriate handle
       LeftButtonReleaseEvent - release the currently selected handle
       MouseMoveEvent - move the handle
     If one of the faces is selected:
       LeftButtonPressEvent - select a box face
       LeftButtonReleaseEvent - release the box face
       MouseMoveEvent - rotate the box
     In all the cases, independent of what is picked, the widget responds to the
     following VTK events:
       MiddleButtonPressEvent - translate the widget
       MiddleButtonReleaseEvent - release the widget
       RightButtonPressEvent - scale the widget's representation
       RightButtonReleaseEvent - stop scaling the widget
       MouseMoveEvent - scale (if right button) or move (if middle button) the widget

Note that the event bindings described above can be changed using this class's vtkWidgetEventTranslator. This class translates VTK events into the vtkBoxWidget2's widget events:

       vtkWidgetEvent::Select – some part of the widget has been selected
       vtkWidgetEvent::EndSelect – the selection process has completed
       vtkWidgetEvent::Scale – some part of the widget has been selected
       vtkWidgetEvent::EndScale – the selection process has completed
       vtkWidgetEvent::Translate – some part of the widget has been selected
       vtkWidgetEvent::EndTranslate – the selection process has completed
       vtkWidgetEvent::Move – a request for motion has been invoked

In turn, when these widget events are processed, the vtkBoxWidget2 invokes the following VTK events on itself (which observers can listen for):

       vtkCommand::StartInteractionEvent (on vtkWidgetEvent::Select)
       vtkCommand::EndInteractionEvent (on vtkWidgetEvent::EndSelect)
       vtkCommand::InteractionEvent (on vtkWidgetEvent::Move)

To create an instance of class vtkBoxWidget2, simply invoke its constructor as follows

      obj = vtkBoxWidget2

# Methods

The class vtkBoxWidget2 has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkBoxWidget2 class.

- `string = obj.GetClassName ()` - Standard class methods for type information and printing.
- `int = obj.IsA (string name)` - Standard class methods for type information and printing.
- `vtkBoxWidget2 = obj.NewInstance ()` - Standard class methods for type information and printing.
- `vtkBoxWidget2 = obj.SafeDownCast (vtkObject o)` - Standard class methods for type information and printing.
- `obj.SetRepresentation (vtkBoxRepresentation r)` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.SetTranslationEnabled (int )` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `int = obj.GetTranslationEnabled ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.TranslationEnabledOn ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.TranslationEnabledOff ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.SetScalingEnabled (int )` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `int = obj.GetScalingEnabled ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.ScalingEnabledOn ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.ScalingEnabledOff ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.SetRotationEnabled (int )` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `int = obj.GetRotationEnabled ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.RotationEnabledOn ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.RotationEnabledOff ()` - Control the behavior of the widget (i.e., how it processes events). Translation, rotation, and scaling can all be enabled and disabled.
- `obj.CreateDefaultRepresentation ()` - Create the default widget representation if one is not set. By default, this is an instance of the vtkBoxRepresentation class.