22 #ifndef GUIPropertyScheme_h 23 #define GUIPropertyScheme_h 56 const std::string& colName =
"",
const bool isFixed =
false,
SUMOReal baseValue = 0) :
60 addColor(baseColor, baseValue, colName);
71 bool setColor(
const std::string& name,
const T& color) {
72 std::vector<std::string>::iterator nameIt =
myNames.begin();
73 typename std::vector<T>::iterator colIt =
myColors.begin();
74 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
75 if (*nameIt == name) {
84 typename std::vector<T>::iterator colIt =
myColors.begin();
85 std::vector<SUMOReal>::iterator threshIt =
myThresholds.begin();
86 std::vector<std::string>::iterator nameIt =
myNames.begin();
88 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
117 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
118 std::vector<SUMOReal>::const_iterator threshIt =
myThresholds.begin() + 1;
119 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
130 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
180 typename std::vector<T>::const_iterator colIt =
myColors.begin();
181 std::vector<SUMOReal>::const_iterator threshIt =
myThresholds.begin();
182 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
189 if ((*nameIt) !=
"") {
217 return min + (max -
min) * weight;
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const std::vector< T > & getColors() const
bool isInterpolated() const
std::string getTagName(std::vector< RGBColor >) const
SUMOReal interpolate(const SUMOReal &min, const SUMOReal &max, SUMOReal weight) const
specializations for GUIScaleScheme
void setThreshold(const int pos, const SUMOReal threshold)
void setAllowsNegativeValues(bool value)
bool myAllowNegativeValues
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, SUMOReal weight)
Interpolates between two colors.
bool operator==(const GUIPropertyScheme &c) const
std::string getTagName(std::vector< SUMOReal >) const
const std::string & getName() const
void setInterpolated(const bool interpolate, SUMOReal interpolationStart=0.f)
int addColor(const T &color, const SUMOReal threshold, const std::string &name="")
bool allowsNegativeValues() const
const T getColor(const SUMOReal value) const
std::vector< std::string > myNames
const std::vector< std::string > & getNames() const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void setColor(const int pos, const T &color)
GUIPropertyScheme< SUMOReal > GUIScaleScheme
void removeColor(const int pos)
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.
bool closeTag()
Closes the most recently opened tag.
void save(OutputDevice &dev) const
GUIPropertyScheme< RGBColor > GUIColorScheme
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
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.