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 
196  int UsingLogScale() override
197  { return this->UseLogScale; }
198 
203 
205 
208  virtual void SetScalarOpacityFunction(vtkPiecewiseFunction *function);
209  virtual vtkPiecewiseFunction* GetScalarOpacityFunction() const;
211 
213 
216  vtkSetMacro(EnableOpacityMapping, bool)
217  vtkGetMacro(EnableOpacityMapping, bool)
218  vtkBooleanMacro(EnableOpacityMapping, bool)
220 
224  vtkMTimeType GetMTime() override;
225 
226 protected:
229 
234 
239 
244 
249 
251 
254 
255  void MapDataArrayToOpacity(
256  vtkDataArray *scalars, int component, vtkUnsignedCharArray* colors);
257 
258 private:
260  void operator=(const vtkDiscretizableColorTransferFunction&) = delete;
261 
262  template<typename T, typename VectorGetter>
263  void MapVectorToOpacity (
264  VectorGetter getter, T* scalars, int component,
265  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
266 
267  template<template<class> class VectorGetter>
268  void AllTypesMapVectorToOpacity (
269  int scalarType,
270  void* scalarsPtr, int component,
271  int numberOfComponents, vtkIdType numberOfTuples, unsigned char* colors);
272 
273  class vtkInternals;
274  vtkInternals* Internals;
275 };
276 
277 #endif
vtkTypeBool Discretize
Flag indicating whether transfer function is discretized.
int UseLogScale
Flag indicating whether log scaling is to be used.
Defines a 1D piecewise function.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:300
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:32
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:345
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:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
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.