MorphoGraphX  2.0-1-227
Public Types | Public Member Functions | Static Public Attributes | List of all members
mgx::TransferFunction Class Reference

#include <TransferFunction.hpp>

Public Types

enum  Interpolation { RGB, HSV, CYCLIC_HSV }
 Type of interpolation. More...
 
typedef Color< float > Colorf
 Type of a color. More...
 
typedef std::vector< std::pair< double, Colorf > > value_list
 Type of a list of value/colors. More...
 
typedef QMap< double, int > key_map
 Type of the mapping from the position to the index in the value list. More...
 

Public Member Functions

 TransferFunction (Interpolation interpolation=RGB)
 Default constructor for a transfer function. More...
 
 TransferFunction (const TransferFunction &copy)
 Copy constructor. More...
 
virtual ~TransferFunction ()
 Virtual destructor. More...
 

Static Public Attributes

static const double epsilon
 epsilon used in floating point comparisons More...
 

Predefined transfer functions

Interpolation _interpolation
 Current interpolation mode. More...
 
value_list values
 List of values. More...
 
key_map keys
 Mapping of the position to the index in the value list. More...
 
bool clamp
 If true, the colors left and right of the defined points are clamped. More...
 
Colorf exteriorColor
 Color left and right of the control points if not clamped. More...
 
QString dump () const
 Store the transfer function into a string. More...
 
void add_rgba_point (double pos, Colorf col)
 Add a point to the interpolation with the color are RGBA. More...
 
void add_hsva_point (double pos, Colorf col)
 Add a point to the interpolation with the color are HSVA. More...
 
void remove_point (double pos)
 Remove the point at the given position (if any) More...
 
size_t size () const
 Returns the number of points. More...
 
void move_point (double old_pos, double new_pos)
 Move a point (if found) More...
 
double next_pos (double old_pos) const
 Position of the next point, or -1 if none. More...
 
double prev_pos (double old_pos) const
 Position of the previous point, or -1 if none. More...
 
double operator[] (int i) const
 Return the i_th point. More...
 
Colorf rgba_point (double position) const
 Return the RGBA point at position. More...
 
Colorf hsva_point (double position) const
 Return the RGBA point at position. More...
 
Colorf rgba (double position) const
 Returns the color at position in RGBA, linearly interpolating between specified points. More...
 
Colorf hsva (double position) const
 Returns the color at position in HSVA, linearly interpolating between specified points. More...
 
double alpha (double position) const
 Returns the transparency of the color at position, linearly interpolating between specified points. More...
 
bool empty () const
 Returns true if no points are defined. More...
 
TransferFunctionoperator= (const TransferFunction &other)
 Assignement operator for transfer function. More...
 
bool operator== (const TransferFunction &other) const
 Test if two transfer functions are equal. More...
 
bool operator!= (const TransferFunction &other) const
 Test if two transfer functions are different. More...
 
void reverse ()
 Reverse the control point. More...
 
void clear ()
 Erase all control points. More...
 
void adjust (double minValue, double maxValue)
 Adjust the control point to span exactly from minValue to maxValue. More...
 
Interpolation interpolation () const
 Returns the current interpolation mode. More...
 
void setInterpolation (Interpolation i)
 Change the interpolation mode. More...
 
void setPointList (const value_list &lst)
 Change all the control points at once. More...
 
static TransferFunction scale (Colorf min, Colorf max, Interpolation interpolation=RGB)
 Predefined transfer-function, scaling from min to \max. More...
 
static TransferFunction hue_scale ()
 Scale in hue. More...
 
static TransferFunction scale_gray ()
 Scale in gray. More...
 
static TransferFunction scale_red ()
 Scale in red. More...
 
static TransferFunction scale_green ()
 Scale in green. More...
 
static TransferFunction scale_blue ()
 Scale in blue. More...
 
static TransferFunction scale_yellow ()
 Scale in yellow. More...
 
static TransferFunction scale_cyan ()
 Scale in cyan. More...
 
static TransferFunction scale_purple ()
 Scale in purple. More...
 
static TransferFunction constant_gray ()
 Scale in transparency. More...
 
static TransferFunction constant_red ()
 Scale in transparency. More...
 
static TransferFunction constant_green ()
 Scale in transparency. More...
 
static TransferFunction constant_blue ()
 Scale in transparency. More...
 
static TransferFunction constant_yellow ()
 Scale in transparency. More...
 
