Strange interaction between tk_getOpenFile and vtkTkRenderWidget
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Dear,
I have a strange behavior in a TCL script (see below). If the line "reader SetFileName $file_in" is included at start the TkRenderWidget reports the following error when the program is terminated:
A TkRenderWidget is being destroyed before it associated vtkRenderWindow is destroyed. This is very bad and usually due to the order in which objects are being destroyed. Always destroy the vtkRenderWindow before destroying the user interface components.
But try to play with the two lines right below vtkPolyDataReader and you'll see different (but deterministic) behaviors depending on which lines are included (You get different different mouse interaction, wireframe on/off works/doesn’t work)
Hope you'll be able to track the bug down.
I'm running on a Dell inspiron 9100 with XP SP1, VTK 4.4 & TCL/Tk 8.3.2 (info patchlevel).
Best wishes, Per R. Andresen
package require vtk package require vtkinteraction
#######################################
Global variables
####################################### set X_SIZE 800; # Size of window set Y_SIZE 500
set maintitle "crop by Claus"; # title is dynamically changed
Get input file name
set typelist_in { {{Visualization Toolkit (polygonal)} {.vtk} } {{All Files } * } } set file_in [tk_getOpenFile -filetypes $typelist_in];
Read file
vtkPolyDataReader reader #reader SetFileName $file_in; # DOESN'T WORK if included but it works if the line is pasted from the vtk interactor (press 'u' - pres reset 'r' after loading the file) reader SetFileName ""; # mouse interaction changes if or not this line is included when using the vtk interactor as described in the previous line?!?!?
vtkPolyDataMapper clipInMapper clipInMapper SetInput [reader GetOutput]
vtkActor actorIn actorIn SetMapper clipInMapper
Create the standard rendering stuff.
vtkRenderer ren1
vtkRenderWindow renWin renWin AddRenderer ren1
Add the actors to the renderer, set the background and size
ren1 AddActor actorIn
Create the Tk widget, associate it with the renderwindow.
set vtkw [vtkTkRenderWidget .ren
-width ${X_SIZE}
-height ${Y_SIZE}
-rw renWin]
Pack the Tk widget.
pack $vtkw -side top -fill both -expand yes
Sets event handlers
::vtk::bind_tk_render_widget $vtkw