GUIColorScheme Class Reference

#include <GUIColorScheme.h>


Detailed Description

Definition at line 43 of file GUIColorScheme.h.


Public Member Functions

unsigned int addColor (const RGBColor &color, const SUMOReal threshold, const std::string &name="")
void clear ()
const RGBColor getColor (const SUMOReal value) const
const std::vector< RGBColor > & getColors () const
const std::string & getName () const
const std::vector< std::string > & getNames () const
const std::vector< SUMOReal > & getThresholds () const
 GUIColorScheme (const std::string &name, const RGBColor &baseColor, const std::string &colName="", const bool isFixed=false)
 Constructor.
const bool isFixed () const
const bool isInterpolated () const
bool operator== (const GUIColorScheme &c) const
void removeColor (const size_t pos)
void save (OutputDevice &dev) const
bool setColor (const std::string &name, const RGBColor &color)
void setColor (const size_t pos, const RGBColor &color)
void setInterpolated (const bool interpolate, SUMOReal interpolationStart=0.f)
void setThreshold (const size_t pos, const SUMOReal threshold)

Private Attributes

std::vector< RGBColormyColors
bool myIsFixed
bool myIsInterpolated
std::string myName
std::vector< std::string > myNames
std::vector< SUMOReal > myThresholds

Constructor & Destructor Documentation

GUIColorScheme::GUIColorScheme ( const std::string &  name,
const RGBColor baseColor,
const std::string &  colName = "",
const bool  isFixed = false 
) [inline]

Constructor.

Definition at line 46 of file GUIColorScheme.h.

References addColor().

00048             : myName(name), myIsInterpolated(!isFixed), myIsFixed(isFixed) {
00049         addColor(baseColor, 0, colName);
00050     }


Member Function Documentation

unsigned int GUIColorScheme::addColor ( const RGBColor color,
const SUMOReal  threshold,
const std::string &  name = "" 
) [inline]

Definition at line 72 of file GUIColorScheme.h.

References myColors, myNames, and myThresholds.

Referenced by GUIColorScheme(), GUISettingsHandler::myStartElement(), and GUIDialog_ViewSettings::onCmdColorChange().

00072                                                                                                      {
00073         std::vector<RGBColor>::iterator colIt = myColors.begin();
00074         std::vector<SUMOReal>::iterator threshIt = myThresholds.begin();
00075         std::vector<std::string>::iterator nameIt = myNames.begin();
00076         unsigned int pos = 0;
00077         while (threshIt != myThresholds.end() && (*threshIt) < threshold) {
00078             ++threshIt;
00079             ++colIt;
00080             ++nameIt;
00081             pos++;
00082         }
00083         myColors.insert(colIt, color);
00084         myThresholds.insert(threshIt, threshold);
00085         myNames.insert(nameIt, name);
00086         return pos;
00087     }

void GUIColorScheme::clear (  )  [inline]

Definition at line 96 of file GUIColorScheme.h.

References myColors, myNames, and myThresholds.

Referenced by GUISettingsHandler::myStartElement().

00096                  {
00097         myColors.clear();
00098         myThresholds.clear();
00099         myNames.clear();
00100     }

const RGBColor GUIColorScheme::getColor ( const SUMOReal  value  )  const [inline]

Definition at line 102 of file GUIColorScheme.h.

References RGBColor::interpolate(), myColors, myIsInterpolated, myThresholds, and SUMOReal.

00102                                                         {
00103         if (myColors.size() == 1 || value < myThresholds.front()) {
00104             return myColors.front();
00105         }
00106         std::vector<RGBColor>::const_iterator colIt = myColors.begin()+1;
00107         std::vector<SUMOReal>::const_iterator threshIt = myThresholds.begin()+1;
00108         while (threshIt != myThresholds.end() && (*threshIt) <= value) {
00109             ++threshIt;
00110             ++colIt;
00111         }
00112         if (threshIt == myThresholds.end()) {
00113             return myColors.back();
00114         }
00115         if (!myIsInterpolated) {
00116             return *(colIt-1);
00117         }
00118         SUMOReal lowVal = *(threshIt-1);
00119         return RGBColor::interpolate(*(colIt-1), *colIt, (value-lowVal)/((*threshIt)-lowVal));
00120     }

const std::vector<RGBColor>& GUIColorScheme::getColors (  )  const [inline]

Definition at line 133 of file GUIColorScheme.h.

References myColors.

Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().

00133                                                  {
00134         return myColors;
00135     }

const std::string& GUIColorScheme::getName (  )  const [inline]

Definition at line 129 of file GUIColorScheme.h.

References myName.

00129                                      {
00130         return myName;
00131     }

const std::vector<std::string>& GUIColorScheme::getNames (  )  const [inline]

Definition at line 145 of file GUIColorScheme.h.

References myNames.

Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().

00145                                                  {
00146         return myNames;
00147     }

const std::vector<SUMOReal>& GUIColorScheme::getThresholds (  )  const [inline]

Definition at line 137 of file GUIColorScheme.h.

References myThresholds.

Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().

00137                                                      {
00138         return myThresholds;
00139     }

