[vtkusers] Reverse color in vtkScalarsToColors?

BBerco bebe0705 at colorado.edu
Sun Dec 4 19:33:13 EST 2016

Hi all,

I am using a vtkColorBarActor provided with an instance of
vtkScalarsToColors obtained from a vtkPolyDataMapper to display a range of
scalar values shown on the vtkPolyData connected to the mapper.

My problem is that the maximum scalar value (i.e the max in "surface_data"
below) corresponds to the blue end of the colorbar, while the minimum scalar
value is associated with its red end. 

I have been looking for a way to reverse this behavior (so as to have the
maximum value matched with the red and the minimum with the blue), to no
avail. I thought I had found what I was looking for  there
, but this was unsuccessful as the GetLookupTable method returns an instance
of vtkScalarsToColors and not vtkLookUpTable...

Any suggestions?


ps: below is how I construct the colorbar from the input data mapper
associated with the polydata 
the data corresponds to

	vtkSmartPointer<vtkActor> shape_actor = this -> parent ->

	shape_actor -> GetMapper() -> SetScalarRange(min_magnitude, max_magnitude);

	shape_actor -> GetMapper() -> GetInput() -> GetCellData() ->
	shape_actor -> GetMapper() -> ScalarVisibilityOn();
	shape_actor -> GetMapper() -> SetScalarModeToUseCellData();

	vtkSmartPointer<vtkScalarBarActor> scalarBar =

	scalarBar -> SetLookupTable(shape_actor -> GetMapper() ->
	scalarBar -> SetTitle("Orthonormal acceleration magnitude (m/s^2)");
	scalarBar -> SetUnconstrainedFontSize (true);
	scalarBar -> GetTitleTextProperty() -> SetFontSize(10);
	scalarBar -> GetLabelTextProperty() -> SetFontSize(10);
	scalarBar -> SetNumberOfLabels(4);

	this -> parent -> get_renderer() -> AddActor2D(scalarBar);
	this -> parent -> qvtkWidget -> GetRenderWindow() -> Render();

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

More information about the vtkusers mailing list