[vtkusers] New Tutorial: Callbacks

John Platt jcplatt at dsl.pipex.com
Wed Mar 24 05:04:30 EDT 2010


David,

You may like to add how to use callbacks with a member function of a class.

MyClass.h
...
    static void ProcessEvents( vtkObject* object, unsigned long event, void* 
clientdata, void* calldata );

MyClass.cpp
...

void MyClass::SomeFunc()
{
    ...
    vtkSmartPointer<vtkCallbackCommand> myEventCBC =
                                      vtkSmartPointer<vtkCallbackCommand>::New();
    myEventCBC->SetCallback( MyClass::ProcessEvents );
    myEventCBC->SetClientData( this );
   ...
}


void MyClass::ProcessEvents( vtkObject* vtkNotUsed(object), unsigned long 
event,
                                                void* clientdata, void* 
callData )
{
    MyClass* self = reinterpret_cast<MyClass*>( clientdata );
    if ( 0 == self )
    return;

    switch( event )
    {
        case vtkCommand::StartInteractionEvent:
        ...
    }
}

John.

----- Original Message ----- 
From: David Doria
To: vtkusers at vtk.org
Sent: Tuesday, March 23, 2010 8:30 PM
Subject: [vtkusers] New Tutorial: Callbacks


I have added a short tutorial on callbacks to the Tutorials section of the 
wiki:
http://www.vtk.org/Wiki/VTK/Tutorials/Callbacks


If anyone has anything to add, please feel free.

Thanks,

David




_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK 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