38
VTK 3D Widgets Karthik Krishnan Karthik Krishnan Will Schroeder Will Schroeder Kitware, Inc. Kitware, Inc.

VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc

Embed Size (px)

Citation preview

VTK 3D Widgets

Karthik KrishnanKarthik KrishnanWill SchroederWill SchroederKitware, Inc.Kitware, Inc.

ThanksThanks

• National Library of Medicine / NIH• Dr. Terry Yoo: A2D2 awards (Algorithms, Adaptors, and Data

Distribution)• National Science Foundation

• Visual Journal project• NIH National Center for Biomedical Computing

• NAMIC • DOE National Labs

• Sandia• Livermore

• Contributors• Will Schroeder• Karthik Krishnan• Lisa Avila• Brad King• Sebastien Barre• Dave Cole

3

GoalsGoals

• Directly interact with data

• Provide complex, potentially 3D interaction techniques• Probing• Annotation• Measurements

4

Interactor stylesInteractor styles

• Everybody has their favorite way of interacting with Data.

RenderWindow

User Events

Interactor Interactor StyleEvents

vtkCamera

Actions

Render()

Object RelationshipsObject Relationships

vtkInteractorObserver

vtkInteractorStyle vtkAbstractWidget

vtkRenderWindowInteractor

6

Interactor Styles (contd..)Interactor Styles (contd..)

7

Interactor styles (usage)Interactor styles (usage)

• Set the interactor style on the Render Window Interactor

vtkInteractorStyleTrackballCamera *style =

vtkInteractorStyleTrackballCamera::New();

renderWindowInteractor -> SetInteractorStyle( style );

8

VTK Widgets

9

VTK - WidgetsVTK - Widgets

• Widgets are simply Interactive Props

• VTK currently has widgets to perform• Measurements• Annotation and Labeling• Segmentation• Registration• Data interaction• Scene parameter manipulation: Light, camera, etc.• Probing underlying data

• Timer support• Multiple geometrical representations for the same widget• Reconfigurable key/mouse bindings• Grouping widgets

10

Visualization pipelineVisualization pipeline

11

vtkRenderWindow

Widget

User Interaction Events

vtkRenderWindowInteractor

Widgets are interactive propsWidgets are interactive props

vtkRendererRender()

Manipulate oneor more props

Widget Representation

12

Widgets – Design goalsWidgets – Design goals

• Separate representation from event processing• Support distributed processing (client-server)

• Reconfigurable bindings

• Support hierarchical use of widgets

• Grouping widgets

• Timer, Hover support

13

RenderWindow

vtkAbstractWidget vtkWidgetRepresentation(type of vtkProp)

Events

Renderer

Render()

Widgets ArchitectureWidgets Architecture

Behavior Geometry

14

One widget, multiple geometriesOne widget, multiple geometries

vtkHandleWidget vtkPointHandleRepresentation2D

vtkPointHandleRepresentation3D

vtkSphereHandleRepresentation

vtkPolygonalHandleRepresentation

Behavior Geometry

15

Configurable bindings: Event TranslationConfigurable bindings: Event Translation

16

Event TranslationEvent Translation

• Re-configurable keyboard/mouse bindings

• Example:

vtkWidgetEventTranslator *eventTranslator = widget->GetEventTranslator();

eventTranslator->SetTranslation( vtkCommand::MiddleButtonPressEvent,

vtkWidgetEvent::Select );

eventTranslator->SetTranslation( vtkCommand::MiddleButtonReleaseEvent,

vtkWidgetEvent::EndSelect );

17

Widget AssembliesWidget Assemblies

• Create composite widgets from several individual widgets

• Children listen to events from Parent. Hence parent can alter behavior of child

Parent

Child Child

RenderWindowEvents

EventsEvents

18

Widget AssembliesWidget Assemblies

• Code reuse

• Component framework: • Change behaviour / geometry of Line widget by changing the

handle widgets.

HandleWidgetHandleWidget

Line Widget

19

Timer supportTimer support

• Widgets may respond to timers

• Hover widget• Balloon widget• Timer based hover annotations, Popups (text, thumbnails etc).

20

Handle FrameworkHandle Framework

• Handles are often fundamental building blocks of other widgets• vtkLineWidget2• vtkDistanceWidget• vtkAngleWidget• vtkBiDimensionalWidget• vtkSeedWidget• vtkParallelopipedWidget

• Need multiple representations for handles

