21 #ifndef GUIPropertyScheme_h
22 #define GUIPropertyScheme_h
55 const std::string& colName =
"",
const bool isFixed =
false,
SUMOReal baseValue = 0) :
59 addColor(baseColor, baseValue, colName);
66 void setColor(
const size_t pos,
const T& color) {
70 bool setColor(
const std::string& name,
const T& color) {
71 std::vector<std::string>::iterator nameIt =
myNames.begin();
72 typename std::vector<T>::iterator colIt =
myColors.begin();
73 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
74 if (*nameIt == name) {
82 unsigned int addColor(
const T& color,
const SUMOReal threshold,
const std::string& name =
"") {
83 typename std::vector<T>::iterator colIt =
myColors.begin();
84 std::vector<SUMOReal>::iterator threshIt =
myThresholds.begin();
85 std::vector<std::string>::iterator nameIt =
myNames.begin();
87 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
116 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
117 std::vector<SUMOReal>::const_iterator threshIt =
myThresholds.begin() + 1;
118 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
129 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
173 dev <<
" <" << tag <<
" name=\"" <<
myName;
178 typename std::vector<T>::const_iterator colIt =
myColors.begin();
179 std::vector<SUMOReal>::const_iterator threshIt =
myThresholds.begin();
180 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
182 dev <<
" <entry color=\"" << (*colIt);
184 dev <<
"\" threshold=\"" << (*threshIt);
186 if ((*nameIt) !=
"") {
187 dev <<
"\" name=\"" << (*nameIt);
194 dev <<
" </" << tag <<
">\n";
214 return min + (max -
min) * weight;
const std::vector< T > & getColors() const
bool isInterpolated() const
GUIPropertyScheme< SUMOReal > GUIScaleScheme
std::string getTagName(std::vector< RGBColor >) const
SUMOReal interpolate(const SUMOReal &min, const SUMOReal &max, SUMOReal weight) const
specializations for GUIScaleScheme
void removeColor(const size_t pos)
void setAllowsNegativeValues(bool value)
void setColor(const size_t pos, const T &color)
bool myAllowNegativeValues
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, SUMOReal weight)
Interpolates between two colors.
bool operator==(const GUIPropertyScheme &c) const
void setThreshold(const size_t pos, const SUMOReal threshold)
std::string getTagName(std::vector< SUMOReal >) const
const std::string & getName() const
void setInterpolated(const bool interpolate, SUMOReal interpolationStart=0.f)
bool allowsNegativeValues() const
const T getColor(const SUMOReal value) const
std::vector< std::string > myNames
const std::vector< std::string > & getNames() const
GUIPropertyScheme< RGBColor > GUIColorScheme
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
unsigned int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
std::vector< SUMOReal > myThresholds
bool setColor(const std::string &name, const T &color)
std::vector< T > myColors
Static storage of an output device and its base (abstract) implementation.
void save(OutputDevice &dev) const
GUIPropertyScheme(const std::string &name, const T &baseColor, const std::string &colName="", const bool isFixed=false, SUMOReal baseValue=0)
Constructor.
RGBColor interpolate(const RGBColor &min, const RGBColor &max, SUMOReal weight) const
specializations for GUIColorScheme
const std::vector< SUMOReal > & getThresholds() const