GUIColorer< T > Class Template Reference

#include <GUIColorer.h>


Detailed Description

template<class T>
class GUIColorer< T >

Base class for coloring. Allows changing the used colors and sets the used color in dependence to a value or a given structure.

Definition at line 52 of file GUIColorer.h.


Public Member Functions

void fill (FXComboBox &cb)
 Fills the given combobox with the names of available colorings.
const size_t getActive () const
virtual SUMOReal getColorValue (const T &i) const =0
 Sets the color using a value from the given instance of T.
GUIColorSchemegetScheme ()
GUIColorSchemegetSchemeByName (std::string name)
 GUIColorer ()
 Constructor.
bool operator== (const GUIColorer &c) const
void save (OutputDevice &dev) const
void setActive (size_t scheme)
virtual bool setFunctionalColor (const T &i) const
 Sets the color using a function call for the given instance of T.
void setGlColor (const T &i) const
 Sets the color using a value from the given instance of T.
virtual ~GUIColorer ()
 Destructor.

Protected Attributes

size_t myActiveScheme
std::vector< GUIColorSchememySchemes

Constructor & Destructor Documentation

template<class T>
GUIColorer< T >::GUIColorer (  )  [inline]

Constructor.

Definition at line 55 of file GUIColorer.h.

00055 : myActiveScheme(0) { }

template<class T>
virtual GUIColorer< T >::~GUIColorer (  )  [inline, virtual]

Destructor.

Definition at line 58 of file GUIColorer.h.

00058 { }


Member Function Documentation

template<class T>
void GUIColorer< T >::fill ( FXComboBox &  cb  )  [inline]

Fills the given combobox with the names of available colorings.

Definition at line 77 of file GUIColorer.h.

00077                               {
00078         typename std::vector<GUIColorScheme>::iterator i;
00079         for (i=mySchemes.begin(); i!=mySchemes.end(); ++i) {
00080             cb.appendItem((*i).getName().c_str());
00081         }
00082         cb.setCurrentItem((FXint)myActiveScheme);
00083     }

template<class T>
const size_t GUIColorer< T >::getActive (  )  const [inline]

template<class T>
virtual SUMOReal GUIColorer< T >::getColorValue ( const T &  i  )  const [pure virtual]

Sets the color using a value from the given instance of T.

Implemented in GUILaneWrapper::Colorer, and GUIVehicle::Colorer.

Referenced by GUIColorer< GUIVehicle >::setGlColor().

template<class T>
GUIColorScheme& GUIColorer< T >::getScheme (  )  [inline]

template<class T>
GUIColorScheme* GUIColorer< T >::getSchemeByName ( std::string  name  )  [inline]

Definition at line 99 of file GUIColorer.h.

Referenced by GUISettingsHandler::myStartElement().

00099                                                     {
00100         typename std::vector<GUIColorScheme>::iterator i;
00101         for (i=mySchemes.begin(); i!=mySchemes.end(); ++i) {
00102             if ((*i).getName() == name) {
00103                 return &(*i);
00104             }
00105         }
00106         return 0;
00107     }

template<class T>
bool GUIColorer< T >::operator== ( const GUIColorer< T > &  c  )  const [inline]

Definition at line 116 of file GUIColorer.h.

00116                                                {
00117         return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
00118     }

template<class T>
void GUIColorer< T >::save ( OutputDevice dev  )  const [inline]

Definition at line 109 of file GUIColorer.h.

Referenced by GUIVisualizationSettings::save().

00109                                        {
00110         typename std::vector<GUIColorScheme>::const_iterator i = mySchemes.begin();
00111         for (; i!=mySchemes.end(); ++i) {
00112             i->save(dev);
00113         }
00114     }

template<class T>
void GUIColorer< T >::setActive ( size_t  scheme  )  [inline]

Definition at line 85 of file GUIColorer.h.

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

00085                                   {
00086         if (scheme < mySchemes.size()) {
00087             myActiveScheme = scheme;
00088         }
00089     }

template<class T>
virtual bool GUIColorer< T >::setFunctionalColor ( const T &  i  )  const [inline, virtual]

Sets the color using a function call for the given instance of T.

Reimplemented in GUIVehicle::Colorer.

Definition at line 64 of file GUIColorer.h.

Referenced by GUIColorer< GUIVehicle >::setGlColor().

00064                                                       {
00065         return false;
00066     }

template<class T>
void GUIColorer< T >::setGlColor ( const T &  i  )  const [inline]

Sets the color using a value from the given instance of T.

Definition at line 69 of file GUIColorer.h.

Referenced by GUIViewTraffic::drawRoute().

00069                                       {
00070         if (!setFunctionalColor(i)) {
00071             const RGBColor& c = mySchemes[myActiveScheme].getColor(getColorValue(i));
00072             glColor3d(c.red(), c.green(), c.blue());
00073         }
00074     }


Field Documentation

template<class T>
size_t GUIColorer< T >::myActiveScheme [protected]

template<class T>
std::vector<GUIColorScheme> GUIColorer< T >::mySchemes [protected]


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