[vtkusers] How to implement overridding the OnLeftButtonDown

zfjgo zfjgo at 126.com
Wed Oct 13 23:00:35 EDT 2004


hello,
I am a new vtkuser . Whenever I am overridding the
OnLeftButtonDown(ctrl,shift,X,Y) function . My Picking
function (CellPicking doesnt work )

The follow is a part of my VC++ code,I know it contain many errors.
Kindly reply urgently.Had better provide me with the entire corresponding VC++ code.Thaks a lot.
God bless you 




void vtkInteractorStyle::OnLeftButtonDown(int ctrl,int shift,int X,int Y)  
{
	
	if(ctrl==1&&shift==0)
{    vtkCellPicker *picker=vtkCellPicker::New();
     CWnd *pMainWnd=AfxGetApp()->m_pMainWnd;
	 CMainFrame *pMainFrame=(CMainFrame *)pMainWnd;
	 CMy3DReconstructionofBloodVesselView *pMyView=(CMy3DReconstructionofBloodVesselView *)pMainFrame->GetActiveView();
	 picker=(vtkCellPicker *)pMyView->Iren->GetPicker();
   	
    vtkInteractorStyle *interstyle=vtkInteractorStyle::New();
	pMyView->Iren->SetInteractorStyle(interstyle);
    pMyView->Iren->SetPicker(picker);
    vtkIdType cell_id=picker->GetCellId();
	if(cell_id<0)
		AfxMessageBox("Sorry,you have not selected any point.");
	else
	{   
		float *selPt;
		float *pickpos;
		int xp,yp,zp;

		selPt=picker->GetSelectionPoint();   
        cout<<"Screen location:"<<selPt[0]<<" "<<selPt[1]<<"\n";
		X=selPt[0];
		Y=selPt[1];
		pickpos = picker->GetPickPosition();
		cout<<"Point location:"<<pickpos[0]<<" "<<pickpos[1]<<" "<<pickpos[2]<<"\n";
	    xp=pickpos[0];
		yp=pickpos[1];
		zp=pickpos[2];
		
	  //picker->Pick();
   
    } 
}
}


-----------------------------------------------------------
马上到http://www.126.com申请260M全国最大免费邮箱!
提供新邮件到达手机短信提醒功能, 随时掌握邮件信息!


More information about the vtkusers mailing list