VTK  9.1.0
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=========================================================================*/
65#ifndef vtkDiscretizableColorTransferFunction_h
66#define vtkDiscretizableColorTransferFunction_h
67
69#include "vtkRenderingCoreModule.h" // For export macro
70#include "vtkSmartPointer.h" // for vtkSmartPointer
71
73class vtkLookupTable;
75
76class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
78{
79public:
82 void PrintSelf(ostream& os, vtkIndent indent) override;
83
85
88 int IsOpaque() override;
89 int IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
91
99 void SetIndexedColorRGB(unsigned int index, const double rgb[3])
100 {
101 this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
102 }
103 void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
104 {
105 this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
106 }
107 void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
108
121 void GetIndexedColor(vtkIdType i, double rgba[4]) override;
122
124
129 void SetNumberOfIndexedColors(unsigned int count);
132
139 void Build() override;
140
142
148 vtkSetMacro(Discretize, vtkTypeBool);
149 vtkGetMacro(Discretize, vtkTypeBool);
150 vtkBooleanMacro(Discretize, vtkTypeBool);
152
154
158 virtual void SetUseLogScale(int useLogScale);
159 vtkGetMacro(UseLogScale, int);
161
163
168 vtkSetMacro(NumberOfValues, vtkIdType);
169 vtkGetMacro(NumberOfValues, vtkIdType);
171
176 const unsigned char* MapValue(double v) override;
177
182 void GetColor(double v, double rgb[3]) override;
183
187 double GetOpacity(double v) override;
188
194 void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
195 int numberOfValues, int inputIncrement, int outputFormat) override;
196
204 void SetAlpha(double alpha) override;
205
207
212 void SetNanColor(double r, double g, double b) override;
213 void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
215
221 void SetNanOpacity(double a) override;
222
227 int UsingLogScale() override { return this->UseLogScale; }
228
233
235
241
243
246 vtkSetMacro(EnableOpacityMapping, bool);
247 vtkGetMacro(EnableOpacityMapping, bool);
248 vtkBooleanMacro(EnableOpacityMapping, bool);
250
255
256protected:
259
264
269
274
279
281
284
286
287private:
289 void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
290
291 template <typename T, typename VectorGetter>
292 void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
293 vtkIdType numberOfTuples, unsigned char* colors);
294
295 template <template <class> class VectorGetter>
296 void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
297 int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
298
299 class vtkInternals;
300 vtkInternals* Internals;
301};
302
303#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:159
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.
int UseLogScale
Flag indicating whether log scaling is to be used.
void MapDataArrayToOpacity(vtkDataArray *scalars, int component, vtkUnsignedCharArray *colors)
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
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.
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...
int IsOpaque(vtkAbstractArray *scalars, int colorMode, int component) override
Returns the negation of EnableOpacityMapping.
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
void SetAlpha(double alpha) override
Specify an additional opacity (alpha) value to blend with.
virtual vtkPiecewiseFunction * GetScalarOpacityFunction() const
Set/get the opacity function to use.
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
virtual void SetUseLogScale(int useLogScale)
Get/Set if log scale must be used while mapping scalars to colors.
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.
double GetOpacity(double v) override
Return the opacity of a given scalar.
int IsOpaque() override
Returns the negation of EnableOpacityMapping.
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.
static vtkDiscretizableColorTransferFunction * New()
void SetNanOpacity(double a) override
Set the opacity to use when a NaN (not a number) is encountered.
int 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:113
map scalar values into colors via a lookup table
Defines a 1D piecewise function.
record modification and/or execution time
Definition: vtkTimeStamp.h:52
dynamic, self-adjusting array of unsigned char
@ component
Definition: vtkX3D.h:181
@ function
Definition: vtkX3D.h:255
@ alpha
Definition: vtkX3D.h:256
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287