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()
| Argument | Type | Required | Description |
|---|---|---|---|
scalars | vtkDataArray | Yes | |
colorMode | ColorMode | Yes | |
componentIn | Number | Yes |
build
Perform any processing required (if any) before processing scalars.
checkForAnnotatedValue
| Argument | Type | Required | Description |
|---|---|---|---|
value | Yes |
convertToRGBA
| Argument | Type | Required | Description |
|---|---|---|---|
colors | Yes | ||
numComp | Yes | ||
numTuples | Yes |
extend
Method used to decorate a given object (publicAPI+model) with vtkScalarsToColors characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IScalarsToColorsInitialValues | No | (default: {}) |
getAlpha
Specify an additional opacity (alpha) value to blend with.
getAnnotatedValue
| Argument | Type | Required | Description |
|---|---|---|---|
idx | Number | Yes |
getAnnotatedValueIndex
| Argument | Type | Required | Description |
|---|---|---|---|
val | Yes |
getAnnotatedValueIndexInternal
An unsafe version of vtkScalarsToColors.checkForAnnotatedValue for internal use (no pointer checks performed)
| Argument | Type | Required | Description |
|---|---|---|---|
value | Yes |
getAnnotation
| Argument | Type | Required | Description |
|---|---|---|---|
idx | Number | Yes |
getAnnotationColor
| Argument | Type | Required | Description |
|---|---|---|---|
val | Yes | ||
rgba | Yes |
getIndexedColor
| Argument | Type | Required | Description |
|---|---|---|---|
val | Yes | ||
rgba | Yes |
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
| Argument | Type | Required | Description |
|---|---|---|---|
newColors | Yes | ||
colors | Yes | ||
alpha | Number | Yes | |
convtFun | Yes |
luminanceToRGBA
| Argument | Type | Required | Description |
|---|---|---|---|
newColors | Yes | ||
colors | Yes | ||
alpha | Number | Yes | |
convtFun | Yes |
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.
| Argument | Type | Required | Description |
|---|---|---|---|
scalars | Yes | ||
colorMode | ColorMode | Yes | |
componentIn | Number | Yes |
mapVectorsThroughTable
Map a set of vector values through the table
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes | ||
output | Yes | ||
outputFormat | ScalarMappingTarget | Yes | |
vectorComponentIn | Yes | ||
vectorSizeIn | Number | Yes |
mapVectorsToMagnitude
| Argument | Type | Required | Description |
|---|---|---|---|
input | Yes | ||
output | Yes | ||
compsToUse | Number | Yes |
newInstance
Method used to create a new instance of vtkScalarsToColors
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IScalarsToColorsInitialValues | No | for pre-setting some of its content |
rGBAToRGBA
| Argument | Type | Required | Description |
|---|---|---|---|
newColors | Yes | ||
colors | Yes | ||
alpha | Number | Yes | |
convtFun | Yes |
rGBToRGBA
| Argument | Type | Required | Description |
|---|---|---|---|
newColors | Yes | ||
colors | Yes | ||
alpha | Number | Yes | |
convtFun | Yes |
removeAnnotation
Remove an existing entry from the list of annotated values.
| Argument | Type | Required | Description |
|---|---|---|---|
value | Yes |
resetAnnotations
Remove all existing values and their annotations.
setAlpha
| Argument | Type | Required | Description |
|---|---|---|---|
alpha | Number | Yes |
setAnnotation
| Argument | Type | Required | Description |
|---|---|---|---|
value | Yes | ||
annotation | Yes |
setAnnotations
| Argument | Type | Required | Description |
|---|---|---|---|
values | Yes | ||
annotations | Yes |
setIndexedLookup
| Argument | Type | Required | Description |
|---|---|---|---|
indexedLookup | Boolean | Yes |
setMappingRange
| Argument | Type | Required | Description |
|---|---|---|---|
min | Number | Yes | |
max | Number | Yes |
setMappingRange
| Argument | Type | Required | Description |
|---|---|---|---|
mappingRange | Range | Yes |
setMappingRangeFrom
| Argument | Type | Required | Description |
|---|---|---|---|
mappingRange | Range | Yes |
setRange
| Argument | Type | Required | Description |
|---|---|---|---|
min | Number | Yes | |
max | Number | Yes |
setVectorComponent
If the mapper does not select which component of a vector to map to colors, you can specify it here.
| Argument | Type | Required | Description |
|---|---|---|---|
vectorComponent | Number | Yes | The 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.
| Argument | Type | Required | Description |
|---|---|---|---|
vectorMode | VectorMode | Yes | The 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.
| Argument | Type | Required | Description |
|---|---|---|---|
vectorSize | Number | Yes | The value of the vectorSize. |
updateAnnotatedValueMap
Update the map from annotated values to indices in the array of annotations.