NA-MIC National Alliance for Medical Image Computing Sebastien BARRE, Ph.D. / NA-MIC Programmers’...
-
Upload
clarence-anthony -
Category
Documents
-
view
214 -
download
0
Transcript of NA-MIC National Alliance for Medical Image Computing Sebastien BARRE, Ph.D. / NA-MIC Programmers’...
NA-MICNational Alliance for Medical Image Computing http://na-mic.org
Sebastien BARRE, Ph.D. / NA-MIC Programmers’ Week 2005
National Alliance for Medical Image Computing http://na-mic.org
What is KWWidgets ?
• A GUI toolkit– Cross-platform
– Open-license
– Free
National Alliance for Medical Image Computing http://na-mic.org
What is KWWidgets ?
• A GUI toolkit that provides low-level and high-level visualization-oriented widgets
Vs.
National Alliance for Medical Image Computing http://na-mic.org
What is KWWidgets ?
• Over 100 C++ classes used by Kitware to develop complete open-source and commercial end-user applications for more than 7 years
National Alliance for Medical Image Computing http://na-mic.org
What is KWWidgets ?
National Alliance for Medical Image Computing http://na-mic.org
What is KWWidgets ?
National Alliance for Medical Image Computing http://na-mic.org
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(app);
cb1->SetText("A checkbutton");
cb1->DeSelect();
app->Script("pack %s", cb1->GetWidgetName());
National Alliance for Medical Image Computing http://na-mic.org
Features
• Can interact with Tcl/Tk from C++
app->Script("frame .myframe");app->Script("pack .myframe");
vtkKWWidget *myframe = vtkKWWidget::New();myframe->SetWidgetName(".myframe");myframe->SetBackgroundColor(0.2, 0.5, 0.8);
vtkKWCheckButton *cb = vtkKWCheckButton::New();cb->SetParent(myframe);cb->Create(app);cb->SetCommand(NULL, ".myframe config –bg #223344");
app->Script("pack %s", cb->GetWidgetName());
National Alliance for Medical Image Computing http://na-mic.org
Features
• Can interact and co-exist with Tcl/Tk directly from Tcl/Tk or Slicer
• Wrapped into a Tcl package just like VTK/ITK
• Fast-prototyping
National Alliance for Medical Image Computing http://na-mic.org
Features
vtkKWCheckButton *cb1 = vtkKWCheckButton::New();cb1->SetParent(parent);cb1->Create(app);
cb1->SetText("A checkbutton");
cb1->DeSelect();
app->Script("pack %s", cb1->GetWidgetName());
package require kwwidgets
vtkKWCheckButton cb1cb1 SetParent $parentcb1 Create $app
cb1 SetText "A checkbutton"
cb1 DeSelect
pack [cb1 GetWidgetName]
…
button .b -text "My Button"pack .b
National Alliance for Medical Image Computing http://na-mic.org
Features
• Testable– Use CMake/CTest/Dashboard framework
– Trace framework
National Alliance for Medical Image Computing http://na-mic.org
Overview
• Core widgets
• Composite widgets
• VTK widgets
• Helper classes
National Alliance for Medical Image Computing http://na-mic.org
Overview
• Core widgetsvtkKWCanvas vtkKWCheckButton vtkKWEntry vtkKWFrame vtkKWLabel vtkKWListBox vtkKWMenu vtkKWOptionMenu vtkKWPushButton vtkKWRadioButton vtkKWScalevtkKWScrollbar vtkKWText vtkKWThumbWheelvtkKWTopLevel vtkKWTree…
National Alliance for Medical Image Computing http://na-mic.org
Overview
• Composite widgetsvtkKWChangeColorButtonvtkKWDialog vtkKWExtentvtkKWListBoxToListBoxSelectionEditor vtkKWHSVColorSelector vtkKWNotebook vtkKWProgressGauge vtkKWRange vtkKWSelectionFrame vtkKWSelectionFrameLayoutManager vtkKWSplashScreen vtkKWSplitFrame vtkKWTclInteractor vtkKWToolbar vtkKWToolbarSetvtkKWUserInterfaceManagervtkKWUserInterfacePanel vtkKWWidgetSetvtkKWWidgetWithScrollbarsvtkKWWindow…
National Alliance for Medical Image Computing http://na-mic.org
Overview
• VTK widgetsvtkKWColorPresetSelector vtkKWColorTransferFunctionEditor vtkKWCornerAnnotationEditor vtkKWHeaderAnnotationEditor vtkKWPiecewiseFunctionEditor vtkKWRenderWidget vtkKWScalarBarAnnotation vtkKWScalarComponentSelectionWidget vtkKWTextPropertyEditor vtkKWVolumeMaterialPropertyWidget vtkKWVolumePropertyWidget …
National Alliance for Medical Image Computing http://na-mic.org
Overview
• Helper classesvtkKWApplication (init Tcl, event loop, windows, version, registry, splashscreen, help/about, email, updates)vtkKWBalloonHelpManagervtkKWDragAndDropTargetSet vtkKWEventMap vtkKWHistogram vtkKWHistogramSet vtkKWIcon vtkKWMostRecentFilesManager vtkKWRegistryHelper vtkKWResourceUtilities vtkKWTkOptions vtkKWTkUtilities…
National Alliance for Medical Image Computing http://na-mic.org
Examples
• A simple image viewer using KWWidgets and VTK
National Alliance for Medical Image Computing http://na-mic.org
Examplespackage require kwwidgets
vtkKWApplication app app RestoreApplicationSettingsFromRegistry app SetHelpDialogStartingPage \ "http://public.kitware.com/KWWidgets"
vtkKWWindowBase win win SupportHelpOn app AddWindow win win Create app
vtkKWRenderWidget rw rw SetParent [win GetViewFrame] rw Create app 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 app 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
National Alliance for Medical Image Computing http://na-mic.org
Examples
• KWWidgetsTour– Show all widgets
– Provide Tcl vs. C++ code comparison
National Alliance for Medical Image Computing http://na-mic.org
Documentation
• Web: http://public.kitware.com/KWWidgets• Wiki: http://public.kitware.com/Wiki/KWWidgets• 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
• Thank you. Give it a try !