NA-MIC, 2008 June Workshop, IHK Akademie Westerham KWWidgets
-
Upload
chelsea-mayer -
Category
Documents
-
view
24 -
download
0
description
Transcript of NA-MIC, 2008 June Workshop, IHK Akademie Westerham KWWidgets
NA-MIC, 2008 June Workshop, IHK Akademie Westerham
KWWidgets
Sebastien BARRE, Ph.D. - Kitware, Inc.
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 22
What is KWWidgets?
• A GUI toolkit• Cross-platform• Open-license• Free
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 3
What is KWWidgets? (cont.)
• A GUI toolkit that provides low-level and high-level visualization-oriented widgets compatible with the VTK framework.
vs.
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 4
What is KWWidgets? (cont.)
• Over 150 C++ classes,• Around 190,000 lines of code, 49 person years, roughly
$5M at 100k per person (source: ohloh.org)• Used extensively by Kitware to develop open-source and
commercial end-user applications for more than 9 years• Used extensively in Slicer3
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 5
What is KWWidgets? (cont.)
Cardiac segmentation and CT Volume Rendering in Slicer3, using data and segmentations from the collaboration with Boston Children's Hospital Pediatric Cardiology.
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 6
What is KWWidgets? (cont.)
VolView 3.0 (Work in Progress)
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 7
Features
• Object-oriented C++ layer on top of Tcl/Tk• Inherit from the VTK coding framework
checkbutton .cb1
.cb1 config -text "A checkbutton"
.cb1 deselect
pack .cb1
vtkKWCheckButton *cb1 = vtkKWCheckButton::New();cb1->SetParent(parent);cb1->Create();
cb1->SetText("A checkbutton");
cb1->DeSelect();
app->Script("pack %s", cb1->GetWidgetName());
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 8
Features (cont.)
• Can interact and co-exist with Tcl/Tk directly from Tcl/Tk or Slicer3
• Wrapped into a Tcl package just like VTK• Fast-prototyping
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 9
Features (cont.)
vtkKWCheckButton *cb1 = vtkKWCheckButton::New();cb1->SetParent(parent);cb1->Create();
cb1->SetText("A checkbutton");
cb1->DeSelect();
app->Script("pack %s", cb1->GetWidgetName());
package require kwwidgets
vtkKWCheckButton cb1cb1 SetParent $parentcb1 Create
cb1 SetText "A checkbutton"
cb1 DeSelect
pack [cb1 GetWidgetName]
…
button .b -text "My Button"pack .b
• C++ vs. Tcl
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 10
Widgets overview
• Core widgets• Composite widgets• VTK widgets• Helper classes
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 11
Widgets overview (cont.)
• Core widgets
vtkKWCanvas vtkKWCheckButton vtkKWEntry vtkKWFrame vtkKWLabel vtkKWListBox vtkKWMenu vtkKWOptionMenu vtkKWPushButton vtkKWRadioButton vtkKWScalevtkKWScrollbar vtkKWText vtkKWThumbWheelvtkKWTopLevel vtkKWTree…
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 12
Widgets overview (cont.)
• Composite widgets
vtkKWChangeColorButtonvtkKWDialog vtkKWExtentvtkKWListBoxToListBoxSelectionEditor vtkKWHSVColorSelector vtkKWNotebook vtkKWProgressGauge vtkKWRange vtkKWSelectionFrame vtkKWSelectionFrameLayoutManager vtkKWSplashScreen vtkKWSplitFrame vtkKWTclInteractor vtkKWToolbar vtkKWToolbarSetvtkKWUserInterfaceManagervtkKWUserInterfacePanel vtkKWWidgetSetvtkKWWidgetWithScrollbarsvtkKWWindow…
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 13
Widgets overview (cont.)
• … more composite widgets: divide and conquer
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 14
Widgets overview (cont.)
• VTK widgets
vtkKWColorPresetSelector vtkKWColorTransferFunctionEditor vtkKWCornerAnnotationEditor vtkKWHeaderAnnotationEditor vtkKWPiecewiseFunctionEditor vtkKWRenderWidget vtkKWScalarBarAnnotation vtkKWScalarComponentSelectionWidget vtkKWTextPropertyEditor vtkKWVolumeMaterialPropertyWidget vtkKWVolumePropertyWidget …
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 15
Examples
• A simple image viewer using KWWidgets and VTK
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 16
Examples (cont.)
package require kwwidgets
vtkKWApplication app vtkKWWindowBase win app AddWindow win win Create
vtkKWRenderWidget rw rw SetParent [win GetViewFrame] rw Create rw CornerAnnotationVisibilityOnpack [rw GetWidgetName] -side top -expand y -fill both \ -padx 0 -pady 0
vtkXMLImageDataReader reader reader SetFileName "head100x100x47.vti"
vtkImageViewer2 viewer viewer SetRenderWindow [rw GetRenderWindow] viewer SetRenderer [rw GetRenderer] viewer SetInput [reader GetOutput]vtkRenderWindowInteractor iren viewer SetupInteractor irenrw ResetCamera
set ca [rw GetCornerAnnotation] $ca SetImageActor [viewer GetImageActor] $ca SetWindowLevel [viewer GetWindowLevel] $ca SetText 2 "<slice>" $ca SetText 3 "<window>\n<level>"
vtkKWScale slice_scale slice_scale SetParent [win GetViewFrame] slice_scale Create slice_scale SetRange \ [viewer GetWholeZMin] [viewer GetWholeZMax] slice_scale SetValue [viewer GetZSlice] slice_scale SetCommand "" \ {viewer SetZSlice [slice_scale GetValue] ; rw Render}pack [slice_scale GetWidgetName] -side top -expand n \ -fill x -padx 2 -pady 2
app Start
rw Deletereader Deleteviewer Deleteiren Deleteslice_scale Deletewin Deleteapp Delete
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 17
Examples (cont.)
• KWWidgetsTour• Show all widgets• Provide Tcl vs.
C++ vs. Python code comparison
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 18
KWWidgets in Slicer3
• in Base/GUI(Load/Save, App Settings, Color, Data, Fiducials, Models, ROI, Slices, Transforms)
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 19
KWWidgets in Slicer3 (cont.)
• in C++ or Tcl modulesslicerWiki: How to implement an Interactive Module GUI
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 20
KWWidgets in Slicer3 (cont.)
• in Command Line Plugins slicerWiki: Execution Model DocumentationUI and command-line generated from self-describing XML
<?xml version="1.0" encoding="utf-8"?><executable> <category> Filtering.Denoising </category> <title> Median Filter </title> <description>The MedianImageFilter is commonly used as a robust approach fornoise reduction. This filter is particularly efficient against"salt-and-pepper" noise. In other words, it is robust to the presenceof gray-level outliers. MedianImageFilter computes the value of each outputpixel as the statistical median of the neighborhood of values around thecorresponding input pixel. </description> <version>0.1.0.$Revision: 2085 $(alpha)</version> <contributor>Bill Lorensen</contributor><parameters> <label>Median Filter Parameters</label> <description>Parameters for the median filter</description>
<integer-vector> <name>neighborhood</name> <longflag>--neighborhood</longflag> <description>The size of the neighborhood in each dimension</description> <label>Neighborhood Size</label> <default>1,1,1</default> </integer-vector>
</parameters>
<parameters> <label>IO</label> <description>Input/output parameters</description> <image> <name>inputVolume</name> <label>Input Volume</label> <channel>input</channel> <index>0</index> <description>Input volume to be filtered</description> </image> <image> <name>outputVolume</name> <label>Output Volume</label> <channel>output</channel> <index>1</index> <description>Output filtered</description> </image> </parameters>
</executable>
June 16-17, 2008 NA-MIC, 2008 June Workshop, IHK Akademie Westerham 21
Find more about KWWidgets…
• Web & Wiki: http://kwwidgets.org
• API: http://public.kitware.com/KWWidgets/doc/nightly/html
• Tutorial and examples available in the source:cvs –d :pserver:[email protected]:/cvsroot/KWWidgets co KWWidgets
• Dashboard: http://www.cdash.org/CDash/index.php?project=KWWidgets