VTK
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 =========================================================================*/
59 #ifndef vtkLookupTable_h
60 #define vtkLookupTable_h
61 
62 #include "vtkCommonCoreModule.h" // For export macro
63 #include "vtkScalarsToColors.h"
64 
65 #include "vtkUnsignedCharArray.h" // Needed for inline method
66 
67 class vtkSimpleMutexLock;
68 
69 #define VTK_RAMP_LINEAR 0
70 #define VTK_RAMP_SCURVE 1
71 #define VTK_RAMP_SQRT 2
72 #define VTK_SCALE_LINEAR 0
73 #define VTK_SCALE_LOG10 1
74 
76 {
77 public:
79 
84  const static vtkIdType NAN_COLOR_INDEX;
87 
90  static vtkLookupTable *New();
91 
93  void PrintSelf(ostream& os, vtkIndent indent);
94 
97  virtual int IsOpaque();
98 
100  int Allocate(int sz=256, int ext=256);
101 
104  virtual void Build();
105 
111  virtual void ForceBuild();
112 
114 
121  vtkSetMacro(Ramp,int);
122  void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
123  void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
124  void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
125  vtkGetMacro(Ramp,int);
127 
129 
132  void SetScale(int scale);
133  void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
134  void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
135  vtkGetMacro(Scale,int);
137 
139 
144  void SetTableRange(double r[2]);
145  virtual void SetTableRange(double min, double max);
146  vtkGetVectorMacro(TableRange,double,2);
148 
150 
152  vtkSetVector2Macro(HueRange,double);
153  vtkGetVector2Macro(HueRange,double);
155 
157 
159  vtkSetVector2Macro(SaturationRange,double);
160  vtkGetVector2Macro(SaturationRange,double);
162 
164 
166  vtkSetVector2Macro(ValueRange,double);
167  vtkGetVector2Macro(ValueRange,double);
169 
171 
173  vtkSetVector2Macro(AlphaRange,double);
174  vtkGetVector2Macro(AlphaRange,double);
176 
178 
180  vtkSetVector4Macro(NanColor, double);
181  vtkGetVector4Macro(NanColor, double);
183 
186  unsigned char* GetNanColorAsUnsignedChars();
187 
189 
191  static void GetColorAsUnsignedChars(const double colorIn[4],
192  unsigned char colorOut[4]);
194 
196 
198  vtkSetVector4Macro(BelowRangeColor, double);
199  vtkGetVector4Macro(BelowRangeColor, double);
201 
203 
204  vtkSetMacro(UseBelowRangeColor, int);
205  vtkGetMacro(UseBelowRangeColor, int);
206  vtkBooleanMacro(UseBelowRangeColor, int);
208 
210 
212  vtkSetVector4Macro(AboveRangeColor, double);
213  vtkGetVector4Macro(AboveRangeColor, double);
215 
217 
218  vtkSetMacro(UseAboveRangeColor, int);
219  vtkGetMacro(UseAboveRangeColor, int);
220  vtkBooleanMacro(UseAboveRangeColor, int);
222 
224  unsigned char* MapValue(double v);
225 
228  void GetColor(double x, double rgb[3]);
229 
232  double GetOpacity(double v);
233 
239  virtual vtkIdType GetIndex(double v);
240 
242 
243  void SetNumberOfTableValues(vtkIdType number);
244  vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
246 
251  virtual void SetTableValue(vtkIdType indx, double rgba[4]);
252 
254 
256  virtual void SetTableValue(vtkIdType indx,
257  double r, double g, double b, double a=1.0);
259 
262  double *GetTableValue(vtkIdType id);
263 
266  void GetTableValue(vtkIdType id, double rgba[4]);
267 
269 
271  unsigned char *GetPointer(const vtkIdType id) {
272  return this->Table->GetPointer(4*id); };
274 
279  unsigned char *WritePointer(const vtkIdType id, const int number);
280 
282 
284  double *GetRange() { return this->GetTableRange(); };
285  void SetRange(double min, double max) { this->SetTableRange(min, max); };
286  void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
288 
289  //BTX
294  static void GetLogRange(const double range[2], double log_range[2]);
295 
297 
298  static double ApplyLogScale(double v, const double range[2],
299  const double log_range[2]);
300  //ETX
302 
304 
308  vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_ID_MAX);
309  vtkGetMacro(NumberOfColors,vtkIdType);
311 
313 
316  void SetTable(vtkUnsignedCharArray *);
319 
321 
322  void MapScalarsThroughTable2(void *input, unsigned char *output,
323  int inputDataType, int numberOfValues,
324  int inputIncrement, int outputIncrement);
326 
328  void DeepCopy(vtkScalarsToColors *lut);
329 
331 
333  virtual int UsingLogScale()
334  {
335  return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
336  }
338 
341 
345  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
346 
347 protected:
348  vtkLookupTable(int sze=256, int ext=256);
349  ~vtkLookupTable();
350 
353  double TableRange[2];
354  double HueRange[2];
355  double SaturationRange[2];
356  double ValueRange[2];
357  double AlphaRange[2];
358  double NanColor[4];
359  double BelowRangeColor[4];
361  double AboveRangeColor[4];
363 
364  int Scale;
365  int Ramp;
368  double RGBA[4]; //used during conversion process
369  unsigned char NanColorChar[4];
370 
373 
375 
376 private:
377  vtkLookupTable(const vtkLookupTable&); // Not implemented.
378  void operator=(const vtkLookupTable&); // Not implemented.
379 };
380 
381 //----------------------------------------------------------------------------
382 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
383  const int number)
384 {
385  this->InsertTime.Modified();
386  return this->Table->WritePointer(4*id,4*number);
387 }
388 
389 #endif
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
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
record modification and/or execution time
Definition: vtkTimeStamp.h:34
map scalar values into colors via a lookup table
void Modified()
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat)
vtkSimpleMutexLock * ResizeMutex
int vtkIdType
Definition: vtkType.h:281
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
static const vtkIdType NUMBER_OF_SPECIAL_COLORS
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
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
#define vtkSetVector4Macro(name, type)
Definition: vtkSetGet.h:312
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
#define vtkGetVector4Macro(name, type)
Definition: vtkSetGet.h:331
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
static const vtkIdType NAN_COLOR_INDEX
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 vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:260
#define VTK_RAMP_LINEAR
#define VTK_ID_MAX
Definition: vtkType.h:284
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
GLboolean GLboolean g
Definition: vtkgl.h:12312
virtual void Build()
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
static const vtkIdType BELOW_RANGE_COLOR_INDEX
#define VTK_SCALE_LINEAR
#define VTK_RAMP_SQRT
vtkTimeStamp BuildTime
virtual void DeepCopy(vtkScalarsToColors *o)
void PrintSelf(ostream &os, vtkIndent indent)
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:414
GLenum GLint * range
Definition: vtkgl.h:14180
static const vtkIdType ABOVE_RANGE_COLOR_INDEX
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
#define max(a, b)
virtual vtkIdType GetNumberOfAvailableColors()
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69