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

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

Dec 14, 2015

Download

Documents

Kaleb Prewett
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

VTK 3D Widgets

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

Page 2: VTK 3D Widgets Karthik Krishnan Will Schroeder 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

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

3

GoalsGoals

• Directly interact with data

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

Page 4: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

4

Interactor stylesInteractor styles

• Everybody has their favorite way of interacting with Data.

RenderWindow

User Events

Interactor Interactor StyleEvents

vtkCamera

Actions

Render()

Page 5: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Object RelationshipsObject Relationships

vtkInteractorObserver

vtkInteractorStyle vtkAbstractWidget

vtkRenderWindowInteractor

Page 6: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

6

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

Page 7: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

7

Interactor styles (usage)Interactor styles (usage)

• Set the interactor style on the Render Window Interactor

vtkInteractorStyleTrackballCamera *style =

vtkInteractorStyleTrackballCamera::New();

renderWindowInteractor -> SetInteractorStyle( style );

Page 8: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

8

VTK Widgets

Page 9: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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

Page 10: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

10

Visualization pipelineVisualization pipeline

Page 11: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

11

vtkRenderWindow

Widget

User Interaction Events

vtkRenderWindowInteractor

Widgets are interactive propsWidgets are interactive props

vtkRendererRender()

Manipulate oneor more props

Widget Representation

Page 12: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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

Page 13: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

13

RenderWindow

vtkAbstractWidget vtkWidgetRepresentation(type of vtkProp)

Events

Renderer

Render()

Widgets ArchitectureWidgets Architecture

Behavior Geometry

Page 14: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

14

One widget, multiple geometriesOne widget, multiple geometries

vtkHandleWidget vtkPointHandleRepresentation2D

vtkPointHandleRepresentation3D

vtkSphereHandleRepresentation

vtkPolygonalHandleRepresentation

Behavior Geometry

Page 15: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

15

Configurable bindings: Event TranslationConfigurable bindings: Event Translation

Page 16: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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 );

Page 17: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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

Page 18: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

18

Widget AssembliesWidget Assemblies

• Code reuse

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

handle widgets.

HandleWidgetHandleWidget

Line Widget

Page 19: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

19

Timer supportTimer support

• Widgets may respond to timers

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

Page 20: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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.

Page 21: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

21

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

vtkHandleWidget vtkPointHandleRepresentation2D

vtkPointHandleRepresentation3D

vtkSphereHandleRepresentation

vtkPolygonalHandleRepresentation

Page 22: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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.

Page 23: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

WidgetsWidgets

• Handles

Page 24: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkSliderWidget• 2D• 3D

• vtkBorderWidget• Widgets with

rectangular borders

• vtkTextWidget• Position & size text

Page 25: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• BalloonWidget• Text and/or image in rectangular popup

Page 26: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkCameraWidget• Keyframe &

playback camera

• vtkCaptionWidget• Text with leader

Page 27: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkCheckerboardWidget• Interleave two images

• vtkRectilinearWipeWidget• Window pane

(2x2 checkerboard)with movable focus

Page 28: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

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

Page 29: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkDistanceWidget• Measure distance

between points

• vtkAngleWidget• Measure angles

Page 30: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkSeedWidget• Add one or more

seeds / markers

• vtkAffineWidget• Translate• Scale• Rotate• Shear images

Page 31: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkBiDimensionalWidget• Tumor response (RECIST vs WHO)

Page 32: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• Box • Implicit Plane

Page 33: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• Finite Plane • Line

Page 34: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

Widgets (cont.)Widgets (cont.)

• vtkScalarBarWidget• vtkSphereWidget

Page 35: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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);

Page 36: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

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;

};

Page 37: VTK 3D Widgets Karthik Krishnan Will Schroeder Kitware, Inc.

37

vtkPointPlacervtkPointPlacer

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

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