[vtkusers] vtkXYPlotActor

Jens F schpacken at gmx.net
Tue Apr 26 12:29:23 EDT 2011


Good day,

while testing vtk I am trying to create a vtkPlotActor showing a simple
sinus line. I have created the following code:
------------->
 iRenderer= vtkRenderer::New();
 iRenderer->SetBackground(0.6784, 0.8471, 0.9020);

 int lNumPoints(361);
 // Points
 vtkPoints *lSinusPoints= vtkPoints::New();
 lSinusPoints->SetNumberOfPoints(lNumPoints);
 for (int i= 0; i < lNumPoints; i++)
  lSinusPoints->SetPoint(i, i, sind(i* 1.0), 0.0);
 for (int i= 0; i < lNumPoints; i++)
  ITRACE_DEVELOP(CDblPoint(lSinusPoints->GetPoint(i)[0],
lSinusPoints->GetPoint(i)[1]).asString());
 double lBounds[6];
 lSinusPoints->GetBounds(lBounds);
 // Vertices
 vtkCellArray *lSinusLineVertices= vtkCellArray::New();
 // Polyline
 vtkPolyLine *lSinusLine= vtkPolyLine::New();
 lSinusLine->GetPointIds()->SetNumberOfIds(lNumPoints);
 for (int i= 0; i < lNumPoints; i++)
  lSinusLine->GetPointIds()->SetId(i, i);
 lSinusLineVertices->InsertNextCell(lSinusLine);

 vtkPolyData* lPlotData= vtkPolyData::New();
 lPlotData->SetPoints(lSinusPoints);
 lPlotData->SetLines(lSinusLineVertices);

 vtkXYPlotActor* lXYPlot= vtkXYPlotActor::New();
 lXYPlot->AddInput(lPlotData);
 lXYPlot->GetPositionCoordinate()->SetValue(0.005, 0.005, 0);
 lXYPlot->GetPosition2Coordinate()->SetValue(1.0- 0.005, 1.0- 0.005, 0);
 lXYPlot->SetXRange(lBounds[0], lBounds[1]);
 lXYPlot->SetYRange(lBounds[2], lBounds[3]);
 lXYPlot->PlotLinesOn();

 iRenderer->AddActor2D(lXYPlot);
<------------

The x and y scales are drawn but unfortunately the sinus curve not. I
thought I have created both, the points and it's topology but with all the
informations public available I am not able to find the reason (btw. self
studying vtk even with the books "VTK User's Guide" and "VTK Textbook" is a
nightmare).

Please note iRenderer is assigned to an existing Window created with a 3rd
party's class library (OS= Windows 7). I am using the following code to link
the vtKWindow and the Win32 Window:
------------>
iRenderWindow= vtkRenderWindow::New();
iRenderWindow->SetParentId(this->handle()); // setup this DrawingCanvas as
the Parent window
<------------
this->handle() returns a system window handle.

Any hints in this matter appreciated.

Best regards,

Jens

--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkXYPlotActor-tp4341339p4341339.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list