[vtk-developers] Class Event Observers

David Cole david.cole at kitware.com
Thu Aug 11 13:15:08 EDT 2005


Given this is your use case... it sounds like you only need this 
behavior for a handful of classes. If you do end up with a class scope 
implementation that works for your use case, maybe it should be limited 
to just the classes you need it for. (With the ability add more easily...?)

Class scope still seems too broad for a proper solution. Don't you need 
to bind to specific instances? If I make two (or three, or more) render 
widgets, do I want the same bindings for all of them?

A class observer would observe, what, *all* instances of the given 
class? What if it's only appropriate for some of the instances? How 
would you differentiate? And how would you even get to all the instances 
of a given class...?


Goodwin Lawlor wrote:

> 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