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