<DIV>Hi guys, </DIV>
<DIV>&nbsp;</DIV>
<DIV>I have to implement user interaction with my renderwindow in MFC: </DIV>
<DIV>&nbsp;</DIV>
<DIV>user&nbsp;picks&nbsp;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-&gt;AddObserver()</STRONG> to call a function to handle it. </DIV>
<DIV>&nbsp;</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>&nbsp;</DIV>
<DIV>&nbsp; <STRONG>interactor-&gt;SetRenderWindow(m_RenderWindow);</STRONG></DIV>
<DIV><STRONG>&nbsp; interactor-&gt;SetInteractorStyle(NULL);</STRONG></DIV>
<DIV><STRONG></STRONG>&nbsp;</DIV>
<DIV><STRONG>&nbsp; vtkPointPicker *picker = vtkPointPicker::New();</STRONG></DIV>
<DIV><STRONG>&nbsp; interactor-&gt;SetPicker(picker);</STRONG></DIV>
<DIV>&nbsp;&nbsp;</DIV>
<DIV>&nbsp;&nbsp;<STRONG>vtkMyCallback* how_execute = vtkMyCallback::New();<BR>&nbsp;&nbsp;interactor-&gt;AddObserver( vtkCommand::LeftButtonPressEvent, how_execute );<BR>&nbsp; interactor-&gt;AddObserver( vtkCommand::EndPickEvent,&nbsp; how_execute);<BR>&nbsp; </STRONG></DIV>
<DIV><STRONG>&nbsp; interactor-&gt;SetInstallMessageProc(false);<BR>&nbsp;&nbsp;interactor-&gt;Initialize();</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>LRESULT CMyView::<STRONG>WindowProc(UINT message, WPARAM wParam, LPARAM lParam)<BR></STRONG>{<BR>&nbsp;// TODO: Add your specialized code here and/or call the base class<BR>&nbsp;<STRONG>switch ( message )<BR>&nbsp;{<BR>&nbsp;case WM_LBUTTONDOWN:<BR>&nbsp;&nbsp;if ( this-&gt;interactor-&gt;GetInitialized() )<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;return vtkHandleMessage2(this-&gt;m_hWnd, message, wParam, lParam, this-&gt;interactor);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;break;<BR>&nbsp;}<BR></STRONG>&nbsp;<STRONG>return CFormView::WindowProc(message, wParam, lParam);<BR>}</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV><STRONG>class vtkMyCallback : public vtkCommand<BR>{</STRONG></DIV>
<DIV><STRONG>public:</STRONG></DIV>
<DIV><STRONG>&nbsp; static vtkMyCallback *New()&nbsp; {&nbsp;return new vtkMyCallback;&nbsp;}<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;virtual void Execute(vtkObject *caller, unsigned long eventId, void*)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkRenderWindowInteractor* interactor =&nbsp;reinterpret_cast&lt;vtkRenderWindowInteractor*&gt;(caller);</STRONG></DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp; <STRONG>if(eventId == vtkCommand::LeftButtonPressEvent)<BR>&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int point[2];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interactor-&gt;GetEventPosition(point);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_viewer-&gt;SelectPoint(point[0],point[1]);<BR>&nbsp;&nbsp; }</STRONG></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp; <STRONG>if(eventId == vtkCommand::EndPickEvent)<BR>&nbsp;&nbsp; {&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkPointPicker* picker = (vtkPointPicker*) interactor-&gt;GetPicker();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(picker-&gt;GetPointId() != -1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; float* position = picker-&gt;GetPickPosition();</STRONG></DIV>
<DIV><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_sphereActor-&gt;SetPosition(position);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</STRONG><BR>&nbsp;&nbsp; }<BR>}</DIV>
<DIV>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
<DIV>Thanks for replyiong, guys,</DIV>
<DIV>&nbsp;</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>