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 =========================================================================*/
34 #ifndef __vtkScalarsToColors_h
35 #define __vtkScalarsToColors_h
36 
37 #include "vtkObject.h"
38 
39 class vtkDataArray;
41 
43 {
44 public:
46  void PrintSelf(ostream& os, vtkIndent indent);
47  static vtkScalarsToColors *New();
48 
51  virtual int IsOpaque();
52 
54  virtual void Build() {};
55 
57 
58  virtual double *GetRange();
59  virtual void SetRange(double min, double max);
60  void SetRange(double rng[2])
61  {this->SetRange(rng[0],rng[1]);}
63 
66  virtual unsigned char *MapValue(double v);
67 
70  virtual void GetColor(double v, double rgb[3]);
71 
73 
75  double *GetColor(double v)
76  {this->GetColor(v,this->RGB); return this->RGB;}
78 
81  virtual double GetOpacity(double v);
82 
84 
87  double GetLuminance(double x)
88  {double rgb[3]; this->GetColor(x,rgb);
89  return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
91 
93 
97  virtual void SetAlpha(double alpha);
98  vtkGetMacro(Alpha,double);
100 
102 
111  virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
112  int component);
114 
116 
119  vtkSetMacro(VectorMode, int);
120  vtkGetMacro(VectorMode, int);
121  void SetVectorModeToMagnitude();
122  void SetVectorModeToComponent();
123  void SetVectorModeToRGBColors();
125 
126 //BTX
127  enum VectorModes {
128  MAGNITUDE=0,
129  COMPONENT=1,
130  RGBCOLORS=2
131  };
132 //ETX
133 
134 
136 
138  vtkSetMacro(VectorComponent, int);
139  vtkGetMacro(VectorComponent, int);
141 
143 
148  vtkSetMacro(VectorSize, int);
149  vtkGetMacro(VectorSize, int);
151 
153 
158  void MapVectorsThroughTable(void *input, unsigned char *output,
159  int inputDataType, int numberOfValues,
160  int inputIncrement, int outputFormat,
161  int vectorComponent, int vectorSize);
162  void MapVectorsThroughTable(void *input, unsigned char *output,
163  int inputDataType, int numberOfValues,
164  int inputIncrement, int outputFormat)
165  { this->MapVectorsThroughTable(input, output, inputDataType, numberOfValues,
166  inputIncrement, outputFormat, -1, -1); }
168 
170 
176  void MapScalarsThroughTable(vtkDataArray *scalars,
177  unsigned char *output,
178  int outputFormat);
179  void MapScalarsThroughTable(vtkDataArray *scalars,
180  unsigned char *output)
181  {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
182  void MapScalarsThroughTable(void *input, unsigned char *output,
183  int inputDataType, int numberOfValues,
184  int inputIncrement,
185  int outputFormat)
186  {this->MapScalarsThroughTable2(input, output, inputDataType,
187  numberOfValues, inputIncrement, outputFormat);}
189 
191 
194  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
195  int inputDataType, int numberOfValues,
196  int inputIncrement,
197  int outputFormat);
199 
201 
204  virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
205  vtkUnsignedCharArray *colors, int numComp, int numTuples);
207 
209  virtual void DeepCopy(vtkScalarsToColors *o);
210 
212 
214  virtual int UsingLogScale()
215  { return 0; }
217 
219  virtual vtkIdType GetNumberOfAvailableColors();
220 
221 protected:
224 
226 
235  void MapColorsToColors(void *input, unsigned char *output,
236  int inputDataType, int numberOfValues,
237  int numberOfComponents, int vectorSize,
238  int outputFormat);
240 
242 
244  void MapVectorsToMagnitude(void *input, double *output,
245  int inputDataType, int numberOfValues,
246  int numberOfComponents, int vectorSize);
248 
249  double Alpha;
250 
251  // How to map arrays with multiple components.
255 
256  // Obsolete, kept so subclasses will still compile
258 
259 private:
260  double RGB[3];
261  unsigned char RGBABytes[4];
262  double InputRange[2];
263 
264  vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented.
265  void operator=(const vtkScalarsToColors&); // Not implemented.
266 };
267 
268 #endif
269 
270 
271