TransFunc Class Reference

Base class for transfer functions. More...

#include <transfunc.h>

Inheritance diagram for TransFunc:
Serializable TransFuncIntensity TransFuncIntensityGradient

List of all members.

Public Member Functions

 TransFunc (int width=256, int height=1, int depth=1, GLint format=GL_RGBA, GLenum dataType=GL_UNSIGNED_BYTE, tgt::Texture::Filter filter=tgt::Texture::NEAREST)
 Constructor.
virtual ~TransFunc ()
 Destructor.
virtual std::string getShaderDefines () const
 Returns a define for the usage of transfer functions in shaders.
virtual std::string getSamplerType () const
 Returns a string representation of the sampler type: "sampler1D" for 1D transfer functions, "sampler2D" for 2D transfer functions, "sampler3D" for 3D transfer functions.
tgt::ivec3 getDimensions () const
 Returns the dimensions of the transfer function's texture.
void bind ()
 Binds the transfer function texture.
tgt::TexturegetTexture ()
 Returns the texture of the transfer function.
virtual void resize (int width, int height=1, int depth=1)
 Sets the dimensions of the transfer function to the given values.
void invalidateTexture ()
 Marks the texture of the transfer function as invalid, so it will be updated on next access.
bool isTextureInvalid () const
 Returns whether the texture will be updated on next access.
virtual void updateTexture ()
 Updates the texture of the transfer function or creates it, if it is not present.
virtual void setPixelData (GLubyte *data)
 Use this function to define the transfer function's look up table.
virtual GLubyte * getPixelData ()
 Returns the transfer function texture's pixel data.
virtual bool load (const std::string &filename)
 Creates a transfer function out of the data contained in the file given by filename.
const std::vector< std::string > & getLoadFileFormats () const
 Returns a vector that contains the endings of suppported file formats for loading.
const std::vector< std::string > & getSaveFileFormats () const
 Returns a vector that contains the endings of supported file formats for saving.
virtual void serialize (XmlSerializer &s) const
 Dummy.
virtual void deserialize (XmlDeserializer &s)
 Dummy.
virtual TransFuncclone () const
 Returns a copy of this object.
GLint getFormat () const
 Returns the format of the transfer function texture internally used.

Protected Member Functions

virtual void createTex ()
 Generates the transfer function texture according to the specified parameters.

Protected Attributes

tgt::Texturetex_
 the texture of the transfer function, is generated internally
tgt::ivec3 dimensions_
 dimensions of the transfer function texture
GLint format_
 format of the transfer function texture
GLenum dataType_
 data type of the transfer function texture
tgt::Texture::Filter filter_
 filtering mode of the transfer function texture.
std::vector< std::string > loadFileFormats_
 endings that are supported for loading a transfer function
std::vector< std::string > saveFileFormats_
 endings that are supported for saving a transfer function
bool textureInvalid_
 indicates whether the transfer function texture has to be updated

Detailed Description

Base class for transfer functions.

The lookup table can be defined by passing pixel data that is directly assigned to the transfer function's texture.

Definition at line 47 of file transfunc.h.


Constructor & Destructor Documentation

TransFunc ( int  width = 256,
int  height = 1,
int  depth = 1,
GLint  format = GL_RGBA,
GLenum  dataType = GL_UNSIGNED_BYTE,
tgt::Texture::Filter  filter = tgt::Texture::NEAREST 
)

Constructor.

Parameters:
width width of transfer function
height of transfer function. Pass one for a 1D transfer function.
depth of transfer function. Pass one for a 1D or 2D transfer function.
format transfer function texture's format (see tgt::Texture)
dataType transfer function texture's data type (see tgt::Texture)
filter transfer function texture's filtering mode (see tgt::Texture)

Definition at line 36 of file transfunc.cpp.


Member Function Documentation

void bind (  ) 

Binds the transfer function texture.

If it has been marked invalid, updateTexture() is called before.

