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 =========================================================================*/
49 #ifndef vtkDiscretizableColorTransferFunction_h
50 #define vtkDiscretizableColorTransferFunction_h
51 
52 #include "vtkRenderingCoreModule.h" // For export macro
54 #include "vtkSmartPointer.h" // for vtkSmartPointer
55 
57 class vtkLookupTable;
59 
61 {
62 public:
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
70  int IsOpaque() override;
71 
79  void SetIndexedColorRGB(unsigned int index, const double rgb[3])
80  { this->SetIndexedColor(index, rgb[0], rgb[1], rgb[2]); }
81  void SetIndexedColorRGBA(unsigned int index, const double rgba[4])
82  { this->SetIndexedColor(index, rgba[0], rgba[1], rgba[2], rgba[3]); }
83  void SetIndexedColor(unsigned int index, double r, double g, double b, double a = 1.0);
84 
97  void GetIndexedColor(vtkIdType i, double rgba[4]) override;
98 
100 
105  void SetNumberOfIndexedColors(unsigned int count);
106  unsigned int GetNumberOfIndexedColors();
108 
115  void Build() override;
116 
118 
124  vtkSetMacro(Discretize, vtkTypeBool);
125  vtkGetMacro(Discretize, vtkTypeBool);
126  vtkBooleanMacro(Discretize, vtkTypeBool);
128 
130 
134  virtual void SetUseLogScale(int useLogScale);
135  vtkGetMacro(UseLogScale, int);
137 
139 
144  vtkSetMacro(NumberOfValues, vtkIdType);
145  vtkGetMacro(NumberOfValues, vtkIdType);
147 
152  const unsigned char *MapValue(double v) override;
153 
158  void GetColor(double v, double rgb[3]) override;
159 
163  double GetOpacity(double v) override;
164 
170  void MapScalarsThroughTable2(void *input, unsigned char *output,
171  int inputDataType, int numberOfValues,
172  int inputIncrement, int outputFormat) override;
173 
181  void SetAlpha(double alpha) override;
182 
184 
189  void SetNanColor(double r, double g, double b) override;
190  void SetNanColor(double rgb[3]) override {
191  this->SetNanColor(rgb[0], rgb[1], rgb[2]);
192  }
194 
200  void SetNanOpacity(double a) override;
201 
206  int UsingLogScale() override
207  { return this->UseLogScale; }
208 
213 
215 
218  virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function);
219  virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const;
221 
223 
226  vtkSetMacro(EnableOpacityMapping, bool)
227  vtkGetMacro(EnableOpacityMapping, bool)
228  vtkBooleanMacro(EnableOpacityMapping, bool)
230 
234  vtkMTimeType GetMTime() override;
235 
236 protected:
239 
244 
249 
254 
259 
261 
264 
265  void MapDataArrayToOpacity(
266  vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors);
267 
268 private:
270  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
271 
272  template<typename T, typename VectorGetter>
273  void MapVectorToOpacity (
274  VectorGetter getter, T* scalars, int component,
275  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
276 
277  template<template<class> class VectorGetter>
278  void AllTypesMapVectorToOpacity (
279  int scalarType,
280  void* scalarsPtr, int component,
281  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
282 
283  class vtkInternals;
284  vtkInternals* Internals;
285 };
286 
287 #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:302
void PrintSelf(ostream &os, vtkIndent indent) override
Print method for vtkColorTransferFunction.
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:347
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.
void SetNanColor(double rgb[3]) override
Set the color to use when a NaN (not a number) is encountered.
a simple class to control print indentation
Definition: vtkIndent.h:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
virtual vtkMTimeType GetMTime()
Return this object&#39;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 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.