[vtkusers] [Fwd: callback to manipulate actors?]

Joby John jzj109 at engr.psu.edu
Wed Oct 31 19:48:23 EDT 2007


Hello VTK users,
 I am new to VTK and I am trying to use "callback" to change the 
position of one of the actors in my renderWindow.
How do I pass the actor (say for example an instance of 
vtkCylinderSource) to the callback and use SetCenter to move its position.
My callback code looks as follows,
%%%%%%%%%%%%%%%%%%%%
class vtkMyCallback : public vtkCommand
{
public:
 static vtkMyCallback *New()
   { return new vtkMyCallback; }
 virtual void Execute(vtkObject *caller1, unsigned long, void*)
   {
     vtkRenderWindowInteractor *interact = 
reinterpret_cast<vtkRenderWindowInteractor*>(caller1);
      char* key = interact->GetKeySym();
      if (*key=='n')
         {              // How to change the position of the actor 
described below. Say using SetCenter();
          }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%
The actor is defined in the main code as such

vtkCylinderSource *C1 = vtkCylinderSource::New();       
C1->SetCenter(5,1.5,0);
   C1->SetRadius(2);
   C1->SetHeight(1);
   C1->SetResolution(24);   %%%%%%%%%%%%%%%%%%%%%%%%%%     
Thanks in advance,
Joby.



More information about the vtkusers mailing list