<div dir="ltr"><div dir="auto">Hi Abdelkhalek,<div dir="auto"><br></div><div>Where is this code located?<br></div><div dir="auto">Do you override the function QWidget::mouseReleaseEvent in a subclass of the QVTKWidget?</div><div dir="auto"><br></div><div dir="auto">I guess not, because ui->qVTK is probably an instance of QVTKWidget.<br></div><div dir="auto"><br></div><div dir="auto">MouseEvent::pos()
returns the position relative to the widget that receives the event.
So, if you override this function in QMainWindow (for example), then you
get a position relative to that widget.</div><div dir="auto"><br></div><div dir="auto">You have three options:</div><div dir="auto">1. map the position relative to the QVTKWidget (Qt may have some helper functions for this)<br></div><div dir="auto">2. subclass QVTKWidget and override mouseReleaseEvent there<br></div><div>3. Handle mouse events in VTK.<br><br></div>See also <a href="https://lorensen.github.io/VTKExamples/site/Cxx/Interaction/MouseEventsObserver/" target="_blank">https://lorensen.github.io/<wbr>VTKExamples/site/Cxx/<wbr>Interaction/<wbr>MouseEventsObserver/</a> for option 3.<br></div><div dir="auto"><br></div><div>Regards,</div><div>Martijn</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-18 11:32 GMT+01:00 Abdelkhalek Bakkari <span dir="ltr"><<a href="mailto:bakkari.abdelkhalek@hotmail.fr" target="_blank">bakkari.abdelkhalek@hotmail.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_4229044346641390775divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:'Times New Roman',Times,serif" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Dear All,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">I am trying to mark on the image using a mouse release event. But the mark appears in different coordinates than which I indicate.</p>
<p style="margin-top:0;margin-bottom:0">Below is my code:</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>if (event->button() == Qt::LeftButton )</div>
<div><span style="white-space:pre-wrap"></span>{ </div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span></div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>// Seed points visualization</div>
<div><span style="white-space:pre-wrap"></span>vtkSmartPointer<<wbr>vtkSphereSource> sphereSource = vtkSmartPointer<<wbr>vtkSphereSource>::New();</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>double center[3] = {event->pos().x(), event->pos().y(), currentSlice};</div>
<div><span style="white-space:pre-wrap"></span>qDebug() << "center: " << center[0] << " "<< center[1] << " " << center[2];</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><br>
</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>sphereSource->SetCenter(0.0, 0.0, 0.0);</div>
<div><span style="white-space:pre-wrap"></span>sphereSource->SetRadius(10.0);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>sphereSource->Update();</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>vtkSmartPointer<<wbr>vtkPolyDataMapper> sphereMapper = vtkSmartPointer<<wbr>vtkPolyDataMapper>::New();</div>
<div><span style="white-space:pre-wrap"></span>sphereMapper-><wbr>SetInputConnection(<wbr>sphereSource->GetOutputPort())<wbr>;</div>
<div><span style="white-space:pre-wrap"></span>sphereMapper->Update();</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::<wbr>New();</div>
<div><span style="white-space:pre-wrap"></span>sphereActor->SetMapper(<wbr>sphereMapper);</div>
<div><span style="white-space:pre-wrap"></span>sphereActor->GetProperty()-><wbr>SetColor(1.0, 0.0, 0.0);</div>
<div><span style="white-space:pre-wrap"></span>sphereActor->GetProperty()-><wbr>SetPointSize(5);</div>
<div><span style="white-space:pre-wrap"></span>sphereActor->SetPosition(<wbr>center);</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>m_renderer->DisplayToWorld();</div>
<div><span style="white-space:pre-wrap"></span>m_renderer->AddActor(<wbr>sphereActor);</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><span style="white-space:pre-wrap"></span></div>
<div><span style="white-space:pre-wrap"></span>ui->qVTK1->update();</div>
-----
<p></p>
<p style="margin-top:0;margin-bottom:0">Thank you in advance</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
</div>
</div>
<br>______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://vtk.org/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://vtk.org/mailman/<wbr>listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>