SUMO - Simulation of Urban MObility
GUIPropertySchemeStorage.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 //
21 /****************************************************************************/
22 #ifndef GUIPropertySchemeStorage_h
23 #define GUIPropertySchemeStorage_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <vector>
36 #include <fx.h>
37 #include "GUIPropertyScheme.h"
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class OutputDevice;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 template<class T>
56 public:
59 
62 
64  void fill(FXComboBox& cb) {
65  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
66  cb.appendItem((*i).getName().c_str());
67  }
68  cb.setCurrentItem((FXint)myActiveScheme);
69  }
70 
71  void setActive(int scheme) {
72  if (scheme < (int)mySchemes.size()) {
73  myActiveScheme = scheme;
74  }
75  }
76 
77  int getActive() const {
78  return myActiveScheme;
79  }
80 
81  T& getScheme() {
82  return mySchemes[myActiveScheme];
83  }
84 
85  const T& getScheme() const {
86  return mySchemes[myActiveScheme];
87  }
88 
89  const std::vector<T>& getSchemes() const {
90  return mySchemes;
91  }
92 
93  T* getSchemeByName(std::string name) {
94  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
95  if ((*i).getName() == name) {
96  return &(*i);
97  }
98  }
99  return 0;
100  }
101 
102  void save(OutputDevice& dev) const {
103  for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
104  i->save(dev);
105  }
106  }
107 
108  bool operator==(const GUIPropertySchemeStorage& c) const {
109  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
110  }
111 
112 
113  void addScheme(T scheme) {
114  mySchemes.push_back(scheme);
115  }
116 
117  int size() const {
118  return (int)mySchemes.size();
119  }
120 
121 
122 protected:
124  std::vector<T> mySchemes;
125 
126 };
127 
130 
131 #endif
132 
133 /****************************************************************************/
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
const std::vector< T > & getSchemes() const
GUIPropertySchemeStorage< GUIScaleScheme > GUIScaler
GUIPropertySchemeStorage< GUIColorScheme > GUIColorer
T * getSchemeByName(std::string name)
void fill(FXComboBox &cb)
Fills the given combobox with the names of available colorings.
bool operator==(const GUIPropertySchemeStorage &c) const
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
virtual ~GUIPropertySchemeStorage()
Destructor.
void save(OutputDevice &dev) const