Skip to content

ScalarsToColors ​

Introduction ​

vtkScalarsToColors is a general-purpose base class for objects that convert scalars to colors. This include vtkLookupTable classes and color transfer functions. By itself, this class will simply rescale the scalars.

The scalar-to-color mapping can be augmented with an additional uniform alpha blend. This is used, for example, to blend a vtkActor's opacity with the lookup table values.

Specific scalar values may be annotated with text strings that will be included in color legends using setAnnotations, setAnnotation, getNumberOfAnnotatedValues, getAnnotatedValue, getAnnotation, removeAnnotation, and resetAnnotations.

This class also has a method for indicating that the set of annotated values form a categorical color map; by setting IndexedLookup to true, you indicate that the annotated values are the only valid values for which entries in the color table should be returned. In this mode, subclasses should then assign colors to annotated values by taking the modulus of an annotated value's index in the list of annotations with the number of colors in the table.

Methods ​

areScalarsOpaque ​

Returns false if scalars are Uint8 LA or RGBA with A < 255, otherwise rely on getAlpha() in case of direct mapping, otherwise return isOpaque()

ArgumentTypeRequiredDescription
scalarsvtkDataArrayYes
colorModeColorModeYes
componentInNumberYes

build ​

Perform any processing required (if any) before processing scalars.

checkForAnnotatedValue ​

ArgumentTypeRequiredDescription
valueYes

convertToRGBA ​

ArgumentTypeRequiredDescription
colorsYes
numCompYes
numTuplesYes

extend ​

Method used to decorate a given object (publicAPI+model) with vtkScalarsToColors characteristics.

ArgumentTypeRequiredDescription
publicAPIYesobject on which methods will be bounds (public)
modelYesobject on which data structure will be bounds (protected)
initialValuesIScalarsToColorsInitialValuesNo(default: {})

getAlpha ​

Specify an additional opacity (alpha) value to blend with.

getAnnotatedValue ​

ArgumentTypeRequiredDescription
idxNumberYes

getAnnotatedValueIndex ​

ArgumentTypeRequiredDescription
valYes

getAnnotatedValueIndexInternal ​

An unsafe version of vtkScalarsToColors.checkForAnnotatedValue for internal use (no pointer checks performed)

ArgumentTypeRequiredDescription
valueYes

getAnnotation ​

ArgumentTypeRequiredDescription
idxNumberYes

getAnnotationColor ​

ArgumentTypeRequiredDescription
valYes
rgbaYes

getIndexedColor ​

ArgumentTypeRequiredDescription
valYes
rgbaYes

getIndexedLookup ​

getMappingRange ​

getMappingRangeByReference ​

getNumberOfAnnotatedValues ​

Return the annotated value at a particular index in the list of annotations.

getNumberOfAvailableColors ​

Get the number of available colors for mapping to.

getRange ​

getVectorComponent ​

Get which component of a vector to map to colors.

getVectorMode ​

getVectorSize ​

isOpaque ​

luminanceAlphaToRGBA ​

ArgumentTypeRequiredDescription
newColorsYes
colorsYes
alphaNumberYes
convtFunYes

luminanceToRGBA ​

ArgumentTypeRequiredDescription
newColorsYes
colorsYes
alphaNumberYes
convtFunYes

mapScalars ​

Internal methods that map a data array into a 4-component, unsigned char RGBA array. The color mode determines the behavior of mapping. If ColorMode.DEFAULT is set, then unsigned char data arrays are treated as colors (and converted to RGBA if necessary); If ColorMode.DIRECT_SCALARS is set, then all arrays are treated as colors (integer types are clamped in the range 0-255, floating point arrays are clamped in the range 0.0-1.0. Note 'char' does not have enough values to represent a color so mapping this type is considered an error); otherwise, the data is mapped through this instance of ScalarsToColors. The component argument is used for data arrays with more than one component; it indicates which component to use to do the blending. When the component argument is -1, then the this object uses its own selected technique to change a vector into a scalar to map.

ArgumentTypeRequiredDescription
scalarsYes
colorModeColorModeYes
componentInNumberYes

mapVectorsThroughTable ​

Map a set of vector values through the table

ArgumentTypeRequiredDescription
inputYes
outputYes
outputFormatScalarMappingTargetYes
vectorComponentInYes
vectorSizeInNumberYes

mapVectorsToMagnitude ​

ArgumentTypeRequiredDescription
inputYes
outputYes
compsToUseNumberYes

newInstance ​

Method used to create a new instance of vtkScalarsToColors

ArgumentTypeRequiredDescription
initialValuesIScalarsToColorsInitialValuesNofor pre-setting some of its content

rGBAToRGBA ​

ArgumentTypeRequiredDescription
newColorsYes
colorsYes
alphaNumberYes
convtFunYes

rGBToRGBA ​

ArgumentTypeRequiredDescription
newColorsYes
colorsYes
alphaNumberYes
convtFunYes

removeAnnotation ​

Remove an existing entry from the list of annotated values.

ArgumentTypeRequiredDescription
valueYes

resetAnnotations ​

Remove all existing values and their annotations.

setAlpha ​

ArgumentTypeRequiredDescription
alphaNumberYes

setAnnotation ​

ArgumentTypeRequiredDescription
valueYes
annotationYes

setAnnotations ​

ArgumentTypeRequiredDescription
valuesYes
annotationsYes

setIndexedLookup ​

ArgumentTypeRequiredDescription
indexedLookupBooleanYes

setMappingRange ​

ArgumentTypeRequiredDescription
minNumberYes
maxNumberYes

setMappingRange ​

ArgumentTypeRequiredDescription
mappingRangeRangeYes

setMappingRangeFrom ​

ArgumentTypeRequiredDescription
mappingRangeRangeYes

setRange ​

ArgumentTypeRequiredDescription
minNumberYes
maxNumberYes

setVectorComponent ​

If the mapper does not select which component of a vector to map to colors, you can specify it here.

ArgumentTypeRequiredDescription
vectorComponentNumberYesThe value of the vector mode.

setVectorMode ​

Change mode that maps vectors by magnitude vs. component. If the mode is "RGBColors", then the vectors components are scaled to the range and passed directly as the colors.

ArgumentTypeRequiredDescription
vectorModeVectorModeYesThe value of the vector mode.

setVectorModeToComponent ​

Set vectorMode to VectorMode.COMPONENT

setVectorModeToMagnitude ​

Set vectorMode to VectorMode.MAGNITUDE

setVectorModeToRGBColors ​

When mapping vectors, consider only the number of components selected by vectorSize to be part of the vector, and ignore any other components. Set to -1 to map all components. If this is not set to -1, then you can use setVectorComponent to set which scalar component will be the first component in the vector to be mapped.

setVectorSize ​

When mapping vectors, consider only the number of components selected by VectorSize to be part of the vector, and ignore any other components.

ArgumentTypeRequiredDescription
vectorSizeNumberYesThe value of the vectorSize.

updateAnnotatedValueMap ​

Update the map from annotated values to indices in the array of annotations.

usingLogScale ​