19 #ifndef GUIPropertyScheme_h 20 #define GUIPropertyScheme_h 50 const std::string& colName =
"",
const bool isFixed =
false,
double baseValue = 0,
58 addColor(baseColor, baseValue, colName);
69 bool setColor(
const std::string& name,
const T& color) {
70 std::vector<std::string>::iterator nameIt =
myNames.begin();
71 typename std::vector<T>::iterator colIt =
myColors.begin();
72 for (; nameIt !=
myNames.end(); ++nameIt, ++colIt) {
73 if (*nameIt == name) {
81 int addColor(
const T& color,
const double threshold,
const std::string& name =
"") {
82 typename std::vector<T>::iterator colIt =
myColors.begin();
83 std::vector<double>::iterator threshIt =
myThresholds.begin();
84 std::vector<std::string>::iterator nameIt =
myNames.begin();
86 while (threshIt !=
myThresholds.end() && (*threshIt) < threshold) {
115 typename std::vector<T>::const_iterator colIt =
myColors.begin() + 1;
116 std::vector<double>::const_iterator threshIt =
myThresholds.begin() + 1;
117 while (threshIt !=
myThresholds.end() && (*threshIt) <= value) {
127 double lowVal = *(threshIt - 1);
128 return interpolate(*(colIt - 1), *colIt, (value - lowVal) / ((*threshIt) - lowVal));
186 typename std::vector<T>::const_iterator colIt =
myColors.begin();
187 std::vector<double>::const_iterator threshIt =
myThresholds.begin();
188 std::vector<std::string>::const_iterator nameIt =
myNames.begin();
195 if ((*nameIt) !=
"") {
222 double interpolate(
const double& min,
const double& max,
double weight)
const {
223 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< double > GUIScaleScheme
const std::string & getName() const
GUIIcon
An enumeration of icons used by the gui applications.
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
const RGBColor & getBackgroundColor() const
GUIPropertyScheme(const std::string &name, const T &baseColor, const std::string &colName="", const bool isFixed=false, double baseValue=0, RGBColor bgColor=RGBColor::INVISIBLE, GUIIcon icon=ICON_EMPTY)
Constructor.
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 const RGBColor INVISIBLE
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)