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 
61 class VTKCOMMONCORE_EXPORT vtkScalarsToColors : public vtkObject
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 
245  virtual void SetAnnotations( vtkAbstractArray* values, vtkStringArray* annotations );
246  vtkGetObjectMacro(AnnotatedValues,vtkAbstractArray);
247  vtkGetObjectMacro(Annotations,vtkStringArray);
249 
254  virtual vtkIdType SetAnnotation(vtkVariant value, vtkStdString annotation);
255 
257  virtual vtkIdType SetAnnotation(vtkStdString value, vtkStdString annotation);
258 
260  vtkIdType GetNumberOfAnnotatedValues();
261 
263  vtkVariant GetAnnotatedValue(vtkIdType idx);
264 
266  vtkStdString GetAnnotation(vtkIdType idx);
267 
269  virtual void GetAnnotationColor(const vtkVariant& val, double rgba[4]);
270 
272  vtkIdType GetAnnotatedValueIndex( vtkVariant val );
273 
275  vtkIdType GetAnnotatedValueIndexInternal(vtkVariant& val);
276 
288  virtual void GetIndexedColor(vtkIdType i, double rgba[4]);
289 
295  virtual bool RemoveAnnotation(vtkVariant value);
296 
298  virtual void ResetAnnotations();
299 
301 
306  vtkSetMacro(IndexedLookup,int);
307  vtkGetMacro(IndexedLookup,int);
308  vtkBooleanMacro(IndexedLookup,int);
310 
311 protected:
314 
316 
325  void MapColorsToColors(void *input, unsigned char *output,
326  int inputDataType, int numberOfValues,
327  int numberOfComponents, int vectorSize,
328  int outputFormat);
330 
332 
334  void MapVectorsToMagnitude(void *input, double *output,
335  int inputDataType, int numberOfValues,
336  int numberOfComponents, int vectorSize);
338 
340  virtual vtkIdType CheckForAnnotatedValue( vtkVariant value );
342  virtual void UpdateAnnotatedValueMap();
343 
344  // Annotations of specific values.
345  class vtkInternalAnnotatedValueMap;
348  vtkInternalAnnotatedValueMap* AnnotatedValueMap;
350 
351  double Alpha;
352 
353  // How to map arrays with multiple components.
357 
358  // Obsolete, kept so subclasses will still compile
360 
361 private:
362  double RGB[3];
363  unsigned char RGBABytes[4];
364  double InputRange[2];
365 
366  vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented.
367  void operator=(const vtkScalarsToColors&); // Not implemented.
368 };
369 
370 #endif
371 
372 
373 
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
Abstract superclass for all arrays.
void SetRange(double rng[2])
a vtkAbstractArray subclass for strings
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.
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
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()
static vtkObject * New()
vtkInternalAnnotatedValueMap * AnnotatedValueMap
vtkAbstractArray * AnnotatedValues
double GetLuminance(double x)
virtual int UsingLogScale()