VTK
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
vtkScalarsToColors Class Reference

Superclass for mapping scalar values to colors. More...

#include <vtkScalarsToColors.h>

Inheritance diagram for vtkScalarsToColors:
Inheritance graph
[legend]
Collaboration diagram for vtkScalarsToColors:
Collaboration graph
[legend]

List of all members.

Public Types

enum  VectorModes { MAGNITUDE = 0, COMPONENT = 1, RGBCOLORS = 2 }
typedef vtkObject Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkScalarsToColorsNewInstance () const
void PrintSelf (ostream &os, vtkIndent indent)
virtual int IsOpaque ()
virtual void Build ()
virtual unsigned char * MapValue (double v)
virtual void GetColor (double v, double rgb[3])
virtual double GetOpacity (double v)
virtual void DeepCopy (vtkScalarsToColors *o)
virtual vtkIdType GetNumberOfAvailableColors ()
virtual vtkIdType SetAnnotation (vtkVariant value, vtkStdString annotation)
 Add a new entry (or change an existing entry) to the list of annotated values.
virtual vtkIdType SetAnnotation (vtkStdString value, vtkStdString annotation)
 This variant of SetAnnotation accepts the value as a string so ParaView can treat annotations as string vector arrays.
vtkIdType GetNumberOfAnnotatedValues ()
 Return the annotated value at a particular index in the list of annotations.
vtkVariant GetAnnotatedValue (vtkIdType idx)
 Return the annotated value at a particular index in the list of annotations.
vtkStdString GetAnnotation (vtkIdType idx)
 Return the annotation at a particular index in the list of annotations.
virtual void GetAnnotationColor (const vtkVariant &val, double rgba[4])
 Obtain the color associated with a particular annotated value (or NanColor if unmatched).
vtkIdType GetAnnotatedValueIndex (vtkVariant val)
 Return the index of the given value in the list of annotated values (or -1 if not present).
vtkIdType GetAnnotatedValueIndexInternal (vtkVariant &val)
 Look up an index into the array of annotations given a value. Does no pointer checks. Returns -1 when val not present.
virtual void GetIndexedColor (vtkIdType i, double rgba[4])
 Get the "indexed color" assigned to an index.
virtual bool RemoveAnnotation (vtkVariant value)
 Remove an existing entry from the list of annotated values.
virtual void ResetAnnotations ()
 Remove all existing values and their annotations.
