Updating Contour widget using QVTKInteractor

(Moravaneni sateesh) #1

Hi ,

As shown in vtkContour widget Example, i have created a contour.
using actor point placer placed it on Image Actor.
But after initializing the widget with polydata, im not able to use the Start() on interactor as im using VtkresliceimageViewer which using QVtkinteractor . Qvtk interactor doesnt have this method support to invoke events.

I’m able to see the widget if i scroll the mouse and change the slice.
is there any way to See the widget without changing the slice. Help is appreciated.

A piece of code is attached below.

vtkContourWidget *axialContour = vtkContourWidget::New();
axialContour->SetInteractor(this->resliceImageViewerAxial->GetInteractor()); // interactor
vtkSmartPointer linter = vtkSmartPointer::New();
vtkSmartPointer placer = vtkSmartPointer::New();
placer->SetImageActor(this->resliceImageViewerAxial->GetImageActor()); //imageactor
vtkSmartPointer rep = vtkSmartPointer::New();
rep->SetLineInterpolator( linter );
rep->SetPointPlacer( placer );
rep->GetProperty()->SetOpacity(0);
rep->DragableOn();

rep->GetLinesProperty()->SetLineWidth(1);
rep->GetLinesProperty()->SetPointSize(1);


rep->GetLinesProperty()->SetColor(1,0,0);

axialContour->SetRepresentation( rep );
axialContour->FollowCursorOn();
axialContour->AllowNodePickingOn();
axialContour->On();
axialContour->ContinuousDrawOn();
axialContour->CloseLoop();

// Generate a set of points arranged in a circle
   int numPts = 10;
   vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
   for (int i = 0; i < numPts; i++)
   {
       // Create numPts points evenly spread around a circumference of radius 0.1
       const double angle = 2.0*vtkMath::Pi()*i/numPts;
       points->InsertPoint(static_cast<vtkIdType>(i), 300*cos(angle), 300*sin(angle), 0.0 );
   }

   // Create a cell array to connect the points into meaningful geometry
   vtkIdType* vertexIndices = new vtkIdType[numPts+1];
   for (int i = 0; i < numPts; i++) { vertexIndices[i] = static_cast<vtkIdType>(i); }
   // Set the last vertex to 0; this means the last line segment will join the 19th point (vertices[19])
   // with the first one (vertices[0]), thus closing the circle.
   vertexIndices[numPts] = 0;
   vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
   lines->InsertNextCell(numPts+1, vertexIndices);

   // Create polydata to hold the geometry just created, and populate it
   vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
   polydata->SetPoints(points);
   polydata->SetLines(lines);

   axialContour->Initialize(polydata);
   //this->resliceImageViewerAxial->GetInteractor()->Start();

Regards ,
Sateesh.