static TransferFunction constant_cyan ()
 Scale in transparency. More...
 
static TransferFunction constant_purple ()
 Scale in transparency. More...
 
static TransferFunction jet ()
 Jet color scale. More...
 
static TransferFunction french_flag ()
 French flag color scale. More...
 
static TransferFunction blackbody ()
 Blackbody colour scale: black - red - yellow - white. More...
 
static TransferFunction uniform_jet ()
 A more uniform version of Jet, with smoothly changing luminance and chromaticity. More...
 
static TransferFunction helix_warm ()
 A helix through colour space, with warm midtones: black - purple - orange - yellow. More...
 
static TransferFunction helix_cool ()
 A helix through colour space, with cool midtones: black - brown - purple - blue. More...
 
static TransferFunction helix_full ()
 A helix making a full turn through colour space: black - brown - purple - blue - green - yellow. More...
 
static TransferFunction batlow_10 ()
 
static TransferFunction parula ()
 
static TransferFunction load (QString spec)
 Load a transfer function from a string. More...
 
Colorf interpolate (double position, double p1, Colorf col1, double p2, Colorf col2) const
 Internal function to interpolate color. More...
 
void update_keys ()
 Update the key map based on the value list. More...
 
Colorf color (double position) const
 Returns the color at position position, using a color mode in accordance with the interpolation mode. More...
 
void add_point (double pos, Colorf col)
 Add a control point with the color using the current color mode. More...
 

Detailed Description

Class defining a transfer function as linear interpolation between set values.

Definition at line 34 of file TransferFunction.hpp.

Member Typedef Documentation

◆ Colorf

Type of a color.

Definition at line 50 of file TransferFunction.hpp.

◆ key_map

typedef QMap<double, int> mgx::TransferFunction::key_map

Type of the mapping from the position to the index in the value list.

Definition at line 60 of file TransferFunction.hpp.

◆ value_list

typedef std::vector<std::pair<double, Colorf> > mgx::TransferFunction::value_list

Type of a list of value/colors.

Definition at line 55 of file TransferFunction.hpp.

Member Enumeration Documentation

◆ Interpolation

Type of interpolation.

Enumerator
RGB 

Red-Green-Blue.

HSV 

Hue-Saturation-Value.

CYCLIC_HSV 

Like HSV but the hue is cyclic (i.e. to go from 0.9 to 0.1 you go via 0)

Definition at line 40 of file TransferFunction.hpp.

Constructor & Destructor Documentation

◆ TransferFunction() [1/2]

mgx::TransferFunction::TransferFunction ( Interpolation  interpolation = RGB)

Default constructor for a transfer function.

Parameters
interpolationType of interpolation

◆ TransferFunction() [2/2]

mgx::TransferFunction::TransferFunction ( const TransferFunction copy)

Copy constructor.

◆ ~TransferFunction()

virtual mgx::TransferFunction::~TransferFunction ( )
inlinevirtual

Virtual destructor.

Definition at line 76 of file TransferFunction.hpp.

Member Function Documentation

◆ add_hsva_point()

void mgx::TransferFunction::add_hsva_point ( double  pos,
Colorf  col 
)

Add a point to the interpolation with the color are HSVA.

◆ add_point()

void mgx::TransferFunction::add_point ( double  pos,
Colorf  col 
)
protected

Add a control point with the color using the current color mode.

Parameters
posPosition to add the point to
colColor added

◆ add_rgba_point()

void mgx::TransferFunction::add_rgba_point ( double  pos,
Colorf  col 
)

Add a point to the interpolation with the color are RGBA.

◆ adjust()

void mgx::TransferFunction::adjust ( double  minValue,
double  maxValue 
)

Adjust the control point to span exactly from minValue to maxValue.

◆ alpha()

double mgx::TransferFunction::alpha ( double  position) const

Returns the transparency of the color at position, linearly interpolating between specified points.

◆ batlow_10()

static TransferFunction mgx::TransferFunction::batlow_10 ( )
static

◆ blackbody()

static TransferFunction mgx::TransferFunction::blackbody ( )
static

Blackbody colour scale: black - red - yellow - white.

◆ clear()

void mgx::TransferFunction::clear ( )

Erase all control points.

◆ color()

Colorf mgx::TransferFunction::color ( double  position) const
protected

Returns the color at position position, using a color mode in accordance with the interpolation mode.

◆ constant_blue()

static TransferFunction mgx::TransferFunction::constant_blue ( )
inlinestatic

