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 #define VTK_RAMP_LINEAR 0
68 #define VTK_RAMP_SCURVE 1
69 #define VTK_RAMP_SQRT 2
70 #define VTK_SCALE_LINEAR 0
71 #define VTK_SCALE_LOG10 1
72 
74 {
75 public:
77 
82  const static vtkIdType NAN_COLOR_INDEX;
85 
88  static vtkLookupTable *New();
89 
91  void PrintSelf(ostream& os, vtkIndent indent);
92 
95  virtual int IsOpaque();
96 
98  int Allocate(int sz=256, int ext=256);
99 
102  virtual void Build();
103 
109  virtual void ForceBuild();
110 
112 
119  vtkSetMacro(Ramp,int);
120  void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
121  void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
122  void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
123  vtkGetMacro(Ramp,int);
125 
127 
130  void SetScale(int scale);
131  void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
132  void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
133  vtkGetMacro(Scale,int);
135 
137 
142  void SetTableRange(double r[2]);
143  virtual void SetTableRange(double min, double max);
144  vtkGetVectorMacro(TableRange,double,2);
146 
148 
150  vtkSetVector2Macro(HueRange,double);
151  vtkGetVector2Macro(HueRange,double);
153 
155 
157  vtkSetVector2Macro(SaturationRange,double);
158  vtkGetVector2Macro(SaturationRange,double);
160 
162 
164  vtkSetVector2Macro(ValueRange,double);
165  vtkGetVector2Macro(ValueRange,double);
167 
169 
171  vtkSetVector2Macro(AlphaRange,double);
172  vtkGetVector2Macro(AlphaRange,double);
174 
176 
178  vtkSetVector4Macro(NanColor, double);
179  vtkGetVector4Macro(NanColor, double);
181 
184  unsigned char* GetNanColorAsUnsignedChars();
185 
187 
189  static void GetColorAsUnsignedChars(const double colorIn[4],
190  unsigned char colorOut[4]);
192 
194 
196  vtkSetVector4Macro(BelowRangeColor, double);
197  vtkGetVector4Macro(BelowRangeColor, double);
199 
201 
202  vtkSetMacro(UseBelowRangeColor, int);
203  vtkGetMacro(UseBelowRangeColor, int);
204  vtkBooleanMacro(UseBelowRangeColor, int);
206 
208 
210  vtkSetVector4Macro(AboveRangeColor, double);
211  vtkGetVector4Macro(AboveRangeColor, double);
213 
215 
216  vtkSetMacro(UseAboveRangeColor, int);
217  vtkGetMacro(UseAboveRangeColor, int);
218  vtkBooleanMacro(UseAboveRangeColor, int);
220 
222  unsigned char* MapValue(double v);
223 
226  void GetColor(double x, double rgb[3]);
227 
230  double GetOpacity(double v);
231 
237  virtual vtkIdType GetIndex(double v);
238 
240 
242  vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
244 
249  virtual void SetTableValue(vtkIdType indx, double rgba[4]);
250 
252 
254  virtual void SetTableValue(vtkIdType indx,
255  double r, double g, double b, double a=1.0);
257 
261 
264  void GetTableValue(vtkIdType id, double rgba[4]);
265 
267 
269  unsigned char *GetPointer(const vtkIdType id) {
270  return this->Table->GetPointer(4*id); };
272 
277  unsigned char *WritePointer(const vtkIdType id, const int number);
278 
280 
282  double *GetRange() { return this->GetTableRange(); };
283  void SetRange(double min, double max) { this->SetTableRange(min, max); };
284  void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
286 
287  //BTX
292  static void GetLogRange(const double range[2], double log_range[2]);
293 
295 
296  static double ApplyLogScale(double v, const double range[2],
297  const double log_range[2]);
298  //ETX
300 
302 
307  vtkGetMacro(NumberOfColors,vtkIdType);
309 
311 
317 
319 
320  void MapScalarsThroughTable2(void *input, unsigned char *output,
321  int inputDataType, int numberOfValues,
322  int inputIncrement, int outputIncrement);
324 
327 
329 
331  virtual int UsingLogScale()
332  {
333  return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
334  }
336 
339 
343  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
344 
345 protected:
346  vtkLookupTable(int sze=256, int ext=256);
348 
351  double TableRange[2];
352  double HueRange[2];
353  double SaturationRange[2];
354  double ValueRange[2];
355  double AlphaRange[2];
356  double NanColor[4];
357  double BelowRangeColor[4];
359  double AboveRangeColor[4];
361 
362  int Scale;
363  int Ramp;
366  double RGBA[4]; //used during conversion process
367  unsigned char NanColorChar[4];
368 
371 
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
vtkLookupTable::WritePointer
unsigned char * WritePointer(const vtkIdType id, const int number)
Definition: vtkLookupTable.h:382
vtkGetObjectMacro
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:232
vtkLookupTable::GetRange
double * GetRange()
Definition: vtkLookupTable.h:282
VTKCOMMONCORE_EXPORT
#define VTKCOMMONCORE_EXPORT
Definition: vtkCommonCoreModule.h:15
vtkLookupTable::NumberOfColors
vtkIdType NumberOfColors
Definition: vtkLookupTable.h:349
vtkSetVector2Macro
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:254
vtkgl::b
GLboolean GLboolean GLboolean b
Definition: vtkgl.h:12312
vtkLookupTable::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkLookupTable::IsOpaque
virtual int IsOpaque()
vtkLookupTable::OpaqueFlagBuildTime
vtkTimeStamp OpaqueFlagBuildTime
Definition: vtkLookupTable.h:370
vtkLookupTable::GetTableValue
double * GetTableValue(vtkIdType id)
vtkGetVector2Macro
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:270
vtkLookupTable::GetNanColorAsUnsignedChars
unsigned char * GetNanColorAsUnsignedChars()
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkLookupTable::NAN_COLOR_INDEX
static const vtkIdType NAN_COLOR_INDEX
Definition: vtkLookupTable.h:82
vtkLookupTable::New
static vtkLookupTable * New()
vtkLookupTable::SetTableValue
virtual void SetTableValue(vtkIdType indx, double rgba[4])
vtkLookupTable::vtkLookupTable
vtkLookupTable(int sze=256, int ext=256)
vtkLookupTable::ABOVE_RANGE_COLOR_INDEX
static const vtkIdType ABOVE_RANGE_COLOR_INDEX
Definition: vtkLookupTable.h:81
vtkLookupTable::ResizeTableForSpecialColors
void ResizeTableForSpecialColors()
vtkLookupTable::BELOW_RANGE_COLOR_INDEX
static const vtkIdType BELOW_RANGE_COLOR_INDEX
Definition: vtkLookupTable.h:80
vtkLookupTable::Build
virtual void Build()
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:35
VTK_RAMP_LINEAR
#define VTK_RAMP_LINEAR
Definition: vtkLookupTable.h:67
vtkgl::scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: vtkgl.h:15942
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:49
vtkLookupTable::InsertTime
vtkTimeStamp InsertTime
Definition: vtkLookupTable.h:364
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkLookupTable::SetScaleToLog10
void SetScaleToLog10()
Definition: vtkLookupTable.h:132
vtkLookupTable::SetTableRange
void SetTableRange(double r[2])
vtkLookupTable::GetPointer
unsigned char * GetPointer(const vtkIdType id)
Definition: vtkLookupTable.h:269
vtkgl::v
const GLdouble * v
Definition: vtkgl.h:11595
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkLookupTable::Scale
int Scale
Definition: vtkLookupTable.h:362
vtkLookupTable::GetColorAsUnsignedChars
static void GetColorAsUnsignedChars(const double colorIn[4], unsigned char colorOut[4])
vtkLookupTable::ApplyLogScale
static double ApplyLogScale(double v, const double range[2], const double log_range[2])
vtkLookupTable::SetTable
void SetTable(vtkUnsignedCharArray *)
vtkLookupTable::MapValue
unsigned char * MapValue(double v)
vtkLookupTable::SetRampToSCurve
void SetRampToSCurve()
Definition: vtkLookupTable.h:121
vtkgl::input
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkGetVectorMacro
#define vtkGetVectorMacro(name, type, count)
Definition: vtkSetGet.h:424
vtkgl::range
GLenum GLint * range
Definition: vtkgl.h:14180
vtkLookupTable::~vtkLookupTable
~vtkLookupTable()
vtkLookupTable::ForceBuild
virtual void ForceBuild()
vtkLookupTable::DeepCopy
void DeepCopy(vtkScalarsToColors *lut)
vtkLookupTable::MapScalarsThroughTable2
void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputIncrement)
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:30
vtkLookupTable::NUMBER_OF_SPECIAL_COLORS
static const vtkIdType NUMBER_OF_SPECIAL_COLORS
Definition: vtkLookupTable.h:83
vtkSetClampMacro
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:143
vtkLookupTable::OpaqueFlag
int OpaqueFlag
Definition: vtkLookupTable.h:369
vtkLookupTable::GetNumberOfAvailableColors
virtual vtkIdType GetNumberOfAvailableColors()
vtkTimeStamp::Modified
void Modified()
vtkLookupTable::SetTableRange
virtual void SetTableRange(double min, double max)
vtkLookupTable::Ramp
int Ramp
Definition: vtkLookupTable.h:363
vtkCommonCoreModule.h
vtkLookupTable::UseAboveRangeColor
int UseAboveRangeColor
Definition: vtkLookupTable.h:360
vtkLookupTable::SetScaleToLinear
void SetScaleToLinear()
Definition: vtkLookupTable.h:131
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkLookupTable::SetTableValue
virtual void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0)
vtkScalarsToColors.h
vtkLookupTable::GetOpacity
double GetOpacity(double v)
vtkLookupTable::SetRampToSQRT
void SetRampToSQRT()
Definition: vtkLookupTable.h:122
vtkUnsignedCharArray.h
vtkGetMacro
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:93
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:63
vtkLookupTable::GetTableValue
void GetTableValue(vtkIdType id, double rgba[4])
vtkLookupTable::SetScale
void SetScale(int scale)
vtkgl::a
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
vtkLookupTable::SetRange
void SetRange(double min, double max)
Definition: vtkLookupTable.h:283
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
vtkLookupTable::GetNumberOfTableValues
vtkIdType GetNumberOfTableValues()
Definition: vtkLookupTable.h:242
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:74
vtkSetVector4Macro
#define vtkSetVector4Macro(name, type)
Definition: vtkSetGet.h:322
vtkLookupTable::UseBelowRangeColor
int UseBelowRangeColor
Definition: vtkLookupTable.h:358
vtkgl::r
GLdouble GLdouble GLdouble r
Definition: vtkgl.h:11610
vtkgl::g
GLboolean GLboolean g
Definition: vtkgl.h:12312
vtkLookupTable::Allocate
int Allocate(int sz=256, int ext=256)
vtkLookupTable::BuildTime
vtkTimeStamp BuildTime
Definition: vtkLookupTable.h:365
VTK_RAMP_SQRT
#define VTK_RAMP_SQRT
Definition: vtkLookupTable.h:69
vtkLookupTable::GetIndexedColor
virtual void GetIndexedColor(vtkIdType idx, double rgba[4])
VTK_ID_MAX
#define VTK_ID_MAX
Definition: vtkType.h:278
vtkLookupTable::UsingLogScale
virtual int UsingLogScale()
Definition: vtkLookupTable.h:331
vtkLookupTable::GetLogRange
static void GetLogRange(const double range[2], double log_range[2])
vtkLookupTable::GetColor
void GetColor(double x, double rgb[3])
vtkLookupTable::SetNumberOfTableValues
void SetNumberOfTableValues(vtkIdType number)
VTK_RAMP_SCURVE
#define VTK_RAMP_SCURVE
Definition: vtkLookupTable.h:68
vtkLookupTable::Table
vtkUnsignedCharArray * Table
Definition: vtkLookupTable.h:350
VTK_SCALE_LOG10
#define VTK_SCALE_LOG10
Definition: vtkLookupTable.h:71
vtkLookupTable::SetRampToLinear
void SetRampToLinear()
Definition: vtkLookupTable.h:120
vtkGetVector4Macro
#define vtkGetVector4Macro(name, type)
Definition: vtkSetGet.h:341
vtkLookupTable::SetRange
void SetRange(double rng[2])
Definition: vtkLookupTable.h:284
VTK_SCALE_LINEAR
#define VTK_SCALE_LINEAR
Definition: vtkLookupTable.h:70
vtkLookupTable::GetIndex
virtual vtkIdType GetIndex(double v)