specialized widgets for vtk - wright state...
TRANSCRIPT
3-1 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Specialized Widgets for VTK
3-2 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Thanks • 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-3 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Goals
• Directly interact with data
• Provide complex, potentially 3D interaction techniques
– Probing
– Annotation
– Measurements
3-4 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
4
Interactor styles • Everybody has their favorite way of interacting with
Data.
RenderWindow
User Events
Interactor Interactor Style
Events
vtkCamera
Actions
Render()
3-5 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Object Relationships
vtkInteractorObserver
vtkInteractorStyle vtkAbstractWidget
vtkRenderWindowInteractor
3-6 Department of Computer Science and Engineering
3 Specialized Widgets for VTK Interactor Styles (contd..)
3-7 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Interactor styles (usage)
• Set the interactor style on the Render Window Interactor
vtkInteractorStyleTrackballCamera *style =
vtkInteractorStyleTrackballCamera::New();
renderWindowInteractor -> SetInteractorStyle( style );
3-8 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
VTK Widgets
3-9 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
VTK - 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
3-10 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Visualization pipeline
3-11 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
vtkRenderWindow
Widget
User Interaction
Events
vtkRenderWindowInteractor
Widgets are interactive props
vtkRenderer Render()
Manipulate one
or more props
Widget Representation
3-12 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets – Design goals
• Separate representation from event processing
– Support distributed processing (client-server)
• Reconfigurable bindings
• Support hierarchical use of widgets
• Grouping widgets
• Timer, Hover support
3-13 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
RenderWindow
vtkAbstractWidget
vtkWidgetRepresentation
(type of vtkProp)
Events
Renderer
Render()
Widgets Architecture
Behavior Geometry
3-14 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
One widget, multiple geometries
vtkHandleWidget vtkPointHandleRepresentation2D
vtkPointHandleRepresentation3D
vtkSphereHandleRepresentation
vtkPolygonalHandleRepresentation
Behavior Geometry
3-15 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
15
Configurable bindings: Event Translation
3-16 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Event Translation
• Re-configurable keyboard/mouse bindings
• Example:
vtkWidgetEventTranslator *eventTranslator = widget->GetEventTranslator();
eventTranslator->SetTranslation( vtkCommand::MiddleButtonPressEvent, vtkWidgetEvent::Select ); eventTranslator->SetTranslation( vtkCommand::MiddleButtonReleaseEvent, vtkWidgetEvent::EndSelect );
3-17 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widget Assemblies • Create composite widgets from several individual widgets
• Children listen to events from Parent. Hence parent can alter
behavior of child
Parent
Child Child
RenderWindow Events
Events Events
3-18 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widget Assemblies
• Code reuse
• Component framework:
– Change behaviour / geometry of Line widget by changing the
handle widgets.
HandleWidget HandleWidget
Line Widget
3-19 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Timer support
• Widgets may respond to timers
– Hover widget
– Balloon widget
– Timer based hover annotations, Popups (text, thumbnails etc).
3-20 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Handle 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.
3-21 Department of Computer Science and Engineering
3 Specialized Widgets for VTK Various handle representations
(geometries)
vtkHandleWidget vtkPointHandleRepresentation2D
vtkPointHandleRepresentation3D
vtkSphereHandleRepresentation
vtkPolygonalHandleRepresentation
3-22 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Constraints – 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.
3-23 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets
• Handles
3-24 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.) • vtkSliderWidget
– 2D
– 3D
• vtkBorderWidget
– Widgets with rectangular borders
• vtkTextWidget
– Position & size text
3-25 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• BalloonWidget
– Text and/or image in rectangular popup
3-26 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkCameraWidget
– Keyframe &
playback camera
• vtkCaptionWidget
– Text with leader
3-27 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkCheckerboardWidget
– Interleave two images
• vtkRectilinearWipeWidget
– Window pane
(2x2 checkerboard)
with movable focus
3-28 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkContourWidget
– 2D (on plane)
– 3D (move contours through slices in a volume)
3-29 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.) • vtkDistanceWidget
– Measure distance
between points
• vtkAngleWidget
– Measure angles
3-30 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkSeedWidget
– Add one or more seeds / markers
• vtkAffineWidget
– Translate
– Scale
– Rotate
– Shear images
3-31 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkBiDimensionalWidget
– Tumor response (RECIST vs WHO)
3-32 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.) • Box
• Implicit Plane
3-33 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.) • Finite Plane • Line
3-34 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widgets (cont.)
• vtkScalarBarWidget
• vtkSphereWidget
3-35 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Slider 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);
3-36 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
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;
};
3-37 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
vtkPointPlacer
3-38 Department of Computer Science and Engineering
3 Specialized Widgets for VTK
Widget Sets
• Grouping widgets on multiple render windows, relieving the
application of the responsibility of doing so.
RenderWindow
Event Widget
RenderWindow Event
Widget
RenderWindow Event
Widget
WidgetSet Event
Event
Event