[vtkusers] Interactor still interacts... why ?
John Biddiscombe
jbiddiscombe at skippingmouse.co.uk
Fri Jun 27 09:04:11 EDT 2003
subclass vtkInteractorStyle instead and then do
interactor->SetInteractorStyle(MyStlye)
JB
RPD - A Graphical Pipeline Editor for VTK
http://www.skippingmouse.co.uk
----- Original Message -----
From: "de Boer Ingo" <I.deBoer at polytec.de>
To: <vtkusers at vtk.org>
Sent: Friday, June 27, 2003 9:39 AM
Subject: [vtkusers] Interactor still interacts... why ?
Hi,
I am trying to write my own windows interactor. But it seems that
only overwriting the OnButton function isn't enough ?! What more to
do ? I have written a small sample based on the cube example. Allthough
I have overwritten all the functions I can still interact with my mouse.
Debugging showed, that the functions from vtkRenderWindowInteractor are
called and not from vtkMyInteractor !!
any hints ?
thanks,
Ingo
############################################################################
#
class vtkMyInteractor : public vtkRenderWindowInteractor
{
public:
vtkMyInteractor::vtkMyInteractor() : vtkRenderWindowInteractor() {}
vtkMyInteractor::~vtkMyInteractor() {};
void OnRButtonDown(HWND wnd, UINT nFlags, int X, int Y) {};
void OnRButtonUp (HWND wnd, UINT nFlags, int X, int Y) {};
void OnMButtonDown(HWND wnd, UINT nFlags, int X, int Y) {};
void OnMButtonUp (HWND wnd, UINT nFlags, int X, int Y) {};
void OnLButtonDown(HWND wnd, UINT nFlags, int X, int Y) {};
void OnLButtonUp (HWND wnd, UINT nFlags, int X, int Y) {};
};
int main( int argc, char *argv[] )
{
int i;
static float x[8][3]={{0,0,0}, {1,0,0}, {1,1,0}, {0,1,0},
{0,0,1}, {1,0,1}, {1,1,1}, {0,1,1}};
static vtkIdType pts[6][4]={{0,1,2,3}, {4,5,6,7}, {0,1,5,4},
{1,2,6,5}, {2,3,7,6}, {3,0,4,7}};
// We'll create the building blocks of polydata including data attributes.
vtkPolyData *cube = vtkPolyData::New();
vtkPoints *points = vtkPoints::New();
vtkCellArray *polys = vtkCellArray::New();
vtkFloatArray *scalars = vtkFloatArray::New();
// Load the point, cell, and data attributes.
for (i=0; i<8; i++) points->InsertPoint(i,x[i]);
for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);
for (i=0; i<8; i++) scalars->InsertTuple1(i,i);
// We now assign the pieces to the vtkPolyData.
cube->SetPoints(points);
points->Delete();
cube->SetPolys(polys);
polys->Delete();
cube->GetPointData()->SetScalars(scalars);
scalars->Delete();
// Now we'll look at it.
vtkPolyDataMapper *cubeMapper = vtkPolyDataMapper::New();
cubeMapper->SetInput(cube);
cubeMapper->SetScalarRange(0,7);
vtkActor *cubeActor = vtkActor::New();
cubeActor->SetMapper(cubeMapper);
// The usual rendering stuff.
vtkCamera *camera = vtkCamera::New();
camera->SetPosition(1,1,1);
camera->SetFocalPoint(0,0,0);
vtkRenderer *renderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(renderer);
vtkMyInteractor *iren = (vtkMyInteractor *)vtkMyInteractor::New();
iren->SetRenderWindow(renWin);
renderer->AddActor(cubeActor);
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
renderer->SetBackground(1,1,1);
renWin->SetSize(300,300);
// interact with data
renWin->Render();
iren->Start();
// Clean up
cube->Delete();
cubeMapper->Delete();
cubeActor->Delete();
camera->Delete();
renderer->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list