SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIColorer.h
Go to the documentation of this file.
1 /****************************************************************************/
10 //
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef GUIColorer_h
24 #define GUIColorer_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include <fx.h>
39 #include "GUIColorScheme.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 template<class T>
52 public:
55 
58 
60  void fill(FXComboBox& cb) {
61  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
62  cb.appendItem((*i).getName().c_str());
63  }
64  cb.setCurrentItem((FXint)myActiveScheme);
65  }
66 
67  void setActive(size_t scheme) {
68  if (scheme < mySchemes.size()) {
69  myActiveScheme = scheme;
70  }
71  }
72 
73  size_t getActive() const {
74  return myActiveScheme;
75  }
76 
77  T& getScheme() {
78  return mySchemes[myActiveScheme];
79  }
80 
81  const T& getScheme() const {
82  return mySchemes[myActiveScheme];
83  }
84 
85  T* getSchemeByName(std::string name) {
86  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
87  if ((*i).getName() == name) {
88  return &(*i);
89  }
90  }
91  return 0;
92  }
93 
94  void save(OutputDevice& dev) const {
95  for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
96  i->save(dev);
97  }
98  }
99 
100  bool operator==(const GUIPropertySchemeStorage& c) const {
101  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
102  }
103 
104 
105  void addScheme(T scheme) {
106  mySchemes.push_back(scheme);
107  }
108 
109  size_t size() const {
110  return mySchemes.size();
111  }
112 
113 
114 protected:
116  std::vector<T> mySchemes;
117 
118 };
119 
122 
123 #endif
124 
125 /****************************************************************************/
const T & getScheme() const
Definition: GUIColorer.h:81
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
Definition: GUIColorer.h:51
GUIPropertySchemeStorage()
Constructor.
Definition: GUIColorer.h:54
std::vector< T > mySchemes
Definition: GUIColorer.h:116
T * getSchemeByName(std::string name)
Definition: GUIColorer.h:85
void fill(FXComboBox &cb)
Fills the given combobox with the names of available colorings.
Definition: GUIColorer.h:60
void setActive(size_t scheme)
Definition: GUIColorer.h:67
size_t getActive() const
Definition: GUIColorer.h:73
void save(OutputDevice &dev) const
Definition: GUIColorer.h:94
size_t size() const
Definition: GUIColorer.h:109
GUIPropertySchemeStorage< GUIScaleScheme > GUIScaler
Definition: GUIColorer.h:121
GUIPropertySchemeStorage< GUIColorScheme > GUIColorer
Definition: GUIColorer.h:120
bool operator==(const GUIPropertySchemeStorage &c) const
Definition: GUIColorer.h:100
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void addScheme(T scheme)
Definition: GUIColorer.h:105
virtual ~GUIPropertySchemeStorage()
Destructor.
Definition: GUIColorer.h:57