<div dir="ltr">Hello Andrew,<div><br></div><div>QVTKWidget is deprecated, you may want to try with QVTKOpenGLSimpleWidget and QVTKOpenGLWidget</div><div> if they are available in the version of VTK you are using.</div><div><br></div><div>Best regards,</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Mathieu Westphal<br></div></div></div>
<br><div class="gmail_quote">On Thu, Jul 5, 2018 at 10:23 AM, andyjk <span dir="ltr"><<a href="mailto:andrewkeeling@hotmail.com" target="_blank">andrewkeeling@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
<br>
Old post but I am having the same issue too, with the same example - the<br>
contour widget point placer found here :<br>
<a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolygonalSurfaceContourLineInterpolator" rel="noreferrer" target="_blank">https://www.vtk.org/Wiki/VTK/<wbr>Examples/Cxx/PolyData/<wbr>PolygonalSurfaceContourLineInt<wbr>erpolator</a><br>
<<a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolygonalSurfaceContourLineInterpolator" rel="noreferrer" target="_blank">https://www.vtk.org/Wiki/VTK/<wbr>Examples/Cxx/PolyData/<wbr>PolygonalSurfaceContourLineInt<wbr>erpolator</a>>  <br>
<br>
The issue seems to be that you cannot define a new interactor for a qvtk<br>
widget. ie you cannot do :<br>
<br>
vtkSmartPointer<<wbr>vtkRenderWindowInteractor> interactor = <br>
       vtkSmartPointer<<wbr>vtkRenderWindowInteractor>::<wbr>New(); <br>
this->ui->qvtkWidget-><wbr>GetRenderWindow()-><wbr>SetInteractor(interactor);<br>
<br>
This breaks the qvtkwidget (nothing appears on screen), even if you call:<br>
ui->qvtkwidget->update();<br>
<br>
or (out of desparation!) :<br>
<br>
interactor->Initialise();<br>
ui->qvtkwidget->update();<br>
interactor->Start()<br>
<br>
However, you can grab the exisiting qvtkwidget interactor and work with it<br>
for some widgets:<br>
<br>
vtkSmartPointer<<wbr>vtkRenderWindowInteractor> renderWindowInteractor =<br>
this->ui->qvtkWidget-><wbr>GetRenderWindow()-><wbr>GetInteractor();<br>
<br>
BUT This doesn't work for the contour widget.<br>
<br>
Heres what I tried (mostly from the example posted above). This version<br>
won't even display my QT ui....<br>
<br>
vtkSmartPointer<<wbr>vtkRenderWindow> renderWindow =<br>
this->ui->qvtkWidget-><wbr>GetRenderWindow();<br>
        vtkSmartPointer<<wbr>vtkRenderWindowInteractor> interactor =<br>
vtkSmartPointer<<wbr>vtkRenderWindowInteractor>::<wbr>New();<br>
        interactor->SetRenderWindow(<wbr>renderWindow);<br>
/*<br>
         // I already have a renderer set up with an actor<br>
        // Add the actors to the renderer, set the background and size<br>
        renderer->AddActor(tw_data_.<wbr>pre_actor);<br>
        renderer->SetBackground(.3, .4, .5);<br>
*/<br>
        // Here comes the contour widget stuff...<br>
        vtkSmartPointer<<wbr>vtkContourWidget> contourWidget =<br>
vtkSmartPointer<<wbr>vtkContourWidget>::New();<br>
        contourWidget->SetInteractor(<wbr>interactor);<br>
        vtkSmartPointer<<wbr>vtkOrientedGlyphContourReprese<wbr>ntation> rep =<br>
                vtkOrientedGlyphContourReprese<wbr>ntation::SafeDownCast(<br>
                        contourWidget-><wbr>GetRepresentation());<br>
        rep->GetLinesProperty()-><wbr>SetColor(0, 0, 1.0);<br>
        rep->GetLinesProperty()-><wbr>SetLineWidth(3.0);<br>
        rep->GetProperty()-><wbr>SetPointSize(10);<br>
        rep->GetProperty()-><wbr>SetRenderPointsAsSpheres(1);<br>
<br>
        vtkSmartPointer<<wbr>vtkPolygonalSurfacePointPlacer<wbr>> pointPlacer =<br>
vtkSmartPointer<<wbr>vtkPolygonalSurfacePointPlacer<wbr>>::New();<br>
        pointPlacer->AddProp(tw_data_.<wbr>pre_actor);<br>
        pointPlacer->GetPolys()-><wbr>AddItem(tw_data_.pre_poly);<br>
        rep->SetPointPlacer(<wbr>pointPlacer);<br>
<br>
        this->ui->qvtkWidget-><wbr>GetRenderWindow()-><wbr>SetInteractor(interactor);<br>
        this->ui->qvtkWidget->update()<wbr>;<br>
<br>
        renderWindow->Render();<br>
        interactor->Initialize();<br>
        contourWidget->EnabledOn();<br>
        renderer_->ResetCamera();<br>
        interactor->Start();<br>
<br>
If I comment out :<br>
        // this->ui->qvtkWidget-><wbr>GetRenderWindow()-><wbr>SetInteractor(interactor);<br>
<br>
and change:<br>
contourWidget->SetInteractor(<wbr>interactor);<br>
to<br>
contourWidget->SetInteractor(<wbr>this->ui->qvtkWidget-><wbr>GetRenderWindow()-><wbr>GetInteractor());<br>
<br>
then I get the QT ui displaying, and normal interaction working but no<br>
contour widget.<br>
<br>
If I set everything up on a separate vtk renderer/renderwindow (ie like a<br>
non-QT pop-up window, the contour widget works fine).<br>
<br>
<br>
Can anyone helps as to why QVTK interactor  doesn't work with contour<br>
widget? <br>
It seems that the contourwidget requires an uninitialised interactor, but<br>
the qvtkwidget interactor is always initialised before we can do anything<br>
with it.<br>
<br>
<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/VTK-Users-f1224199.html</a><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://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>