VTK
vtkScalarsToColors.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkScalarsToColors.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
48 #ifndef vtkScalarsToColors_h
49 #define vtkScalarsToColors_h
50 
51 #include "vtkCommonCoreModule.h" // For export macro
52 #include "vtkVariant.h" // Set/get annotation methods require variants.
53 #include "vtkObject.h"
54 
55 class vtkAbstractArray;
56 class vtkDataArray;
58 class vtkAbstractArray;
59 class vtkStringArray;
60 
61 
63 {
64 public:
66  void PrintSelf(ostream& os, vtkIndent indent);
68 
71  virtual int IsOpaque();
72 
75  virtual void Build() {}
76 
78 
79  virtual double *GetRange();
80  virtual void SetRange(double min, double max);
81  void SetRange(double rng[2])
82  {this->SetRange(rng[0],rng[1]);}
84 
87  virtual unsigned char *MapValue(double v);
88 
91  virtual void GetColor(double v, double rgb[3]);
92 
94 
96  double *GetColor(double v)
97  {this->GetColor(v,this->RGB); return this->RGB;}
99 
103  virtual double GetOpacity(double v);
104 
106 
109  double GetLuminance(double x)
110  {double rgb[3]; this->GetColor(x,rgb);
111  return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
113 
115 
119  virtual void SetAlpha(double alpha);
120  vtkGetMacro(Alpha,double);
122 
124 
138  virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
139  int component);
140  virtual vtkUnsignedCharArray *MapScalars(vtkAbstractArray *scalars, int colorMode,
141  int component);
143 
145 
148  vtkSetMacro(VectorMode, int);
149  vtkGetMacro(VectorMode, int);
154 
155 //BTX
156  enum VectorModes {
157  MAGNITUDE=0,
158  COMPONENT=1,
159  RGBCOLORS=2
160  };
161 //ETX
162 
163 
165 
167  vtkSetMacro(VectorComponent, int);
168  vtkGetMacro(VectorComponent, int);
170 
172 
177  vtkSetMacro(VectorSize, int);
178  vtkGetMacro(VectorSize, int);
180 
182 
187  void MapVectorsThroughTable(void *input, unsigned char *output,
188  int inputDataType, int numberOfValues,
189  int inputIncrement, int outputFormat,
190  int vectorComponent, int vectorSize);
191  void MapVectorsThroughTable(void *input, unsigned char *output,
192  int inputDataType, int numberOfValues,
193  int inputIncrement, int outputFormat)
194  { this->MapVectorsThroughTable(input, output, inputDataType, numberOfValues,
195  inputIncrement, outputFormat, -1, -1); }
197 
199 
206  unsigned char *output,
207  int outputFormat);
209  unsigned char *output)
210  {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
211  void MapScalarsThroughTable(void *input, unsigned char *output,
212  int inputDataType, int numberOfValues,
213  int inputIncrement,
214  int outputFormat)
215  {this->MapScalarsThroughTable2(input, output, inputDataType,
216  numberOfValues, inputIncrement, outputFormat);}
218 
220 
223  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
224  int inputDataType, int numberOfValues,
225  int inputIncrement,
226  int outputFormat);
228 
230  virtual void DeepCopy(vtkScalarsToColors *o);
231 
233 
235  virtual int UsingLogScale()
236  { return 0; }
238 
241 
243 
252  virtual void SetAnnotations( vtkAbstractArray* values, vtkStringArray* annotations );
256 
261 
265 
269 
273 
277 
280  virtual void GetAnnotationColor(const vtkVariant& val, double rgba[4]);
281 
285 
289 
300  virtual void GetIndexedColor(vtkIdType i, double rgba[4]);
301 
306 
308  virtual void ResetAnnotations();
309 
311 
316  vtkSetMacro(IndexedLookup,int);
317  vtkGetMacro(IndexedLookup,int);
318  vtkBooleanMacro(IndexedLookup,int);
320 
321 
323 
326  template<typename T> static
327  unsigned char ColorToUChar(T t)
328  {
329  return t;
330  }
331  template<typename T> static
332  void ColorToUChar(T t, unsigned char* dest)
333  {
334  *dest = ColorToUChar(t);
335  }
337 
338 
339 
340 protected:
343 
345 
354  void MapColorsToColors(void *input, unsigned char *output,
355  int inputDataType, int numberOfValues,
356  int numberOfComponents, int vectorSize,
357  int outputFormat);
359 
361 
365  vtkDataArray *colors, int numComp, int numTuples);
367 
368 
370 
372  void MapVectorsToMagnitude(void *input, double *output,
373  int inputDataType, int numberOfValues,
374  int numberOfComponents, int vectorSize);
376 
380 
383  virtual void UpdateAnnotatedValueMap();
384 
385  // Annotations of specific values.
388 
389  class vtkInternalAnnotatedValueMap;
390  vtkInternalAnnotatedValueMap* AnnotatedValueMap;
391 
393 
394  double Alpha;
395 
396  // How to map arrays with multiple components.
400 
401  // Obsolete, kept so subclasses will still compile
403 
404  unsigned char RGBABytes[4];
405 
406 private:
407  double RGB[3];
408  double InputRange[2];
409 
410  vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented.
411  void operator=(const vtkScalarsToColors&); // Not implemented.
412 };
413 
415 
418 template<> inline
419 unsigned char vtkScalarsToColors::ColorToUChar(double t)
420 {
421  return static_cast<unsigned char>(t*255 + 0.5);
422 }
423 template<> inline
425 {
426  return static_cast<unsigned char>(t*255 + 0.5);
427 }
429 
430 
431 #endif
vtkScalarsToColors::vtkScalarsToColors
vtkScalarsToColors()
vtkScalarsToColors::GetAnnotatedValue
vtkVariant GetAnnotatedValue(vtkIdType idx)
vtkScalarsToColors::SetAnnotation
virtual vtkIdType SetAnnotation(vtkVariant value, vtkStdString annotation)
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkVariant.h
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkScalarsToColors::ColorToUChar
static void ColorToUChar(T t, unsigned char *dest)
Definition: vtkScalarsToColors.h:332
vtkScalarsToColors::VectorModes
VectorModes
Definition: vtkScalarsToColors.h:156
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkScalarsToColors::MapColorsToColors
void MapColorsToColors(void *input, unsigned char *output, int inputDataType, int numberOfValues, int numberOfComponents, int vectorSize, int outputFormat)
vtkScalarsToColors::MapScalars
virtual vtkUnsignedCharArray * MapScalars(vtkDataArray *scalars, int colorMode, int component)
vtkScalarsToColors::MapValue
virtual unsigned char * MapValue(double v)
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:49
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkScalarsToColors::VectorComponent
int VectorComponent
Definition: vtkScalarsToColors.h:398
vtkgl::v
const GLdouble * v
Definition: vtkgl.h:11595
vtkScalarsToColors::RemoveAnnotation
virtual bool RemoveAnnotation(vtkVariant value)
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkScalarsToColors::IndexedLookup
int IndexedLookup
Definition: vtkScalarsToColors.h:392
vtkScalarsToColors::Build
virtual void Build()
Definition: vtkScalarsToColors.h:75
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkgl::input
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkScalarsToColors::VectorMode
int VectorMode
Definition: vtkScalarsToColors.h:397
vtkScalarsToColors::GetIndexedColor
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
vtkScalarsToColors::SetAlpha
virtual void SetAlpha(double alpha)
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:30
vtkgl::val
GLuint GLfloat * val
Definition: vtkgl.h:13789
vtkScalarsToColors::SetAnnotations
virtual void SetAnnotations(vtkAbstractArray *values, vtkStringArray *annotations)
vtkScalarsToColors::SetVectorModeToMagnitude
void SetVectorModeToMagnitude()
vtkScalarsToColors::MapVectorsThroughTable
void MapVectorsThroughTable(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
Definition: vtkScalarsToColors.h:191
vtkScalarsToColors::GetOpacity
virtual double GetOpacity(double v)
vtkScalarsToColors::GetNumberOfAnnotatedValues
vtkIdType GetNumberOfAnnotatedValues()
vtkScalarsToColors::ColorToUChar
static unsigned char ColorToUChar(T t)
Definition: vtkScalarsToColors.h:327
vtkgl::value
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
vtkScalarsToColors::MapScalarsThroughTable
void MapScalarsThroughTable(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
Definition: vtkScalarsToColors.h:211
vtkScalarsToColors::DeepCopy
virtual void DeepCopy(vtkScalarsToColors *o)
vtkCommonCoreModule.h
vtkgl::values
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
vtkScalarsToColors::SetVectorModeToComponent
void SetVectorModeToComponent()
vtkScalarsToColors::GetColor
double * GetColor(double v)
Definition: vtkScalarsToColors.h:96
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkScalarsToColors::SetAnnotation
virtual vtkIdType SetAnnotation(vtkStdString value, vtkStdString annotation)
vtkScalarsToColors::AnnotatedValues
vtkAbstractArray * AnnotatedValues
Definition: vtkScalarsToColors.h:386
vtkScalarsToColors::MapScalarsThroughTable
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output, int outputFormat)
vtkScalarsToColors::GetAnnotationColor
virtual void GetAnnotationColor(const vtkVariant &val, double rgba[4])
vtkVariant
A atomic type representing the union of many types.
Definition: vtkVariant.h:79
vtkScalarsToColors::ResetAnnotations
virtual void ResetAnnotations()
vtkScalarsToColors::~vtkScalarsToColors
~vtkScalarsToColors()
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkScalarsToColors::UsingLogScale
virtual int UsingLogScale()
Definition: vtkScalarsToColors.h:235
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:63
vtkScalarsToColors::MapVectorsToMagnitude
void MapVectorsToMagnitude(void *input, double *output, int inputDataType, int numberOfValues, int numberOfComponents, int vectorSize)
vtkScalarsToColors::SetRange
virtual void SetRange(double min, double max)
vtkObject.h
vtkScalarsToColors::GetColor
virtual void GetColor(double v, double rgb[3])
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:65
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkScalarsToColors::UpdateAnnotatedValueMap
virtual void UpdateAnnotatedValueMap()
vtkScalarsToColors::ConvertToRGBA
vtkUnsignedCharArray * ConvertToRGBA(vtkDataArray *colors, int numComp, int numTuples)
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkScalarsToColors::GetNumberOfAvailableColors
virtual vtkIdType GetNumberOfAvailableColors()
vtkScalarsToColors::GetAnnotation
vtkStdString GetAnnotation(vtkIdType idx)
vtkgl::alpha
GLclampf GLclampf GLclampf alpha
Definition: vtkgl.h:11313
vtkScalarsToColors::SetRange
void SetRange(double rng[2])
Definition: vtkScalarsToColors.h:81
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkScalarsToColors::GetRange
virtual double * GetRange()
vtkScalarsToColors::GetLuminance
double GetLuminance(double x)
Definition: vtkScalarsToColors.h:109
vtkScalarsToColors::MapVectorsThroughTable
void MapVectorsThroughTable(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat, int vectorComponent, int vectorSize)
VTK_RGBA
#define VTK_RGBA
Definition: vtkSystemIncludes.h:96
vtkScalarsToColors::GetAnnotatedValueIndexInternal
vtkIdType GetAnnotatedValueIndexInternal(vtkVariant &val)
vtkScalarsToColors::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkScalarsToColors::AnnotatedValueMap
vtkInternalAnnotatedValueMap * AnnotatedValueMap
Definition: vtkScalarsToColors.h:389
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:45
vtkScalarsToColors::MapScalarsThroughTable2
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
vtkScalarsToColors::Alpha
double Alpha
Definition: vtkScalarsToColors.h:394
vtkScalarsToColors::UseMagnitude
int UseMagnitude
Definition: vtkScalarsToColors.h:402
vtkStdString
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:48
vtkScalarsToColors::Annotations
vtkStringArray * Annotations
Definition: vtkScalarsToColors.h:387
vtkScalarsToColors::New
static vtkScalarsToColors * New()
vtkScalarsToColors::MapScalars
virtual vtkUnsignedCharArray * MapScalars(vtkAbstractArray *scalars, int colorMode, int component)
vtkScalarsToColors::GetAnnotatedValueIndex
vtkIdType GetAnnotatedValueIndex(vtkVariant val)
vtkScalarsToColors::MapScalarsThroughTable
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output)
Definition: vtkScalarsToColors.h:208
vtkScalarsToColors::SetVectorModeToRGBColors
void SetVectorModeToRGBColors()
vtkScalarsToColors::CheckForAnnotatedValue
virtual vtkIdType CheckForAnnotatedValue(vtkVariant value)
vtkScalarsToColors::VectorSize
int VectorSize
Definition: vtkScalarsToColors.h:399
vtkScalarsToColors::IsOpaque
virtual int IsOpaque()