AW: [vtkusers] Interaction with VTK window

de Boer Ingo I.deBoer at polytec.de
Mon Oct 13 08:11:20 EDT 2003


> I'm going to write a program with VTK in MFC. I don't know how to interact with the VTK window.
> If anyone can show me how to do it or show me some examples?
Make your own "vtkMyInteractorStyle" based on e.g. vtkInteractorStyleTrackballCamera.
Like this:

#include "vtkInteractorStyleTrackballCamera.h"

class vtkMyInteractorStyle : public vtkInteractorStyleTrackballCamera
{
public:
	static vtkMyInteractorStyle *New();

	void OnLeftButtonDown();
	void OnLeftButtonUp();

protected:
	vtkMyInteractorStyle();
};


vtkStandardNewMacro(vtkMyInteractorStyle);

vtkMyInteractorStyle::vtkMyInteractorStyle() : vtkInteractorStyleTrackballCamera()
{
}

void vtkMyInteractorStyle::OnLeftButtonDown()
{
  AfxMessageBox("left button down");
}
void vtkMyInteractorStyle::OnLeftButtonUp()
{
  AfxMessageBox("left button up");
}

Add the interactor to your renderer, like
m_pvtkWin32RenderWI->SetInteractorStyle(m_pvtkMyInteractorStyle);

greets
  Ingo



More information about the vtkusers mailing list