From KitwarePublic
Jump to: navigation, search



3D widget for manipulating a spline
This 3D widget defines a spline that can be interactively placed in a scene. The spline has handles, the number of which can be changed, plus it can be picked on the spline itself to translate or rotate it in the scene. A nice feature of the object is that the vtkSplineWidget, like any 3D widget, will work with the current interactor style.
The vtkSplineWidget has several methods that can be used in conjunction with other VTK objects. The Set/GetResolution() methods control the number of subdivisions of the spline; the GetPolyData() method can be used to get the polygonal representation and can be used for things like seeding streamlines or probing other data sets. Typical usage of the widget is to make use of the StartInteractionEvent, InteractionEvent, and EndInteractionEvent events.
Some additional features of this class include the ability to control the properties of the widget. You can set the properties of the selected and unselected representations of the spline. For example, you can set the property for the handles and spline. In addition there are methods to constrain the spline so that it is aligned with a plane. Note that a simple ruler widget can be derived by setting the resolution to 1, the number of handles to 2, and calling the GetSummedLength method!

Classes Used

  • vtkSplineWidget
  • vtkSplineRepresentation
  • vtkActor
  • vtkCellPicker
  • vtkParametricFunctionSource
  • vtkParametricSpline
  • vtkPlaneSource
  • vtkProperty
  • vtkSphereSource
  • vtkTransform

Class Diagram

3DWidgets class arch spline.jpg

Using the widget (example code)

vtkSplineWidget * spllineWidget = vtkSplineWidget::New();
vtkSplineRepresentation * spllineRep = splineWidget->GetRepresentation();

Basic event handling is automatically generated so no need to set up a callback/event translator unless you need to change the way the events are handled. In such a case use GetEventTranslator() which returns a pointer to the vtkWidgetEventTranslator in use. Thereafter, you can set event handling directly to this translator.

Anything affecting the widgets representation can be accessed using the splineRep as shown above, such as PlaceWidget(double bounds[6]).

To set a representation other than the default vtkSplineRepresentation, instead of calling splineWidget->GetRepresentation(), which instantiates the default representation if none exists, use SetRepresentation(vtkSplineRepresentation *r) to pass an instance of a representation inheriting from vtkSplineRepresentation.

KWWidgets: [Welcome | Site Map]