[vtk-developers] Class Event Observers

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu Aug 11 12:59:25 EDT 2005


Brad King wrote:

> Goodwin Lawlor wrote:
>
>> I'd appreciate any thoughts people may have on a proposal for 
>> class/global event observers.
>
>
> Can you post a sample use case for this please?

Take the tcl bindings for vtkTkRenderWidget in the vtkinteraction 
package (bindings.tcl), for example.

To set up vtkTkRenderWidget correctly, you have to call
 ::vtk::bind_tk_widget{.renWidget renWin}
to create the tcl bindings (to fire tcl events into the vtk event loop) 
and setup observers.

Normally in tcl/tk you dont need to bind default bindings yourself with 
a proc, they are already bound to the widget class. This could be done 
for vtkTk*Widget too.

Similarly, there are default observers for vtkRenderWindow 
(AbortCheckEvent) and vtkGenericRenderWindowInteractor (UserEvent, 
ConfigureEvent, ExposeEvent, ExitEvent)- it would nice to be able to add 
observers to the classes rather than the instance each time.

It would also make vtk/tcl application programming a little easier but 
if it would be difficult to implement or just bad design then maybe, as 
David posted, it would be best left to the library client (tcl).

"static vtkObserver *GlobalStart;" was just the first way I thought of. 
John's idea of an Object factory, creating vtk objects with default 
observers sound betters- I didn't like the prospect of adding a static 
member to every class either.

Thanks for your input,

Goodwin








More information about the vtk-developers mailing list