[vtkusers] Loading and display of 2D graph data

Gary Graf glgraf at asu.edu
Thu Aug 25 17:36:25 EDT 2005


  I am having difficulty getting data loaded and displayed in a 2D graph.
Most of the help expamles are 3D or don't address 2D aspects and
differences.  To attempt a simple test, right now I have the following data
file:

 

# vtk DataFile Version 3.0

track data of XX well

ASCII

DATASET POLYDATA

POINTS 5 float

             0.00         0.00      0.00

             1.00         1.00      0.00

             3.00         2.48      0.00

             2.50         3.34      0.00

             4.68         4.17      0.00

 

LINES 1 5 

0 1 2 3 4

 

 

This is read and displayed with the following vtk C++ snippets:

 

  bool hasOpened = false;

  vtkPolyDataReader *vtkReader; 

...

  vtkReader = vtkPolyDataReader::New();

...

  vtkReader->SetFileName(lpszPathName);

  hasOpened = vtkReader->OpenVTKFile();

  if(hasOpened){

            hasOpened = vtkReader->IsFilePolyData();

  }         //end if

...

  vtkXYPlotActor *xyPlot = vtkXYPlotActor::New();

  vtkPolyDataMapper2D *dataMap = vtkPolyDataMapper2D::New();

 

  if(pDoc->hasOpened){

            dataMap->SetInput(pDoc->vtkReader->GetOutput());

            xyPlot->AddInput(dataMap->GetInput());

  }         //end if

 

 
xyPlot->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay();

    xyPlot->GetPositionCoordinate()->SetValue( 0.05, 0.05, 0);

    xyPlot->GetPosition2Coordinate()->SetValue( 0.95, 0.95, 0);

    xyPlot->SetNumberOfXLabels( 6);

    xyPlot->SetTitle( "Profile Data ");

    xyPlot->SetXTitle( "x");

    xyPlot->SetYTitle( "f(x)");

    xyPlot->SetXRange( 0, 6);

    xyPlot->SetYRange( 0, 6);

    xyPlot->GetProperty()->SetColor( 0, 0, 0);

    xyPlot->GetProperty()->SetLineWidth( 2);

    xyPlot->SetLabelFormat("%g");

    vtkTextProperty* tprop = xyPlot->GetTitleTextProperty();

    tprop->SetColor(0.02,0.06,0.62);

    tprop->SetFontFamilyToArial();

    xyPlot->SetAxisTitleTextProperty(tprop);

    xyPlot->SetAxisLabelTextProperty(tprop);

    xyPlot->SetTitleTextProperty(tprop);

...         

  renderer->AddActor(xyPlot);

 

The program runs w/o error, and displays the axis, legends, etc. (code not
shown), but no data.  What am I missing, and what tools are available to
simplify handling 2D data?  Thanks - Gary Graf

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050825/cbc593c4/attachment.htm>


More information about the vtkusers mailing list