[vtkusers] scalar bar values

Lubos Brieda lbrieda at yahoo.com
Mon Feb 27 15:52:43 EST 2012


Hi folks,

I remember having done this in the past but can't figure out how. I am trying to use the vtkScalarBarActor to show contour levels. The range for my scalars is let's say 0:100. Yet, the labels on the actor always go from 0 to 1. How do I get the scalar bar to show the right range?

The code is something along the lines of (loosely based on the ScalarBarActor example)

vtkXMLStructuredGridReader reader = new vtkXMLStructuredGridReader();
reader.SetFileName(file_name);
reader.Update();

vtkDataSet data = reader.GetOutputAsDataSet();

vtkLookupTable lut = new vtkLookupTable();
lut.SetNumberOfTableValues(25);
lut.SetHueRange (0.75,0);
lut.SetSaturationRange (1, 1);
lut.SetValueRange (1, 1);
double range[] = data.GetPointData().GetScalars().GetRange();
lut.SetRange(range);

lut.Build();

vtkDataSetMapper mapper = new vtkDataSetMapper();
mapper.SetInput(data);
mapper.ScalarVisibilityOn();

mapper.SetScalarModeToUsePointData();
mapper.SetColorModeToMapScalars();
mapper.SetLookupTable(lut);
vtkScalarBarActor bar = new vtkScalarBarActor();

bar.SetTitle(data_name);
bar.SetNumberOfLabels(5);
bar.SetLookupTable(lut);

Thanks!

--
Lubos
@particleincell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120227/49b6ba88/attachment.htm>


More information about the vtkusers mailing list