<DIV>Hi guys, </DIV>
<DIV> </DIV>
<DIV>I have to implement user interaction with my renderwindow in MFC: </DIV>
<DIV> </DIV>
<DIV>user picks points on the displayed medical image and notices them with spheres. I saw that I have to use <STRONG>vtkHandleMessage2</STRONG> with <STRONG>vtkWin32RenderWindowInteractor</STRONG> to handle a left button mouse click and <STRONG>interactor->AddObserver()</STRONG> to call a function to handle it. </DIV>
<DIV> </DIV>
<DIV>But now, I see that <STRONG>vtkPointPicker</STRONG> exists and that is doing the same thing. I am really a bit confused with all the options. Here is what I did:</DIV>
<DIV> </DIV>
<DIV> <STRONG>interactor->SetRenderWindow(m_RenderWindow);</STRONG></DIV>
<DIV><STRONG> interactor->SetInteractorStyle(NULL);</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> vtkPointPicker *picker = vtkPointPicker::New();</STRONG></DIV>
<DIV><STRONG> interactor->SetPicker(picker);</STRONG></DIV>
<DIV> </DIV>
<DIV> <STRONG>vtkMyCallback* how_execute = vtkMyCallback::New();<BR> interactor->AddObserver( vtkCommand::LeftButtonPressEvent, how_execute );<BR> interactor->AddObserver( vtkCommand::EndPickEvent, how_execute);<BR> </STRONG></DIV>
<DIV><STRONG> interactor->SetInstallMessageProc(false);<BR> interactor->Initialize();</STRONG></DIV>
<DIV> </DIV>
<DIV>LRESULT CMyView::<STRONG>WindowProc(UINT message, WPARAM wParam, LPARAM lParam)<BR></STRONG>{<BR> // TODO: Add your specialized code here and/or call the base class<BR> <STRONG>switch ( message )<BR> {<BR> case WM_LBUTTONDOWN:<BR> if ( this->interactor->GetInitialized() )<BR> {<BR> return vtkHandleMessage2(this->m_hWnd, message, wParam, lParam, this->interactor);<BR> }<BR> break;<BR> }<BR></STRONG> <STRONG>return CFormView::WindowProc(message, wParam, lParam);<BR>}</STRONG></DIV>
<DIV> </DIV>
<DIV><STRONG>class vtkMyCallback : public vtkCommand<BR>{</STRONG></DIV>
<DIV><STRONG>public:</STRONG></DIV>
<DIV><STRONG> static vtkMyCallback *New() { return new vtkMyCallback; }<BR> <BR> virtual void Execute(vtkObject *caller, unsigned long eventId, void*)<BR> {<BR> vtkRenderWindowInteractor* interactor = reinterpret_cast<vtkRenderWindowInteractor*>(caller);</STRONG></DIV>
<DIV> </DIV>
<DIV> <STRONG>if(eventId == vtkCommand::LeftButtonPressEvent)<BR> { <BR> int point[2];<BR> interactor->GetEventPosition(point);<BR> m_viewer->SelectPoint(point[0],point[1]);<BR> }</STRONG></DIV>
<DIV> </DIV>
<DIV> <STRONG>if(eventId == vtkCommand::EndPickEvent)<BR> { <BR> vtkPointPicker* picker = (vtkPointPicker*) interactor->GetPicker();<BR> if(picker->GetPointId() != -1)<BR> {<BR> float* position = picker->GetPickPosition();</STRONG></DIV>
<DIV><STRONG> m_sphereActor->SetPosition(position);<BR> }</STRONG><BR> }<BR>}</DIV>
<DIV> </DIV>
<DIV>- This seems not to work. I think that I have to choose between handling one of the event: LeftButtonPressEvent or EndPickEvent. But I don't know what is the best option. Could someone tell me what is best? </DIV>
<DIV> </DIV>
<DIV>- Btw, my purpose is to add a circle on each point that user picked. Do I have to handle a <STRONG>array of vtkSphereSource</STRONG> to display so many spheres?</DIV>
<DIV> </DIV>
<DIV>Thanks for replyiong, guys,</DIV>
<DIV> </DIV>
<DIV>Isabelle</DIV><p>
                <hr size=1>
<b><font color=#FF0000>Appel audio GRATUIT</font> partout dans le monde</b> avec le nouveau Yahoo! Messenger<br>
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">Téléchargez le ici !</a>