[vtk-developers] new Observers related method

Sebastien BARRE sebastien.barre at kitware.com
Fri May 3 13:29:37 EDT 2002


Hi

In order to enable easier control of the VTK Observer feature from Tcl (and 
fix some pb), I've added two small features that might help:

a) RemoveObservers:
    ++++++++++++++

vtkObject:

   void RemoveObservers(unsigned long event);
   void RemoveObservers(const char *event);

both will remove all observers registred for a specific event type (for 
example, say you want to really override the LeftButtonPressEvent of an 
interactor style, clean these event observers first)

b) AddObserver with priority from Tcl
    ++++++++++++++

vtkWrapTcl.c:

//BTX
unsigned long AddObserver(unsigned long event, vtkCommand *, float 
priority=0.0);
unsigned long AddObserver(const char *event, vtkCommand *, float priority=0.0);
   //ETX

these functions now support the priority parameter from Tcl (default being 
0.0, you can provide anything higher to execute the command first).

Example (test.tcl) :
    ++++++++++++++

vtkCoordinate foo

foo AddObserver ModifiedEvent {
     puts "You shall not see this"
}

foo RemoveObservers ModifiedEvent

foo AddObserver ModifiedEvent {
     puts "You shall see this"
}

foo AddObserver ModifiedEvent {
     puts "You shall see this first"
} 1.0

foo Modified


 > vtk test.tcl
You shall see this first
You shall see this

--
Sebastien Barre




More information about the vtk-developers mailing list