[vtkusers] Problem with vtkContourWidget and QVTKWidget

Jothybasu Selvaraj jothybasu at gmail.com
Tue Nov 22 08:27:58 EST 2011


Try

contourWidget->SetInteractor(renderWindow->GetInteractor());

Jothy

On Tue, Nov 22, 2011 at 1:08 PM, Xavius <xavierelf at gmail.com> wrote:

> Hi all!
> I've tried to use vtkContourWidget as shown in examples and found that it
> doesn't work with QVTKWidget.
> Here is a sample code:
>
> /
> QVTKWidget *widget = new QVTKWidget;
> setCentralWidget(widget);
> vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
>  vtkRenderWindow *renderWindow = widget->GetRenderWindow();
>  renderWindow->AddRenderer(renderer);
>
>  QVTKInteractor *interactor = QVTKInteractor::New()
>  interactor->SetRenderWindow(renderWindow);
>
>  renderer->SetBackground(0.1, 0.2, 0.4);
>  renderWindow->SetSize(600, 600);
>
>  vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
>      vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
>  contourRep->GetLinesProperty()->SetColor(1, 0, 0); //set color to red
>
>  vtkSmartPointer<vtkContourWidget> contourWidget =
>      vtkSmartPointer<vtkContourWidget>::New();
>  contourWidget->SetInteractor(interactor);
>  contourWidget->SetRepresentation(contourRep);
>  contourWidget->On();
>
>  vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();
>  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
>  vtkSmartPointer<vtkCellArray> lines =
> vtkSmartPointer<vtkCellArray>::New();
>  vtkIdType* lineIndices = new vtkIdType[21];
>  for (int i = 0; i< 20; i++)
>    {
>    const double angle = 2.0*vtkMath::Pi()*i/20.0;
>    points->InsertPoint(static_cast<vtkIdType>(i), 0.1*cos(angle),
>                        0.1*sin(angle), 0.0 );
>    lineIndices[i] = static_cast<vtkIdType>(i);
>    }
>
>  lineIndices[20] = 0;
>  lines->InsertNextCell(21,lineIndices);
>  delete [] lineIndices;
>  pd->SetPoints(points);
>  pd->SetLines(lines);
>
>  contourWidget->Initialize(pd);
>  contourWidget->Render();
>  renderer->ResetCamera();
>  renderWindow->Render();
>
>  interactor->Initialize();
> /
>
> Please help me! What I'm doing wrong? The same code outside QVTKWidget
> works
> flawless.
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Problem-with-vtkContourWidget-and-QVTKWidget-tp5013481p5013481.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20111122/152bba84/attachment.htm>


More information about the vtkusers mailing list