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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 //
19 /****************************************************************************/
20 #ifndef GUIPropertySchemeStorage_h
21 #define GUIPropertySchemeStorage_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <vector>
30 #include <fx.h>
31 #include "GUIPropertyScheme.h"
32 
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class OutputDevice;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
48 template<class T>
50 public:
53 
56 
58  void fill(FXComboBox& cb) {
59  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
60  cb.appendItem((*i).getName().c_str());
61  }
62  cb.setCurrentItem((FXint)myActiveScheme);
63  }
64 
65  void setActive(int scheme) {
66  if (scheme < (int)mySchemes.size()) {
67  myActiveScheme = scheme;
68  }
69  }
70 
71  int getActive() const {
72  return myActiveScheme;
73  }
74 
75  T& getScheme() {
76  return mySchemes[myActiveScheme];
77  }
78 
79  const T& getScheme() const {
80  return mySchemes[myActiveScheme];
81  }
82 
83  const std::vector<T>& getSchemes() const {
84  return mySchemes;
85  }
86 
87  T* getSchemeByName(std::string name) {
88  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
89  if ((*i).getName() == name) {
90  return &(*i);
91  }
92  }
93  return 0;
94  }
95 
96  void save(OutputDevice& dev) const {
97  for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
98  i->save(dev);
99  }
100  }
101 
102  bool operator==(const GUIPropertySchemeStorage& c) const {
103  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
104  }
105 
106 
107  void addScheme(T scheme) {
108  mySchemes.push_back(scheme);
109  }
110 
111  int size() const {
112  return (int)mySchemes.size();
113  }
114 
115 
116 protected:
118  std::vector<T> mySchemes;
119 
120 };
121 
124 
125 #endif
126 
127 /****************************************************************************/
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:64
virtual ~GUIPropertySchemeStorage()
Destructor.
void save(OutputDevice &dev) const