help: how to use vtkInteractorStyle::SetLeftButtonPressMethod()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

help: how to use vtkInteractorStyle::SetLeftButtonPressMethod()

Alexander Sendobry
Hello,

I'm writing a small tool for a very huge program.
througout the whole program there is defined a
vtkInteractorStyleTrackballActor to zoom / pan and rotate images.

Now i want to implement a function that does a pickCallback (it is
called Measure Callback) if you press the left mouse button. For this
purpose i want to use the class vtkInteractorStyleUser to tell the program:
- If  the left button ist pressed, do a pickcallback and don't rotate
the image.
- All the other functionality of vtkInteractorStyleTrackballActor should
be left unchanged.

I don't understand how to use the method
"vtkInteractorStyle::SetLeftButtonPressMethod(void(*f)(void *), void
*arg)"  correctly. what does the call "void(*f)(void *)" mean?
In a former question by someone else i read, that you can only define a
C function, but not a C++ function, is that right?
How must the function void(*f)(void *) look like?

The following is a snippet of my code.
there is only defined an wxVTKRenderWindowInteractor, for interaction
between wxWidgets and VTK. so i did a dynamic_cast to
vtkWin32RenderWindowInteractor*.
afterwards i do another dynamic_cast back to
wxVTKRenderWindowInteractor*, and it should work.
My only Problem can be found in the line
*iasu->SetLeftButtonPressMethod(......);
*How can i tell the Interactor not to rotate when pressing (and holding
down) the left mouse button, but to do a Measure Callback, as defined in
the last line of this few lines

  // init Measure callback
  m_pMeasureCallback = vtkMeasureCallback::New(this);
  //Define interactor and interactorStyle
  vtkInteractorStyleUser* iasu = vtkInteractorStyleUser::New();
  vtkWin32RenderWindowInteractor* pvtkWin32Interactor =
dynamic_cast<vtkWin32RenderWindowInteractor*>(m_pWXVTKRenderWindowInteractor);
  iasu->SetLeftButtonPressMethod();
  pvtkWin32Interactor->SetInteractorStyle(iasu);

 
m_pMeasureCallback->SetInteractor(dynamic_cast<wxVTKRenderWindowInteractor*>(pvtkWin32Interactor));
  //m_pWXVTKRenderWindowInteractor->SetIgnoreLeftMButton(false);
 
m_pWXVTKRenderWindowInteractor->AddObserver(vtkCommand::LeftButtonPressEvent,
m_pMeasureCallback);
  m_pRenderer->AddObserver(vtkCommand::LeftButtonPressEvent,
m_pMeasureCallback);


With the following commented line it is possible to do a Callback with
the left mouse button, but the image will also be rotated, if you don't
have calm fingers.....
//m_pWXVTKRenderWindowInteractor->SetIgnoreLeftMButton(false);

Thank you for your answers
Alexander Sendobry


_______________________________________________
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