[vtkusers] re: world coordinates picking with mouse

Robert Mitchell robmitch at eng.uts.edu.au
Mon Sep 10 20:58:42 EDT 2001


Sedat,

Dont know if this will help,(I'm using MFC/VC++) but...

//============================================================================

void CvtkImageView::OnLButtonDown(UINT nFlags, CPoint point)
//============================================================================

{
  if (m_nMode == MODE_PICK_POINT)
  {
    PickPoint();
    return;
  }
  vtkMFCRenderView::OnLButtonDown(nFlags, point);
}
//============================================================================

void CvtkImageView::PickPoint()
//============================================================================

{
  vtkMFCRenderView::OnChar('p', 0, 0);

  m_pPicker = (vtkPointPicker*) m_Interactor->GetPicker();

  float x,y,z;
  float *pos;

  pos = m_pPicker->GetPickPosition();
  x = *pos;
  y = *(++pos);
  z = *(++pos);

// Do some other stuff specific to my problem (get I,J & K values...)
...
...
...
   // Write to status bar
  CString str;
  CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;
  CStatusBar* pStatus = &pFrame->m_wndStatusBar;
  if ( pStatus )
  {
    str.Format(" I index = %d \t J index = %d", Ival, Jval);
    pStatus->SetPaneText(0,str);
  }
}



You wrote:
===================================
I want to pick world coordinates of a point on vtkRenderWindow. For this
=
purpose, I have written necassary codes in the MouseDown Function of the
=
renderwindow. But it does not effect. I.e, mouse coordinates are not =
returned.=20
I think I should override on its interactor. But I don't know how to do
=
this. How can I solve this problem?
===================================

--
Robert Mitchell
Faculty of Engineering
University of Technology, Sydney
+61 2 9514 2317





More information about the vtkusers mailing list