SUMO - Simulation of Urban MObility

GUIColorer.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef GUIColorer_h
00020 #define GUIColorer_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #ifdef _WIN32
00033 #include <windows.h>
00034 #endif
00035 
00036 #include <GL/gl.h>
00037 
00038 #include <vector>
00039 #include <fx.h>
00040 #include <utils/iodevices/OutputDevice.h>
00041 #include "GUIColorScheme.h"
00042 
00043 
00044 // ===========================================================================
00045 // class definitions
00046 // ===========================================================================
00052 class GUIColorer {
00053 public:
00055     GUIColorer() : myActiveScheme(0) { }
00056 
00058     virtual ~GUIColorer() { }
00059 
00061     void fill(FXComboBox& cb) {
00062         for (std::vector<GUIColorScheme>::iterator i=mySchemes.begin(); i!=mySchemes.end(); ++i) {
00063             cb.appendItem((*i).getName().c_str());
00064         }
00065         cb.setCurrentItem((FXint)myActiveScheme);
00066     }
00067 
00068     void setActive(size_t scheme) {
00069         if (scheme < mySchemes.size()) {
00070             myActiveScheme = scheme;
00071         }
00072     }
00073 
00074     size_t getActive() const {
00075         return myActiveScheme;
00076     }
00077 
00078     GUIColorScheme& getScheme() {
00079         return mySchemes[myActiveScheme];
00080     }
00081 
00082     const GUIColorScheme& getScheme() const {
00083         return mySchemes[myActiveScheme];
00084     }
00085 
00086     GUIColorScheme* getSchemeByName(std::string name) {
00087         for (std::vector<GUIColorScheme>::iterator i=mySchemes.begin(); i!=mySchemes.end(); ++i) {
00088             if ((*i).getName() == name) {
00089                 return &(*i);
00090             }
00091         }
00092         return 0;
00093     }
00094 
00095     void save(OutputDevice& dev) const {
00096         for (std::vector<GUIColorScheme>::const_iterator i = mySchemes.begin(); i!=mySchemes.end(); ++i) {
00097             i->save(dev);
00098         }
00099     }
00100 
00101     bool operator==(const GUIColorer& c) const {
00102         return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
00103     }
00104 
00105 
00106     void addScheme(GUIColorScheme scheme) {
00107         mySchemes.push_back(scheme);
00108     }
00109 
00110 
00111 protected:
00112     size_t myActiveScheme;
00113     std::vector<GUIColorScheme> mySchemes;
00114 
00115 };
00116 
00117 
00118 #endif
00119 
00120 /****************************************************************************/
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines