<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>It's me again... </DIV>
<DIV> </DIV>
<DIV>Does anyone have an example that implements vtkRenderWindowInteractor, AddObserver and pick event with MFC? I would like to draw a circle where user clicks in the render window. </DIV>
<DIV> </DIV>
<DIV>Isabelle<BR><BR><B><I>Renaud Isabelle <renauisa@yahoo.fr></I></B> a écrit :</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">
<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> _______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR></BLOCKQUOTE><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/yahoofr/*http://fr.messenger.yahoo.com">Téléchargez le ici !</a>