<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div>Hi, <br>There can be number of solutions for such problem an inefficient one will be to have the main QT window as a pointer in this class which is initialized at the time the interactor is set and then you can call a QT function which can initiate a qt Singnal. Also there is something called void * user_data (last argument in the Execute function, you can set the user data as the pointer to the QT window. i hope this helps. <br><br>Regards,<br>Rashid <br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> G G <greenlander1986@gmail.com><br><b><span style="font-weight: bold;">To:</span></b>
Rashid Tanweer <quantum_cook@yahoo.com><br><b><span style="font-weight: bold;">Cc:</span></b> vtkusers@vtk.org<br><b><span style="font-weight: bold;">Sent:</span></b> Mon, April 25, 2011 9:49:13 PM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [vtkusers] interaction problem<br></font><br>
I have something like this...<br><br><span style="font-family: courier new,monospace;">void ImageInteraction::Execute(vtkObject *, unsigned long event, void *)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkRenderWindowInteractor *interactor = this->GetInteractor();</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> int lastPos[2];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> interactor->GetLastEventPosition(lastPos);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> int currPos[2];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> interactor->GetEventPosition(currPos);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (event == vtkCommand::LeftButtonPressEvent)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this->Slicing = 1;</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // Pick at the mouse location provided by the interactor</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this->Picker->Pick(interactor->GetEventPosition()[0],</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> interactor->GetEventPosition()[1],</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> interactor->GetEventPosition()[2], this->Renderer);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> double pos[3];</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this->Picker->GetPickPosition(pos);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> // There could be other props assigned to this picker, so </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> // make sure we picked the image actor</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkAssemblyPath* path = this->Picker->GetPath();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> bool validPick = false;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (path)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkCollectionSimpleIterator sit;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> path->InitTraversal(sit);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> vtkAssemblyNode *node;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> for (int i = 0; i < path->GetNumberOfItems() && !validPick; ++i)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> node = path->GetNextNode(sit);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (this->Actor == vtkImageActor::SafeDownCast(node->GetViewProp()))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> validPick = true; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> if (!validPick)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> else if (event == vtkCommand::LeftButtonReleaseEvent)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> this->Slicing = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> else if (event == vtkCommand::MouseMoveEvent)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (this->Slicing)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> { // something</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> else</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> vtkInteractorStyle *style = vtkInteractorStyle::SafeDownCast(interactor->GetInteractorStyle());</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (style)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> style->OnMouseMove();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br><br>And I would like to get array pos to my GUI QT. I dont know, how to emit signal from this class/method or "return" value to GUI class<br>Thanks for all answers.<br>
<br><br><div class="gmail_quote">2011/4/25 G G <span dir="ltr"><<a rel="nofollow" ymailto="mailto:greenlander1986@gmail.com" target="_blank" href="mailto:greenlander1986@gmail.com">greenlander1986@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Do you have some example? or example on the internet, please. I am trying something all afternoon but any solution :(<br><br><div class="gmail_quote"><div><div></div><div class="h5">2011/4/25 Rashid Tanweer <span dir="ltr"><<a rel="nofollow" ymailto="mailto:quantum_cook@yahoo.com" target="_blank" href="mailto:quantum_cook@yahoo.com">quantum_cook@yahoo.com</a>></span><br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5"><div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div>
Hi, <br>QT and VTK events are different and are generated through seperate pipelines. Best way is to have them both catch, vtk events in vtkCommand Callback by registering it through interactor and QT Event by registering a proper slot for it. <br>
<br>Regards,<br>Rashid <br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><hr size="1">
<b><span style="font-weight: bold;">From:</span></b> G G <<a rel="nofollow" ymailto="mailto:greenlander1986@gmail.com" target="_blank" href="mailto:greenlander1986@gmail.com">greenlander1986@gmail.com</a>><br><b><span style="font-weight: bold;">To:</span></b> <a rel="nofollow" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>
<b><span style="font-weight: bold;">Sent:</span></b> Mon, April 25, 2011 1:30:35 AM<br><b><span style="font-weight: bold;">Subject:</span></b> [vtkusers] interaction
problem<br></font><div><div></div><div><br>
Hi, could someone help me, how to connect this code<br><span><span><a target="_blank" href="http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/ImageProcessing/Cxx/ImageSlicing.cxx">http://vtk.org/gitweb?p=VTK.git;a=blob;f=Examples/ImageProcessing/Cxx/ImageSlicing.cxx</a></span></span><br>
with <br>vtkEventQtSlotConnect<br>?<br>A dont know how to connect it :( <br>Thanks a lot<br>
</div></div></div></div>
</div></div><br></div></div>_______________________________________________<br>
Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a><br>
<br><span>
Visit other Kitware open-source projects at <a target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></span><br>
<br><span>
Please keep messages on-topic and check the VTK FAQ at: <a target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a></span><br>
<br>
Follow this link to subscribe/unsubscribe:<br><span>
<a target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a></span><br>
<br></blockquote></div><br>
</blockquote></div><br>
</div></div>
</div></body></html>