KWWidgets/Projects/3DWidgets/HowTo/UseWidgets

From KitwarePublic

Jump to: navigation, search

Using the Widgets

This example uses vtkBoxWidget (new) to show the basic of using a widget.

vtkBoxWidget * boxWidget = vtkBoxWidget::New();
vtkBoxRepresentation * boxRep = boxWidget->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 boxRep as shown above, such as PlaceWidget(double bounds[6]).

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



KWWidgets: [Welcome | Site Map]
Personal tools