OpenWalnut
1.5.0dev
|
A class that stores a 1D transfer function which consists of a linear interpolation of alpha and color values. More...
#include <WTransferFunction.h>
Classes | |
struct | AlphaEntry |
Alpha entries represent linearly interpolated transparency values along the isovalue scale. More... | |
struct | ColorEntry |
Color entries are linearly interpolated colors along isovalues. More... | |
struct | Entry |
Prototype for a storage element. More... | |
struct | LessPred |
Templatized comparison predicate for internal searching. More... | |
Public Member Functions | |
WTransferFunction () | |
Default constructor of a meaningless transfer function. More... | |
WTransferFunction (const WTransferFunction &rhs) | |
Deep copy constructor. More... | |
WTransferFunction & | operator= (const WTransferFunction &rhs) |
Deep copy operator. More... | |
bool | operator== (const WTransferFunction &rhs) const |
Check equivalence of two transfer functions. More... | |
bool | operator!= (const WTransferFunction &rhs) const |
Check equivalence of two transfer functions. More... | |
~WTransferFunction () | |
Default destuctor. More... | |
size_t | numAlphas () const |
Get the number of alphas. More... | |
size_t | numColors () const |
Get the number of colors. More... | |
double | getOpacityScale () const |
Get the scaling factor for the opacity. More... | |
void | setOpacityScale (double factor) |
Set the scaling factor for the opacity. More... | |
double | getAlphaIsovalue (size_t i) const |
Get the isovalue at a given index in the alpha values. More... | |
double | getColorIsovalue (size_t i) const |
The isovalue of the color at a given index. More... | |
double | getAlpha (size_t i) const |
Get alpha at given index. More... | |
const WColor & | getColor (size_t i) const |
Get color at given index. More... | |
void | addColor (double iso, const WColor &color) |
Insert a new color point. More... | |
void | addAlpha (double iso, double alpha) |
Insert a new alpha point. More... | |
void | setHistogram (std::vector< double > &data) |
Set the histogram going along with the transfer function. More... | |
void | removeHistogram () |
Clears the histogram data so the gui won't show any. More... | |
const std::vector< double > & | getHistogram () const |
Returns the histogram. More... | |
void | sample1DTransferFunction (unsigned char *array, int width, double min, double max) const |
sample/render the transfer function linearly between min and max in an RGBA texture. More... | |
Static Public Member Functions | |
static WTransferFunction | createFromRGBA (unsigned char const *const rgba, size_t size) |
Try to estimate a transfer function from an RGBA image. More... | |
Private Attributes | |
std::vector< ColorEntry > | m_colors |
Sorted list of colors. More... | |
std::vector< AlphaEntry > | m_alphas |
Sorted list of alpha values. More... | |
double | m_isomin |
The smallest used iso value. More... | |
double | m_isomax |
The largest used iso value. More... | |
double | m_opacityScale |
Factor by which the output opacity is scaled to allow for easier specification of very small opacity values. More... | |
std::vector< double > | m_histogram |
Sores a histogram. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const WTransferFunction &tf) |
Default output operator. More... | |
A class that stores a 1D transfer function which consists of a linear interpolation of alpha and color values.
Definition at line 37 of file WTransferFunction.h.
|
inline |
Default constructor of a meaningless transfer function.
Definition at line 43 of file WTransferFunction.h.
|
inline |
Deep copy constructor.
rhs | the value to histogram |
Definition at line 52 of file WTransferFunction.h.
|
inline |
Default destuctor.
Definition at line 95 of file WTransferFunction.h.
void WTransferFunction::addAlpha | ( | double | iso, |
double | alpha | ||
) |
Insert a new alpha point.
iso | the new iso value |
alpha | the new alpha value at the given iso value |
Definition at line 211 of file WTransferFunction.cpp.
References m_alphas, m_colors, m_isomax, and m_isomin.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::create(), createFromRGBA(), WMTransferFunction1D::properties(), WVisualizationPropertyHandler::setColorGradient(), and WTransferFunctionWidget::updateTransferFunction().
void WTransferFunction::addColor | ( | double | iso, |
const WColor & | color | ||
) |
Insert a new color point.
iso | the new iso value |
color | the new color at the given iso value |
Definition at line 187 of file WTransferFunction.cpp.
References m_alphas, m_colors, m_isomax, and m_isomin.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::create(), createFromRGBA(), WMTransferFunction1D::properties(), WVisualizationPropertyHandler::setColorGradient(), and WTransferFunctionWidget::updateTransferFunction().
|
static |
Try to estimate a transfer function from an RGBA image.
rgba | values between 0 and 255 representing the red, green, and blue channel |
size | number of color entries in rgba |
the threshold here is larger than for alpha, becuase we compare all colors at once
Definition at line 235 of file WTransferFunction.cpp.
References addAlpha(), and addColor().
Referenced by WTransferFunctionScene::dropEvent().
|
inline |
Get alpha at given index.
i | the index to query |
Definition at line 166 of file WTransferFunction.h.
References m_alphas, and m_opacityScale.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), and WPropertyTransferFunctionWidget::update().
|
inline |
Get the isovalue at a given index in the alpha values.
i | the index of the point to query |
Definition at line 144 of file WTransferFunction.h.
References m_alphas.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), and WPropertyTransferFunctionWidget::update().
|
inline |
Get color at given index.
i | the index to query |
Definition at line 177 of file WTransferFunction.h.
References m_colors.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), and WPropertyTransferFunctionWidget::update().
|
inline |
The isovalue of the color at a given index.
i | the index of the point to query. |
Definition at line 155 of file WTransferFunction.h.
References m_colors.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), and WPropertyTransferFunctionWidget::update().
|
inline |
Returns the histogram.
Definition at line 225 of file WTransferFunction.h.
References m_histogram.
Referenced by WPropertyTransferFunctionWidget::update().
|
inline |
Get the scaling factor for the opacity.
Definition at line 124 of file WTransferFunction.h.
References m_opacityScale.
|
inline |
Get the number of alphas.
Definition at line 104 of file WTransferFunction.h.
References m_alphas.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), WMTransferFunction1D::moduleMain(), and WPropertyTransferFunctionWidget::update().
|
inline |
Get the number of colors.
Definition at line 114 of file WTransferFunction.h.
References m_colors.
Referenced by PROPERTY_TYPE_HELPER::WStringConversion< WPVBaseTypes::PV_TRANSFERFUNCTION >::asString(), and WPropertyTransferFunctionWidget::update().
bool WTransferFunction::operator!= | ( | const WTransferFunction & | rhs | ) | const |
Check equivalence of two transfer functions.
rhs | the value to compare with |
Definition at line 91 of file WTransferFunction.cpp.
|
inline |
Deep copy operator.
rhs | the value to copy |
Definition at line 65 of file WTransferFunction.h.
References m_alphas, m_colors, m_histogram, m_isomax, and m_isomin.
bool WTransferFunction::operator== | ( | const WTransferFunction & | rhs | ) | const |
Check equivalence of two transfer functions.
rhs | object to compare with |
Definition at line 33 of file WTransferFunction.cpp.
References m_alphas, m_colors, m_histogram, m_isomax, and m_isomin.
|
inline |
Clears the histogram data so the gui won't show any.
Definition at line 215 of file WTransferFunction.h.
References m_histogram.
Referenced by WMTransferFunction1D::moduleMain().
void WTransferFunction::sample1DTransferFunction | ( | unsigned char * | array, |
int | width, | ||
double | min, | ||
double | max | ||
) | const |
sample/render the transfer function linearly between min and max in an RGBA texture.
array | pointer to an allocated data structure |
width | is the number of RGBA samples. |
min | the lowest value to be sampled |
max | the hightes value to be sampled |
Definition at line 115 of file WTransferFunction.cpp.
References m_alphas, m_colors, m_isomax, m_isomin, and m_opacityScale.
Referenced by WMTransferFunction1D::moduleMain(), and WCsvConverter::sampleTransferFunction().
|
inline |
Set the histogram going along with the transfer function.
This should be changed in the future to be handled in a different way. A good option would be to introduce an object encapsulating a transfer function and histogram information.
data | the histogram data between m_isomin and m_isomax |
Definition at line 207 of file WTransferFunction.h.
References m_histogram.
Referenced by WMTransferFunction1D::moduleMain(), and WTransferFunctionWidget::updateTransferFunction().
|
inline |
Set the scaling factor for the opacity.
factor | scaling factor of opacity values |
Definition at line 133 of file WTransferFunction.h.
References m_opacityScale.
Referenced by WMTransferFunction1D::moduleMain().
|
friend |
Default output operator.
Currently stores values the same way as it is done in the properties. This code should only be used for debugging and you should not rely on the interface.
tf | The transfer function to output |
out | The stream to which we write |
Definition at line 355 of file WTransferFunction.cpp.
|
private |
Sorted list of alpha values.
Definition at line 368 of file WTransferFunction.h.
Referenced by addAlpha(), addColor(), getAlpha(), getAlphaIsovalue(), numAlphas(), operator=(), operator==(), and sample1DTransferFunction().
|
private |
Sorted list of colors.
Definition at line 363 of file WTransferFunction.h.
Referenced by addAlpha(), addColor(), getColor(), getColorIsovalue(), numColors(), operator=(), operator==(), and sample1DTransferFunction().
|
private |
Sores a histogram.
This is used for property-handling only and does not change the transfer function at all.
Definition at line 391 of file WTransferFunction.h.
Referenced by getHistogram(), operator=(), operator==(), removeHistogram(), and setHistogram().
|
private |
The largest used iso value.
Definition at line 378 of file WTransferFunction.h.
Referenced by addAlpha(), addColor(), operator=(), operator==(), and sample1DTransferFunction().
|
private |
The smallest used iso value.
Definition at line 373 of file WTransferFunction.h.
Referenced by addAlpha(), addColor(), operator=(), operator==(), and sample1DTransferFunction().
|
private |
Factor by which the output opacity is scaled to allow for easier specification of very small opacity values.
Definition at line 385 of file WTransferFunction.h.
Referenced by getAlpha(), getOpacityScale(), sample1DTransferFunction(), and setOpacityScale().