[vtkusers] vtkCallbackCommand !!

John Platt jcplatt at lineone.net
Tue Jun 1 06:08:16 EDT 2004


Hi AJ,

Here are some code snippets from a class CCutterPlane (VS6) which may
help.

static void PlaneWidgetEvents( vtkObject* object, unsigned long eventId,
void* clientdata, void* calldata );
.....

m_vtkPlaneWidgetCBC = vtkCallbackCommand::New();
m_vtkPlaneWidgetCBC->SetCallback( CCutterPlane::PlaneWidgetEvents );
m_vtkPlaneWidgetCBC->SetClientData( this );
m_vtkPlaneWidget->AddObserver( vtkCommand::EnableEvent,
m_vtkPlaneWidgetCBC );

.....

void CCutterPlane::PlaneWidgetEvents( vtkObject* vtkNotUsed(object), 
                                      unsigned long eventId,
                                      void* clientdata, 
                                      void* vtkNotUsed(calldata) )
{
   CCutterPlane* self = reinterpret_cast<CCutterPlane*>( clientdata );

   switch( eventId )
   {
      case vtkCommand::EnableEvent :
      case vtkCommand::StartInteractionEvent :
      case vtkCommand::InteractionEvent :
      {
         self->m_vtkPlaneWidget->GetPlane( self->m_vtkCuttingPlane );
      }
   }
}

But there are other ways.

John.

-----Original Message-----
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On
Behalf Of A J
Sent: 01 June 2004 00:39
To: vtkusers at vtk.org
Subject: RE: [vtkusers] vtkCallbackCommand !!

..BTWi'm on Linux redhat 8 using gcc

and so my compile error is

no matching function for call to
`vtkCallbackCommand::SetCallback(<unknown 
type>)'
/usr/local/include/vtk/vtkCallbackCommand.h:
65: candidates are: void vtkCallbackCommand::SetCallback(void 
(*)(vtkObject*, long unsigned int, void*, void*))

but my function prototype looks like:
void DoStuff( vtkObject* , unsigned long, void* , void* );

and the definition is something like:

void MyClass::DoStuff( vtkObject* caller, unsigned long eid, void* 
clientdata, void* calldata)
{
    cout<<"event detected"<<endl;
}

and I just followed the examples I found on some posts and in some of
the 
vtk pages etc and I do:
void MyClass::function()
{
        Iren->AddObserver( vtkCommand::EnterEvent , CallbackCommand );
        CallbackCommand->SetCallback(DoStuff);
}

but the compiler doesnt like that second line...
so again, any help would be really really appreciated!!!!!!!!!!!!  Sorry
for 
the million posts but just wanted to clarify my problem... and hoping
that 
one person at least will write back something, ..anything!  Thanks for 
bearing with me I know this must be a basic question,
Thanks in advance,
AJ



>..Or am I supposed to derive a class from vtkCommand like on page 64 of
the 
>3rd edition of the VTK text book??
>
>I thought htat vtkCallbackCommand simplifies having to do all this?!
>
>
>
>>... am I supposed to include all the parameters in the DoStuff
function 
>>when I do:
>>
>>CallbackCommand->SetCallback(DoStuff);
>>
>>??
>>Anywyas I tried this but I must be putting in the wrong parameters
because 
>>it still wont accept it..
>>but from all the examples i've seen so far, what I have should work!!
but 
>>it doesnt..!!!
>>It must be something really basic which I am not seeing, so if someone

>>could point this out then that woudl be great and then i can finally
move 
>>on
>>thank you again!!
>>
>>
>>
>>>Hi, why do I get the following compile error?? I have the correct 
>>>parameters in the function taken in by SetCallback..? So why doenst
it 
>>>seem to recognize it??
>>>
>>>no matching function for call to `vtkCallbackCommand::   
>>>SetCallback(<unknown type>)'
>>>/usr/local/include/vtk/vtkCallbackCommand.h:65: candidates are:
>>>void vtkCallbackCommand::SetCallback(void (*)(vtkObject*, long
unsigned 
>>>int, void*, void*))
>>>
>>>I have a class, say MyClass, and I have the following:
>>>
>>>void MyClass::function()
>>>{
>>>        Iren->AddObserver( vtkCommand::EnterEvent , CallbackCommand
);
>>>	CallbackCommand->SetCallback(DoStuff);
>>>}
>>>
>>>void MyClass::DoStuff( vtkObject* caller, long unsigned int a, void*
arg, 
>>>void* b)
>>>{
>>>    cout<<"detected event"<<endl;
>>>}
>>>
>>>
>>>void MyClass::Anotherfunction()
>>>{
>>>   while(1) Iren->Render();
>>>}

_________________________________________________________________
Get 200+ ad-free, high-fidelity stations and LIVE Major League Baseball 
Gameday Audio!
http://radio.msn.click-url.com/go/onm00200491ave/direct/01/

_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list