[vtkusers] Finding the X,Y,Z Position of where Mouse was clicked

neerav neerav at interchange.ubc.ca
Thu May 6 14:46:16 EDT 2004


Hi,
 
I have been trying to generate the x,y,z position of where the mouse has been pressed in a 3D model using the vtkPointPicker method; however, it has not been working and I do not know what I have done wrong.  The code that should perform a Beep (just for testing purposes) each time the mouse's left button is pressed.  This code is in Visual C++ 6.0
 
 
void pickMthd( vtkObject *caller, unsigned long eid, void *clientdata, void *calldata ) {
 Beep( 500, 100 );
 }
 
 

void VTKModel::OnInitialUpdate()  {
...
...
...
 Reader = vtkPolyDataReader::New();
 renderer = vtkRenderer::New();
 renWin = vtkRenderWindow::New();
 iren = vtkRenderWindowInteractor::New();
 VeinMapper = vtkPolyDataMapper::New();
 colorLUT = vtkLookupTable::New();
 Vein = vtkActor::New();
 PointPick = vtkPointPicker::New();
 call1 = vtkCallbackCommand::New();

 colorLUT->SetTableRange (0, 255);
 colorLUT->SetSaturationRange (1, 1);
 colorLUT->SetHueRange (0, 1.0/3.0);
 colorLUT->Build();
 colorLUT->SetTableValue(255, 0.726, 0.137, 0.047, 1.0);
 
 renWin->AddRenderer(renderer);
 renWin->SetParentId( this->GetSafeHwnd() );
 renWin->SetSize( rWndSize.Width(), rWndSize.Height() );
 renderer->AddActor(Vein);
 
 iren->SetRenderWindow(renWin);
 renderer->SetBackground(0.0,0.0,0.0);
 
 call2->SetCallback( &oldCallbackTest );
 
 PointPick->AddObserver( call1->GetEventIdFromString("LeftButtonPressEvent"), call1, 10 );
 PointPick->SetPickMethod( &pickMthd, NULL );

 Reader->SetFileName("VeinModel.vtk");
 
 VeinMapper->SetInput(Reader->GetOutput());
 VeinMapper->SetLookupTable(colorLUT);
 Vein->SetMapper(VeinMapper);
 
 iren->SetPicker( PointPick );
 renWin->Render( );

...
...
...
}

While doing this I have followed the tcl example found at vtk/examples/annotation/tcl/annotatePick.tcl to some degree but I can seem to get it to work.
 
Any help would be greatly appreciated.
 
Thanks
 
Neerav Patel



More information about the vtkusers mailing list