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

Sebastien BARRE seb-ml-vtk at barre.nom.fr
Sat Sep 2 23:03:52 EDT 2000


Hi

I have not seen any serious changes in the CVS regarding the Tk Widgets 
(vtkTkRenderWidget, vtkTkImageWindowWidget), nevertheless I guess I found 
evidence of a strange and non-compliant behaviour (although I'm still not 
sure if it's not a framebuffer problem) :

	- widgets are not packed correctly. The Tk documentation is clear about 
that : "if a widget is not managed [by pack, grid or any geometry 
managers)], it doesn't appear on your display at all". Sadly, this is not 
the case with the VTK Tk widgets on two of my computers. Moreover, "[By 
unpacking it], the widget gets unmapped so it's not visible". Which does 
not work either :) And as the widget visibility gets corrupted, the VTK 
widgets accept events where they should not.

	- this problem arises only with combination of two different type of 
widgets at the same Tk level (which is puzzling),

I'm using Tcl/Tk 8.3.0, the very latest VTK CVS, Windows NT4 SP6, a SGI 
Visual 320 and a conventional Home-PC running an 3Dlabs Oxygen GMX 2000.

I noticed the "bug" as I tried to put *both* a render widget and an image 
widget in a tabnotebook. You all know what a tabnotebook is :), it's a 
convenient GUI metaphor that provides access to "pages" through small 
"tabs". Many "Preferences" dialog use this representation, as well as 
serious apps as an alternative to the MDI (multidocument interface) scheme.

There is no tabnotebook in the Tcl/Tk distrib. The best tabnotebook is to 
be found in the BLT package. There is also one in the Iwidgets package 
(Itcl/Itk). I tried BOTH, and was able to reproduce the bug. Then I wrote a 
Tk-only script (attached to the email) which basically focus on the problem.

The trick is well-know, given a parent widget...
	.p

and two children at the same level...
	.p.a
	.p.b

...you might simulate a tabnotebook by packing a *single* children at a 
time. If the user selects another tab, then you unpack the previous 
"selection", and pack the new selection.

	pack forget old_widget
	pack widget

...will respectively map/unmap the widget relative to its parent, thus 
explicitly making it visible or no more visible (but still existing of 
course).

The important thing to note is that you cannot pack/unpack a widget A in a 
widget P if A is not a children of P. But this is not a problem, because 
even if you create a frame and 2 buttons:
	frame .p
	button .p.a
	button .p.b
there is not display conflict, as nothing is visible until you pack one of 
them. Up to you to decide.

Which leads us to the problem. Given a Tk frame and two VTK widgets :
	frame .p
	vtkRenderWidget .p.a
	vtkImageWindowWidget .p.b

guess what ? even if you did not pack them, the Image Widget is visible 
(sort-of). And if you bind the Expose and Configure events to each of them 
(as you should)... they will both respond to their respective events ! 
Simultaneously. And although not packed, not visible, not mapped.

And if you start packing/unpacking one of them in a "tabnotebook" manner, 
you will notice that the RenderWidget never shows up. Or sometimes, but 
with some parts of the old Image Window widget as a "ghost" background. 
Some refresh or framebuffer problem ?

This is demonstrated in the small script attached to this email.

	- it creates an imaging and rendering pipeline,
	- it creates a vtkRenderWidget and vtkImageWindowWidget at the same level,
	- it creates two buttons that will be used to display one widget, or the 
other,

=> at this time, there is two buttons on the top (no one has been 
selected), and as no widget has been packed, there should not be anything 
visible ! But it's not the case, you should already see the content of the 
ImageWidget :(

Moreover, I've bound the <Expose> <Configure> to each widget so that they 
render themselves automatically and send a message to the standard output, 
giving the event/widget names. But if you play with the window, you will 
see that both widgets already respond to their events, although they are 
not packed, visible or mapped !!

[...]
expose:    ImageWidget
expose:    RenderWidget
expose:    ImageWidget
expose:    RenderWidget
[...]
(tests) 8 % winfo viewable $parent.iwid
0
(tests) 9 % winfo viewable $parent.rwid
0
(tests) 11 % winfo ismapped $parent.rwid
0
(tests) 12 % winfo ismapped $parent.iwid
0

Smashing ? Not finished. If you play with the buttons, you will see that 
the pack/unpack trick works for the button, but not for the widget. 
Basically, the render widget never shows up.

Still awake ? Be aware that this problem disappears if you use only one 
widget, or two widgets of the same type ! Two render widget have no 
problem. Two imagewidget neither !

Very puzzling.

Any clues would be welcome.
Thanks


-------------- next part --------------
# S?bastien Barr? (Time-stamp: <2000-09-03 04:40:22 barre>  




More information about the vtkusers mailing list