#include <OpenMS/VISUAL/MultiGradient.h>
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.
Public Types | |
enum | InterpolationMode { IM_LINEAR, IM_STAIRS } |
Interploation mode. More... | |
Public Member Functions | |
MultiGradient () | |
Constructor. | |
~MultiGradient () | |
Destructor. | |
void | insert (Int position, const QColor &color) |
sets or replaces the color at position position | |
bool | remove (Int position) |
removes the color at position position . Colors at positions 0 and 100 cannot be removed. | |
bool | exists (Int position) |
returns if a value for position position exists | |
UInt | position (UInt index) throw (Exception::IndexUnderflow,Exception::IndexOverflow) |
returns the position of the index -th point | |
const QColor & | color (UInt index) throw (Exception::IndexUnderflow,Exception::IndexOverflow) |
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) | |
const QColor & | precalculatedColorAt (DoubleReal position) const |
Returns a precalculated color. | |
UInt | size () const |
return the number of color points | |
void | setInterpolationMode (UInt mode) |
sets the interploation mode (default or stairs). Default is linear | |
UInt | 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. | |
Protected Attributes | |
std::map< UInt, QColor > | pos_col_ |
Map of index and color. | |
UInt | 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. |
enum InterpolationMode |
MultiGradient | ( | ) |
Constructor.
~MultiGradient | ( | ) |
Destructor.
void insert | ( | Int | position, | |
const QColor & | color | |||
) |
sets or replaces the color at position position
bool remove | ( | Int | position | ) |
removes the color at position position
. Colors at positions 0 and 100 cannot be removed.
bool exists | ( | Int | position | ) |
returns if a value for position position
exists
UInt position | ( | UInt | index | ) | throw (Exception::IndexUnderflow,Exception::IndexOverflow) |
returns the position of the index
-th point
const QColor& color | ( | UInt | index | ) | throw (Exception::IndexUnderflow,Exception::IndexOverflow) |
returns the color of the index
-th point
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.
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)
const 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:
UInt size | ( | ) | const |
return the number of color points
void setInterpolationMode | ( | UInt | mode | ) |
sets the interploation mode (default or stairs). Default is linear
UInt 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.
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 an integer (0-100) followed by a comma and a "#". Then follows a color in RGB notation "#RRGGBB" and finally a semicolon.
Examples are:
UInt interpolation_mode_ [protected] |
Current interpolation mode.
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.
Generated Tue Apr 1 15:36:48 2008 -- using doxygen 1.5.4 | OpenMS / TOPP 1.1 |