VTK  9.3.0
vtkDiscretizableColorTransferFunction.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
37 #ifndef vtkDiscretizableColorTransferFunction_h
38 #define vtkDiscretizableColorTransferFunction_h
39 
41 #include "vtkRenderingCoreModule.h" // For export macro
42 #include "vtkSmartPointer.h" // for vtkSmartPointer
43 
44 VTK_ABI_NAMESPACE_BEGIN
46 class vtkLookupTable;
49 
50 class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
52 {
53 public:
56  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59 
62  vtkTypeBool IsOpaque() override;
63  vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
64  vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component,
65  vtkUnsignedCharArray* ghosts, unsigned char ghostsToSkip = 0xff) override;
67 
75  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
76  {
77  this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
78  }
79  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
80  {
81  this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
82  }
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(vtkTypeBool useLogScale);
135  vtkGetMacro(UseLogScale, vtkTypeBool);
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, int inputDataType,
171  int numberOfValues, int inputIncrement, int outputFormat) override;
172 
180  void SetAlpha(double alpha) override;
181 
183 
188  void SetNanColor(double r, double g, double b) override;
189  void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
191 
197  void SetNanOpacity(double a) override;
198 
203  vtkTypeBool UsingLogScale() override { return this->UseLogScale; }
204 
209 
211 
217 
219 
222  vtkSetMacro(EnableOpacityMapping, bool);
223  vtkGetMacro(EnableOpacityMapping, bool);
224  vtkBooleanMacro(EnableOpacityMapping, bool);
226 
230  vtkMTimeType GetMTime() override;
231 
232 protected:
235 
240 
245 
250 
255 
257 
260 
262 
263 private:
265  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
266 
267  template <typename T, typename VectorGetter>
268  void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
269  vtkIdType numberOfTuples, unsigned char* colors);
270 
271  template <template <class> class VectorGetter>
272  void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
273  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
274 
275  class vtkInternals;
276  vtkInternals* Internals;
277 };
278 
279 VTK_ABI_NAMESPACE_END
280 #endif
Abstract superclass for all arrays.
Defines a transfer function for mapping a property to an RGB color value.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
a combination of vtkColorTransferFunction and vtkLookupTable.
void SetNanColor(const double rgb[3]) override
Set the color to use when a NaN (not a number) is encountered.
unsigned int GetNumberOfIndexedColors()
Set the number of indexed colors.
vtkMTimeType GetMTime() override
Overridden to include the ScalarOpacityFunction's MTime.
vtkIdType NumberOfValues
Number of values to use in discretized color map.
vtkTypeBool IsOpaque(vtkAbstractArray *scalars, int colorMode, int component) override
Returns the negation of EnableOpacityMapping.
void MapDataArrayToOpacity(vtkDataArray *scalars, int component, vtkUnsignedCharArray *colors)
vtkTypeBool UseLogScale
Flag indicating whether log scaling is to be used.
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
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...
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.
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 ...
void SetNumberOfIndexedColors(unsigned int count)
Set the number of indexed colors.
void GetIndexedColor(vtkIdType i, double rgba[4]) override
Get the "indexed color" assigned to an index.
virtual void SetUseLogScale(vtkTypeBool useLogScale)
Get/Set if log scale must be used while mapping scalars to colors.
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
void SetAlpha(double alpha) override
Specify an additional opacity (alpha) value to blend with.
vtkTypeBool IsOpaque() override
Returns the negation of EnableOpacityMapping.
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function)
Set/get the opacity function to use.
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
vtkTypeBool IsOpaque(vtkAbstractArray *scalars, int colorMode, int component, vtkUnsignedCharArray *ghosts, unsigned char ghostsToSkip=0xff) override
Returns the negation of EnableOpacityMapping.
static vtkDiscretizableColorTransferFunction * New()
double GetOpacity(double v) override
Return the opacity of a given scalar.
void SetIndexedColor(unsigned int index, double r, double g, double b, double a=1.0)
void SetNanColor(double r, double g, double b) override
Set the color to use when a NaN (not a number) is encountered.
void SetNanOpacity(double a) override
Set the opacity to use when a NaN (not a number) is encountered.
virtual vtkPiecewiseFunction * GetScalarOpacityFunction() const
Set/get the opacity function to use.
vtkTypeBool UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
void Build() override
Generate discretized lookup table, if applicable.
a simple class to control print indentation
Definition: vtkIndent.h:29
map scalar values into colors via a lookup table
Defines a 1D piecewise function.
record modification and/or execution time
Definition: vtkTimeStamp.h:25
dynamic, self-adjusting array of unsigned char
@ component
Definition: vtkX3D.h:175
@ alpha
Definition: vtkX3D.h:250
@ index
Definition: vtkX3D.h:246
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270