VTK
vtkColorTransferFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkColorTransferFunction.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 =========================================================================*/
42 #ifndef vtkColorTransferFunction_h
43 #define vtkColorTransferFunction_h
44 
45 #include "vtkRenderingCoreModule.h" // For export macro
46 #include "vtkScalarsToColors.h"
47 
48 class vtkColorTransferFunctionInternals;
49 
50 #define VTK_CTF_RGB 0
51 #define VTK_CTF_HSV 1
52 #define VTK_CTF_LAB 2
53 #define VTK_CTF_DIVERGING 3
54 
55 #define VTK_CTF_LINEAR 0
56 #define VTK_CTF_LOG10 1
57 
58 class VTKRENDERINGCORE_EXPORT vtkColorTransferFunction : public vtkScalarsToColors
59 {
60 public:
65 
69  void PrintSelf(ostream& os, vtkIndent indent);
70 
74  int GetSize();
75 
77 
83  int AddRGBPoint( double x, double r, double g, double b );
84  int AddRGBPoint( double x, double r, double g, double b,
85  double midpoint, double sharpness );
86  int AddHSVPoint( double x, double h, double s, double v );
87  int AddHSVPoint( double x, double h, double s, double v,
88  double midpoint, double sharpness );
89  int RemovePoint( double x );
91 
93 
97  void AddRGBSegment( double x1, double r1, double g1, double b1,
98  double x2, double r2, double g2, double b2 );
99  void AddHSVSegment( double x1, double h1, double s1, double v1,
100  double x2, double h2, double s2, double v2 );
102 
107 
111  double *GetColor(double x) {
112  return vtkScalarsToColors::GetColor(x); }
113  void GetColor(double x, double rgb[3]);
114 
116 
119  double GetRedValue( double x );
120  double GetGreenValue( double x );
121  double GetBlueValue( double x );
123 
125 
130  int GetNodeValue( int index, double val[6] );
131  int SetNodeValue( int index, double val[6] );
133 
137  virtual unsigned char *MapValue(double v);
138 
140 
143  vtkGetVector2Macro( Range, double );
145 
151  int AdjustRange(double range[2]);
152 
154 
160  void GetTable( double x1, double x2, int n, double* table );
161  void GetTable( double x1, double x2, int n, float* table );
162  const unsigned char *GetTable( double x1, double x2, int n );
164 
174  void BuildFunctionFromTable( double x1, double x2, int size, double *table );
175 
177 
185  vtkSetClampMacro( Clamping, int, 0, 1 );
186  vtkGetMacro( Clamping, int );
187  vtkBooleanMacro( Clamping, int );
189 
191 
200  vtkSetClampMacro( ColorSpace, int, VTK_CTF_RGB, VTK_CTF_DIVERGING );
201  void SetColorSpaceToRGB(){this->SetColorSpace(VTK_CTF_RGB);};
202  void SetColorSpaceToHSV(){this->SetColorSpace(VTK_CTF_HSV);};
203  void SetColorSpaceToLab(){this->SetColorSpace(VTK_CTF_LAB);};
204  void SetColorSpaceToDiverging(){this->SetColorSpace(VTK_CTF_DIVERGING);}
205  vtkGetMacro( ColorSpace, int );
206  vtkSetMacro(HSVWrap, int);
207  vtkGetMacro(HSVWrap, int);
208  vtkBooleanMacro(HSVWrap, int);
210 
212 
217  vtkSetMacro(Scale,int);
218  void SetScaleToLinear() { this->SetScale(VTK_CTF_LINEAR); };
219  void SetScaleToLog10() { this->SetScale(VTK_CTF_LOG10); };
220  vtkGetMacro(Scale,int);
222 
224 
229  vtkSetVector3Macro(NanColor, double);
230  vtkGetVector3Macro(NanColor, double);
232 
234 
238  vtkSetVector3Macro(BelowRangeColor, double);
239  vtkGetVector3Macro(BelowRangeColor, double);
241 
243 
246  vtkSetMacro(UseBelowRangeColor, int);
247  vtkGetMacro(UseBelowRangeColor, int);
248  vtkBooleanMacro(UseBelowRangeColor, int);
250 
252 
256  vtkSetVector3Macro(AboveRangeColor, double);
257  vtkGetVector3Macro(AboveRangeColor, double);
259 
261 
264  vtkSetMacro(UseAboveRangeColor, int);
265  vtkGetMacro(UseAboveRangeColor, int);
266  vtkBooleanMacro(UseAboveRangeColor, int);
268 
276  double* GetDataPointer();
277 
283  void FillFromDataPointer(int n, double* ptr);
284 
288  virtual void MapScalarsThroughTable2(void *input, unsigned char *output,
289  int inputDataType, int numberOfValues,
290  int inputIncrement, int outputIncrement);
291 
293 
297  vtkSetMacro(AllowDuplicateScalars, int);
298  vtkGetMacro(AllowDuplicateScalars, int);
299  vtkBooleanMacro(AllowDuplicateScalars, int);
301 
306 
313  virtual void GetIndexedColor(vtkIdType idx, double rgba[4]);
314 
319  int EstimateMinNumberOfSamples(double const & x1, double const & x2);
320 
321 protected:
324 
325  vtkColorTransferFunctionInternals *Internal;
326 
333  int Clamping;
334 
339 
343  int HSVWrap;
344 
348  int Scale;
349 
353  double NanColor[3];
354 
358  double BelowRangeColor[3];
359 
364 
368  double AboveRangeColor[3];
369 
374 
378  double* Function;
379 
383  double Range[2];
384 
388  unsigned char UnsignedCharRGBAValue[4];
389 
394 
396  unsigned char *Table;
397 
403 
408  virtual void SetRange(double, double) {}
409  void SetRange(double rng[2]) {this->SetRange(rng[0],rng[1]);};
410 
417 
422  bool UpdateRange();
423 
428  void MovePoint(double oldX, double newX);
429 
434 
435 private:
436  vtkColorTransferFunction(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
437  void operator=(const vtkColorTransferFunction&) VTK_DELETE_FUNCTION;
438 };
439 
440 #endif
vtkColorTransferFunction::DeepCopy
void DeepCopy(vtkScalarsToColors *f)
Copy the contents from another object.
vtkColorTransferFunction::GetColor
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
Definition: vtkColorTransferFunction.h:111
vtkColorTransferFunction::BuildTime
vtkTimeStamp BuildTime
Definition: vtkColorTransferFunction.h:395
vtkColorTransferFunction::~vtkColorTransferFunction
~vtkColorTransferFunction()
vtkColorTransferFunction::GetDataPointer
double * GetDataPointer()
Returns a pointer to an array of all node values in an interleaved array with the layout [X1,...
vtkColorTransferFunction::AddHSVPoint
int AddHSVPoint(double x, double h, double s, double v)
vtkIdType
int vtkIdType
Definition: vtkType.h:287
vtkColorTransferFunction::New
static vtkColorTransferFunction * New()
vtkColorTransferFunction::GetTable
void GetTable(double x1, double x2, int n, float *table)
vtkColorTransferFunction::vtkColorTransferFunction
vtkColorTransferFunction()
vtkColorTransferFunction::GetNumberOfAvailableColors
virtual vtkIdType GetNumberOfAvailableColors()
Get the number of available colors for mapping to.
vtkColorTransferFunction::MapValue
virtual unsigned char * MapValue(double v)
Map one value through the lookup table.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
VTK_CTF_LAB
#define VTK_CTF_LAB
Definition: vtkColorTransferFunction.h:52
vtkColorTransferFunction::GetTable
const unsigned char * GetTable(double x1, double x2, int n)
vtkColorTransferFunction::SetColorSpaceToDiverging
void SetColorSpaceToDiverging()
Definition: vtkColorTransferFunction.h:204
vtkColorTransferFunction::MovePoint
void MovePoint(double oldX, double newX)
Moves point from oldX to newX.
vtkColorTransferFunction::Internal
vtkColorTransferFunctionInternals * Internal
Definition: vtkColorTransferFunction.h:325
vtkX3D::range
@ range
Definition: vtkX3D.h:238
vtkColorTransferFunction::GetTable
void GetTable(double x1, double x2, int n, double *table)
Fills in a table of n colors mapped from values mapped with even spacing between x1 and x2,...
vtkColorTransferFunction::SetRange
void SetRange(double rng[2])
Definition: vtkColorTransferFunction.h:409
vtkColorTransferFunction::FillFromDataPointer
void FillFromDataPointer(int n, double *ptr)
Defines the nodes from an array ptr with the layout [X1, R1, G1, B1, X2, R2, G2, B2,...
vtkColorTransferFunction::UpdateRange
bool UpdateRange()
Returns true if the range has been changed.
vtkColorTransferFunction::Scale
int Scale
The color interpolation scale (linear or logarithmic).
Definition: vtkColorTransferFunction.h:348
vtkColorTransferFunction::HSVWrap
int HSVWrap
Specify if HSV is wrap or not.
Definition: vtkColorTransferFunction.h:343
vtkColorTransferFunction::GetSize
int GetSize()
How many nodes define this function?
vtkColorTransferFunction::BuildFunctionFromTable
void BuildFunctionFromTable(double x1, double x2, int size, double *table)
Construct a color transfer function from a table.
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:59
vtkColorTransferFunction::SetRange
virtual void SetRange(double, double)
Set the range of scalars being mapped.
Definition: vtkColorTransferFunction.h:408
vtkColorTransferFunction::AddRGBPoint
int AddRGBPoint(double x, double r, double g, double b)
Add/Remove a point to/from the function defined in RGB or HSV Return the index of the point (0 based)...
vtkColorTransferFunction::SetColorSpaceToLab
void SetColorSpaceToLab()
Definition: vtkColorTransferFunction.h:203
vtkColorTransferFunction::AddRGBPoint
int AddRGBPoint(double x, double r, double g, double b, double midpoint, double sharpness)
vtkColorTransferFunction::GetRedValue
double GetRedValue(double x)
Get the color components individually.
VTK_CTF_LINEAR
#define VTK_CTF_LINEAR
Definition: vtkColorTransferFunction.h:55
vtkColorTransferFunction::GetBlueValue
double GetBlueValue(double x)
vtkColorTransferFunction::SetScaleToLog10
void SetScaleToLog10()
Definition: vtkColorTransferFunction.h:219
vtkColorTransferFunction::SetColorSpaceToRGB
void SetColorSpaceToRGB()
Definition: vtkColorTransferFunction.h:201
vtkColorTransferFunction::SetScaleToLinear
void SetScaleToLinear()
Definition: vtkColorTransferFunction.h:218
vtkColorTransferFunction::AdjustRange
int AdjustRange(double range[2])
Remove all points out of the new range, and make sure there is a point at each end of that range.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkColorTransferFunction::AddHSVPoint
int AddHSVPoint(double x, double h, double s, double v, double midpoint, double sharpness)
vtkScalarsToColors.h
vtkColorTransferFunction::TableSize
int TableSize
Temporary storage for the size of the table.
Definition: vtkColorTransferFunction.h:402
vtkX3D::size
@ size
Definition: vtkX3D.h:253
VTK_CTF_RGB
#define VTK_CTF_RGB
Definition: vtkColorTransferFunction.h:50
vtkColorTransferFunction::AddRGBSegment
void AddRGBSegment(double x1, double r1, double g1, double b1, double x2, double r2, double g2, double b2)
Add two points to the function and remove all the points between them.
vtkColorTransferFunction::UseAboveRangeColor
int UseAboveRangeColor
Flag indicating whether below-range color should be used.
Definition: vtkColorTransferFunction.h:373
vtkScalarsToColors
Superclass for mapping scalar values to colors.
Definition: vtkScalarsToColors.h:67
vtkColorTransferFunction::Table
unsigned char * Table
Definition: vtkColorTransferFunction.h:396
vtkColorTransferFunction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Print method for vtkColorTransferFunction.
vtkScalarsToColors::GetColor
virtual void GetColor(double v, double rgb[3])
Map one value through the lookup table and store the color as an RGB array of doubles between 0 and 1...
vtkColorTransferFunction::UseBelowRangeColor
int UseBelowRangeColor
Flag indicating whether below-range color should be used.
Definition: vtkColorTransferFunction.h:363
vtkColorTransferFunction::RemoveAllPoints
void RemoveAllPoints()
Remove all points.
vtkColorTransferFunction::GetGreenValue
double GetGreenValue(double x)
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkColorTransferFunction::ColorSpace
int ColorSpace
The color space in which interpolation is performed.
Definition: vtkColorTransferFunction.h:338
vtkColorTransferFunction::RemovePoint
int RemovePoint(double x)
vtkColorTransferFunction::SetColorSpaceToHSV
void SetColorSpaceToHSV()
Definition: vtkColorTransferFunction.h:202
vtkColorTransferFunction::Clamping
int Clamping
Determines the function value outside of defined points Zero = always return 0.0 outside of defined p...
Definition: vtkColorTransferFunction.h:333
vtkColorTransferFunction::SetNodeValue
int SetNodeValue(int index, double val[6])
vtkColorTransferFunction::GetNodeValue
int GetNodeValue(int index, double val[6])
For the node specified by index, set/get the location (X), R, G, and B values, midpoint,...
vtkColorTransferFunction::SortAndUpdateRange
void SortAndUpdateRange()
Internal method to sort the vector and update the Range whenever a node is added, edited or removed I...
vtkColorTransferFunction::EstimateMinNumberOfSamples
int EstimateMinNumberOfSamples(double const &x1, double const &x2)
Estimates the minimum size of a table such that it would correctly sample this function.
vtkColorTransferFunction::AllowDuplicateScalars
int AllowDuplicateScalars
If on, the same scalar value may have more than one node assigned to it.
Definition: vtkColorTransferFunction.h:393
vtkColorTransferFunction::GetColor
void GetColor(double x, double rgb[3])
Map one value through the lookup table and store the color as an RGB array of doubles between 0 and 1...
VTK_CTF_LOG10
#define VTK_CTF_LOG10
Definition: vtkColorTransferFunction.h:56
vtkColorTransferFunction::Function
double * Function
Temporary array to store data from the nodes.
Definition: vtkColorTransferFunction.h:378
vtkColorTransferFunction::GetIndexedColor
virtual void GetIndexedColor(vtkIdType idx, double rgba[4])
Return a color given an integer index.
VTK_CTF_DIVERGING
#define VTK_CTF_DIVERGING
Definition: vtkColorTransferFunction.h:53
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkColorTransferFunction::ShallowCopy
void ShallowCopy(vtkColorTransferFunction *f)
vtkColorTransferFunction::AddHSVSegment
void AddHSVSegment(double x1, double h1, double s1, double v1, double x2, double h2, double s2, double v2)
vtkColorTransferFunction::MapScalarsThroughTable2
virtual void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputIncrement)
Map a set of scalars through the lookup table.
VTK_CTF_HSV
#define VTK_CTF_HSV
Definition: vtkColorTransferFunction.h:51
vtkColorTransferFunction::FindMinimumXDistance
double FindMinimumXDistance()
Traverses the nodes to find the minimum distance.