OGS
|
Calculates and stores a colour lookup table.
Based on a start colour and an end colour, RGB-values are interpolated and stored in vector of GeoLib::Color. If no colours are set, default values are used for start (blue) and end (red). The number of entries of the colour table can be set in the constructor, the default value is 256. If additional colours are inserted into the table using setColor() the interpolation will be calculated iteratively between set colour values. Interpolation can be linear (default) or exponential. Based on the set range of values, colour values can be retrieved using getColor().
Definition at line 34 of file VtkColorLookupTable.h.
#include <VtkColorLookupTable.h>
Public Member Functions | |
vtkTypeMacro (VtkColorLookupTable, vtkLookupTable) | |
void | Build () override |
Builds the colour table based on the previously set parameters. This method should only be called after all options have been set. | |
void | setColor (double pos, DataHolderLib::Color const &color) |
void | getColor (vtkIdType indx, unsigned char rgba[4]) const |
DataHolderLib::LUTType | getInterpolationType () const |
Returns the type of interpolation used. | |
void | setInterpolationType (DataHolderLib::LUTType type) |
Sets the type of interpolation. | |
void | setLookupTable (DataHolderLib::ColorLookupTable const &lut) |
Imports settings of OGS lookup table class. | |
void | writeToFile (const std::string &filename) |
Exports a color table to a file. | |
void | SetTableValueRGBA (vtkIdType idx, unsigned char rgba[4]) |
Set a value within the LUT. | |
void | GetTableValue (vtkIdType idx, unsigned char rgba[4]) |
Get a value from the LUT. | |
Static Public Member Functions | |
static VtkColorLookupTable * | New () |
Create new objects with New() because of VTKs object reference counting. | |
Static Public Attributes | |
static const int | DEFAULTMINVALUE = -9999 |
static const int | DEFAULTMAXVALUE = 9999 |
Protected Member Functions | |
VtkColorLookupTable () | |
Constructor. | |
~VtkColorLookupTable () override | |
Destructor. | |
Private Member Functions | |
unsigned char | linInterpolation (unsigned char a, unsigned char b, double p) const |
Interpolates values linearly. | |
unsigned char | expInterpolation (unsigned char a, unsigned char b, double gamma, double p) const |
Interpolates values exponentially. gamma should roughly be in [0,4), for gamma=1 interpolation is linear. | |
Private Attributes | |
std::map< double, unsigned char * > | _dict |
DataHolderLib::LUTType | _type {DataHolderLib::LUTType::LINEAR} |
|
protecteddefault |
Constructor.
|
overrideprotected |
Destructor.
Definition at line 29 of file VtkColorLookupTable.cpp.
References _dict.
|
override |
Builds the colour table based on the previously set parameters. This method should only be called after all options have been set.
Definition at line 53 of file VtkColorLookupTable.cpp.
References _dict, _type, expInterpolation(), DataHolderLib::EXPONENTIAL, DataHolderLib::LINEAR, linInterpolation(), and SetTableValueRGBA().
Referenced by VtkCompositeElementSelectionFilter::GetLookupTable(), VtkCompositeColorByHeightFilter::init(), and setLookupTable().
|
private |
Interpolates values exponentially. gamma should roughly be in [0,4), for gamma=1 interpolation is linear.
Definition at line 44 of file VtkColorLookupTable.cpp.
Referenced by Build().
void VtkColorLookupTable::getColor | ( | vtkIdType | indx, |
unsigned char | rgba[4] ) const |
Definition at line 193 of file VtkColorLookupTable.cpp.
|
inline |
Returns the type of interpolation used.
Definition at line 63 of file VtkColorLookupTable.h.
References _type.
Referenced by VtkColorByHeightFilter::PrintSelf().
void VtkColorLookupTable::GetTableValue | ( | vtkIdType | idx, |
unsigned char | rgba[4] ) |
Get a value from the LUT.
Definition at line 171 of file VtkColorLookupTable.cpp.
Referenced by writeToFile().
|
private |
Interpolates values linearly.
Definition at line 37 of file VtkColorLookupTable.cpp.
Referenced by Build().
|
static |
Create new objects with New() because of VTKs object reference counting.
Referenced by VtkCompositeElementSelectionFilter::GetLookupTable(), and VtkAlgorithmProperties::SetLookUpTable().
void VtkColorLookupTable::setColor | ( | double | pos, |
DataHolderLib::Color const & | color ) |
Definition at line 182 of file VtkColorLookupTable.cpp.
References _dict.
Referenced by VtkCompositeElementSelectionFilter::GetLookupTable(), VtkCompositeColorByHeightFilter::init(), and setLookupTable().
|
inline |
Sets the type of interpolation.
Definition at line 66 of file VtkColorLookupTable.h.
References _type.
Referenced by VtkCompositeColorByHeightFilter::init(), and setLookupTable().
void VtkColorLookupTable::setLookupTable | ( | DataHolderLib::ColorLookupTable const & | lut | ) |
Imports settings of OGS lookup table class.
Definition at line 125 of file VtkColorLookupTable.cpp.
References Build(), DataHolderLib::ColorLookupTable::getInterpolationType(), DataHolderLib::ColorLookupTable::getTableRange(), setColor(), setInterpolationType(), and DataHolderLib::ColorLookupTable::size().
Referenced by VtkAlgorithmProperties::SetLookUpTable().
void VtkColorLookupTable::SetTableValueRGBA | ( | vtkIdType | idx, |
unsigned char | rgba[4] ) |
Set a value within the LUT.
Definition at line 159 of file VtkColorLookupTable.cpp.
Referenced by Build().
VtkColorLookupTable::vtkTypeMacro | ( | VtkColorLookupTable | , |
vtkLookupTable | ) |
void VtkColorLookupTable::writeToFile | ( | const std::string & | filename | ) |
Exports a color table to a file.
Definition at line 139 of file VtkColorLookupTable.cpp.
References GetTableValue(), and INFO().
|
private |
Definition at line 94 of file VtkColorLookupTable.h.
Referenced by ~VtkColorLookupTable(), Build(), and setColor().
|
private |
Definition at line 95 of file VtkColorLookupTable.h.
Referenced by Build(), getInterpolationType(), and setInterpolationType().
|
static |
Definition at line 38 of file VtkColorLookupTable.h.
|
static |
Definition at line 37 of file VtkColorLookupTable.h.