VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkLookupTable.h
Go to the documentation of this file.
1  /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkLookupTable.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 =========================================================================*/
50 #ifndef __vtkLookupTable_h
51 #define __vtkLookupTable_h
52 
53 #include "vtkCommonCoreModule.h" // For export macro
54 #include "vtkScalarsToColors.h"
55 
56 #include "vtkUnsignedCharArray.h" // Needed for inline method
57 
58 #define VTK_RAMP_LINEAR 0
59 #define VTK_RAMP_SCURVE 1
60 #define VTK_RAMP_SQRT 2
61 #define VTK_SCALE_LINEAR 0
62 #define VTK_SCALE_LOG10 1
63 
65 {
66 public:
69  static vtkLookupTable *New();
70 
72  void PrintSelf(ostream& os, vtkIndent indent);
73 
76  virtual int IsOpaque();
77 
79  int Allocate(int sz=256, int ext=256);
80 
83  virtual void Build();
84 
90  virtual void ForceBuild();
91 
93 
100  vtkSetMacro(Ramp,int);
101  void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
102  void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
103  void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
104  vtkGetMacro(Ramp,int);
106 
108 
111  void SetScale(int scale);
112  void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
113  void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
114  vtkGetMacro(Scale,int);
116 
118 
123  void SetTableRange(double r[2]);
124  virtual void SetTableRange(double min, double max);
125  vtkGetVectorMacro(TableRange,double,2);
127 
129 
131  vtkSetVector2Macro(HueRange,double);
132  vtkGetVector2Macro(HueRange,double);
134 
136 
138  vtkSetVector2Macro(SaturationRange,double);
139  vtkGetVector2Macro(SaturationRange,double);
141 
143 
145  vtkSetVector2Macro(ValueRange,double);
146  vtkGetVector2Macro(ValueRange,double);
148 
150 
152  vtkSetVector2Macro(AlphaRange,double);
153  vtkGetVector2Macro(AlphaRange,double);
155 
157 
159  vtkSetVector4Macro(NanColor, double);
160  vtkGetVector4Macro(NanColor, double);
162 
165  unsigned char* GetNanColorAsUnsignedChars();
166 
168  unsigned char* MapValue(double v);
169 
172  void GetColor(double x, double rgb[3]);
173 
176  double GetOpacity(double v);
177 
183  virtual vtkIdType GetIndex(double v);
184 
186 
187  void SetNumberOfTableValues(vtkIdType number);
188  vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
190 
195  virtual void SetTableValue(vtkIdType indx, double rgba[4]);
196 
198 
200  virtual void SetTableValue(vtkIdType indx,
201  double r, double g, double b, double a=1.0);
203 
206  double *GetTableValue(vtkIdType id);
207 
210  void GetTableValue(vtkIdType id, double rgba[4]);
211 
213 
215  unsigned char *GetPointer(const vtkIdType id) {
216  return this->Table->GetPointer(4*id); };
218 
223  unsigned char *WritePointer(const vtkIdType id, const int number);
224 
226 
228  double *GetRange() { return this->GetTableRange(); };
229  void SetRange(double min, double max) { this->SetTableRange(min, max); };
230  void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
232 
233  //BTX
238  static void GetLogRange(const double range[2], double log_range[2]);
239 
241 
242  static double ApplyLogScale(double v, const double range[2],
243  const double log_range[2]);
244  //ETX
246 
248 
252  vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_ID_MAX);
253  vtkGetMacro(NumberOfColors,vtkIdType);
255 
257 
260  void SetTable(vtkUnsignedCharArray *);
261  vtkGetObjectMacro(Table,vtkUnsignedCharArray);
263 
265 
266  void MapScalarsThroughTable2(void *input, unsigned char *output,
267  int inputDataType, int numberOfValues,
268  int inputIncrement, int outputIncrement);
270 
272  void DeepCopy(vtkScalarsToColors *lut);
273 
275 
277  virtual int UsingLogScale()
278  {
279  return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
280  }
282 
285 
289  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
290 
291 protected:
292  vtkLookupTable(int sze=256, int ext=256);
293  ~vtkLookupTable();
294 
297  double TableRange[2];
298  double HueRange[2];
299  double SaturationRange[2];
300  double ValueRange[2];
301  double AlphaRange[2];
302  double NanColor[4];
303  int Scale;
304  int Ramp;
307  double RGBA[4]; //used during conversion process
308  unsigned char NanColorChar[4];
309 
312 
313 private:
314  vtkLookupTable(const vtkLookupTable&); // Not implemented.
315  void operator=(const vtkLookupTable&); // Not implemented.
316 };
317 
318 //----------------------------------------------------------------------------
319 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
320  const int number)
321 {
322  this->InsertTime.Modified();
323  return this->Table->WritePointer(4*id,4*number);
324 }
325 
326 #endif
327 
328 
329 
void SetRampToLinear()
GLboolean GLboolean GLboolean b
Definition: vtkgl.h:12312
vtkTimeStamp InsertTime
const GLdouble * v
Definition: vtkgl.h:11595
void SetRange(double min, double max)
virtual int UsingLogScale()
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkIdType NumberOfColors
vtkTimeStamp OpaqueFlagBuildTime
GLenum GLenum GLenum GLenum GLenum scale
Definition: vtkgl.h:15942
#define VTKCOMMONCORE_EXPORT
record modification and/or execution time
Definition: vtkTimeStamp.h:34
map scalar values into colors via a lookup table
void Modified()
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
int vtkIdType
Definition: vtkType.h:268
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
void SetScaleToLog10()
virtual unsigned char * MapValue(double v)
void SetRampToSCurve()
Superclass for mapping scalar values to colors.
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
virtual double GetOpacity(double v)
static vtkScalarsToColors * New()
double * GetRange()
virtual int IsOpaque()
void SetScaleToLinear()
#define VTK_SCALE_LOG10
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void GetColor(double v, double rgb[3])
vtkIdType GetNumberOfTableValues()
#define VTK_RAMP_SCURVE
unsigned char * GetPointer(const vtkIdType id)
dynamic, self-adjusting array of unsigned char
void SetRange(double rng[2])
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
unsigned char * WritePointer(const vtkIdType id, const int number)
vtkUnsignedCharArray * Table
#define VTK_RAMP_LINEAR
#define VTK_ID_MAX
Definition: vtkType.h:271
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
Get the "indexed color" assigned to an index.
GLboolean GLboolean g
Definition: vtkgl.h:12312
virtual void Build()
#define VTK_SCALE_LINEAR
#define VTK_RAMP_SQRT
vtkTimeStamp BuildTime
virtual void DeepCopy(vtkScalarsToColors *o)
void PrintSelf(ostream &os, vtkIndent indent)
GLenum GLint * range
Definition: vtkgl.h:14180
#define max(a, b)
virtual vtkIdType GetNumberOfAvailableColors()