[vtkusers] Drawing 2D Annotations Circle, Rectangle, Arrow, etc Dynamically

kumar kumar.gr at teleradtech.com
Tue Apr 7 05:22:23 EDT 2015


Hi,

AM able to draw the line, in case of Circle and rectangle am facing issue.

bool myVtkInteractorStyleImage :: RectangleDraw2(double x, double y)
{
	/*
	vtkSmartPointer<vtkCellPicker> picker2 =
vtkSmartPointer<vtkCellPicker>::New();
    picker2->SetTolerance(0.0005);

	// Pick from this location.
	picker2->Pick(x, y, 0, _ImageViewer->GetRenderer());
	double* worldPosition = picker2->GetPickPosition();

	x_rb = worldPosition[0];
	y_rb = worldPosition[1];*/

	x_rb = x;
	y_rb = y;

	vtkImageData* image = _ImageViewer->GetInput();
		
	//points->SetPoint(1,x_lt,y_rb,0);
    //points->SetPoint(2,x_rb,y_rb,0);
    //points->SetPoint(3,x_rb,y_lt,0);

	points->InsertPoint(1,x_lt,y_rb,0);
	points->InsertPoint(2,x_rb,y_rb,0);
	points->InsertPoint(3,x_rb,y_lt,0);

	//vtkSmartPointer<vtkCellArray> lines  =
vtkSmartPointer<vtkCellArray>::New();	 
    //lines->InsertNextCell(5); 
    lines->InsertCellPoint(0); 
    lines->InsertCellPoint(1); 
    lines->InsertCellPoint(2); 
    lines->InsertCellPoint(3); 
    lines->InsertCellPoint(0); 

	//vtkSmartPointer<vtkPolyData> polyData  =
vtkSmartPointer<vtkPolyData>::New();
    polyData->SetPoints(points);
    polyData->SetLines(lines);

	//vtkSmartPointer<vtkPolyDataMapper> mapper  =
vtkSmartPointer<vtkPolyDataMapper>::New();	
    mapper->SetInput(polyData);

	//vtkSmartPointer<vtkActor> rectActor   = vtkSmartPointer<vtkActor>::New();			
    //rectActor->SetMapper(mapper);	
	actor->SetMapper(mapper);
	
	vtkSmartPointer<vtkRenderer> renderer =  _ImageViewer->GetRenderer();
	renderer->AddActor(actor);

	vtkSmartPointer<vtkRenderWindow> renderWindow =
_ImageViewer->GetRenderWindow();

	vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
_ImageViewer->GetRenderWindow()->GetInteractor();

	renderWindowInteractor->SetRenderWindow(renderWindow);

	renderWindow->Render();
	renderWindowInteractor->Start();

	return true;
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Drawing-2D-Annotations-Circle-Rectangle-Arrow-etc-Dynamically-tp5731315p5731379.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list