[vtkusers] Trouble using VTK Widget with QVTK

Mathieu Westphal mathieu.westphal at kitware.com
Thu Jul 5 04:26:12 EDT 2018


Hello Andrew,

QVTKWidget is deprecated, you may want to try with QVTKOpenGLSimpleWidget
and QVTKOpenGLWidget
 if they are available in the version of VTK you are using.

Best regards,

Mathieu Westphal

On Thu, Jul 5, 2018 at 10:23 AM, andyjk <andrewkeeling at hotmail.com> wrote:

> Hi
>
> Old post but I am having the same issue too, with the same example - the
> contour widget point placer found here :
> https://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/
> PolygonalSurfaceContourLineInterpolator
> <https://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/
> PolygonalSurfaceContourLineInterpolator>
>
> The issue seems to be that you cannot define a new interactor for a qvtk
> widget. ie you cannot do :
>
> vtkSmartPointer<vtkRenderWindowInteractor> interactor =
>        vtkSmartPointer<vtkRenderWindowInteractor>::New();
> this->ui->qvtkWidget->GetRenderWindow()->SetInteractor(interactor);
>
> This breaks the qvtkwidget (nothing appears on screen), even if you call:
> ui->qvtkwidget->update();
>
> or (out of desparation!) :
>
> interactor->Initialise();
> ui->qvtkwidget->update();
> interactor->Start()
>
> However, you can grab the exisiting qvtkwidget interactor and work with it
> for some widgets:
>
> vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> this->ui->qvtkWidget->GetRenderWindow()->GetInteractor();
>
> BUT This doesn't work for the contour widget.
>
> Heres what I tried (mostly from the example posted above). This version
> won't even display my QT ui....
>
> vtkSmartPointer<vtkRenderWindow> renderWindow =
> this->ui->qvtkWidget->GetRenderWindow();
>         vtkSmartPointer<vtkRenderWindowInteractor> interactor =
> vtkSmartPointer<vtkRenderWindowInteractor>::New();
>         interactor->SetRenderWindow(renderWindow);
> /*
>          // I already have a renderer set up with an actor
>         // Add the actors to the renderer, set the background and size
>         renderer->AddActor(tw_data_.pre_actor);
>         renderer->SetBackground(.3, .4, .5);
> */
>         // Here comes the contour widget stuff...
>         vtkSmartPointer<vtkContourWidget> contourWidget =
> vtkSmartPointer<vtkContourWidget>::New();
>         contourWidget->SetInteractor(interactor);
>         vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep =
>                 vtkOrientedGlyphContourRepresentation::SafeDownCast(
>                         contourWidget->GetRepresentation());
>         rep->GetLinesProperty()->SetColor(0, 0, 1.0);
>         rep->GetLinesProperty()->SetLineWidth(3.0);
>         rep->GetProperty()->SetPointSize(10);
>         rep->GetProperty()->SetRenderPointsAsSpheres(1);
>
>         vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer =
> vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New();
>         pointPlacer->AddProp(tw_data_.pre_actor);
>         pointPlacer->GetPolys()->AddItem(tw_data_.pre_poly);
>         rep->SetPointPlacer(pointPlacer);
>
>         this->ui->qvtkWidget->GetRenderWindow()->
> SetInteractor(interactor);
>         this->ui->qvtkWidget->update();
>
>         renderWindow->Render();
>         interactor->Initialize();
>         contourWidget->EnabledOn();
>         renderer_->ResetCamera();
>         interactor->Start();
>
> If I comment out :
>         // this->ui->qvtkWidget->GetRenderWindow()->
> SetInteractor(interactor);
>
> and change:
> contourWidget->SetInteractor(interactor);
> to
> contourWidget->SetInteractor(this->ui->qvtkWidget->GetRenderWindow()->
> GetInteractor());
>
> then I get the QT ui displaying, and normal interaction working but no
> contour widget.
>
> If I set everything up on a separate vtk renderer/renderwindow (ie like a
> non-QT pop-up window, the contour widget works fine).
>
>
> Can anyone helps as to why QVTK interactor  doesn't work with contour
> widget?
> It seems that the contourwidget requires an uninitialised interactor, but
> the qvtkwidget interactor is always initialised before we can do anything
> with it.
>
>
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180705/cb219a7e/attachment.html>


More information about the vtkusers mailing list