Note:
If the texture is not present when calling this function, it is created. Therefore, the caller has to make sure that a valid OpenGL context is active.

Definition at line 68 of file transfunc.cpp.

void deserialize ( XmlDeserializer s  )  [virtual]

Dummy.

The lookup table is not deserialized.

See also:
Serializable::deserialize

Implements Serializable.

Reimplemented in TransFuncIntensity, and TransFuncIntensityGradient.

Definition at line 180 of file transfunc.cpp.

const std::vector< std::string > & getLoadFileFormats (  )  const

Returns a vector that contains the endings of suppported file formats for loading.

Returns:
vector with endings of supported file formats

Definition at line 52 of file transfunc.cpp.

std::string getSamplerType (  )  const [virtual]

Returns a string representation of the sampler type: "sampler1D" for 1D transfer functions, "sampler2D" for 2D transfer functions, "sampler3D" for 3D transfer functions.

Returns:
string representation of the sampler type used by the transfer function

Definition at line 101 of file transfunc.cpp.

const std::vector< std::string > & getSaveFileFormats (  )  const

Returns a vector that contains the endings of supported file formats for saving.

Returns:
vector with endings of supported file formats

Definition at line 56 of file transfunc.cpp.

std::string getShaderDefines (  )  const [virtual]

Returns a define for the usage of transfer functions in shaders.

For 1D transfer functions the define looks like: "#define TF_SAMPLER_TYPE sampler1D \n" and with sampler2D for 2D transfer functions.

Returns:
define for usage of transfer functions in shaders

Definition at line 110 of file transfunc.cpp.

tgt::Texture * getTexture (  ) 

Returns the texture of the transfer function.

If it has been marked invalid, updateTexture() is called before.

Note:
If the texture is not present when calling this function, it is created. Therefore, the caller has to make sure that a valid OpenGL context is active.

Definition at line 93 of file transfunc.cpp.

bool load ( const std::string &  filename  )  [virtual]

Creates a transfer function out of the data contained in the file given by filename.

Parameters:
filename The path to the file in which the data is stored
Returns:
true when the load was successful, false otherwise

Reimplemented in TransFuncIntensity, and TransFuncIntensityGradient.

Definition at line 172 of file transfunc.cpp.

void resize ( int  width,
int  height = 1,
int  depth = 1 
) [virtual]

Sets the dimensions of the transfer function to the given values.

The texture is not updated at this point, but mark as invalid so it will be updated on next access.

Parameters:
width width of the transfer function.
height height of the transfer function. Set to one for 1D transfer functions.
depth height of the transfer function. Set to one for 1D or 2D transfer functions.

Definition at line 114 of file transfunc.cpp.

void serialize ( XmlSerializer s  )  const [virtual]

Dummy.

The lookup table is not serialized.

See also:
Serializable::serialize

Implements Serializable.

Reimplemented in TransFuncIntensity, and TransFuncIntensityGradient.

Definition at line 176 of file transfunc.cpp.

void setPixelData ( GLubyte *  data  )  [virtual]

Use this function to define the transfer function's look up table.

The passed pixel data is assigned to the transfer function's texture.

Parameters:
data the pixel data to assign. Must match the transfer function in dimension, format and data type. Use reinterpret_cast in order to pass data of other type than GLubyte.
Warning:
The transfer function object takes ownership of the passed memory chunk. Therefore, the caller must not delete it!

Definition at line 184 of file transfunc.cpp.

void updateTexture (  )  [virtual]

Updates the texture of the transfer function or creates it, if it is not present.

The base class implementation uploads the texture data to the GPU.

Note:
This function is called automatically on each texture access, when the texture is marked as invalid. You might call it directly in order to force an immediate update. But then you have to make sure that an valid OpenGL context is active.

Reimplemented in TransFuncIntensity, and TransFuncIntensityGradient.

Definition at line 76 of file transfunc.cpp.