VTK
vtkDiscretizableColorTransferFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkDiscretizableColorTransferFunction.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 =========================================================================*/
49 #ifndef vtkDiscretizableColorTransferFunction_h
50 #define vtkDiscretizableColorTransferFunction_h
51 
52 #include "vtkRenderingCoreModule.h" // For export macro
54 #include "vtkSmartPointer.h" // for vtkSmartPointer
55 
57 class vtkLookupTable;
59 
61 {
62 public:
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
70  int IsOpaque() override;
71 
79  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
80  { this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]); }
81  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
82  { this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]); }
83  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
84 
97  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
98 
100 
105  void SetNumberOfIndexedColors(unsigned int count);
106  unsigned int GetNumberOfIndexedColors();
108 
115  void Build() override;
116 
118 
124  vtkSetMacro(Discretize, vtkTypeBool);
125  vtkGetMacro(Discretize, vtkTypeBool);
126  vtkBooleanMacro(Discretize, vtkTypeBool);
128 
130 
134  virtual void SetUseLogScale(int useLogScale);
135  vtkGetMacro(UseLogScale, int);
137 
139 
144  vtkSetMacro(NumberOfValues, vtkIdType);
145  vtkGetMacro(NumberOfValues, vtkIdType);
147 
152  const unsigned char *MapValue(double v) override;
153 
158  void GetColor(double v, double rgb[3]) override;
159 
163  double GetOpacity(double v) override;
164 
170  void MapScalarsThroughTable2(void *input, unsigned char *output,
171  int inputDataType, int numberOfValues,
172  int inputIncrement, int outputFormat) override;
173 
181  void SetAlpha(double alpha) override;
182 
184 
189  void SetNanColor(double r, double g, double b) override;
190  void SetNanColor(double rgb[3]) override {
191  this->SetNanColor(rgb[0], rgb[1], rgb[2]);
192  }
194 
200  void SetNanOpacity(double a) override;
201 
206  int UsingLogScale() override
207  { return this->UseLogScale; }
208 
213 
215 
221 
223 
226  vtkSetMacro(EnableOpacityMapping, bool)
227  vtkGetMacro(EnableOpacityMapping, bool)
228  vtkBooleanMacro(EnableOpacityMapping, bool)
230 
234  vtkMTimeType GetMTime() override;
235 
236 protected:
239 
243  vtkTypeBool Discretize;
244 
248  int UseLogScale;
249 
253  vtkIdType NumberOfValues;
254 
258  vtkLookupTable* LookupTable;
259 
260  vtkTimeStamp LookupTableUpdateTime;
261 
262  bool EnableOpacityMapping;
263  vtkSmartPointer<vtkPiecewiseFunction> ScalarOpacityFunction;
264 
265  void MapDataArrayToOpacity(
266  vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors);
267 
268 private:
270  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
271 
272  template<typename T, typename VectorGetter>
273  void MapVectorToOpacity (
274  VectorGetter getter, T* scalars, int component,
275  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
276 
277  template<template<class> class VectorGetter>
278  void AllTypesMapVectorToOpacity (
279  int scalarType,
280  void* scalarsPtr, int component,
281  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
282 
283  class vtkInternals;
284  vtkInternals* Internals;
285 };
286 
287 #endif
vtkDiscretizableColorTransferFunction::MapValue
const unsigned char * MapValue(double v) override
Map one value through the lookup table and return a color defined as a RGBA unsigned char tuple (4 by...
vtkDiscretizableColorTransferFunction::GetNumberOfIndexedColors
unsigned int GetNumberOfIndexedColors()
vtkX3D::alpha
@ alpha
Definition: vtkX3D.h:250
vtkX3D::component
@ component
Definition: vtkX3D.h:175
vtkDiscretizableColorTransferFunction::SetNumberOfIndexedColors
void SetNumberOfIndexedColors(unsigned int count)
Set the number of indexed colors.
vtkDiscretizableColorTransferFunction::SetNanColor
void SetNanColor(double r, double g, double b) override
Set the color to use when a NaN (not a number) is encountered.
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkDiscretizableColorTransferFunction::SetNanOpacity
void SetNanOpacity(double a) override
Set the opacity to use when a NaN (not a number) is encountered.
vtkColorTransferFunction::SetNanColor
virtual void SetNanColor(double, double, double)
Set the RGB color to use when a NaN (not a number) is encountered.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:42
vtkSmartPointer
Hold a reference to a vtkObjectBase instance.
Definition: vtkSmartPointer.h:37
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
vtkDiscretizableColorTransferFunction::New
static vtkDiscretizableColorTransferFunction * New()
vtkDiscretizableColorTransferFunction
a combination of vtkColorTransferFunction and vtkLookupTable.
Definition: vtkDiscretizableColorTransferFunction.h:61
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:55
vtkDiscretizableColorTransferFunction::SetIndexedColorRGBA
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
Definition: vtkDiscretizableColorTransferFunction.h:81
vtkColorTransferFunction.h
vtkDiscretizableColorTransferFunction::GetNumberOfAvailableColors
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
vtkDiscretizableColorTransferFunction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
vtkDiscretizableColorTransferFunction::SetNanColor
void SetNanColor(double rgb[3]) override
Definition: vtkDiscretizableColorTransferFunction.h:190
vtkDiscretizableColorTransferFunction::GetIndexedColor
void GetIndexedColor(vtkIdType i, double rgba[4]) override
Get the "indexed color" assigned to an index.
vtkDiscretizableColorTransferFunction::GetScalarOpacityFunction
virtual vtkPiecewiseFunction * GetScalarOpacityFunction() const
vtkDiscretizableColorTransferFunction::MapScalarsThroughTable2
void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputFormat) override
Map a set of scalars through the lookup table.
vtkDiscretizableColorTransferFunction::SetUseLogScale
virtual void SetUseLogScale(int useLogScale)
Get/Set if log scale must be used while mapping scalars to colors.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkDiscretizableColorTransferFunction::GetColor
void GetColor(double v, double rgb[3]) override
Map one value through the lookup table and return the color as an RGB array of doubles between 0 and ...
vtkDiscretizableColorTransferFunction::SetAlpha
void SetAlpha(double alpha) override
Specify an additional opacity (alpha) value to blend with.
vtkDiscretizableColorTransferFunction::UsingLogScale
int UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
Definition: vtkDiscretizableColorTransferFunction.h:206
vtkSmartPointer.h
vtkDiscretizableColorTransferFunction::GetOpacity
double GetOpacity(double v) override
Return the opacity of a given scalar.
vtkDiscretizableColorTransferFunction::IsOpaque
int IsOpaque() override
Returns the negation of EnableOpacityMapping.
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:52
vtkDiscretizableColorTransferFunction::SetScalarOpacityFunction
virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function)
Set/get the opacity function to use.
vtkDiscretizableColorTransferFunction::SetIndexedColor
void SetIndexedColor(unsigned int index, double r, double g, double b, double a=1.0)
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:75
vtkDiscretizableColorTransferFunction::SetIndexedColorRGB
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
Definition: vtkDiscretizableColorTransferFunction.h:79
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkDiscretizableColorTransferFunction::Build
void Build() override
Generate discretized lookup table, if applicable.