VTK  9.2.6
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 
53 #include "vtkRenderingCoreModule.h" // For export macro
54 #include "vtkSmartPointer.h" // for vtkSmartPointer
55 
57 class vtkLookupTable;
60 
61 class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
63 {
64 public:
67  void PrintSelf(ostream& os, vtkIndent indent) override;
68 
70 
73  int IsOpaque() override;
74  int IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
75  int IsOpaque(vtkAbstractArray* scalars, int colorMode, int component,
76  vtkUnsignedCharArray* ghosts, unsigned char ghostsToSkip = 0xff) override;
78 
86  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
87  {
88  this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
89  }
90  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
91  {
92  this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
93  }
94  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
95 
108  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
109 
111 
116  void SetNumberOfIndexedColors(unsigned int count);
117  unsigned int GetNumberOfIndexedColors();
119 
126  void Build() override;
127 
129 
135  vtkSetMacro(Discretize, vtkTypeBool);
136  vtkGetMacro(Discretize, vtkTypeBool);
137  vtkBooleanMacro(Discretize, vtkTypeBool);
139 
141 
145  virtual void SetUseLogScale(int useLogScale);
146  vtkGetMacro(UseLogScale, int);
148 
150 
155  vtkSetMacro(NumberOfValues, vtkIdType);
156  vtkGetMacro(NumberOfValues, vtkIdType);
158 
163  const unsigned char* MapValue(double v) override;
164 
169  void GetColor(double v, double rgb[3]) override;
170 
174  double GetOpacity(double v) override;
175 
181  void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
182  int numberOfValues, int inputIncrement, int outputFormat) override;
183 
191  void SetAlpha(double alpha) override;
192 
194 
199  void SetNanColor(double r, double g, double b) override;
200  void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
202 
208  void SetNanOpacity(double a) override;
209 
214  int UsingLogScale() override { return this->UseLogScale; }
215 
220 
222 
225  virtual void SetScalarOpacityFunction(vtkPiecewiseFunction* function);
226  virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const;
228 
230 
233  vtkSetMacro(EnableOpacityMapping, bool);
234  vtkGetMacro(EnableOpacityMapping, bool);
235  vtkBooleanMacro(EnableOpacityMapping, bool);
237 
241  vtkMTimeType GetMTime() override;
242 
243 protected:
246 
251 
256 
261 
266 
268 
271 
272  void MapDataArrayToOpacity(vtkDataArray* scalars, int component, vtkUnsignedCharArray* colors);
273 
274 private:
276  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
277 
278  template <typename T, typename VectorGetter>
279  void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
280  vtkIdType numberOfTuples, unsigned char* colors);
281 
282  template <template <class> class VectorGetter>
283  void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
284  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
285 
286  class vtkInternals;
287  vtkInternals* Internals;
288 };
289 
290 #endif
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
int UseLogScale
Flag indicating whether log scaling is to be used.
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:287
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:35
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:332
vtkIdType NumberOfValues
Number of values to use in discretized color map.
void MapScalarsThroughTable2(void *input, unsigned char *output, int inputDataType, int numberOfValues, int inputIncrement, int outputIncrement) override
Map a set of scalars through the lookup table.
int vtkTypeBool
Definition: vtkABI.h:69
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...
virtual int IsOpaque()
Return true if all of the values defining the mapping have an opacity equal to 1. ...
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:55
virtual vtkMTimeType GetMTime()
Return this object's modified time.
int UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
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.
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.