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 
73 class vtkLookupTable;
75 
76 class VTKRENDERINGCORE_EXPORT vtkDiscretizableColorTransferFunction
78 {
79 public:
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);
130  unsigned int GetNumberOfIndexedColors();
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 
254  vtkMTimeType GetMTime() override;
255 
256 protected:
259 
264 
269 
274 
279 
281 
284 
286 
287 private:
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
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:280
vtkDiscretizableColorTransferFunction::GetNumberOfIndexedColors
unsigned int GetNumberOfIndexedColors()
Set the number of indexed colors.
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:332
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:268
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:52
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:145
vtkSmartPointer< vtkPiecewiseFunction >
vtkDiscretizableColorTransferFunction::LookupTable
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
Definition: vtkDiscretizableColorTransferFunction.h:278
vtkDiscretizableColorTransferFunction::Discretize
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
Definition: vtkDiscretizableColorTransferFunction.h:263
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkDiscretizableColorTransferFunction::New
static vtkDiscretizableColorTransferFunction * New()
vtkDiscretizableColorTransferFunction
a combination of vtkColorTransferFunction and vtkLookupTable.
Definition: vtkDiscretizableColorTransferFunction.h:78
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:164
vtkDiscretizableColorTransferFunction::SetIndexedColorRGBA
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
Definition: vtkDiscretizableColorTransferFunction.h:103
vtkDiscretizableColorTransferFunction::EnableOpacityMapping
bool EnableOpacityMapping
Definition: vtkDiscretizableColorTransferFunction.h:282
vtkDiscretizableColorTransferFunction::IsOpaque
int IsOpaque(vtkAbstractArray *scalars, int colorMode, int component) override
Returns the negation of EnableOpacityMapping.
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
Set/get the opacity function to use.
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:113
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:227
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:145
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
Set the color to use when a NaN (not a number) is encountered.
Definition: vtkDiscretizableColorTransferFunction.h:213
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:178
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:99
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:273
vtkX3D::index
@ index
Definition: vtkX3D.h:252
vtkDiscretizableColorTransferFunction::ScalarOpacityFunction
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
Definition: vtkDiscretizableColorTransferFunction.h:283
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
vtkDiscretizableColorTransferFunction::Build
void Build() override
Generate discretized lookup table, if applicable.