KWWidgets/Projects/3DWidgets/Widgets/TheWidgets/LineWidget

From KitwarePublic
Jump to: navigation, search

vtkLineWidget

Description

3D widget for manipulating a line
This 3D widget defines a line that can be interactively placed in a scene. The line has two handles (at its endpoints), plus the line can be picked to translate it in the scene. A nice feature of the object is that the vtkLineWidget, like any 3D widget, will work with the current interactor style and any other widgets present in the scene.
The vtkLineWidget has several methods that can be used in conjunction with other VTK objects. The Set/GetResolution() methods control the number of subdivisions of the line; the GetPolyData() method can be used to get the polygonal representation and can be used for things like seeding streamlines. 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 line. For example, you can set the property for the handles and line. In addition there are methods to constrain the line so that it is aligned along the x-y-z axes.

Classes Used

  • vtkLineWidget
  • vtkLineRepresentation
  • vtkActor
  • vtkCellPicker
  • vtkLineSource
  • vtkPointRepresentation
  • vtkPolyDataMapper
  • vtkProperty
  • vtkSphereSource

Class Diagram

3DWidgets class arch line.jpg

Using the widget (example code)

vtkLineWidget * lineWidget = vtkLineWidget::New();
vtkLineRepresentation * lineRep = lineWidget->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 lineRep as shown above, such as PlaceWidget(double bounds[6]).

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



KWWidgets: [Welcome | Site Map]