Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

vlTxFunction Class Reference

This class provides a single transfer function. More...

#include <vltxfunction.h>

List of all members.

Public Member Functions

 vlTxFunction (vlColor4f const &color=vlColor4f(1.0, 1.0, 1.0, 1.0), std::string const &name="noname")
 Default constructor.

virtual ~vlTxFunction ()
 Default destructor.

bool addPoint (float const x, float const y)
 Add a point to the map.

bool addPoint (vlPoint2f const &point)
 Add a point to the map.

bool removePoint (float const x)
 Remove point nearest to the given point from the map.

std::vector< vlPoint2fpoints () const
 Returns the points which make up the map.

std::vector< float > lookUpTable () const
 Get the look up table.

const std::vector< float > & lookUpTableRef () const
 Get a const reference to the look up table.

std::string name () const
 Get the name for this transfer function.

void setAutoUpdate (bool autoUpdate=true)
 Set auto update - if true, table is automatically updated when points are add/removed.

bool setTableWidth (uint32 width)
 Set the new width for the look up table.

void setActive (bool active=true)
 Sets the active/inactive state of the map.

void setEditable (bool editable=true)
 Sets the editable/non-editable state of the map.

bool isActive () const
 Returns true if the map is active.

bool isEditable () const
 Returns true if the map is editable.

void print ()
 prints the map to cout

vlTxFunctionoperator= (vlTxFunction const &other)
 Overloading operator =.

void clear ()
 Clears all the transfer function points.


Protected Member Functions

bool initialize ()
 Initializes the class to default values.

bool updateTable (bool force=false)
 Creates the LUT from map points stored in m_mapPoints.

void clearPoints ()
 Clears the map points and re-initializes them.

bool createRamp (unsigned int startPos, unsigned int endPos, float startVal, float endVal)
 This creates a ramp from startPos to endPos (range 0-tableWidth) with values from startVal to endVal.

bool createRamp (float startPos, float endPos, float startVal, float endVal)
 This creates a ramp from startPos to endPos (range 0.0-1.0) with values from startVal to endVal.

bool createLevel (unsigned int startPos, unsigned int endPos, float levelVal)
 This sets values between (and including) startPos and endPos to levelVal.


Static Protected Attributes

const uint16 defaultTableWidth = 256

Private Attributes

std::vector< float > m_lookUpTable
 The actual Look Up Table.

std::vector< vlPoint2fm_mapPoints
 Stores the map as points - the LUT is created from these points.

bool m_updateTable
 This bit is set when points are added/removed and reset when table is updated.

bool m_autoUpdate
 If true, any change in points will reflect on the stored map.

bool m_active
 When false, the values in the transfer function will be all set to zero.

bool m_editable
 If false, points add/remove will not work.

vlColor4f m_color
 Color associated with the map.

std::string m_name
 A name for the transfer function.


Detailed Description

The transfer function stores points internally and has the ability to generate a look up table when needed. The lookup table can be generated using different methods from the given set of points (linear ramp, bezier etc. when implemented).

To use this transfer function, declare a transfer function with a color and a name. Initially, the transfer function will have just two points (0,0) and (1,1). Now you can add more points using addPoint() and remove points using removePoints(). Internally, only these points are stored. The transfer function also has the ability to give a look up table of floats (like the one OpenGL expects). A call to getTable() will check if points were changed, and if so, it will generate a look up table based on the current set of points. The width of the table can be adjusted using setTableWidth(). The default width of the table is 256. The LUT can also be automatically updated as points are added/removed/changed. This can be done by calling setAutoUpdate(true).

Author:
Sarang Lakare <sarang#users.sf.net>

Definition at line 56 of file vltxfunction.h.


Constructor & Destructor Documentation

vlTxFunction::vlTxFunction vlColor4f const &  color = vlColor4f(1.0, 1.0, 1.0, 1.0),
std::string const &  name = "noname"
 

Definition at line 32 of file vltxfunction.cpp.

References initialize(), and name.

