VTK  9.7.1
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 #include "vtkWrappingHints.h" // For VTK_MARSHALMANUAL
44 
45 VTK_ABI_NAMESPACE_BEGIN
47 class vtkLookupTable;
50 
53 {
54 public:
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
60 
63  vtkTypeBool IsOpaque() override;
64  vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
65  vtkTypeBool IsOpaque(vtkAbstractArray* scalars, int colorMode, int component,
66  vtkUnsignedCharArray* ghosts, unsigned char ghostsToSkip = 0xff) override;
68 
76  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
77  {
78  this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
79  }
80  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
81  {
82  this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
83  }
84  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
85 
98  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
99 
101 
106  void SetNumberOfIndexedColors(unsigned int count);
107  unsigned int GetNumberOfIndexedColors();
109 
116  void Build() override;
117 
119 
125  vtkSetMacro(Discretize, vtkTypeBool);
126  vtkGetMacro(Discretize, vtkTypeBool);
127  vtkBooleanMacro(Discretize, vtkTypeBool);
129 
131 
135  virtual void SetUseLogScale(vtkTypeBool useLogScale);
136  vtkGetMacro(UseLogScale, vtkTypeBool);
138 
140 
145  vtkSetMacro(NumberOfValues, vtkIdType);
146  vtkGetMacro(NumberOfValues, vtkIdType);
148 
153  const unsigned char* MapValue(double v) override;
154 
159  void GetColor(double v, double rgb[3]) override;
160 
164  double GetOpacity(double v) override;
165 
167 
172  void MapScalarsThroughTable(vtkAbstractArray* input, unsigned char* output, int numberOfTuples,
173  int numberOfComponents, int vectorComponent, int outputFormat) override;
176 
184  void SetAlpha(double alpha) override;
185 
187 
192  void SetNanColor(double r, double g, double b) override;
193  void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
195 
201  void SetNanOpacity(double a) override;
202 
207  vtkTypeBool UsingLogScale() override { return this->UseLogScale; }
208 
213 
215 
218  virtual void SetScalarOpacityFunction(vtkPiecewiseFunction* function);
219  virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const;
221 
223 
226  vtkSetMacro(EnableOpacityMapping, bool);
227  vtkGetMacro(EnableOpacityMapping, bool);
228  vtkBooleanMacro(EnableOpacityMapping, bool);
230 
234  vtkMTimeType GetMTime() override;
235 
236 protected:
239 
244 
249 
254 
259 
261 
264 
265  void MapDataArrayToOpacity(vtkDataArray* scalars, int component, vtkUnsignedCharArray* colors);
266 
267 private:
269  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
270 
271  template <typename T, typename VectorGetter>
272  void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
273  vtkIdType numberOfTuples, unsigned char* colors);
274 
275  template <template <class> class VectorGetter>
276  void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
277  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
278 
279  class vtkInternals;
280  vtkInternals* Internals;
281 };
282 
283 VTK_ABI_NAMESPACE_END
284 #endif
void MapScalarsThroughTable(vtkAbstractArray *input, unsigned char *output, int numberOfTuples, int numberOfComponents, int vectorComponent, int outputFormat) override
Map a set of scalars through the lookup table.
vtkTypeBool UseLogScale
Flag indicating whether log scaling is to be used.
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
virtual vtkTypeBool IsOpaque()
Return true if all of the values defining the mapping have an opacity equal to 1. ...
virtual void SetNanOpacity(double)
Get/Set the opacity to use when a NaN (not a number) is encountered.
Defines a 1D piecewise function.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
Abstract superclass for all arrays.
void GetIndexedColor(vtkIdType idx, double rgba[4]) override
Return a color given an integer index.
record modification and/or execution time
Definition: vtkTimeStamp.h:24
static vtkColorTransferFunction * New()
map scalar values into colors via a lookup table
virtual void SetAlpha(double alpha)
Specify an additional opacity (alpha) value to blend with.
int vtkIdType
Definition: vtkType.h:363
vtkIdType NumberOfValues
Number of values to use in discretized color map.
int vtkTypeBool
Definition: vtkABI.h:64
virtual void SetNanColor(double, double, double)
Set the RGB color to use when a NaN (not a number) is encountered.
virtual double GetOpacity(double v)
Map one value through the lookup table and return the alpha value (the opacity) as a double between 0...
#define VTK_MARSHALMANUAL
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual vtkMTimeType GetMTime()
Return this object's modified time.
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
dynamic, self-adjusting array of unsigned char
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
a combination of vtkColorTransferFunction and vtkLookupTable.
Defines a transfer function for mapping a property to an RGB color value.
void SetNanColor(const double rgb[3]) override
Set the color to use when a NaN (not a number) is encountered.
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
virtual void Build()
Perform any processing required (if any) before processing scalars.
vtkTypeBool UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
const unsigned char * MapValue(double v) override
Map one value through the lookup table.
void MapScalarsThroughTable(vtkDataArray *scalars, unsigned char *output, int outputFormat)
Map a set of scalars through the lookup table in a single operation.