[vtkusers] vtkXYPlotActor range

Jérôme Coloos jerome.coloos at samcef.com
Tue Apr 10 06:23:28 EDT 2001


Hello,

I'm using a recent vtk release (nighly release from April 2001) and I found
a strange behaviour with the vtkXYPlotActor object.

I try to plot y=x (from x=0 to 100)

When I set the Yrange to [50, 100], the points below the X-axis (y=50) are
not hidden
This is annoying because I got another plot below this plot and there are
points from the above plot on it.

Is it a normal behaviour ?

Thanks.




Here's an example :
////////////////////////////////////////////////////////////////////
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkXYPlotActor.h"
#include "vtkRectilinearGrid.h"
#include "vtkScalars.h"

int main()
{

	// Create the rendering stuff
	vtkRenderWindow *renWin = vtkRenderWindow::New();
	vtkRenderWindowInteractor *iren   = vtkRenderWindowInteractor::New();
		iren->SetRenderWindow(renWin);
	vtkRenderer *ren = vtkRenderer::New();
	renWin->AddRenderer(ren);

	vtkScalars *xCoords = vtkScalars::New();
		xCoords->SetDataTypeToFloat();
	vtkScalars *yCoords = vtkScalars::New();
		yCoords->SetDataTypeToFloat();

	int dataSize = 100;
	for(int i=0; i<dataSize; i++)
	{
		xCoords -> InsertScalar(i, i );
		yCoords -> InsertScalar(i, i );
	}

// First Plot
	vtkXYPlotActor *xyplot = vtkXYPlotActor::New();
 		xyplot -> SetXValuesToValue();
		xyplot -> GetPositionCoordinate()->SetValue(0,0.5,0);
		xyplot -> GetPosition2Coordinate()->SetValue(1,0.45,0);
		xyplot -> SetYRange(50,100);

	vtkRectilinearGrid *curve  = vtkRectilinearGrid::New();
		curve -> SetDimensions(dataSize,1,1);
		curve -> SetXCoordinates(xCoords);
		curve -> GetPointData()->SetScalars(yCoords);
		xyplot-> AddInput(curve);

	ren->AddActor2D(xyplot);

// Second Plot
	vtkXYPlotActor *xyplot2 = vtkXYPlotActor::New();
 		xyplot2 -> SetXValuesToValue();
		xyplot2 -> GetPositionCoordinate()->SetValue(0,0,0);
		xyplot2 -> GetPosition2Coordinate()->SetValue(1,0.45,0);

	vtkRectilinearGrid *curve2  = vtkRectilinearGrid::New();
		curve2 -> SetDimensions(dataSize,1,1);
		curve2 -> SetXCoordinates(xCoords);
		curve2 -> GetPointData()->SetScalars(yCoords);
		xyplot2-> AddInput(curve2);

	ren->AddActor2D(xyplot2);

  renWin->Render();

  // interact with data
  iren->Initialize();
  iren->Start();
  exit(1);
}
////////////////////////////////////////////////////////////////////////
__________________________________________
   ___    Jérôme COLOOS
 @/   \@  Tel : 32-4/361.69.69
  \° °/   Fax : 32-4/361.69.80
 ==\ /==  mailto:jerome.coloos at samcef.com
    °     http://www.samcef.com
SAMTECH s.a.
Parc Scientifique du Sart-Tilman
rue des Chasseurs-Ardennais, 8
B-4031 Angleur-LIEGE
___________________________________________





More information about the vtkusers mailing list