<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hello all,<br>
<br>
I am an undergraduate student in a rush to create a project for my professor who will flunk me if I don't finish. I am attempting to use VTK in conjunction with Tcl and KWWidgets in order to display a volume of medical image data. I use the
<font size="2"><span style="font-size: 10pt;">vtkKWVolumePropertyWidget to update the volume properties, like color and opacity transfer functions, but, in order for the properties to be updated, the render widget needs to be clicked on. Is some sort of local
variable or callback function needed?</span></font> In addition, I need to create a directory browser. I can again use a KWWidget to add a directory browser representation, but, how do I have actions placed on the widget directly effect the properties of the
volume in real-time. Any help is appreciated! The code I have so far is at the bottom of this message.<br>
<br>
Thanks in advance for your help,<br>
Jason<br>
<br>
<font size="2"><span style="font-size: 10pt;"># Load the KWWidgets package<br>
<br>
package require kwwidgets<br>
<br>
# Create the application<br>
# If --test was provided, ignore all registry settings, and exit silently<br>
# Restore the settings that have been saved to the registry, like<br>
# the geometry of the user interface so far.<br>
<br>
set app [vtkKWApplication New]<br>
$app SetName "Brain Viewer"<br>
<br>
# Set a help link. Can be a remote link (URL), or a local file<br>
<br>
$app SetHelpDialogStartingPage "http://www.kwwidgets.org"<br>
<br>
# Add a window<br>
# Set 'SupportHelp' to automatically add a menu entry for the help link<br>
<br>
set win [vtkKWWindow New]<br>
$win SupportHelpOn<br>
$app AddWindow $win<br>
$win Create<br>
$win SecondaryPanelVisibilityOff<br>
<br>
# Add a render widget, attach it to the view frame, and pack<br>
<br>
# Create a render widget, <br>
<br>
set rw [vtkKWRenderWidget New]<br>
$rw SetParent [$win GetViewFrame]<br>
$rw Create<br>
<br>
pack [$rw GetWidgetName] -side top -expand y -fill both -padx 0 -pady 0<br>
<br>
# Create a volume reader<br>
vtkVolume16Reader v16<br>
v16 SetDataDimensions 64 64<br>
v16 SetDataByteOrderToLittleEndian <br>
v16 SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"<br>
v16 SetImageRange 1 93<br>
v16 SetDataSpacing 3.2 3.2 1.5<br>
<br>
vtkVolumeRayCastCompositeFunction rayCastFunction<br>
<br>
vtkVolumeRayCastMapper volumeMapper<br>
volumeMapper SetInput [v16 GetOutput]<br>
volumeMapper SetVolumeRayCastFunction rayCastFunction<br>
<br>
# Create frame for widget<br>
<br>
set vpw_frame [vtkKWFrameWithScrollbar New]<br>
$vpw_frame SetParent [$win GetMainPanelFrame]<br>
$vpw_frame Create<br>
<br>
pack [$vpw_frame GetWidgetName] -side top -fill both -expand y<br>
<br>
# -----------------------------------------------------------------------<br>
<br>
# Create a volume property widget<br>
<br>
set vpw [vtkKWVolumePropertyWidget New]<br>
$vpw SetParent [$vpw_frame GetFrame] <br>
$vpw Create<br>
<br>
pack [$vpw GetWidgetName] -side top -anchor nw -expand y -padx 2 -pady 2<br>
<br>
# Create a volume property and assign it<br>
# We need color tfuncs opacity and gradient<br>
<br>
set vpw_vp [vtkVolumeProperty New]<br>
$vpw_vp SetIndependentComponents 1<br>
<br>
set vpw_cfun [vtkColorTransferFunction New]<br>
$vpw_cfun SetColorSpaceToRGB<br>
$vpw_cfun AddRGBPoint 0 0.0 0.0 0.0<br>
$vpw_cfun AddRGBPoint 500 1.0 0.5 0.3<br>
$vpw_cfun AddRGBPoint 1000 1.0 0.5 0.3<br>
$vpw_cfun AddRGBPoint 1150 1.0 1.0 0.9<br>
<br>
set vpw_ofun [vtkPiecewiseFunction New]<br>
$vpw_ofun AddSegment 0.0 0.2 255.0 0.8<br>
$vpw_ofun AddSegment 40 0.9 120.0 0.1<br>
<br>
set vpw_gfun [vtkPiecewiseFunction New]<br>
$vpw_gfun AddSegment 0.0 0.2 60.0 0.4<br>
<br>
$vpw_vp SetColor 0 $vpw_cfun<br>
$vpw_vp SetScalarOpacity 0 $vpw_ofun<br>
$vpw_vp SetGradientOpacity 0 $vpw_gfun<br>
<br>
$vpw SetVolumeProperty $vpw_vp<br>
$vpw SetWindowLevel 565 565<br>
<br>
vtkVolume volume<br>
volume SetMapper volumeMapper<br>
volume SetProperty $vpw_vp<br>
<br>
set ren [$rw GetRenderer]<br>
$ren AddViewProp volume<br>
<br>
$rw ResetCamera<br>
set camera [$ren GetActiveCamera]<br>
set c [volume GetCenter]<br>
$camera SetFocalPoint [lindex $c 0] [lindex $c 1] [lindex $c 2]<br>
$camera SetPosition [expr [lindex $c 0] + 400] [lindex $c 1] [lindex $c 2]<br>
$camera SetViewUp 0 0 -1<br>
<br>
# Start the application<br>
set ret 0<br>
$win Display<br>
$app Start<br>
set ret [$app GetExitStatus]<br>
$win Close<br>
<br>
# Deallocate and exit<br>
<br>
$rw Delete<br>
$win Delete<br>
$app Delete<br>
<br>
exit $ret</span></font><br>
</div>
</body>
</html>