[vtkusers] Using Tcl and KWWidgets, retreiving a selected file path name for a DICOM reader

Jason K Wang jkwang01 at syr.edu
Tue May 31 17:06:56 EDT 2011


Dear VTK Users,

Currently, I'm using the vtkKWFileBrowserDialog class described here: http://www.kwwidgets.org/doc/nightly/html/classvtkKWFileBrowserDialog.html#ae6369457df9ac6c20126d86643007361

At the bottom is my pipeline described in Tcl code.

Where it says "___________________INSERT FILE DIRECTORY PATH NAME HERE_________________________________" you can type the file path name, such as c:/folder_name, to render a DICOM image set as a volume.

How do I use the vtkKWFileBrowserDialog to select a directory path and then retrieve that path name to be used in the DICOM reader?

Basically, what should I do to retrieve the directory path name from the vtkKWFileBrowserDialog class?

That's the part that I'm confused with. I don't know how to retrieve the directory path name and I don't know how to link it with the DICOM reader.

What does GetChooseDirectory or GetLastPath do? How I use those commands? Do these commands lead to a solution? Does anybody know or have experience with this?

See the code and please help me!

Thanks,
Jason


Here is the code:

# Load the KWWidgets package

package require kwwidgets

# Create the application

set app [vtkKWApplication New]
$app SetName "3d dicom viewer"

# Set a help link. Can be a remote link (URL), or a local file

$app SetHelpDialogStartingPage "http://www.kwwidgets.org"

# Add a window
# Set 'SupportHelp' to automatically add a menu entry for the help link

set win [vtkKWWindow New]
$win SupportHelpOn
$app AddWindow $win
$win Create
$win SecondaryPanelVisibilityOff

# Add a render widget, attach it to the view frame, and pack
# Create the render widget,

set rw [vtkKWRenderWidget New]
$rw SetParent [$win GetViewFrame]
$rw Create

pack [$rw GetWidgetName] -side top -expand y -fill both -padx 0 -pady 0

# Create a directory browser dialog that pops up and displays

set dir_browser [vtkKWFileBrowserDialog New]
$dir_browser SetParent [$win GetMainPanelFrame]
$dir_browser Display

# Create a volume reader for DICOM images
vtkDICOMImageReader v16
v16 SetDirectoryName ___________________INSERT FILE DIRECTORY PATH NAME HERE_________________________________

vtkVolumeRayCastCompositeFunction rayCastFunction

vtkVolumeRayCastMapper volumeMapper
  volumeMapper SetInput [v16 GetOutput]
  volumeMapper SetVolumeRayCastFunction rayCastFunction

# Use the render window and renderer of the renderwidget

set vpw_frame [vtkKWFrameWithScrollbar New]
  $vpw_frame SetParent [$win GetMainPanelFrame]
  $vpw_frame Create

  pack [$vpw_frame GetWidgetName] -side top -fill both -expand y

  # -----------------------------------------------------------------------

  # Create a volume property widget

  set vpw [vtkKWVolumePropertyWidget New]
  $vpw SetParent [$vpw_frame GetFrame]
  $vpw Create

  pack [$vpw GetWidgetName] -side top -anchor nw -expand y -padx 2 -pady 2

  # Create a volume property and assign it
  # We need color tfuncs opacity and gradient

  set vpw_vp [vtkVolumeProperty New]
  $vpw_vp SetIndependentComponents 1

  set vpw_cfun [vtkColorTransferFunction New]
  $vpw_cfun SetColorSpaceToRGB
  $vpw_cfun AddRGBPoint 0    0.0 0.0 0.0
  $vpw_cfun AddRGBPoint 500  1.0 0.5 0.3
  $vpw_cfun AddRGBPoint 1000 1.0 0.5 0.3
  $vpw_cfun AddRGBPoint 1150 1.0 1.0 0.9
  $vpw_cfun AddRGBPoint 3150 1.0 1.0 0.9
  #$vpw_cfun AddHSVSegment 0.0 0.2 1.0 1.0 255.0 0.8 1.0 1.0
  #$vpw_cfun AddHSVSegment 80 0.8 1.0 1.0 130.0 0.1 1.0 1.0

  set vpw_ofun [vtkPiecewiseFunction New]
  $vpw_ofun AddSegment 0.0 0.2 255.0 0.8
  $vpw_ofun AddSegment 40 0.9 120.0 0.1

  set vpw_gfun [vtkPiecewiseFunction New]
  $vpw_gfun AddSegment 0.0 0.2 60.0 0.4

  $vpw_vp SetColor 0 $vpw_cfun
  $vpw_vp SetScalarOpacity 0 $vpw_ofun
  $vpw_vp SetGradientOpacity 0 $vpw_gfun

  #$vpw SetVolumeProperty volumeProperty
  $vpw SetVolumeProperty $vpw_vp
  $vpw SetWindowLevel 128 128

# Create volume linked to volume property

vtkVolume volume
  volume SetMapper volumeMapper
volume SetProperty $vpw_vp

# Render volume

set ren [$rw GetRenderer]
$ren AddViewProp volume

$rw ResetCamera
set camera [$ren GetActiveCamera]
set c [volume GetCenter]
$camera SetFocalPoint [lindex $c 0] [lindex $c 1] [lindex $c 2]
$camera SetPosition [expr [lindex $c 0] + 400] [lindex $c 1] [lindex $c 2]
$camera SetViewUp 0 0 -1

# Set command linked to volume property widget
#used in order to update volume property in real-time

$vpw SetVolumePropertyChangedCommand $rw "Render"
$vpw SetVolumePropertyChangingCommand $rw "Render"

# Start the application

set ret 0
$win Display
$app Start
set ret [$app GetExitStatus]
$win Close

# Deallocate and exit

$rw Delete
$win Delete
$app Delete
exit $ret
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110531/86b1eee6/attachment.htm>


More information about the vtkusers mailing list