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 
241  void SetNumberOfTableValues(vtkIdType number);
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 
260  double *GetTableValue(vtkIdType id);
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 
306  vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_ID_MAX);
307  vtkGetMacro(NumberOfColors,vtkIdType);
309 
311 
314  void SetTable(vtkUnsignedCharArray *);
315  vtkGetObjectMacro(Table,vtkUnsignedCharArray);
317 
319 
320  void MapScalarsThroughTable2(void *input, unsigned char *output,
321  int inputDataType, int numberOfValues,
322  int inputIncrement, int outputIncrement);
324 
326  void DeepCopy(vtkScalarsToColors *lut);
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);
347  ~vtkLookupTable();
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 
374  void ResizeTableForSpecialColors();
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()
vtkTimeStamp InsertTime
void SetRange(double min, double max)
virtual int UsingLogScale()
vtkIdType NumberOfColors
vtkTimeStamp OpaqueFlagBuildTime
#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:247
static const vtkIdType NUMBER_OF_SPECIAL_COLORS
void SetScaleToLog10()
virtual unsigned char * MapValue(double v)
void SetRampToSCurve()
Superclass for mapping scalar values to colors.
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
static const vtkIdType NAN_COLOR_INDEX
unsigned char * GetPointer(const vtkIdType id)
dynamic, self-adjusting array of unsigned char
void SetRange(double rng[2])
unsigned char * WritePointer(const vtkIdType id, const int number)
vtkUnsignedCharArray * Table
#define VTK_RAMP_LINEAR
#define VTK_ID_MAX
Definition: vtkType.h:251
virtual void GetIndexedColor(vtkIdType i, double rgba[4])
virtual void Build()
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)
static const vtkIdType ABOVE_RANGE_COLOR_INDEX
#define max(a, b)
virtual vtkIdType GetNumberOfAvailableColors()