[vtkusers] BUG in vtk[Render/ImageWindow]Widget ?

Sebastien BARRE seb-ml-vtk at barre.nom.fr
Mon Sep 4 08:23:44 EDT 2000


At 15:38 04/09/00 +0930, David J. Netherway a écrit:
(cc: to the list, just in case)

 >Hello,
 >
 >The attachment does not seem to have any tcl code with it.
 >
 >Regards, David

That's very strange indeed.
OK, here is the code (see below)

Might also be downloaded here :
ftp://sic.sp2mi.univ-poitiers.fr/pub/barre/vtk/tmp/t_bugtk.tcl


# Sébastien Barré (Time-stamp: <2000-09-03 05:27:31 barre>
catch {package require ::sb::debug }
catch {load vtktcl}
# ----------- Image widget -----------
vtkImageReader reader
     reader SetDataByteOrderToLittleEndian
     reader SetDataExtent 0 255 0 255 1 90
     reader SetFilePrefix "$env(VTK_DATA)/fullHead/headsq"
vtkImageMapper imapper
     imapper SetInput [reader GetOutput]
vtkActor2D iactor
     iactor SetMapper imapper
vtkImager imager
     imager AddProp iactor
     imager SetBackground 0.56 0.6 0.66
vtkImageWindow iwin
     iwin AddImager imager
# ----------- Render widget -----------
vtkSphereSource sphere
vtkPolyDataMapper rmapper
     rmapper SetInput [sphere GetOutput]
vtkActor ractor
     ractor SetMapper rmapper
vtkRenderer renderer
     renderer AddProp ractor
     renderer SetBackground 0.66 0.53 0.6
vtkRenderWindow rwin
     rwin AddRenderer renderer
# ----------- Display one or the other -----------
set bt .buttons
frame $bt
pack $bt -side top
set parent .frame
frame $parent
pack $parent -side top -fill both -expand yes
# Play with 1/0 to enable/disable the widget
if {1} {
     vtkTkImageWindowWidget $parent.iwid -iw iwin
     bind $parent.iwid <Expose> "$parent.iwid Render ; puts 
{expose:    ImageWidget}"
     bind $parent.iwid <Configure> "$parent.iwid Render; puts {configure: 
ImageWidget}"
     button $bt.iwid -text "Show ImageWidget" -command {select iwid} -bg 
#8899ee
     pack $bt.iwid -side left -anchor nw
}
if {1} {
     vtkTkRenderWidget $parent.rwid -rw rwin
     bind $parent.rwid <Expose> "$parent.rwid Render; puts 
{expose:    RenderWidget}"
     bind $parent.rwid <Configure> "$parent.rwid Render; puts {configure: 
RenderWidget}"
     button $bt.rwid -text "Show RenderWidget" -command {select rwid} -bg 
#ee8899
     pack $bt.rwid -side left -anchor nw
}
set selection ""
# Select a widget, pack it, forget the previously selected widget
# (vice-versa for the button)
proc select {widget} {
     global selection bt parent
     if {$selection == $widget} {
         return
     }
     if {$selection != ""} {
         pack forget $parent.$selection
         pack $bt.$selection -side left -anchor nw
     }
     set selection $widget
     pack $parent.$selection -fill both -expand yes -anchor nw
     pack forget $bt.$selection
}
wm geometry . 400x400




More information about the vtkusers mailing list