VTK  9.0.1
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 =========================================================================*/
46 #ifndef vtkDiscretizableColorTransferFunction_h
47 #define vtkDiscretizableColorTransferFunction_h
48 
50 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkSmartPointer.h" // for vtkSmartPointer
52 
54 class vtkLookupTable;
56 
57 class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
59 {
60 public:
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
66 
69  int IsOpaque() override;
70  int IsOpaque(vtkAbstractArray* scalars, int colorMode, int component) override;
72 
80  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
81  {
82  this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]);
83  }
84  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
85  {
86  this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]);
87  }
88  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
89 
102  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
103 
105 
110  void SetNumberOfIndexedColors(unsigned int count);
111  unsigned int GetNumberOfIndexedColors();
113 
120  void Build() override;
121 
123 
129  vtkSetMacro(Discretize, vtkTypeBool);
130  vtkGetMacro(Discretize, vtkTypeBool);
131  vtkBooleanMacro(Discretize, vtkTypeBool);
133 
135 
139  virtual void SetUseLogScale(int useLogScale);
140  vtkGetMacro(UseLogScale, int);
142 
144 
149  vtkSetMacro(NumberOfValues, vtkIdType);
150  vtkGetMacro(NumberOfValues, vtkIdType);
152 
157  const unsigned char* MapValue(double v) override;
158 
163  void GetColor(double v, double rgb[3]) override;
164 
168  double GetOpacity(double v) override;
169 
175  void MapScalarsThroughTable2(void* input, unsigned char* output, int inputDataType,
176  int numberOfValues, int inputIncrement, int outputFormat) override;
177 
185  void SetAlpha(double alpha) override;
186 
188 
193  void SetNanColor(double r, double g, double b) override;
194  void SetNanColor(const double rgb[3]) override { this->SetNanColor(rgb[0], rgb[1], rgb[2]); }
196 
202  void SetNanOpacity(double a) override;
203 
208  int UsingLogScale() override { return this->UseLogScale; }
209 
214 
216 
222 
224 
227  vtkSetMacro(EnableOpacityMapping, bool);
228  vtkGetMacro(EnableOpacityMapping, bool);
229  vtkBooleanMacro(EnableOpacityMapping, bool);
231 
235  vtkMTimeType GetMTime() override;
236 
237 protected:
240 
245 
250 
255 
260 
262 
265 
267 
268 private:
270  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
271 
272  template <typename T, typename VectorGetter>
273  void MapVectorToOpacity(VectorGetter getter, T* scalars, int component, int numberOfComponents,
274  vtkIdType numberOfTuples, unsigned char* colors);
275 
276  template <template <class> class VectorGetter>
277  void AllTypesMapVectorToOpacity(int scalarType, void* scalarsPtr, int component,
278  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
279 
280  class vtkInternals;
281  vtkInternals* Internals;
282 };
283 
284 #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::LookupTableUpdateTime
vtkTimeStamp LookupTableUpdateTime
Definition: vtkDiscretizableColorTransferFunction.h:261
vtkDiscretizableColorTransferFunction::GetNumberOfIndexedColors
unsigned int GetNumberOfIndexedColors()
vtkX3D::alpha
@ alpha
Definition: vtkX3D.h:256
vtkX3D::component
@ component
Definition: vtkX3D.h:181
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:338
vtkDiscretizableColorTransferFunction::SetNanOpacity
void SetNanOpacity(double a) override
Set the opacity to use when a NaN (not a number) is encountered.
vtkDiscretizableColorTransferFunction::UseLogScale
int UseLogScale
Flag indicating whether log scaling is to be used.
Definition: vtkDiscretizableColorTransferFunction.h:249
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:33
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:36
vtkSmartPointer< vtkPiecewiseFunction >
vtkDiscretizableColorTransferFunction::LookupTable
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
Definition: vtkDiscretizableColorTransferFunction.h:259
vtkDiscretizableColorTransferFunction::Discretize
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
Definition: vtkDiscretizableColorTransferFunction.h:244
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
vtkDiscretizableColorTransferFunction::New
static vtkDiscretizableColorTransferFunction * New()
vtkDiscretizableColorTransferFunction
a combination of vtkColorTransferFunction and vtkLookupTable.
Definition: vtkDiscretizableColorTransferFunction.h:59
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:84
vtkDiscretizableColorTransferFunction::EnableOpacityMapping
bool EnableOpacityMapping
Definition: vtkDiscretizableColorTransferFunction.h:263
vtkDiscretizableColorTransferFunction::IsOpaque
int IsOpaque(vtkAbstractArray *scalars, int colorMode, int component) override
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::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.
vtkDiscretizableColorTransferFunction::GetMTime
vtkMTimeType GetMTime() override
Overridden to include the ScalarOpacityFunction's MTime.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
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:208
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:46
vtkAbstractArray
Abstract superclass for all arrays.
Definition: vtkAbstractArray.h:76
vtkDiscretizableColorTransferFunction::SetScalarOpacityFunction
virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function)
Set/get the opacity function to use.
vtkDiscretizableColorTransferFunction::SetNanColor
void SetNanColor(const double rgb[3]) override
Definition: vtkDiscretizableColorTransferFunction.h:194
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:69
vtkDiscretizableColorTransferFunction::~vtkDiscretizableColorTransferFunction
~vtkDiscretizableColorTransferFunction() override
vtkDiscretizableColorTransferFunction::vtkDiscretizableColorTransferFunction
vtkDiscretizableColorTransferFunction()
vtkDiscretizableColorTransferFunction::SetIndexedColorRGB
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
Definition: vtkDiscretizableColorTransferFunction.h:80
vtkDiscretizableColorTransferFunction::MapDataArrayToOpacity
void MapDataArrayToOpacity(vtkDataArray *scalars, int component, vtkUnsignedCharArray *colors)
vtkDiscretizableColorTransferFunction::NumberOfValues
vtkIdType NumberOfValues
Number of values to use in discretized color map.
Definition: vtkDiscretizableColorTransferFunction.h:254
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkDiscretizableColorTransferFunction::ScalarOpacityFunction
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
Definition: vtkDiscretizableColorTransferFunction.h:264
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:293
vtkDiscretizableColorTransferFunction::Build
void Build() override
Generate discretized lookup table, if applicable.