Scale in transparency.

Main color is blue.

Definition at line 155 of file TransferFunction.hpp.

◆ constant_cyan()

static TransferFunction mgx::TransferFunction::constant_cyan ( )
inlinestatic

Scale in transparency.

Main color is cyan.

Definition at line 167 of file TransferFunction.hpp.

◆ constant_gray()

static TransferFunction mgx::TransferFunction::constant_gray ( )
inlinestatic

Scale in transparency.

Main color is gray.

Definition at line 137 of file TransferFunction.hpp.

◆ constant_green()

static TransferFunction mgx::TransferFunction::constant_green ( )
inlinestatic

Scale in transparency.

Main color is green.

Definition at line 149 of file TransferFunction.hpp.

◆ constant_purple()

static TransferFunction mgx::TransferFunction::constant_purple ( )
inlinestatic

Scale in transparency.

Main color is purple.

Definition at line 173 of file TransferFunction.hpp.

◆ constant_red()

static TransferFunction mgx::TransferFunction::constant_red ( )
inlinestatic

Scale in transparency.

Main color is red.

Definition at line 143 of file TransferFunction.hpp.

◆ constant_yellow()

static TransferFunction mgx::TransferFunction::constant_yellow ( )
inlinestatic

Scale in transparency.

Main color is yellow.

Definition at line 161 of file TransferFunction.hpp.

◆ dump()

QString mgx::TransferFunction::dump ( ) const

Store the transfer function into a string.

◆ empty()

bool mgx::TransferFunction::empty ( ) const
inline

Returns true if no points are defined.

Definition at line 291 of file TransferFunction.hpp.

◆ french_flag()

static TransferFunction mgx::TransferFunction::french_flag ( )
static

French flag color scale.

◆ helix_cool()

static TransferFunction mgx::TransferFunction::helix_cool ( )
static

A helix through colour space, with cool midtones: black - brown - purple - blue.

◆ helix_full()

static TransferFunction mgx::TransferFunction::helix_full ( )
static

A helix making a full turn through colour space: black - brown - purple - blue - green - yellow.

◆ helix_warm()

static TransferFunction mgx::TransferFunction::helix_warm ( )
static

A helix through colour space, with warm midtones: black - purple - orange - yellow.

◆ hsva()

Colorf mgx::TransferFunction::hsva ( double  position) const

Returns the color at position in HSVA, linearly interpolating between specified points.

◆ hsva_point()

Colorf mgx::TransferFunction::hsva_point ( double  position) const

Return the RGBA point at position.

If the position is not a defined point, it returns Colorf(-1.0f)

◆ hue_scale()

static TransferFunction mgx::TransferFunction::hue_scale ( )
static

Scale in hue.

Varies hue and transparency.

◆ interpolate()

Colorf mgx::TransferFunction::interpolate ( double  position,
double  p1,
Colorf  col1,
double  p2,
Colorf  col2 
) const
protected

Internal function to interpolate color.

Parameters
positionTarget position
p1Position of the color before position
col1Color at position p1
p2Position of the color after position
col2Color at position p2

◆ interpolation()

Interpolation mgx::TransferFunction::interpolation ( ) const
inline

Returns the current interpolation mode.

Definition at line 335 of file TransferFunction.hpp.

◆ jet()

static TransferFunction mgx::TransferFunction::jet ( )
static

Jet color scale.

◆ load()

static TransferFunction mgx::TransferFunction::load ( QString  spec)
static

Load a transfer function from a string.

◆ move_point()

void mgx::TransferFunction::move_point ( double  old_pos,
double  new_pos 
)

Move a point (if found)

◆ next_pos()

double mgx::TransferFunction::next_pos ( double  old_pos) const

Position of the next point, or -1 if none.

◆ operator!=()

bool mgx::TransferFunction::operator!= ( const TransferFunction other) const

Test if two transfer functions are different.

They are equal only if they are defined using the same control points, and use the same interpolation and border conditions.

◆ operator=()

TransferFunction& mgx::TransferFunction::operator= ( const TransferFunction other)

Assignement operator for transfer function.

◆ operator==()

bool mgx::TransferFunction::operator== ( const TransferFunction other) const

Test if two transfer functions are equal.

They are equal only if they are defined using the same control points, and use the same interpolation and border conditions.

◆ operator[]()

double mgx::TransferFunction::operator[] ( int  i) const

Return the i_th point.

◆ parula()

static TransferFunction mgx::TransferFunction::parula ( )
static

