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 =========================================================================*/
37 #ifndef __vtkLookupTable_h
38 #define __vtkLookupTable_h
39 
40 #include "vtkScalarsToColors.h"
41 
42 #include "vtkUnsignedCharArray.h" // Needed for inline method
43 
44 #define VTK_RAMP_LINEAR 0
45 #define VTK_RAMP_SCURVE 1
46 #define VTK_RAMP_SQRT 2
47 #define VTK_SCALE_LINEAR 0
48 #define VTK_SCALE_LOG10 1
49 
51 {
52 public:
55  static vtkLookupTable *New();
56 
58  void PrintSelf(ostream& os, vtkIndent indent);
59 
62  virtual int IsOpaque();
63 
65  int Allocate(int sz=256, int ext=256);
66 
69  virtual void Build();
70 
76  virtual void ForceBuild();
77 
79 
86  vtkSetMacro(Ramp,int);
87  void SetRampToLinear() { this->SetRamp(VTK_RAMP_LINEAR); };
88  void SetRampToSCurve() { this->SetRamp(VTK_RAMP_SCURVE); };
89  void SetRampToSQRT() { this->SetRamp(VTK_RAMP_SQRT); };
90  vtkGetMacro(Ramp,int);
92 
94 
97  void SetScale(int scale);
98  void SetScaleToLinear() { this->SetScale(VTK_SCALE_LINEAR); };
99  void SetScaleToLog10() { this->SetScale(VTK_SCALE_LOG10); };
100  vtkGetMacro(Scale,int);
102 
104 
108  void SetTableRange(double r[2]);
109  virtual void SetTableRange(double min, double max);
110  vtkGetVectorMacro(TableRange,double,2);
112 
114 
116  vtkSetVector2Macro(HueRange,double);
117  vtkGetVector2Macro(HueRange,double);
119 
121 
123  vtkSetVector2Macro(SaturationRange,double);
124  vtkGetVector2Macro(SaturationRange,double);
126 
128 
130  vtkSetVector2Macro(ValueRange,double);
131  vtkGetVector2Macro(ValueRange,double);
133 
135 
137  vtkSetVector2Macro(AlphaRange,double);
138  vtkGetVector2Macro(AlphaRange,double);
140 
142 
144  vtkSetVector4Macro(NanColor, double);
145  vtkGetVector4Macro(NanColor, double);
147 
149  unsigned char *MapValue(double v);
150 
153  void GetColor(double x, double rgb[3]);
154 
157  double GetOpacity(double v);
158 
160  virtual vtkIdType GetIndex(double v);
161 
163 
164  void SetNumberOfTableValues(vtkIdType number);
165  vtkIdType GetNumberOfTableValues() { return this->NumberOfColors; };
167 
172  void SetTableValue(vtkIdType indx, double rgba[4]);
173 
176  void SetTableValue(vtkIdType indx, double r, double g, double b, double a=1.0);
177 
180  double *GetTableValue(vtkIdType id);
181 
184  void GetTableValue(vtkIdType id, double rgba[4]);
185 
187 
189  unsigned char *GetPointer(const vtkIdType id) {
190  return this->Table->GetPointer(4*id); };
192 
197  unsigned char *WritePointer(const vtkIdType id, const int number);
198 
200 
202  double *GetRange() { return this->GetTableRange(); };
203  void SetRange(double min, double max) { this->SetTableRange(min, max); };
204  void SetRange(double rng[2]) { this->SetRange(rng[0], rng[1]); };
206 
207  //BTX
212  static void GetLogRange(const double range[2], double log_range[2]);
213 
215 
216  static double ApplyLogScale(double v, const double range[2],
217  const double log_range[2]);
218  //ETX
220 
222 
226  vtkSetClampMacro(NumberOfColors,vtkIdType,2,VTK_LARGE_ID);
227  vtkGetMacro(NumberOfColors,vtkIdType);
229 
231 
234  void SetTable(vtkUnsignedCharArray *);
235  vtkGetObjectMacro(Table,vtkUnsignedCharArray);
237 
239 
240  void MapScalarsThroughTable2(void *input, unsigned char *output,
241  int inputDataType, int numberOfValues,
242  int inputIncrement, int outputIncrement);
244 
246  void DeepCopy(vtkLookupTable *lut);
247 
249 
251  virtual int UsingLogScale()
252  {
253  return (this->GetScale() == VTK_SCALE_LOG10)? 1 : 0;
254  }
256 
259 
260 protected:
261  vtkLookupTable(int sze=256, int ext=256);
262  ~vtkLookupTable();
263 
266  double TableRange[2];
267  double HueRange[2];
268  double SaturationRange[2];
269  double ValueRange[2];
270  double AlphaRange[2];
271  double NanColor[4];
272  int Scale;
273  int Ramp;
276  double RGBA[4]; //used during conversion process
277 
280 
281 private:
282  vtkLookupTable(const vtkLookupTable&); // Not implemented.
283  void operator=(const vtkLookupTable&); // Not implemented.
284 };
285 
286 //----------------------------------------------------------------------------
287 inline unsigned char *vtkLookupTable::WritePointer(const vtkIdType id,
288  const int number)
289 {
290  this->InsertTime.Modified();
291  return this->Table->WritePointer(4*id,4*number);
292 }
293 
294 #endif
295 
296 
297 
void SetRampToLinear()
vtkTimeStamp InsertTime
void SetRange(double min, double max)
virtual int UsingLogScale()
vtkIdType NumberOfColors
vtkTimeStamp OpaqueFlagBuildTime
virtual vtkIdType GetNumberOfAvailableColors()=0
record modification and/or execution time
Definition: vtkTimeStamp.h:33
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)=0
int vtkIdType
Definition: vtkType.h:255
virtual unsigned char * MapValue(double v)=0
void SetScaleToLog10()
void SetRampToSCurve()
Superclass for mapping scalar values into colors.
double * GetRange()
virtual int IsOpaque()
void SetScaleToLinear()
unsigned char * WritePointer(vtkIdType id, vtkIdType number)
#define VTK_SCALE_LOG10
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual double GetOpacity(double vtkNotUsed(v))
vtkIdType GetNumberOfTableValues()
#define VTK_RAMP_SCURVE
#define VTK_COMMON_EXPORT
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
virtual void GetColor(double v, double rgb[3])=0
void SetRampToSQRT()
#define VTK_LARGE_ID
Definition: vtkType.h:257
virtual void Build()
#define VTK_SCALE_LINEAR
#define VTK_RAMP_SQRT
static vtkObject * New()
vtkTimeStamp BuildTime
void PrintSelf(ostream &os, vtkIndent indent)