46 GUIPropertyScheme(
const std::string& name,
const std::string& translatedName,
const T& baseColor,
47 const std::string& colName =
"",
const bool isFixed =
false,
double baseValue = 0,
57 addColor(baseColor, baseValue, colName);
61 const std::string& colName =
"",
const bool isFixed =
false,
double baseValue = 0,
71 addColor(baseColor, baseValue, colName);
82 bool setColor(
const std::string& name,
const T& color) {
83 std::vector<std::string>::iterator nameIt =
myNames.begin();
84 typename std::vector<T>::iterator colIt =
myColors.begin();
85 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
86 if (*nameIt == name) {
94 int addColor(
const T& color,
const double threshold,
const std::string& name =
"") {
95 typename std::vector<T>::iterator colIt =
myColors.begin();
96 std::vector<double>::iterator threshIt =
myThresholds.begin();
97 std::vector<std::string>::iterator nameIt =
myNames.begin();
99 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
128 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
129 std::vector<double>::const_iterator threshIt =
myThresholds.begin() + 1;
130 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
140 double lowVal = *(threshIt - 1);
141 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
197 const bool checkPrecision = precision <= 2;
205 typename std::vector<T>::const_iterator colIt =
myColors.begin();
206 std::vector<double>::const_iterator threshIt =
myThresholds.begin();
207 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
211 if (!
myIsFixed && (*threshIt) != std::numeric_limits<double>::max()) {
212 const double t = *threshIt;
213 if (checkPrecision && t != 0 && fabs(t) < 0.01) {
219 if ((*nameIt) !=
"") {
246 double interpolate(
const double& min,
const double& max,
double weight)
const {
247 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)
std::string getTagName(std::vector< double >) const
T getColor(const double value) 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)
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)
GUIPropertyScheme(const std::string &name, const std::string &translatedName, const T &baseColor, const std::string &colName="", const bool isFixed=false, double baseValue=0, RGBColor bgColor=RGBColor::WHITE, GUIIcon icon=GUIIcon::EMPTY)
Constructor.
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
std::string myTranslatedName
bool setColor(const std::string &name, const T &color)
const std::string & getTranslatedName() const
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