[vtk-developers] RE: vtkTkRenderWidget.cxx breaks Win (Borlan d) builds
Blezek, Daniel J (Research)
blezek at crd.ge.com
Tue Sep 3 10:46:29 EDT 2002
Hi,
Sorry about the bad checkin on Friday. My laptop is soooooo slow to compile VTK, that I thought I
had time to test Windows, but didn't.
This is now fixed w/Dean's suggestions. The command checks the ImageData WholeExtent and works
correctly on the example Tcl included below.
-dan
--
Daniel Blezek, Ph.D.
blezek at crd.ge.com
Visualization and Computer Vision Lab, Imaging Technologies
GE Global Research Center
> -----Original Message-----
> From: dean.inglis at on.aibn.com [mailto:dean.inglis at on.aibn.com]
> Sent: Monday, September 02, 2002 5:19 PM
> To: vtk-developers at public.kitware.com
> Subject: [vtk-developers] RE: vtkTkRenderWidget.cxx breaks
> Win (Borland)
> builds
>
>
> Hi,
>
> the changet to vtkTkRenderWidget on Friday has broken my CVS
> builds of VTK. I have a couple of suggestions for a fix:
>
> 1) move the function body and remove VTK_TK_EXPORT as in
> <snip>
> extern "C" {
> int vtkImageDataToTkPhoto_Cmd (ClientData clientData,
> Tcl_Interp *interp,
> int argc, char **argv)
> {
> <snip>
> to between the function bodys for vtkTkRenderWidget_Cmd and
> vtkTkRenderWidget_RW
>
> and make the vtkTkRenderWidget_Init:
> <snip>
> //------------------------------------------------------------
> ----------------
> // vtkTkRenderWidget_Init
> // Called upon system startup to create vtkTkRenderWidget command.
> extern "C" {int VTK_TK_EXPORT
> Vtktkrenderwidget_Init(Tcl_Interp *interp);}
> int VTK_TK_EXPORT Vtktkrenderwidget_Init(Tcl_Interp *interp)
> {
> if (Tcl_PkgProvide(interp,(char *)"Vtktkrenderwidget",(char
> *)"1.2") != TCL_OK)
> {
> return TCL_ERROR;
> }
>
> Tcl_CreateCommand(interp, (char *) "vtkTkRenderWidget",
> vtkTkRenderWidget_Cmd,
> Tk_MainWindow(interp), NULL);
>
> Tcl_CreateCommand(interp, (char *) "vtkImageDataToTkPhoto",
> vtkImageDataToTkPhoto_Cmd,
> NULL, NULL );
>
> return TCL_OK;
> }
> <snip>
>
>
> 2) once a z slice is selected, in vtkImageDataToTkPhoto_Cmd,
> subsequent calls to vtkImageDataToTkPhoto with a z-slice arg
> fails to change the z slice due to:
> <snip>
> extent[4] = extent[5] = z;
> image->SetUpdateExtent ( extent );
> image->Update();
> <snip>
>
> So, one way to accomodate say a scroll bar widget, are to
> have static vars :
> <snip>
> static int zmin;
> static int zmax;
> int extent[6];
> image->GetExtent ( extent );
> if(extent[4] != extent[5])
> {
> zmin = extent[4];
> zmax = extent[5];
> }
> else
> {
> extent[4] = zmin;
> extent[5] = zmax;
> }
> <snip>
> to reset the imagedata extents. I don't know if any of the
> above will choke other compilers.
>
> Dean
>
> PS
> A tcl example to illustrate:
> (sorry, but I don't know how to mime encode)
>
> #////////////////////////////////////////////////
> package require vtk
> package require vtkinteraction
>
> # Image pipeline
>
> vtkVolume16Reader reader
> reader SetDataDimensions 64 64
> reader SetDataByteOrderToLittleEndian
> reader SetFilePrefix "$VTK_DATA_ROOT/Data/headsq/quarter"
> reader SetImageRange 1 93
> reader SetDataSpacing 3.2 3.2 1.5
> reader Update
>
> vtkImageShiftScale cast
> cast SetInput [reader GetOutput]
> cast SetOutputScalarTypeToUnsignedChar
> cast ClampOverflowOn
> cast Update
> set photo [image create photo]
> set extents [[cast GetOutput] GetExtent]
> set z0 [lindex $extents 4]
> set z1 [lindex $extents 5]
> vtkImageDataToTkPhoto [cast GetOutput] $photo $z0
>
> set range [[reader GetOutput] GetScalarRange]
> set l [lindex $range 0]
> set h [lindex $range 1]
>
> wm withdraw .
> toplevel .c
> wm title .c "Tcl Version of vtkImageDataToTkPhoto"
> wm protocol .c WM_DELETE_WINDOW ::vtk::cb_exit
>
> pack [button .c.b -image $photo]
> pack [scale .c.w -label Window -orient horizontal -from 1 -to
> [expr ($h - $l) / 2] -command SetWindow ] -fill x -expand 1
> pack [scale .c.l -label Level -orient horizontal -from $l -to
> $h -command SetWindow ] -fill x -expand 1
>
> pack [scale .c.z -label Z -orient horizontal -from $z0 -to
> $z1 -command SetWindow ] -fill x -expand 1
>
> .c.w set 500
> .c.l set 153
>
> # Scale = 255 / window
> # Shift = Window / 2 - level
> proc SetWindow { foo } {
> global cast photo
> set Window [.c.w get]
> set Level [.c.l get]
> cast SetScale [expr 255.0 / $Window]
> cast SetShift [expr $Window / 2.0 - $Level]
> vtkImageDataToTkPhoto [cast GetOutput] $photo [.c.z get]
> }
> #///////////////////////////////////////////////////
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at public.kitware.com
> http://public.kitware.com/mailman/listinfo/vtk-developers
>
More information about the vtk-developers
mailing list