[vtkusers] RE: Using vtkCallbackCommand inside a class

Aroosha Laghaee s9738436 at sms.ed.ac.uk
Thu Apr 6 11:24:25 EDT 2006


Dear John,

Many thanks for your prompt reply and help! Yes that seems to have been 
exactly the problem.

Thanks again,
         Aroosha :0)

>
> Your callback must be a static member function ...
>
> static void UpdateTargetPosition(vtkObject* Object, unsigned long
> eventid,
> 			       void* ClientData, void* CallData);
>
> and the object instance passed as client data ...
>
>       m_Callback->SetClientData( this );
>
>
> In the callback implementation, cast the client data to your object
> instance ...
>
> void Arm::UpdateTargetPosition(vtkObject* Object, unsigned long eventid,
> 			       void* ClientData, void* CallData )
> {
>    Arm* self = reinterpret_cast<Arm*>( ClientData);
>    ...
>
> HTH
>
> John.
>
> -----Original Message-----
> From: vtkusers-bounces+jcplatt=dsl.pipex.com at vtk.org
> [mailto:vtkusers-bounces+jcplatt=dsl.pipex.com at vtk.org] On Behalf Of
> Aroosha Laghaee
> Sent: 06 April 2006 15:26
> To: vtkusers at vtk.org
> Cc: Toby Breckon; B.J.Lamond at sms.ed.ac.uk
> Subject: [vtkusers] Using vtkCallbackCommand inside a class
>
> Hello,
>
> I am trying to use the vtkCallbackCommand in a c++ class. I would like
> to set the callback function to one of my class's member functions
> which is declared before the call is made, however on calling:
>
> vtkCallbackCommand* m_Callback = vtkCallbackCommand::New();
> m_Callback->SetCallback(Arm::UpdateTargetPosition);
>
> I get the following error:
>
> e:\myprojects\lara\arm.cpp(1075) : error C2664: 'SetCallback' : cannot
> convert parameter 1 from 'void (class vtkObject *,unsigned long,void
> *,void *)' to 'void (__cdecl *)(class vtkObject *,unsigned long,void
> *,void *)'
>          None of the functions with this name in scope match the target
> type
>
> I get the same error message if I say:
> m_Callback->SetCallback(UpdateTargetPosition);
>
> Here is the declaration of UpdateTargetPosition:
>
> void Arm::UpdateTargetPosition(vtkObject* Object,unsigned long eventid,
> 			       void* ClientData,void* CallData)
> {
>      // the code for this
> }
>
> Can anyone please tell me what I am doing wrong?
>
> Many thanks,
>          Aroosha
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>






More information about the vtkusers mailing list