[vtkusers] QVTKWidget with mouse release

Abdelkhalek Bakkari bakkari.abdelkhalek at hotmail.fr
Mon Dec 18 05:32:11 EST 2017


Dear All,


I am trying to mark on the image using  a mouse release event. But the mark appears in different coordinates than which I indicate.

Below is my code:


if (event->button() == Qt::LeftButton )
{

// Seed points visualization
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();

double center[3] = {event->pos().x(), event->pos().y(), currentSlice};
qDebug() << "center: " << center[0] << "  "<< center[1] << "  " << center[2];


sphereSource->SetCenter(0.0, 0.0, 0.0);
sphereSource->SetRadius(10.0);

sphereSource->Update();

vtkSmartPointer<vtkPolyDataMapper> sphereMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
sphereMapper->Update();

vtkSmartPointer<vtkActor> sphereActor = vtkSmartPointer<vtkActor>::New();
sphereActor->SetMapper(sphereMapper);
sphereActor->GetProperty()->SetColor(1.0, 0.0, 0.0);
sphereActor->GetProperty()->SetPointSize(5);
sphereActor->SetPosition(center);

m_renderer->DisplayToWorld();
m_renderer->AddActor(sphereActor);
}
ui->qVTK1->update();
-----

Thank you in advance

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vtk.org/pipermail/vtkusers/attachments/20171218/57682247/attachment.html>


More information about the vtkusers mailing list