29 #include "WMTransferFunction1D.h"
30 #include "WMTransferFunction1D.xpm"
31 #include "core/common/WTransferFunction.h"
32 #include "core/dataHandler/WDataSetScalar.h"
33 #include "core/dataHandler/WGrid.h"
34 #include "core/dataHandler/WGridRegular3D.h"
35 #include "core/dataHandler/WValueSet.h"
36 #include "core/dataHandler/WValueSetBase.h"
37 #include "core/dataHandler/datastructures/WValueSetHistogram.h"
38 #include "core/kernel/WKernel.h"
43 WMTransferFunction1D::WMTransferFunction1D():
48 WMTransferFunction1D::~WMTransferFunction1D()
60 return WMTransferFunction1D_xpm;
65 return "Transfer Function 1D";
70 return "A module to modify a transfer function.";
77 "histogram input",
"The data set used to display a histogram." );
81 "transferFunction1D",
"The selected transfer function" );
91 tf.
addColor( 0.0, WColor( 0.0, 0.0, 1.0, 1.0 ) );
92 tf.
addColor( 0.5, WColor( 0.0, 1.0, 0.0, 1.0 ) );
95 tf.
addColor( 1.0, WColor( 1.0, 0.0, 0.0, 1.0 ) );
99 "Factor used to scale opacity for easier interaction",
110 "Number of samples in the transfer function. "
111 "Some modules connected to the output may have additional restrictions. Volume rendering, e.g., requires a power of two "
112 "samples at the moment."
145 bool dataValid = ( dataSet != NULL );
155 std::shared_ptr< WValueSetBase > values = dataSet->getValueSet();
160 std::vector<double> vhistogram( histogram.
size() );
161 for(
int i = 0; i < binsize; ++i )
163 vhistogram[ i ] = histogram[ i ];
178 std::shared_ptr< std::vector<unsigned char> > data(
new std::vector<unsigned char>( resolution * 4 ) );
187 std::shared_ptr< WGridRegular3D > newGrid(
new WGridRegular3D( resolution, 1, 1, transform ) );
188 std::shared_ptr< WDataSetSingle > newData(
new WDataSetSingle( newValueSet, newGrid ) );
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
A data set consisting of a set of values based on a grid.
A grid that has parallelepiped cells which all have the same proportion.
A module to provide 1D transfer functions, e.g., for volume rendering.
virtual void connectors()
Initialize the connectors this module is using.
virtual void requirements()
Initialize requirements for this module.
WPropTransferFunction m_transferFunction
The transfer function property.
virtual const std::string getDescription() const
Gives back a description of this module.
virtual void properties()
Initialize the properties for this module.
WPropInt m_binSize
Histogram bin size.
WPropDouble m_opacityScale
Histogram bin size.
WModuleOutputData< WDataSetSingle >::SPtr m_output
The output connector used to provide the calculated data to other modules.
virtual void moduleMain()
Entry point after loading the module.
WPropInt m_resolution
Resolution of the transfer function.
WModuleInputData< WDataSetSingle >::SPtr m_input
virtual const std::string getName() const
Gives back the name of this module.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
std::shared_ptr< WCondition > getDataChangedCondition()
Gets the condition variable that gets fired whenever new data has been sent.
Class offering an instantiate-able data connection between modules.
virtual void updateData(std::shared_ptr< T > data)
Update the data associated.
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
std::shared_ptr< WProperties > m_properties
The property object for the module.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
virtual void connectors()
Initialize connectors in this function.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
A class that stores a 1D transfer function which consists of a linear interpolation of alpha and colo...
void setHistogram(std::vector< double > &data)
Set the histogram going along with the transfer function.
void setOpacityScale(double factor)
Set the scaling factor for the opacity.
void removeHistogram()
Clears the histogram data so the gui won't show any.
size_t numAlphas() const
Get the number of alphas.
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.
void addColor(double iso, const WColor &color)
Insert a new color point.
void addAlpha(double iso, double alpha)
Insert a new alpha point.
Used to find the occurrence frequencies of values in a value set.
virtual size_t size() const
Returns the number of buckets in the histogram with the actual mapping.
Base Class for all value set types.