35 #ifndef OPENMS_VISUAL_MULTIGRADIENT_H 36 #define OPENMS_VISUAL_MULTIGRADIENT_H 39 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h> 48 #include <QtGui/QColor> 75 static MultiGradient getDefaultGradientLogarithmicIntensityMode();
97 void insert(
double position, QColor color);
99 bool remove(
double position);
101 bool exists(
double position);
113 QColor color(
UInt index);
122 QColor interpolatedColorAt(
double position)
const;
129 QColor interpolatedColorAt(
double position,
double min,
double max)
const;
132 void activatePrecalculationMode(
double min,
double max,
UInt steps);
134 void deactivatePrecalculationMode();
139 OPENMS_PRECONDITION(pre_.size() != 0,
"MultiGradient::precalculatedColorIndex(double): Precalculation mode not activated!");
140 OPENMS_PRECONDITION(position >= pre_min_, (
String(
"MultiGradient::precalculatedColorIndex(double): position ") + position +
" out of specified range (" + pre_min_ +
"-" + (pre_min_ + pre_size_) +
")!").c_str());
142 Int index = (
Int)((position - pre_min_) / pre_size_ * pre_steps_);
144 return qBound( 0, index, (
Int)pre_.size() - 1 );
150 OPENMS_PRECONDITION(pre_.size() != 0,
"MultiGradient::precalculatedColorByIndex(Int): Precalculation mode not activated!");
151 OPENMS_PRECONDITION( index >= 0,
"MultiGradient::precalculatedColorByIndex(Int): negative indexes not allowed");
152 OPENMS_PRECONDITION( index < (
Int)pre_.size(), (
String(
"MultiGradient::indexedColor(Int): index ") + index +
" out of specified range (0-" + pre_.size() +
")!").c_str());
166 return precalculatedColorByIndex( precalculatedColorIndex( position ) );
200 void fromString(
const std::string & gradient);
219 #endif // OPENMS_VISUAL_MULTIGRADIENT_H
InterpolationMode
Interpolation mode.
Definition: MultiGradient.h:78
A more convenient string class.
Definition: String.h:57
QColor precalculatedColorAt(double position) const
Returns a precalculated color.
Definition: MultiGradient.h:164
Int precalculatedColorIndex(double position) const
index of color in precalculated table by position in gradient
Definition: MultiGradient.h:137
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:107
unsigned int UInt
Unsigned integer type.
Definition: Types.h:95
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
QColor precalculatedColorByIndex(Int index) const
precalculated color by its index in the table
Definition: MultiGradient.h:148
double pre_min_
Minimum of the precalculated color range.
Definition: MultiGradient.h:210
InterpolationMode interpolation_mode_
Current interpolation mode.
Definition: MultiGradient.h:206
UInt pre_steps_
Steps of the precalculated color range.
Definition: MultiGradient.h:214
Size precalculatedSize() const
size of precalculated colors table
Definition: MultiGradient.h:173
std::vector< QColor > pre_
Precalculated colors.
Definition: MultiGradient.h:208
IM_LINEAR returns the linear interpolation (default).
Definition: MultiGradient.h:80
std::map< double, QColor > pos_col_
Map of index and color.
Definition: MultiGradient.h:204
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:128
String toString(T i)
toString functions (single argument)
Definition: StringUtils.h:69
A gradient of multiple colors and arbitrary distances between colors.
Definition: MultiGradient.h:68
int Int
Signed integer type.
Definition: Types.h:103
double pre_size_
Width of the precalculated color range.
Definition: MultiGradient.h:212