• Need a framework for constraints on handles • To plane• To surface• To a terrain• To a region.

21

Various handle representations (geometries)Various handle representations (geometries)

vtkHandleWidget vtkPointHandleRepresentation2D

vtkPointHandleRepresentation3D

vtkSphereHandleRepresentation

vtkPolygonalHandleRepresentation

22

Constraints – Point PlacersConstraints – Point Placers

• To map 2D display positions to 3D world coordinates. Does a 2D display position map to:

• Focal Plane ?• Point on a surface ?• Point on a plane / image ?• Out of bounds ?

• Allows a variety of constraints to be placed the placement of widgets.

WidgetsWidgets

• Handles

Widgets (cont.)Widgets (cont.)

• vtkSliderWidget• 2D• 3D

• vtkBorderWidget• Widgets with

rectangular borders

• vtkTextWidget• Position & size text

Widgets (cont.)Widgets (cont.)

• BalloonWidget• Text and/or image in rectangular popup

Widgets (cont.)Widgets (cont.)

• vtkCameraWidget• Keyframe &

playback camera

• vtkCaptionWidget• Text with leader

Widgets (cont.)Widgets (cont.)

• vtkCheckerboardWidget• Interleave two images

• vtkRectilinearWipeWidget• Window pane

(2x2 checkerboard)with movable focus

Widgets (cont.)Widgets (cont.)

• vtkContourWidget• 2D (on plane)• 3D (move contours through slices in a volume)

Widgets (cont.)Widgets (cont.)

• vtkDistanceWidget• Measure distance

between points

• vtkAngleWidget• Measure angles

Widgets (cont.)Widgets (cont.)

• vtkSeedWidget• Add one or more

seeds / markers

• vtkAffineWidget• Translate• Scale• Rotate• Shear images

Widgets (cont.)Widgets (cont.)

• vtkBiDimensionalWidget• Tumor response (RECIST vs WHO)

Widgets (cont.)Widgets (cont.)

• Box • Implicit Plane

Widgets (cont.)Widgets (cont.)

• Finite Plane • Line

Widgets (cont.)Widgets (cont.)

• vtkScalarBarWidget• vtkSphereWidget

Slider Widget ExampleSlider Widget Example

vtkSliderRepresentation2D *sliderRep = vtkSliderRepresentation2D::New(); sliderRep->SetValue(0.25); sliderRep->SetTitleText("Spike Size"); sliderRep->GetPoint1Coordinate()->SetCoordinateSystemToNormalizedDisplay(); sliderRep->GetPoint1Coordinate()->SetValue(0.2,0.15); sliderRep->GetPoint2Coordinate()->SetCoordinateSystemToNormalizedDisplay(); sliderRep->GetPoint2Coordinate()->SetValue(0.8,0.15); sliderRep->SetSliderLength(0.02); sliderRep->SetSliderWidth(0.03); sliderRep->SetEndCapLength(0.01); sliderRep->SetEndCapWidth(0.03); sliderRep->SetTubeWidth(0.005);

vtkSliderWidget *sliderWidget = vtkSliderWidget::New(); sliderWidget->SetInteractor(iren); sliderWidget->SetRepresentation(sliderRep); sliderWidget->SetAnimationModeToAnimate();

vtkSlider2DCallback *callback = vtkSlider2DCallback::New(); callback->Glyph = glyph; sliderWidget->AddObserver(vtkCommand::InteractionEvent,callback);

Slider Widget Example (Cont.)Slider Widget Example (Cont.)

class vtkSlider2DCallback : public vtkCommand

{

public:

static vtkSlider2DCallback *New()

{ return new vtkSlider2DCallback; }

virtual void Execute(vtkObject *caller, unsigned long, void*)

{

vtkSliderWidget *sliderWidget =

reinterpret_cast<vtkSliderWidget*>(caller);

this->Glyph->SetScaleFactor(static_cast<vtkSliderRepresentation *>(sliderWidget->GetRepresentation())->GetValue());

}

vtkSlider2DCallback():Glyph(0) {}

vtkGlyph3D *Glyph;

};

37

vtkPointPlacervtkPointPlacer

38

Widget SetsWidget Sets

• Grouping widgets on multiple render windows, relieving the application of the responsibility of doing so.

RenderWindowEvent

Widget

RenderWindowEvent

Widget

RenderWindowEvent

Widget

WidgetSetEvent

Event

Event