◆ prev_pos()

double mgx::TransferFunction::prev_pos ( double  old_pos) const

Position of the previous point, or -1 if none.

◆ remove_point()

void mgx::TransferFunction::remove_point ( double  pos)

Remove the point at the given position (if any)

◆ reverse()

void mgx::TransferFunction::reverse ( )

Reverse the control point.

Each control point is moved to 1-position.

◆ rgba()

Colorf mgx::TransferFunction::rgba ( double  position) const

Returns the color at position in RGBA, linearly interpolating between specified points.

◆ rgba_point()

Colorf mgx::TransferFunction::rgba_point ( double  position) const

Return the RGBA point at position.

If the position is not a defined point, it returns Colorf(-1.0f)

◆ scale()

static TransferFunction mgx::TransferFunction::scale ( Colorf  min,
Colorf  max,
Interpolation  interpolation = RGB 
)
static

Predefined transfer-function, scaling from min to \max.

Parameters
minColor for 0
maxColor for 1
interpolationType of interpolation

◆ scale_blue()

static TransferFunction mgx::TransferFunction::scale_blue ( )
inlinestatic

Scale in blue.

Varies blue and transparency.

Definition at line 113 of file TransferFunction.hpp.

◆ scale_cyan()

static TransferFunction mgx::TransferFunction::scale_cyan ( )
inlinestatic

Scale in cyan.

Varies cyan and transparency.

Definition at line 125 of file TransferFunction.hpp.

◆ scale_gray()

static TransferFunction mgx::TransferFunction::scale_gray ( )
inlinestatic

Scale in gray.

Varies gray and transparency.

Definition at line 95 of file TransferFunction.hpp.

◆ scale_green()

static TransferFunction mgx::TransferFunction::scale_green ( )
inlinestatic

Scale in green.

Varies green and transparency.

Definition at line 107 of file TransferFunction.hpp.

◆ scale_purple()

static TransferFunction mgx::TransferFunction::scale_purple ( )
inlinestatic

Scale in purple.

Varies purple and transparency.

Definition at line 131 of file TransferFunction.hpp.

◆ scale_red()

static TransferFunction mgx::TransferFunction::scale_red ( )
inlinestatic

Scale in red.

Varies red and transparency.

Definition at line 101 of file TransferFunction.hpp.

◆ scale_yellow()

static TransferFunction mgx::TransferFunction::scale_yellow ( )
inlinestatic

Scale in yellow.

Varies yellow and transparency.

Definition at line 119 of file TransferFunction.hpp.

◆ setInterpolation()

void mgx::TransferFunction::setInterpolation ( Interpolation  i)

Change the interpolation mode.

◆ setPointList()

void mgx::TransferFunction::setPointList ( const value_list lst)

Change all the control points at once.

◆ size()

size_t mgx::TransferFunction::size ( ) const
inline

Returns the number of points.

Definition at line 237 of file TransferFunction.hpp.

◆ uniform_jet()

static TransferFunction mgx::TransferFunction::uniform_jet ( )
static

A more uniform version of Jet, with smoothly changing luminance and chromaticity.

◆ update_keys()

void mgx::TransferFunction::update_keys ( )
protected

Update the key map based on the value list.

Member Data Documentation

◆ _interpolation

Interpolation mgx::TransferFunction::_interpolation
protected

Current interpolation mode.

Definition at line 364 of file TransferFunction.hpp.

◆ clamp

bool mgx::TransferFunction::clamp
protected

If true, the colors left and right of the defined points are clamped.

Otherwise, they are set to the exterior color.

Definition at line 395 of file TransferFunction.hpp.

◆ epsilon

const double mgx::TransferFunction::epsilon
static

epsilon used in floating point comparisons

Definition at line 47 of file TransferFunction.hpp.

◆ exteriorColor

Colorf mgx::TransferFunction::exteriorColor
protected

Color left and right of the control points if not clamped.

Definition at line 400 of file TransferFunction.hpp.

◆ keys

key_map mgx::TransferFunction::keys
protected

Mapping of the position to the index in the value list.

Definition at line 389 of file TransferFunction.hpp.

◆ values

value_list mgx::TransferFunction::values
protected

List of values.

If the mode is HSV or CYCLIC_HSV, the colors are stored in HSVA. Otherwise, the colors are stored in RGBA.

Definition at line 385 of file TransferFunction.hpp.


The documentation for this class was generated from the following file: