[vtkusers] vtkCommand calldata parameter of Execute()

Sebastien Jourdain sebastien.jourdain at kitware.com
Thu Dec 29 08:04:56 EST 2011


Hi Luke,

You think something too specific here. vtkCommand is not an observer
of the TimerEvent,
it's potentially an observer of any vtkObject classes that trigger events.

Let's pretend that A and B are 2 instance of some vtkObject and C a
vtkCommand instance.

if you do :

A.AddObserver(vtkCommand::XXXX_A, C);
B.AddObserver(vtkCommand::XXXX_B, C);

When you call

A.InvokeEvent(vtkCommand::XXXX_A, whatever)

The method on C get called

Execute (vtkObject *caller, unsigned long eventId, void *callData)

where

- caller = A
- eventId = vtkCommand::XXXX_A
- callData = whatever

same with

B.InvokeEvent(vtkCommand::XXXX_B)
C::Execute (vtkObject *caller, unsigned long eventId, void *callData)
- caller = B
- eventId = vtkCommand::XXXX_B
- callData = NULL

So what I was saying is if you need A or B to retrieve some of the
information that you need, you can cast them into their real classname
and perform a GetSomething() on them...

Otherwise, when you construct your command, just provide the reference
that you need so each time the event get triggered you can ask the
questions that you need to the right objects without expecting them as
argument of the event...

Seb


On Wed, Dec 28, 2011 at 3:58 PM, Luke <hazelnusse at gmail.com> wrote:
> On Mon, Dec 26, 2011 at 2:44 PM, Sebastien Jourdain
> <sebastien.jourdain at kitware.com> wrote:
>> Can't you request the informations that you need as you do get a
>> pointer to the source where the event was generated ?
>
> As I understand it, the vtkCommand subclass is an observer of the
> TimerEvent of the renderWindowInteracter instance.  So somehow I need
> to tell the renderWindowInteracter what data I want it to pass to my
> callback when the TimerEvent is triggered.  I don't know how to do
> this -- can you be more specific?
>
>> Otherwise, you just put anything as it's a void pointer. Create your
>> own struct and that's it. But make sure you know who delete the
>> pointer...
>
> Yes this make sense, I just don't know how to tell
> renderWindowInteracter that I want my struct (or whatever) passed to
> observers of the TimerEvent.  After reading the documentation of
> renderWindowInteractor, I am no clearer, and I haven't been able to
> find any examples.
>
> ~Luke



More information about the vtkusers mailing list