VTK
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 
49 #include "vtkRenderingCoreModule.h" // For export macro
51 #include "vtkSmartPointer.h" // for vtkSmartPointer
52 
54 class vtkLookupTable;
56 
58 {
59 public:
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
67  int IsOpaque() override;
68 
76  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
77  { this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]); }
78  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
79  { this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]); }
80  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
81 
94  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
95 
97 
102  void SetNumberOfIndexedColors(unsigned int count);
103  unsigned int GetNumberOfIndexedColors();
105 
112  void Build() override;
113 
115 
121  vtkSetMacro(Discretize, vtkTypeBool);
122  vtkGetMacro(Discretize, vtkTypeBool);
123  vtkBooleanMacro(Discretize, vtkTypeBool);
125 
127 
131  virtual void SetUseLogScale(int useLogScale);
132  vtkGetMacro(UseLogScale, int);
134 
136 
141  vtkSetMacro(NumberOfValues, vtkIdType);
142  vtkGetMacro(NumberOfValues, vtkIdType);
144 
149  const unsigned char *MapValue(double v) override;
150 
155  void GetColor(double v, double rgb[3]) override;
156 
160  double GetOpacity(double v) override;
161 
167  void MapScalarsThroughTable2(void *input, unsigned char *output,
168  int inputDataType, int numberOfValues,
169  int inputIncrement, int outputFormat) override;
170 
178  void SetAlpha(double alpha) override;
179 
181 
186  void SetNanColor(double r, double g, double b) override;
187  void SetNanColor(double rgb[3]) override {
188  this->SetNanColor(rgb[0], rgb[1], rgb[2]);
189  }
191 
197  void SetNanOpacity(double a) override;
198 
203  int UsingLogScale() override
204  { return this->UseLogScale; }
205 
210 
212 
215  virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function);
216  virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const;
218 
220 
223  vtkSetMacro(EnableOpacityMapping, bool)
224  vtkGetMacro(EnableOpacityMapping, bool)
225  vtkBooleanMacro(EnableOpacityMapping, bool)
227 
231  vtkMTimeType GetMTime() override;
232 
233 protected:
236 
241 
246 
251 
256 
258 
261 
262  void MapDataArrayToOpacity(
263  vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors);
264 
265 private:
267  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
268 
269  template<typename T, typename VectorGetter>
270  void MapVectorToOpacity (
271  VectorGetter getter, T* scalars, int component,
272  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
273 
274  template<template<class> class VectorGetter>
275  void AllTypesMapVectorToOpacity (
276  int scalarType,
277  void* scalarsPtr, int component,
278  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
279 
280  class vtkInternals;
281  vtkInternals* Internals;
282 };
283 
284 #endif
vtkColorTransferFunction::GetColor
double * GetColor(double x)
Returns an RGB color for the specified scalar value.
Definition: vtkColorTransferFunction.h:106
vtkDiscretizableColorTransferFunction::LookupTableUpdateTime
vtkTimeStamp LookupTableUpdateTime
Definition: vtkDiscretizableColorTransferFunction.h:257
vtkX3D::alpha
Definition: vtkX3D.h:250
vtkX3D::component
Definition: vtkX3D.h:175
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkColorTransferFunction::New
static vtkColorTransferFunction * New()
vtkColorTransferFunction::SetNanColor
virtual void SetNanColor(double, double, double)
Set the RGB color 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:245
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkSmartPointer< vtkPiecewiseFunction >
vtkDiscretizableColorTransferFunction::LookupTable
vtkLookupTable * LookupTable
Internal lookup table used for some aspects of the color mapping.
Definition: vtkDiscretizableColorTransferFunction.h:255
vtkDiscretizableColorTransferFunction::Discretize
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
Definition: vtkDiscretizableColorTransferFunction.h:240
vtkScalarsToColors::Build
virtual void Build()
Perform any processing required (if any) before processing scalars.
Definition: vtkScalarsToColors.h:77
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkDiscretizableColorTransferFunction
a combination of vtkColorTransferFunction and vtkLookupTable.
Definition: vtkDiscretizableColorTransferFunction.h:57
vtkColorTransferFunction
Defines a transfer function for mapping a property to an RGB color value.
Definition: vtkColorTransferFunction.h:53
vtkDiscretizableColorTransferFunction::SetIndexedColorRGBA
void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
Definition: vtkDiscretizableColorTransferFunction.h:78
vtkScalarsToColors::SetAlpha
virtual void SetAlpha(double alpha)
Specify an additional opacity (alpha) value to blend with.
vtkDiscretizableColorTransferFunction::EnableOpacityMapping
bool EnableOpacityMapping
Definition: vtkDiscretizableColorTransferFunction.h:259
vtkColorTransferFunction.h
vtkColorTransferFunction::GetIndexedColor
void GetIndexedColor(vtkIdType idx, double rgba[4]) override
Return a color given an integer index.
vtkScalarsToColors::GetOpacity
virtual double GetOpacity(double v)
Map one value through the lookup table and return the alpha value (the opacity) as a double between 0...
vtkColorTransferFunction::GetNumberOfAvailableColors
vtkIdType GetNumberOfAvailableColors() override
Get the number of available colors for mapping to.
vtkDiscretizableColorTransferFunction::SetNanColor
void SetNanColor(double rgb[3]) override
Definition: vtkDiscretizableColorTransferFunction.h:187
vtkObject::GetMTime
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkDiscretizableColorTransferFunction::UsingLogScale
int UsingLogScale() override
This should return 1 if the subclass is using log scale for mapping scalars to colors.
Definition: vtkDiscretizableColorTransferFunction.h:203
vtkSmartPointer.h
vtkColorTransferFunction::SetNanOpacity
virtual void SetNanOpacity(double)
Get/Set the opacity to use when a NaN (not a number) is encountered.
vtkPiecewiseFunction
Defines a 1D piecewise function.
Definition: vtkPiecewiseFunction.h:45
vtkLookupTable
map scalar values into colors via a lookup table
Definition: vtkLookupTable.h:68
vtkColorTransferFunction::MapValue
const unsigned char * MapValue(double v) override
Map one value through the lookup table.
vtkColorTransferFunction::MapScalarsThroughTable2
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.
vtkDiscretizableColorTransferFunction::SetIndexedColorRGB
void SetIndexedColorRGB(unsigned int index, const double rgb[3])
Add colors to use when IndexedLookup is true.
Definition: vtkDiscretizableColorTransferFunction.h:76
vtkDiscretizableColorTransferFunction::NumberOfValues
vtkIdType NumberOfValues
Number of values to use in discretized color map.
Definition: vtkDiscretizableColorTransferFunction.h:250
vtkX3D::index
Definition: vtkX3D.h:246
vtkDiscretizableColorTransferFunction::ScalarOpacityFunction
vtkSmartPointer< vtkPiecewiseFunction > ScalarOpacityFunction
Definition: vtkDiscretizableColorTransferFunction.h:260
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkScalarsToColors::IsOpaque
virtual int IsOpaque()
Return true if all of the values defining the mapping have an opacity equal to 1.
vtkColorTransferFunction::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.