VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 vtkDataArray;
57 class vtkAbstractArray;
58 class vtkStringArray;
59 
60 
62 {
63 public:
65  void PrintSelf(ostream& os, vtkIndent indent);
66  static vtkScalarsToColors *New();
67 
70  virtual int IsOpaque();
71 
73  virtual void Build() {}
74 
76 
77  virtual double *GetRange();
78  virtual void SetRange(double min, double max);
79  void SetRange(double rng[2])
80  {this->SetRange(rng[0],rng[1]);}
82 
85  virtual unsigned char *MapValue(double v);
86 
89  virtual void GetColor(double v, double rgb[3]);
90 
92 
94  double *GetColor(double v)
95  {this->GetColor(v,this->RGB); return this->RGB;}
97 
100  virtual double GetOpacity(double v);
101 
103 
106  double GetLuminance(double x)
107  {double rgb[3]; this->GetColor(x,rgb);
108  return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
110 
112 
116  virtual void SetAlpha(double alpha);
117  vtkGetMacro(Alpha,double);
119 
121 
130  virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
131  int component);
133 
135 
138  vtkSetMacro(VectorMode, int);
139  vtkGetMacro(VectorMode, int);
140  void SetVectorModeToMagnitude();
141  void SetVectorModeToComponent();
142  void SetVectorModeToRGBColors();
144 
145 //BTX
146  enum VectorModes {
147  MAGNITUDE=0,
148  COMPONENT=1,
149  RGBCOLORS=2
150  };
151 //ETX
152 
153 
155 
157  vtkSetMacro(VectorComponent, int);
158  vtkGetMacro(VectorComponent, int);
160 
162 
167  vtkSetMacro(VectorSize, int);
168  vtkGetMacro(VectorSize, int);
170 
172 
177  void MapVectorsThroughTable(void *input, unsigned char *output,
178  int inputDataType, int numberOfValues,
179  int inputIncrement, int outputFormat,
180  int vectorComponent, int vectorSize);
181  void MapVectorsThroughTable(void *input, unsigned char *output,
182  int inputDataType, int numberOfValues,
183  int inputIncrement, int outputFormat)
184  { this->MapVectorsThroughTable(input, output, inputDataType, numberOfValues,
185  inputIncrement, outputFormat, -1, -1); }
187 
189 
195  void MapScalarsThroughTable(vtkDataArray *scalars,
196  unsigned char *output,
197  int outputFormat);
199  unsigned char *output)
200  {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
201  void MapScalarsThroughTable(void *input, unsigned char *output,
202  int inputDataType, int numberOfValues,
203  int inputIncrement,
204  int outputFormat)
205  {this->MapScalarsThroughTable2(input, output, inputDataType,
206  numberOfValues, inputIncrement, outputFormat);}
208 
210 
213  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
214  int inputDataType, int numberOfValues,
215  int inputIncrement,
216  int outputFormat);
218 
220 
223  virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
224  vtkUnsignedCharArray *colors, int numComp, int numTuples);
226 
228  virtual void DeepCopy(vtkScalarsToColors *o);
229 
231 
233  virtual int UsingLogScale()
234  { return 0; }
236 
238  virtual vtkIdType GetNumberOfAvailableColors();
239 
241 
250  virtual void SetAnnotations( vtkAbstractArray* values, vtkStringArray* annotations );
251  vtkGetObjectMacro(AnnotatedValues,vtkAbstractArray);
252  vtkGetObjectMacro(Annotations,vtkStringArray);
254 
259  virtual vtkIdType SetAnnotation(vtkVariant value, vtkStdString annotation);
260 
262  virtual vtkIdType SetAnnotation(vtkStdString value, vtkStdString annotation);
263 
265  vtkIdType GetNumberOfAnnotatedValues();
266 
268  vtkVariant GetAnnotatedValue(vtkIdType idx);
269 
271  vtkStdString GetAnnotation(vtkIdType idx);
272 
274  virtual void GetAnnotationColor(const vtkVariant& val, double rgba[4]);
275 
277  vtkIdType GetAnnotatedValueIndex( vtkVariant val );
278 
280  vtkIdType GetAnnotatedValueIndexInternal(vtkVariant& val);
281 
293  virtual void GetIndexedColor(vtkIdType i, double rgba[4]);
294 
300  virtual bool RemoveAnnotation(vtkVariant value);
301 
303  virtual void ResetAnnotations();
304 
306 
311  vtkSetMacro(IndexedLookup,int);
312  vtkGetMacro(IndexedLookup,int);
313  vtkBooleanMacro(IndexedLookup,int);
315 
316 protected:
319 
321 
330  void MapColorsToColors(void *input, unsigned char *output,
331  int inputDataType, int numberOfValues,
332  int numberOfComponents, int vectorSize,
333  int outputFormat);
335 
337 
339  void MapVectorsToMagnitude(void *input, double *output,
340  int inputDataType, int numberOfValues,
341  int numberOfComponents, int vectorSize);
343 
345  virtual vtkIdType CheckForAnnotatedValue( vtkVariant value );
347  virtual void UpdateAnnotatedValueMap();
348 
349  // Annotations of specific values.
350  class vtkInternalAnnotatedValueMap;
353  vtkInternalAnnotatedValueMap* AnnotatedValueMap;
355 
356  double Alpha;
357 
358  // How to map arrays with multiple components.
362 
363  // Obsolete, kept so subclasses will still compile
365 
366 private:
367  double RGB[3];
368  unsigned char RGBABytes[4];
369  double InputRange[2];
370 
371  vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented.
372  void operator=(const vtkScalarsToColors&); // Not implemented.
373 };
374 
375 #endif
376 
377 
378 
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output)
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
abstract base class for most VTK objects
Definition: vtkObject.h:61
const GLdouble * v
Definition: vtkgl.h:11595
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
Abstract superclass for all arrays.
void SetRange(double rng[2])
#define VTKCOMMONCORE_EXPORT
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
a vtkAbstractArray subclass for strings
GLsizei const GLfloat * value
Definition: vtkgl.h:12021
int vtkIdType
Definition: vtkType.h:268
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
Superclass for mapping scalar values to colors.
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
GLboolean GLenum GLenum GLvoid * values
Definition: vtkgl.h:11354
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
void MapScalarsThroughTable(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
dynamic, self-adjusting array of unsigned char
#define VTK_RGBA
double * GetColor(double v)
vtkStringArray * Annotations
void MapVectorsThroughTable(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
virtual void Build()
GLclampf GLclampf GLclampf alpha
Definition: vtkgl.h:11313
static vtkObject * New()
vtkInternalAnnotatedValueMap * AnnotatedValueMap
vtkAbstractArray * AnnotatedValues
#define max(a, b)
double GetLuminance(double x)
virtual int UsingLogScale()
GLuint GLfloat * val
Definition: vtkgl.h:13789