Title: VTK 3D Widgets
1VTK 3D Widgets
Karthik Krishnan Will Schroeder Kitware, Inc.
2Thanks
- 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
3Goals
- Directly interact with data
- Provide complex, potentially 3D interaction
techniques - Probing
- Annotation
- Measurements
4Interactor styles
- Everybody has their favorite way of interacting
with Data.
User Events
RenderWindow
Interactor
Interactor Style
Events
Actions
vtkCamera
Render()
5Object Relationships
vtkRenderWindowInteractor
vtkInteractorObserver
vtkInteractorStyle
vtkAbstractWidget
6Interactor Styles (contd..)
7Interactor styles (usage)
- Set the interactor style on the Render Window
Interactor - vtkInteractorStyleTrackballCamera style
- vtkInteractorStyleTrackballCameraNew()
- renderWindowInteractor -gt SetInteractorStyle(
style )
8 9VTK - 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
10Visualization pipeline
11Widgets are interactive props
vtkRenderWindow
vtkRenderWindowInteractor
User Interaction Events
Widget
Manipulate one or more props
vtkRenderer
Render()
Widget Representation
12Widgets Design goals
- Separate representation from event processing
- Support distributed processing (client-server)
- Reconfigurable bindings
- Support hierarchical use of widgets
- Grouping widgets
- Timer, Hover support
13Widgets Architecture
Behavior
Geometry
RenderWindow
Renderer
Events
Render()
vtkAbstractWidget
vtkWidgetRepresentation(type of vtkProp)
14One widget, multiple geometries
Behavior
Geometry
vtkPointHandleRepresentation2D
vtkHandleWidget
vtkPointHandleRepresentation3D
vtkSphereHandleRepresentation
vtkPolygonalHandleRepresentation
15Configurable bindings Event Translation
16Event Translation
- Re-configurable keyboard/mouse bindings
- Example
- vtkWidgetEventTranslator eventTranslator
widget-gtGetEventTranslator() - eventTranslator-gtSetTranslation(
- vtkCommandMiddleButtonPressEvent,
- vtkWidgetEventSelect )
- eventTranslator-gtSetTranslation(
- vtkCommandMiddleButtonReleaseEvent,
- vtkWidgetEventEndSelect )
17Widget Assemblies
- Create composite widgets from several individual
widgets - Children listen to events from Parent. Hence
parent can alter behavior of child
RenderWindow
Events
Parent
Events
Events
Child
Child
18Widget Assemblies
- Code reuse
- Component framework
- Change behaviour / geometry of Line widget by
changing the handle widgets.
Line Widget
HandleWidget
HandleWidget
19Timer support
- Widgets may respond to timers
- Hover widget
- Balloon widget
- Timer based hover annotations, Popups (text,
thumbnails etc).
20Handle 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.
21Various handle representations (geometries)
vtkPointHandleRepresentation2D
vtkHandleWidget
vtkPointHandleRepresentation3D
vtkSphereHandleRepresentation
vtkPolygonalHandleRepresentation
22Constraints 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.
23Widgets
24Widgets (cont.)
- vtkSliderWidget
- 2D
- 3D
- vtkBorderWidget
- Widgets with rectangular borders
- vtkTextWidget
- Position size text
25Widgets (cont.)
- BalloonWidget
- Text and/or image in rectangular popup
26Widgets (cont.)
- vtkCameraWidget
- Keyframe playback camera
- vtkCaptionWidget
- Text with leader
27Widgets (cont.)
- vtkCheckerboardWidget
- Interleave two images
- vtkRectilinearWipeWidget
- Window pane(2x2 checkerboard)with movable focus
28Widgets (cont.)
- vtkContourWidget
- 2D (on plane)
- 3D (move contours through slices in a volume)
29Widgets (cont.)
- vtkDistanceWidget
- Measure distance between points
- vtkAngleWidget
- Measure angles
30Widgets (cont.)
- vtkSeedWidget
- Add one or more seeds / markers
- vtkAffineWidget
- Translate
- Scale
- Rotate
- Shear images
31Widgets (cont.)
- vtkBiDimensionalWidget
- Tumor response (RECIST vs WHO)
32Widgets (cont.)
33Widgets (cont.)
34Widgets (cont.)
35Slider Widget Example
- vtkSliderRepresentation2D sliderRep
vtkSliderRepresentation2DNew() - sliderRep-gtSetValue(0.25)
- sliderRep-gtSetTitleText("Spike Size")
- sliderRep-gtGetPoint1Coordinate()-gtSetCoordinateS
ystemToNormalizedDisplay() - sliderRep-gtGetPoint1Coordinate()-gtSetValue(0.2,0
.15) - sliderRep-gtGetPoint2Coordinate()-gtSetCoordinateS
ystemToNormalizedDisplay() - sliderRep-gtGetPoint2Coordinate()-gtSetValue(0.8,0
.15) - sliderRep-gtSetSliderLength(0.02)
- sliderRep-gtSetSliderWidth(0.03)
- sliderRep-gtSetEndCapLength(0.01)
- sliderRep-gtSetEndCapWidth(0.03)
- sliderRep-gtSetTubeWidth(0.005)
- vtkSliderWidget sliderWidget
vtkSliderWidgetNew() - sliderWidget-gtSetInteractor(iren)
- sliderWidget-gtSetRepresentation(sliderRep)
- sliderWidget-gtSetAnimationModeToAnimate()
- vtkSlider2DCallback callback
vtkSlider2DCallbackNew()
36Slider 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_castltvtkSliderWidgetgt(caller)
- this-gtGlyph-gtSetScaleFactor(static_castltvtkS
liderRepresentation gt(sliderWidget-gtGetRepresenta
tion())-gtGetValue()) -
- vtkSlider2DCallback()Glyph(0)
- vtkGlyph3D Glyph
-
37vtkPointPlacer
38Widget Sets
- Grouping widgets on multiple render windows,
relieving the application of the responsibility
of doing so.
Event
RenderWindow
Widget
Event
Event
Event
RenderWindow
WidgetSet
Widget
Event
RenderWindow
Event
Widget