Newbie Q: C++ callbacks in vtk ???

Audrius Stundzia adv_biologic at excite.com
Mon Jun 28 17:57:30 EDT 1999


Dear vtkers,

>From looking at various Python and C++ fragments in the mailing list
archive, I've put together the below C++ callback functions to rotate an
actor when
the left mouse button is pressed.

3 newbie questions:

1. Where do the global variables lastX and lastY get read?
2. What are the arguement lists for the vtkRenderWindowInteractor methods
   StartTimer and EndTimer?
3. Are these all the callback methods I need to rotate in proportion to a
   left mouse key press and mouse drag?

Any advice would be most appreciated.

Regards, 

Audrius Stundzia

The callback code:

int lastX;
int lastY;

static void RotateCallBack( void *arg) // Mouse drag callback
{ 
  int *xyPosition = new int[2];
  
  vtkRenderWindowInteractor *interactor = (vtkRenderWindowInteractor *)arg;
  
  xyPosition = interactor->GetEventPosition();
  
  lastX = xyPosition[X];
  lastY = xyPosition[Y];
  
  interactor->StartRotate();
  
  delete[] xyPosition;  
}

static void NullCallBack( void *arg) // Do nada callback
{ 

}

static void LeftButtonPressedCallBack( void *arg) // Left button pressed
// callback
{
  int *xyPosition = new int[2];
  
  vtkRenderWindowInteractor *interactor = (vtkRenderWindowInteractor *)arg;
  
  xyPosition = interactor->GetEventPosition();
  
  lastX = xyPosition[X];
  lastY = xyPosition[Y];
  
  interactor->SetTimerMethod( RotateCallBack
                            , (void *) interactor );
  interactor->StartTimer();
  
  delete[] xyPosition;  
}

static void LeftButtonReleaseCallBack(  void *arg) // Left button released
// callback
{
  int *xyPosition = new int[2];
  
  vtkRenderWindowInteractor *interactor = (vtkRenderWindowInteractor *)arg;
  
  interactor->EndTimer();
  interactor->SetTimerMethod( NullCallBack
                            , (void *) interactor );
  
  xyPosition = interactor->GetEventPosition();
  
  lastX = xyPosition[X];
  lastY = xyPosition[Y];
  
  delete[] xyPosition;  
}

... in the body of the code

myInteractor->SetLeftButtonPressMethod( LeftButtonPressCallBack)
myInteracton->SetLeftButtonReleaseMethod( LeftButtonReleaseCallBack)




_______________________________________________________
Get your free, private email at http://mail.excite.com/


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list