const bool GUIColorScheme::isFixed (  )  const [inline]

const bool GUIColorScheme::isInterpolated (  )  const [inline]

Definition at line 141 of file GUIColorScheme.h.

References myIsInterpolated.

Referenced by GUIDialog_ViewSettings::rebuildColorMatrices().

00141                                       {
00142         return myIsInterpolated;
00143     }

bool GUIColorScheme::operator== ( const GUIColorScheme c  )  const [inline]

Definition at line 178 of file GUIColorScheme.h.

References myColors, myIsInterpolated, myName, and myThresholds.

00178                                                    {
00179         return myName == c.myName && myColors == c.myColors && myThresholds == c.myThresholds && myIsInterpolated == c.myIsInterpolated;
00180     }

void GUIColorScheme::removeColor ( const size_t  pos  )  [inline]

Definition at line 89 of file GUIColorScheme.h.

References myColors, myNames, and myThresholds.

Referenced by GUIDialog_ViewSettings::onCmdColorChange().

00089                                        {
00090         assert(pos < myColors.size());
00091         myColors.erase(myColors.begin()+pos);
00092         myThresholds.erase(myThresholds.begin()+pos);
00093         myNames.erase(myNames.begin()+pos);
00094     }

void GUIColorScheme::save ( OutputDevice dev  )  const [inline]

Definition at line 153 of file GUIColorScheme.h.

References myColors, myIsFixed, myIsInterpolated, myName, myNames, and myThresholds.

00153                                        {
00154         dev << "            <colorScheme name=\"" << myName;
00155         if (!myIsFixed) {
00156             dev << "\" interpolated=\"" << myIsInterpolated;
00157         }
00158         dev << "\">\n";
00159         std::vector<RGBColor>::const_iterator colIt = myColors.begin();
00160         std::vector<SUMOReal>::const_iterator threshIt = myThresholds.begin();
00161         std::vector<std::string>::const_iterator nameIt = myNames.begin();
00162         while (threshIt != myThresholds.end()) {
00163             dev << "                <entry color=\"" << (*colIt);
00164             if (!myIsFixed) {
00165                 dev << "\" threshold=\"" << (*threshIt);
00166             }
00167             if ((*nameIt) != "") {
00168                 dev << "\" name=\"" << (*nameIt);
00169             }
00170             dev << "\"/>\n";
00171             ++threshIt;
00172             ++colIt;
00173             ++nameIt;
00174         }
00175         dev << "            </colorScheme>\n";
00176     }

bool GUIColorScheme::setColor ( const std::string &  name,
const RGBColor color 
) [inline]

Definition at line 60 of file GUIColorScheme.h.

References myColors, and myNames.

00060                                                                 {
00061         std::vector<std::string>::iterator nameIt = myNames.begin();
00062         std::vector<RGBColor>::iterator colIt = myColors.begin();
00063         for (; nameIt != myNames.end(); ++nameIt, ++colIt) {
00064             if (*nameIt == name) {
00065                 (*colIt) = color;
00066                 return true;
00067             }
00068         }
00069         return false;
00070     }

void GUIColorScheme::setColor ( const size_t  pos,
const RGBColor color 
) [inline]

Definition at line 56 of file GUIColorScheme.h.

References myColors.

Referenced by GUISettingsHandler::myStartElement(), and GUIDialog_ViewSettings::onCmdColorChange().

00056                                                            {
00057         myColors[pos] = color;
00058     }

void GUIColorScheme::setInterpolated ( const bool  interpolate,
SUMOReal  interpolationStart = 0.f 
) [inline]

Definition at line 122 of file GUIColorScheme.h.

References myIsInterpolated, and myThresholds.

Referenced by GUISettingsHandler::myStartElement(), and GUIDialog_ViewSettings::onCmdColorChange().

00122                                                                                   {
00123         myIsInterpolated = interpolate;
00124         if (interpolate) {
00125             myThresholds[0] = interpolationStart;
00126         }
00127     }

void GUIColorScheme::setThreshold ( const size_t  pos,
const SUMOReal  threshold 
) [inline]

Definition at line 52 of file GUIColorScheme.h.

References myThresholds.

Referenced by GUIDialog_ViewSettings::onCmdColorChange().

00052                                                                   {
00053         myThresholds[pos] = threshold;
00054     }


Field Documentation

std::vector<RGBColor> GUIColorScheme::myColors [private]

Definition at line 188 of file GUIColorScheme.h.

Referenced by isFixed(), and save().

Definition at line 186 of file GUIColorScheme.h.

Referenced by getColor(), isInterpolated(), operator==(), save(), and setInterpolated().

std::string GUIColorScheme::myName [private]

Definition at line 183 of file GUIColorScheme.h.

Referenced by getName(), operator==(), and save().

std::vector<std::string> GUIColorScheme::myNames [private]

Definition at line 187 of file GUIColorScheme.h.

Referenced by addColor(), clear(), getNames(), removeColor(), save(), and setColor().

std::vector<SUMOReal> GUIColorScheme::myThresholds [private]


The documentation for this class was generated from the following file:

Generated on Wed May 5 00:06:41 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6