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 
50  virtual int IsOpaque();
51 
53  virtual void Build() {};
54 
56 
57  virtual double *GetRange() = 0;
58  virtual void SetRange(double min, double max) = 0;
59  void SetRange(double rng[2])
60  {this->SetRange(rng[0],rng[1]);}
62 
65  virtual unsigned char *MapValue(double v) = 0;
66 
69  virtual void GetColor(double v, double rgb[3]) = 0;
70 
72 
74  double *GetColor(double v)
75  {this->GetColor(v,this->RGB); return this->RGB;}
77 
79 
81  virtual double GetOpacity(double vtkNotUsed(v))
82  {return 1.0;}
84 
86 
89  double GetLuminance(double x)
90  {double rgb[3]; this->GetColor(x,rgb);
91  return static_cast<double>(rgb[0]*0.30 + rgb[1]*0.59 + rgb[2]*0.11);}
93 
95 
99  virtual void SetAlpha(double alpha);
100  vtkGetMacro(Alpha,double);
102 
104 
113  virtual vtkUnsignedCharArray *MapScalars(vtkDataArray *scalars, int colorMode,
114  int component);
116 
118 
119  vtkSetMacro(VectorMode, int);
120  vtkGetMacro(VectorMode, int);
121  void SetVectorModeToMagnitude();
122  void SetVectorModeToComponent();
124 
125 //BTX
126  enum VectorModes {
127  MAGNITUDE=0,
128  COMPONENT=1
129  };
130 //ETX
131 
132 
134 
136  vtkSetMacro(VectorComponent, int);
137  vtkGetMacro(VectorComponent, int);
139 
141 
146  void MapScalarsThroughTable(vtkDataArray *scalars,
147  unsigned char *output,
148  int outputFormat);
150  unsigned char *output)
151  {this->MapScalarsThroughTable(scalars,output,VTK_RGBA);}
153 
154 
156 
157  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
158  int inputDataType, int numberOfValues,
159  int inputIncrement,
160  int outputFormat) = 0;
162 
164 
167  virtual vtkUnsignedCharArray *ConvertUnsignedCharToRGBA(
168  vtkUnsignedCharArray *colors, int numComp, int numTuples);
170 
172 
174  virtual int UsingLogScale()
175  { return 0; }
177 
179  virtual vtkIdType GetNumberOfAvailableColors() = 0;
180 
181 protected:
184 
185  double Alpha;
186 
187  // How to map arrays with multiple components.
189  // Internal flag used to togle between vector and component mode.
190  // We need this flag because the mapper can override our mode, and
191  // I do not want to change the interface to the map scalars methods.
194 
195 private:
196  double RGB[3];
197 
198  vtkScalarsToColors(const vtkScalarsToColors&); // Not implemented.
199  void operator=(const vtkScalarsToColors&); // Not implemented.
200 };
201 
202 #endif
203 
204 
205 
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output)
abstract base class for most VTK objects
Definition: vtkObject.h:60
void SetRange(double rng[2])
int vtkIdType
Definition: vtkType.h:255
Superclass for mapping scalar values into colors.
virtual void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:37
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:53
virtual double GetOpacity(double vtkNotUsed(v))
#define VTK_COMMON_EXPORT
dynamic, self-adjusting array of unsigned char
#define VTK_RGBA
double * GetColor(double v)
virtual void Build()
double GetLuminance(double x)
virtual int UsingLogScale()