47 const std::string& colName =
"",
const bool isFixed =
false,
double baseValue = 0,
55 addColor(baseColor, baseValue, colName);
66 bool setColor(
const std::string& name,
const T& color) {
67 std::vector<std::string>::iterator nameIt =
myNames.begin();
68 typename std::vector<T>::iterator colIt =
myColors.begin();
69 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
70 if (*nameIt == name) {
78 int addColor(
const T& color,
const double threshold,
const std::string& name =
"") {
79 typename std::vector<T>::iterator colIt =
myColors.begin();
80 std::vector<double>::iterator threshIt =
myThresholds.begin();
81 std::vector<std::string>::iterator nameIt =
myNames.begin();
83 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
112 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
113 std::vector<double>::const_iterator threshIt =
myThresholds.begin() + 1;
114 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
124 double lowVal = *(threshIt - 1);
125 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
177 const bool checkPrecision = precision <= 2;
185 typename std::vector<T>::const_iterator colIt =
myColors.begin();
186 std::vector<double>::const_iterator threshIt =
myThresholds.begin();
187 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
191 if (!
myIsFixed && (*threshIt) != std::numeric_limits<double>::max()) {
192 const double t = *threshIt;
193 if (checkPrecision && t != 0 && fabs(t) < 0.01) {
199 if ((*nameIt) !=
"") {
226 double interpolate(
const double& min,
const double& max,
double weight)
const {
227 return min + (max - min) * weight;
GUIIcon
An enumeration of icons used by the gui applications.
GUIPropertyScheme< RGBColor > GUIColorScheme
GUIPropertyScheme< double > GUIScaleScheme
@ SUMO_ATTR_COLOR
A color information.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const T getColor(const double value) const
std::string getTagName(std::vector< double >) const
void setAllowsNegativeValues(bool value)
const std::vector< double > & getThresholds() const
std::string getTagName(std::vector< RGBColor >) const
const RGBColor & getBackgroundColor() const
void setColor(const int pos, const T &color)
GUIPropertyScheme(const std::string &name, const T &baseColor, const std::string &colName="", const bool isFixed=false, double baseValue=0, RGBColor bgColor=RGBColor::WHITE, GUIIcon icon=GUIIcon::EMPTY)
Constructor.
bool myAllowNegativeValues
std::vector< double > myThresholds
void setThreshold(const int pos, const double threshold)
const std::vector< std::string > & getNames() const
void removeColor(const int pos)
std::vector< std::string > myNames
void save(OutputDevice &dev, const std::string &prefix="") const
const std::string & getName() const
const std::vector< T > & getColors() const
int addColor(const T &color, const double threshold, const std::string &name="")
void setInterpolated(const bool interpolate, double interpolationStart=0.f)
double interpolate(const double &min, const double &max, double weight) const
specializations for GUIScaleScheme
bool isInterpolated() const
bool operator==(const GUIPropertyScheme &c) const
std::vector< T > myColors
bool setColor(const std::string &name, const T &color)
RGBColor interpolate(const RGBColor &min, const RGBColor &max, double weight) const
specializations for GUIColorScheme
bool allowsNegativeValues() const
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
int getPrecision()
Returns the precision of the underlying stream.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
static RGBColor interpolate(const RGBColor &minColor, const RGBColor &maxColor, double weight)
Interpolates between two colors.
static const RGBColor WHITE