19 #ifndef GUIPropertyScheme_h 20 #define GUIPropertyScheme_h 49 const std::string& colName =
"",
const bool isFixed =
false,
double baseValue = 0) :
53 addColor(baseColor, baseValue, colName);
64 bool setColor(
const std::string& name,
const T& color) {
65 std::vector<std::string>::iterator nameIt =
myNames.begin();
66 typename std::vector<T>::iterator colIt =
myColors.begin();
67 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
68 if (*nameIt == name) {
76 int addColor(
const T& color,
const double threshold,
const std::string& name =
"") {
77 typename std::vector<T>::iterator colIt =
myColors.begin();
78 std::vector<double>::iterator threshIt =
myThresholds.begin();
79 std::vector<std::string>::iterator nameIt =
myNames.begin();
81 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
110 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
111 std::vector<double>::const_iterator threshIt =
myThresholds.begin() + 1;
112 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
122 double lowVal = *(threshIt - 1);
123 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
173 typename std::vector<T>::const_iterator colIt =
myColors.begin();
174 std::vector<double>::const_iterator threshIt =
myThresholds.begin();
175 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
182 if ((*nameIt) !=
"") {
209 double interpolate(
const double& min,
const double& max,
double weight)
const {
210 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(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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)