Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes

MultiGradient Class Reference
[Visual]

A gradient of multiple colors and arbitrary distances between colors. More...

#include <OpenMS/VISUAL/MultiGradient.h>

List of all members.

Public Types

enum  InterpolationMode { IM_LINEAR, IM_STAIRS }
 

Interploation mode.

More...

Public Member Functions

 MultiGradient ()
 Constructor.
 MultiGradient (const MultiGradient &multigradient)
 Copy constructor.
 ~MultiGradient ()
 Destructor.
MultiGradientoperator= (const MultiGradient &rhs)
 Assignment operator.
void insert (DoubleReal position, QColor color)
 sets or replaces the color at position position
bool remove (DoubleReal position)
 removes the color at position position
bool exists (DoubleReal position)
 returns if a value for position position exists
UInt position (UInt index)
 returns the position of the index -th point
QColor color (UInt index)
 returns the color of the index -th point
QColor interpolatedColorAt (DoubleReal position) const
 Returns the color as position.
QColor interpolatedColorAt (DoubleReal position, DoubleReal min, DoubleReal max) const
 returns the color as position with the gradient stretched between min and max.
void activatePrecalculationMode (DoubleReal min, DoubleReal max, UInt steps)
 activates the precalculation of values (only approximate results are given)
void deactivatePrecalculationMode ()
 deactivates the precalculation of values ( and deletes the precalculated values)
Int precalculatedColorIndex (DoubleReal position) const
 index of color in precalculated table by position in gradient
QColor precalculatedColorByIndex (Int index) const
 precalculated color by its index in the table
QColor precalculatedColorAt (DoubleReal position) const
 Returns a precalculated color.
Size size () const
 return the number of color points
Size precalculatedSize () const
 size of precalculated colors table
void setInterpolationMode (InterpolationMode mode)
 sets the interploation mode (default or stairs). Default is linear
InterpolationMode getInterpolationMode () const
 returns the interpolaion mode
std::string toString () const
 convert to string representation
void fromString (const std::string &gradient)
 Sets the gradient by string representation.

Static Public Member Functions

static MultiGradient getDefaultGradientLinearIntensityMode ()
 Returns the default gradient for linear intensity mode.
static MultiGradient getDefaultGradientLogarithmicIntensityMode ()
 Returns the default gradient for linear intensity mode.

Protected Attributes

std::map< DoubleReal, QColor > pos_col_
 Map of index and color.
InterpolationMode interpolation_mode_
 Current interpolation mode.
std::vector< QColor > pre_
 Precalculated colors.
DoubleReal pre_min_
 Minimum of the precalculated color range.
DoubleReal pre_size_
 Width of the precalculated color range.
UInt pre_steps_
 Steps of the precalculated color range.

Detailed Description

A gradient of multiple colors and arbitrary distances between colors.

Positions associated with numbers range from 0 to 100. There is always a color associated with position 0 and 100. Stretching the gradient to a specified range, and precalculation and caching is also possible.


Member Enumeration Documentation

Interploation mode.

Enumerator:
IM_LINEAR 

IM_LINEAR returns the linear interploation (default).

IM_STAIRS 

IM_STAIRS returns the color of the next lower position.


Constructor & Destructor Documentation

MultiGradient (  ) 

Constructor.

MultiGradient ( const MultiGradient multigradient  ) 

Copy constructor.

~MultiGradient (  ) 

Destructor.


Member Function Documentation

void activatePrecalculationMode ( DoubleReal  min,
DoubleReal  max,
UInt  steps 
)

activates the precalculation of values (only approximate results are given)

QColor color ( UInt  index  ) 

returns the color of the index -th point

Exceptions:
Exception::IndexOverflow is thrown for a too large index
void deactivatePrecalculationMode (  ) 

deactivates the precalculation of values ( and deletes the precalculated values)

bool exists ( DoubleReal  position  ) 

returns if a value for position position exists

void fromString ( const std::string &  gradient  ) 

Sets the gradient by string representation.

The string represenation of a gradient starts with the interpolation mode: "Linear" or "Stairs" and the separator "|". It is followed by an arbitrary number of integer-color-pairs.

Such a pair consists of floating point number (0.0-100.0) followed by a comma and a "#". Then follows a color in RGB notation "#RRGGBB" and finally a semicolon.

Examples are:

  • "Linear|0,#ffff00;100,#000000"
  • "Stairs|0,#ffff00;11.5,#ffaa00;32,#ff0000;55,#aa00ff;78,#5500ff;100,#000000"
static MultiGradient getDefaultGradientLinearIntensityMode (  )  [static]

Returns the default gradient for linear intensity mode.

Referenced by TOPPViewBase::setIntensityMode().

static MultiGradient getDefaultGradientLogarithmicIntensityMode (  )  [static]

Returns the default gradient for linear intensity mode.

Referenced by TOPPViewBase::setIntensityMode().

InterpolationMode getInterpolationMode (  )  const

returns the interpolaion mode

void insert ( DoubleReal  position,
QColor  color 
)

sets or replaces the color at position position

QColor interpolatedColorAt ( DoubleReal  position  )  const

Returns the color as position.

If the position is higher or lower than the range [0,100] the highest, respectively the lowest, color is returned.

QColor interpolatedColorAt ( DoubleReal  position,
DoubleReal  min,
DoubleReal  max 
) const

returns the color as position with the gradient stretched between min and max.

If the position is higher or lower than the range [min,max] the highest, respectively the lowest, color is returned.

MultiGradient& operator= ( const MultiGradient rhs  ) 

Assignment operator.

UInt position ( UInt  index  ) 

returns the position of the index -th point

Exceptions:
Exception::IndexOverflow is thrown for a too large index
QColor precalculatedColorAt ( DoubleReal  position  )  const [inline]

Returns a precalculated color.

If the position is out of the the range specified in activatePrecalculationMode() the behaviour depends on the debug mode:

  • With debug information an Precondition exception is thrown
  • Wihtout debug information array boundaries are violated, which probably causes a segmentation fault.
QColor precalculatedColorByIndex ( Int  index  )  const [inline]

precalculated color by its index in the table

References OPENMS_PRECONDITION.

Referenced by Spectrum2DCanvas::heightColor_().

Int precalculatedColorIndex ( DoubleReal  position  )  const [inline]

index of color in precalculated table by position in gradient

References OPENMS_PRECONDITION.

Referenced by Spectrum2DCanvas::precalculatedColorIndex_().

Size precalculatedSize (  )  const [inline]

size of precalculated colors table

bool remove ( DoubleReal  position  ) 

removes the color at position position

void setInterpolationMode ( InterpolationMode  mode  ) 

sets the interploation mode (default or stairs). Default is linear

Size size (  )  const

return the number of color points

std::string toString (  )  const

convert to string representation


Member Data Documentation

Current interpolation mode.

std::map<DoubleReal, QColor> pos_col_ [protected]

Map of index and color.

std::vector<QColor> pre_ [protected]

Precalculated colors.

DoubleReal pre_min_ [protected]

Minimum of the precalculated color range.

DoubleReal pre_size_ [protected]

Width of the precalculated color range.

UInt pre_steps_ [protected]

Steps of the precalculated color range.


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:58 using doxygen 1.7.1