vlTxFunction::~vlTxFunction  )  [virtual]
 

Definition at line 45 of file vltxfunction.cpp.


Member Function Documentation

bool vlTxFunction::addPoint vlPoint2f const &  point  )  [inline]
 

Definition at line 70 of file vltxfunction.h.

References addPoint(), vlCouple< T >::x(), and vlCouple< T >::y().

bool vlTxFunction::addPoint float const  x,
float const  y
 

Points have to be in the range (0.0-1.0, 0.0-1.0). The first coordinate is the position and the second is the value.

Parameters:
x The position (0.0 - 1.0)
y The value (0.0 - 1.0)
Returns:
true if the point was successfully added, else false

Definition at line 215 of file vltxfunction.cpp.

References m_active, m_autoUpdate, m_editable, m_lookUpTable, m_mapPoints, m_updateTable, updateTable(), vlPoint2f, x, and y.

Referenced by addPoint().

void vlTxFunction::clear  ) 
 

There will be only two map points 0.0 and 1.0

Definition at line 450 of file vltxfunction.cpp.

References clearPoints(), and m_editable.

void vlTxFunction::clearPoints  )  [protected]
 

There will be only two map points 0.0 and 1.0

Definition at line 461 of file vltxfunction.cpp.

References m_autoUpdate, m_editable, m_mapPoints, m_updateTable, updateTable(), and vlPoint2f.

Referenced by clear().

bool vlTxFunction::createLevel unsigned int  startPos,
unsigned int  endPos,
float  levelVal
[protected]
 

This is done in m_lookUpTable irrespective of the map being active or not. The same effect (of levelling) can be done using CreateRamp(). This is a little bit faster than CreateRamp() function to make a level.

Parameters:
startPos 
endPos 
levelVal 
Returns:

Definition at line 614 of file vltxfunction.cpp.

References m_lookUpTable.

bool vlTxFunction::createRamp float  startPos,
float  endPos,
float  startVal,
float  endVal
[protected]
 

This ramp is created in m_lookUpTable irrespective of the map being active or not.

Parameters:
startPos 
endPos 
startVal 
endVal 
Returns:

Definition at line 543 of file vltxfunction.cpp.

References m_lookUpTable.

bool vlTxFunction::createRamp unsigned int  startPos,
unsigned int  endPos,
float  startVal,
float  endVal
[protected]
 

This ramp is created in m_lookUpTable irrespective of the map being active or not.

Parameters:
startPos 
endPos 
startVal 
endVal 
Returns:

Definition at line 489 of file vltxfunction.cpp.

References m_lookUpTable.

Referenced by updateTable().

bool vlTxFunction::initialize  )  [protected]
 

Returns:
(true) if everything was fine.

Definition at line 120 of file vltxfunction.cpp.

References defaultTableWidth, m_lookUpTable, m_mapPoints, setActive(), setAutoUpdate(), setEditable(), updateTable(), and vlPoint2f.

Referenced by vlTxFunction().

bool vlTxFunction::isActive  )  const
 

Definition at line 83 of file vltxfunction.cpp.

References m_active.

bool vlTxFunction::isEditable  )  const
 

Definition at line 89 of file vltxfunction.cpp.

References m_editable.

std::vector< float > vlTxFunction::lookUpTable  )  const
 

Todo:
Shouldn't there be a createTable() here?

Definition at line 59 of file vltxfunction.cpp.

References m_lookUpTable.

const std::vector< float > & vlTxFunction::lookUpTableRef  )  const
 

Definition at line 64 of file vltxfunction.cpp.

References m_lookUpTable.

std::string vlTxFunction::name  )  const
 

Definition at line 70 of file vltxfunction.cpp.

References m_name.

vlTxFunction & vlTxFunction::operator= vlTxFunction const &  other  ) 
 

Parameters:
other 
Returns:

Definition at line 100 of file vltxfunction.cpp.

References m_active, m_autoUpdate, m_color, m_editable, m_lookUpTable, and m_mapPoints.

std::vector< vlPoint2f > vlTxFunction::points  )  const
 

Definition at line 52 of file vltxfunction.cpp.

References m_mapPoints.

void vlTxFunction::print  ) 
 

Definition at line 652 of file vltxfunction.cpp.

References m_lookUpTable.

bool vlTxFunction::removePoint float const  x  ) 
 

Parameters:
x The position from which to search for the nearest point
Returns:
true if a point was successfully removed, false otherwise

Definition at line 299 of file vltxfunction.cpp.

References m_active, m_autoUpdate, m_editable, m_lookUpTable, m_mapPoints, m_updateTable, updateTable(), and x.

void vlTxFunction::setActive bool  active = true  ) 
 

i.e. this map will be used for any rendering calls henceforth.

Parameters:
active true = active; false = inactive.

Definition at line 155 of file vltxfunction.cpp.

References m_active.

Referenced by initialize().

void vlTxFunction::setAutoUpdate bool  autoUpdate = true  ) 
 

Definition at line 76 of file vltxfunction.cpp.

References m_autoUpdate.

Referenced by initialize().

void vlTxFunction::setEditable bool  editable = true  ) 
 

the following edit operations will affect the map.

Parameters:
editable true = editable; false = non-editable

Definition at line 200 of file vltxfunction.cpp.

References m_editable.

Referenced by initialize().

bool vlTxFunction::setTableWidth uint32  width  ) 
 

Parameters:
width The new width of the table
Returns:
true if the new tabe width is set, else false

Definition at line 176 of file vltxfunction.cpp.

References m_lookUpTable, m_updateTable, and updateTable().

bool vlTxFunction::updateTable bool  force = false  )  [protected]
 

Parameters:
force when true, the update is forced.
Returns:
(true) if it went well, else (false).

Definition at line 397 of file vltxfunction.cpp.

References createRamp(), m_mapPoints, m_updateTable, vlCouple< T >::x(), and vlCouple< T >::y().

Referenced by addPoint(), clearPoints(), initialize(), removePoint(), and setTableWidth().


Member Data Documentation

const uint16 vlTxFunction::defaultTableWidth = 256 [static, protected]
 

Definition at line 142 of file vltxfunction.h.

Referenced by initialize().

bool vlTxFunction::m_active [private]
 

Definition at line 159 of file vltxfunction.h.

Referenced by addPoint(), isActive(), operator=(), removePoint(), and setActive().

bool vlTxFunction::m_autoUpdate [private]
 

Definition at line 156 of file vltxfunction.h.

Referenced by addPoint(), clearPoints(), operator=(), removePoint(), and setAutoUpdate().

vlColor4f vlTxFunction::m_color [private]
 

Definition at line 165 of file vltxfunction.h.

Referenced by operator=().

bool vlTxFunction::m_editable [private]
 

Definition at line 162 of file vltxfunction.h.

Referenced by addPoint(), clear(), clearPoints(), isEditable(), operator=(), removePoint(), and setEditable().

std::vector<float> vlTxFunction::m_lookUpTable [private]
 

Definition at line 147 of file vltxfunction.h.

Referenced by addPoint(), createLevel(), createRamp(), initialize(), lookUpTable(), lookUpTableRef(), operator=(), print(), removePoint(), and setTableWidth().

std::vector<vlPoint2f> vlTxFunction::m_mapPoints [private]
 

Definition at line 150 of file vltxfunction.h.

Referenced by addPoint(), clearPoints(), initialize(), operator=(), points(), removePoint(), and updateTable().

std::string vlTxFunction::m_name [private]
 

Definition at line 168 of file vltxfunction.h.

Referenced by name().

bool vlTxFunction::m_updateTable [private]
 

Definition at line 153 of file vltxfunction.h.

Referenced by addPoint(), clearPoints(), removePoint(), setTableWidth(), and updateTable().


The documentation for this class was generated from the following files:
Generated on Fri Mar 18 11:33:19 2005 for OpenVL by doxygen 1.3.3