virtual doubleGetRange ()
virtual void SetRange (double min, double max)
void SetRange (double rng[2])
doubleGetColor (double v)
double GetLuminance (double x)
virtual void SetAlpha (double alpha)
virtual double GetAlpha ()
virtual vtkUnsignedCharArrayMapScalars (vtkDataArray *scalars, int colorMode, int component)
virtual void SetVectorMode (int)
virtual int GetVectorMode ()
void SetVectorModeToMagnitude ()
void SetVectorModeToComponent ()
void SetVectorModeToRGBColors ()
virtual void SetVectorComponent (int)
virtual int GetVectorComponent ()
virtual void SetVectorSize (int)
virtual int GetVectorSize ()
void MapVectorsThroughTable (void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat, int vectorComponent, int vectorSize)
void MapVectorsThroughTable (void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
void MapScalarsThroughTable (vtkDataArray *scalars, unsigned char *output, int outputFormat)
void MapScalarsThroughTable (vtkDataArray *scalars, unsigned char *output)
void MapScalarsThroughTable (void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
virtual void MapScalarsThroughTable2 (void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
virtual vtkUnsignedCharArrayConvertUnsignedCharToRGBA (vtkUnsignedCharArray *colors, int numComp, int numTuples)
virtual int UsingLogScale ()
virtual void SetAnnotations (vtkAbstractArray *values, vtkStringArray *annotations)
virtual vtkAbstractArrayGetAnnotatedValues ()
virtual vtkStringArrayGetAnnotations ()
virtual void SetIndexedLookup (int)
virtual int GetIndexedLookup ()
virtual void IndexedLookupOn ()
virtual void IndexedLookupOff ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkScalarsToColorsSafeDownCast (vtkObjectBase *o)
static vtkScalarsToColorsNew ()

Protected Member Functions

virtual vtkObjectBaseNewInstanceInternal () const
 vtkScalarsToColors ()
 ~vtkScalarsToColors ()
virtual vtkIdType CheckForAnnotatedValue (vtkVariant value)
 Allocate annotation arrays if needed, then return the index of the given value or -1 if not present.
virtual void UpdateAnnotatedValueMap ()
 Update the map from annotated values to indices in the array of annotations.
void MapColorsToColors (void *input, unsigned char *output, int inputDataType, int numberOfValues, int numberOfComponents, int vectorSize, int outputFormat)
void MapVectorsToMagnitude (void *input, double *output, int inputDataType, int numberOfValues, int numberOfComponents, int vectorSize)

Protected Attributes

vtkAbstractArrayAnnotatedValues
vtkStringArrayAnnotations
vtkInternalAnnotatedValueMap * AnnotatedValueMap
int IndexedLookup
double Alpha
int VectorMode
int VectorComponent
int VectorSize
int UseMagnitude

Detailed Description

Superclass for mapping scalar values to colors.

vtkScalarsToColors is a general purpose superclass 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 scalars 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.

See also:
vtkLookupTable vtkColorTransferFunction
Tests:
vtkScalarsToColors (Tests)

Definition at line 61 of file vtkScalarsToColors.h.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
MAGNITUDE 
COMPONENT 
RGBCOLORS 

Definition at line 146 of file vtkScalarsToColors.h.


Constructor & Destructor Documentation


Member Function Documentation

static int vtkScalarsToColors::IsTypeOf ( const char *  name) [static]

Return 1 if this class type is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, vtkDiscretizableColorTransferFunction, vtkLookupTableWithEnabling, vtkWindowLevelLookupTable, and vtkLogLookupTable.

virtual int vtkScalarsToColors::IsA ( const char *  name) [virtual]

Return 1 if this class is the same type of (or a subclass of) the named class. Returns 0 otherwise. This method works in combination with vtkTypeMacro found in vtkSetGet.h.

Reimplemented from vtkObject.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, vtkDiscretizableColorTransferFunction, vtkLookupTableWithEnabling, vtkWindowLevelLookupTable, and vtkLogLookupTable.

virtual vtkObjectBase* vtkScalarsToColors::NewInstanceInternal ( ) const [protected, virtual]
void vtkScalarsToColors::PrintSelf ( ostream &  os,
vtkIndent  indent 
) [virtual]

Methods invoked by print to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.

Reimplemented from vtkObject.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, vtkDiscretizableColorTransferFunction, vtkLookupTableWithEnabling, vtkWindowLevelLookupTable, and vtkLogLookupTable.

Create an object with Debug turned off, modified time initialized to zero, and reference counting on.

Reimplemented from vtkObject.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, vtkDiscretizableColorTransferFunction, vtkLookupTableWithEnabling, vtkWindowLevelLookupTable, and vtkLogLookupTable.

virtual int vtkScalarsToColors::IsOpaque ( ) [virtual]

Return true if all of the values defining the mapping have an opacity equal to 1. Default implementation return true.

Reimplemented in vtkLookupTable, and vtkDiscretizableColorTransferFunction.

virtual void vtkScalarsToColors::Build ( ) [inline, virtual]

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

Reimplemented in vtkLookupTable, vtkDiscretizableColorTransferFunction, and vtkWindowLevelLookupTable.

Definition at line 73 of file vtkScalarsToColors.h.

virtual double* vtkScalarsToColors::GetRange ( ) [virtual]

Sets/Gets the range of scalars which will be mapped.

Reimplemented in vtkLookupTable, and vtkColorTransferFunction.

virtual void vtkScalarsToColors::SetRange ( double  min,
double  max 
) [virtual]

Sets/Gets the range of scalars which will be mapped.

Reimplemented in vtkColorTransferFunction, and vtkLookupTable.

void vtkScalarsToColors::SetRange ( double  rng[2]) [inline]

Sets/Gets the range of scalars which will be mapped.

Reimplemented in vtkColorTransferFunction, and vtkLookupTable.

Definition at line 79 of file vtkScalarsToColors.h.

virtual unsigned char* vtkScalarsToColors::MapValue ( double  v) [virtual]

Map one value through the lookup table and return a color defined as a RGBA unsigned char tuple (4 bytes).

Reimplemented in vtkLookupTable, vtkColorTransferFunction, and vtkDiscretizableColorTransferFunction.

virtual void vtkScalarsToColors::GetColor ( double  v,
double  rgb[3] 
) [virtual]

Map one value through the lookup table and return the color as an RGB array of doubles between 0 and 1.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, and vtkDiscretizableColorTransferFunction.

Map one value through the lookup table and return the color as an RGB array of doubles between 0 and 1.

Reimplemented in vtkColorTransferFunction.

Definition at line 94 of file vtkScalarsToColors.h.

virtual double vtkScalarsToColors::GetOpacity ( double  v) [virtual]

Map one value through the lookup table and return the alpha value (the opacity) as a double between 0 and 1.

Reimplemented in vtkLookupTable, and vtkDiscretizableColorTransferFunction.

Map one value through the lookup table and return the luminance 0.3*red + 0.59*green + 0.11*blue as a double between 0 and 1. Returns the luminance value for the specified scalar value.

Definition at line 106 of file vtkScalarsToColors.h.

virtual void vtkScalarsToColors::SetAlpha ( double  alpha) [virtual]

Specify an additional opacity (alpha) value to blend with. Values != 1 modify the resulting color consistent with the requested form of the output. This is typically used by an actor in order to blend its opacity.

Reimplemented in vtkDiscretizableColorTransferFunction.

virtual double vtkScalarsToColors::GetAlpha ( ) [virtual]

Specify an additional opacity (alpha) value to blend with. Values != 1 modify the resulting color consistent with the requested form of the output. This is typically used by an actor in order to blend its opacity.

virtual vtkUnsignedCharArray* vtkScalarsToColors::MapScalars ( vtkDataArray scalars,
int  colorMode,
int  component 
) [virtual]

An internal method maps a data array into a 4-component, unsigned char RGBA array. The color mode determines the behavior of mapping. If VTK_COLOR_MODE_DEFAULT is set, then unsigned char data arrays are treated as colors (and converted to RGBA if necessary); otherwise, the data is mapped through this instance of ScalarsToColors. The offset 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.

Reimplemented in vtkDiscretizableColorTransferFunction.

virtual void vtkScalarsToColors::SetVectorMode ( int  ) [virtual]

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.

virtual int vtkScalarsToColors::GetVectorMode ( ) [virtual]

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.

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.

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.

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.

virtual void vtkScalarsToColors::SetVectorComponent ( int  ) [virtual]

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

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

virtual void vtkScalarsToColors::SetVectorSize ( int  ) [virtual]

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.

virtual int vtkScalarsToColors::GetVectorSize ( ) [virtual]

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.

void vtkScalarsToColors::MapVectorsThroughTable ( void *  input,
unsigned char *  output,
int  inputDataType,
int  numberOfValues,
int  inputIncrement,
int  outputFormat,
int  vectorComponent,
int  vectorSize 
)

Map vectors through the lookup table. Unlike MapScalarsThroughTable, this method will use the VectorMode to decide how to map vectors. The output format can be set to VTK_RGBA (4 components), VTK_RGB (3 components), VTK_LUMINANCE (1 component, greyscale), or VTK_LUMINANCE_ALPHA (2 components)

void vtkScalarsToColors::MapVectorsThroughTable ( void *  input,
unsigned char *  output,
int  inputDataType,
int  numberOfValues,
int  inputIncrement,
int  outputFormat 
) [inline]

Map vectors through the lookup table. Unlike MapScalarsThroughTable, this method will use the VectorMode to decide how to map vectors. The output format can be set to VTK_RGBA (4 components), VTK_RGB (3 components), VTK_LUMINANCE (1 component, greyscale), or VTK_LUMINANCE_ALPHA (2 components)

Definition at line 181 of file vtkScalarsToColors.h.

void vtkScalarsToColors::MapScalarsThroughTable ( vtkDataArray scalars,
unsigned char *  output,
int  outputFormat 
)

Map a set of scalars through the lookup table in a single operation. This method ignores the VectorMode and the VectorComponent. The output format can be set to VTK_RGBA (4 components), VTK_RGB (3 components), VTK_LUMINANCE (1 component, greyscale), or VTK_LUMINANCE_ALPHA (2 components) If not supplied, the output format defaults to RGBA.

void vtkScalarsToColors::MapScalarsThroughTable ( vtkDataArray scalars,
unsigned char *  output 
) [inline]

Map a set of scalars through the lookup table in a single operation. This method ignores the VectorMode and the VectorComponent. The output format can be set to VTK_RGBA (4 components), VTK_RGB (3 components), VTK_LUMINANCE (1 component, greyscale), or VTK_LUMINANCE_ALPHA (2 components) If not supplied, the output format defaults to RGBA.

Definition at line 198 of file vtkScalarsToColors.h.

void vtkScalarsToColors::MapScalarsThroughTable ( void *  input,
unsigned char *  output,
int  inputDataType,
int  numberOfValues,
int  inputIncrement,
int  outputFormat 
) [inline]

Map a set of scalars through the lookup table in a single operation. This method ignores the VectorMode and the VectorComponent. The output format can be set to VTK_RGBA (4 components), VTK_RGB (3 components), VTK_LUMINANCE (1 component, greyscale), or VTK_LUMINANCE_ALPHA (2 components) If not supplied, the output format defaults to RGBA.

Definition at line 201 of file vtkScalarsToColors.h.

virtual void vtkScalarsToColors::MapScalarsThroughTable2 ( void *  input,
unsigned char *  output,
int  inputDataType,
int  numberOfValues,
int  inputIncrement,
int  outputFormat 
) [virtual]

An internal method typically not used in applications. This should be a protected function, but it must be kept public for backwards compatibility. Never call this method directly.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, and vtkLookupTableWithEnabling.

virtual vtkUnsignedCharArray* vtkScalarsToColors::ConvertUnsignedCharToRGBA ( vtkUnsignedCharArray colors,
int  numComp,
int  numTuples 
) [virtual]

An internal method used to convert a color array to RGBA. The method instantiates a vtkUnsignedCharArray and returns it. The user is responsible for managing the memory.

virtual void vtkScalarsToColors::DeepCopy ( vtkScalarsToColors o) [virtual]

Copy the contents from another object.

Reimplemented in vtkLookupTable, and vtkColorTransferFunction.

virtual int vtkScalarsToColors::UsingLogScale ( ) [inline, virtual]

This should return 1 is the subclass is using log scale for mapping scalars to colors. Default implementation returns 0.

Reimplemented in vtkLookupTable, and vtkDiscretizableColorTransferFunction.

Definition at line 233 of file vtkScalarsToColors.h.

Get the number of available colors for mapping to.

Reimplemented in vtkLookupTable, vtkColorTransferFunction, and vtkDiscretizableColorTransferFunction.

virtual void vtkScalarsToColors::SetAnnotations ( vtkAbstractArray values,
vtkStringArray annotations 
) [virtual]

Set a list of discrete values, either as a categorical set of values (when IndexedLookup is true) or as a set of annotations to add to a scalar array (when IndexedLookup is false). The two arrays must both either be NULL or of the same length or the call will be ignored.

Set a list of discrete values, either as a categorical set of values (when IndexedLookup is true) or as a set of annotations to add to a scalar array (when IndexedLookup is false). The two arrays must both either be NULL or of the same length or the call will be ignored.

Set a list of discrete values, either as a categorical set of values (when IndexedLookup is true) or as a set of annotations to add to a scalar array (when IndexedLookup is false). The two arrays must both either be NULL or of the same length or the call will be ignored.

virtual vtkIdType vtkScalarsToColors::SetAnnotation ( vtkVariant  value,
vtkStdString  annotation 
) [virtual]

Add a new entry (or change an existing entry) to the list of annotated values.

Returns the index of value in the list of annotations.

virtual vtkIdType vtkScalarsToColors::SetAnnotation ( vtkStdString  value,
vtkStdString  annotation 
) [virtual]

This variant of SetAnnotation accepts the value as a string so ParaView can treat annotations as string vector arrays.

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

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

Return the annotation at a particular index in the list of annotations.

virtual void vtkScalarsToColors::GetAnnotationColor ( const vtkVariant val,
double  rgba[4] 
) [virtual]

Obtain the color associated with a particular annotated value (or NanColor if unmatched).

Return the index of the given value in the list of annotated values (or -1 if not present).

Look up an index into the array of annotations given a value. Does no pointer checks. Returns -1 when val not present.

virtual void vtkScalarsToColors::GetIndexedColor ( vtkIdType  i,
double  rgba[4] 
) [virtual]

Get the "indexed color" assigned to an index.

The index is used in IndexedLookup mode to assign colors to annotations (in the order the annotations were set). Subclasses must implement this and interpret how to treat the index. vtkLookupTable simply returns GetTableValue(index % this->GetNumberOfTableValues()). vtkColorTransferFunction returns the color assocated with node index % this->GetSize().

Note that implementations must set the opacity (alpha) component of the color, even if they do not provide opacity values in their colormaps. In that case, alpha = 1 should be used.

Reimplemented in vtkLookupTable, and vtkColorTransferFunction.

virtual bool vtkScalarsToColors::RemoveAnnotation ( vtkVariant  value) [virtual]

Remove an existing entry from the list of annotated values.

True is returned when the entry was actually removed (i.e., it existed before the call). Otherwise, false is returned.

virtual void vtkScalarsToColors::ResetAnnotations ( ) [virtual]

Remove all existing values and their annotations.

virtual void vtkScalarsToColors::SetIndexedLookup ( int  ) [virtual]

Set/get whether the lookup table is for categorical or ordinal data. The default is ordinal data; values not present in the lookup table will be assigned an interpolated color. When categorical data is present, only values in the lookup table will be considered valid; all other values will be assigned NanColor.

Set/get whether the lookup table is for categorical or ordinal data. The default is ordinal data; values not present in the lookup table will be assigned an interpolated color. When categorical data is present, only values in the lookup table will be considered valid; all other values will be assigned NanColor.

virtual void vtkScalarsToColors::IndexedLookupOn ( ) [virtual]

Set/get whether the lookup table is for categorical or ordinal data. The default is ordinal data; values not present in the lookup table will be assigned an interpolated color. When categorical data is present, only values in the lookup table will be considered valid; all other values will be assigned NanColor.

virtual void vtkScalarsToColors::IndexedLookupOff ( ) [virtual]

Set/get whether the lookup table is for categorical or ordinal data. The default is ordinal data; values not present in the lookup table will be assigned an interpolated color. When categorical data is present, only values in the lookup table will be considered valid; all other values will be assigned NanColor.

void vtkScalarsToColors::MapColorsToColors ( void *  input,
unsigned char *  output,
int  inputDataType,
int  numberOfValues,
int  numberOfComponents,
int  vectorSize,
int  outputFormat 
) [protected]

An internal method that assumes that the input already has the right colors, and only remaps the range to [0,255] and pads to the desired output format. If the input has 1 or 2 components, the first component will duplicated if the output format is RGB or RGBA. If the input has 2 or 4 components, the last component will be used for the alpha if the output format is RGBA or LuminanceAlpha. If the input has 3 or 4 components but the output is Luminance or LuminanceAlpha, then the components will be combined to compute the luminance. Any components past the fourth component will be ignored.

void vtkScalarsToColors::MapVectorsToMagnitude ( void *  input,
double output,
int  inputDataType,
int  numberOfValues,
int  numberOfComponents,
int  vectorSize 
) [protected]

An internal method for converting vectors to magnitudes, used as a preliminary step before doing magnitude mapping.

virtual vtkIdType vtkScalarsToColors::CheckForAnnotatedValue ( vtkVariant  value) [protected, virtual]

Allocate annotation arrays if needed, then return the index of the given value or -1 if not present.

virtual void vtkScalarsToColors::UpdateAnnotatedValueMap ( ) [protected, virtual]

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


Member Data Documentation

Definition at line 345 of file vtkScalarsToColors.h.

Definition at line 347 of file vtkScalarsToColors.h.

vtkInternalAnnotatedValueMap* vtkScalarsToColors::AnnotatedValueMap [protected]

Definition at line 348 of file vtkScalarsToColors.h.

Definition at line 349 of file vtkScalarsToColors.h.

Definition at line 351 of file vtkScalarsToColors.h.

Definition at line 354 of file vtkScalarsToColors.h.

Definition at line 355 of file vtkScalarsToColors.h.

Definition at line 356 of file vtkScalarsToColors.h.

Definition at line 359 of file vtkScalarsToColors.h.


The documentation for this class was generated from the following file: