SUMO - Simulation of Urban MObility
GUIPropertySchemeStorage.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-2015 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 GUIPropertySchemeStorage_h
24 #define GUIPropertySchemeStorage_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>
38 #include "GUIPropertyScheme.h"
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class OutputDevice;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
55 template<class T>
57 public:
60 
63 
65  void fill(FXComboBox& cb) {
66  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
67  cb.appendItem((*i).getName().c_str());
68  }
69  cb.setCurrentItem((FXint)myActiveScheme);
70  }
71 
72  void setActive(size_t scheme) {
73  if (scheme < mySchemes.size()) {
74  myActiveScheme = scheme;
75  }
76  }
77 
78  size_t getActive() const {
79  return myActiveScheme;
80  }
81 
82  T& getScheme() {
83  return mySchemes[myActiveScheme];
84  }
85 
86  const T& getScheme() const {
87  return mySchemes[myActiveScheme];
88  }
89 
90  T* getSchemeByName(std::string name) {
91  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
92  if ((*i).getName() == name) {
93  return &(*i);
94  }
95  }
96  return 0;
97  }
98 
99  void save(OutputDevice& dev) const {
100  for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
101  i->save(dev);
102  }
103  }
104 
105  bool operator==(const GUIPropertySchemeStorage& c) const {
106  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
107  }
108 
109 
110  void addScheme(T scheme) {
111  mySchemes.push_back(scheme);
112  }
113 
114  size_t size() const {
115  return mySchemes.size();
116  }
117 
118 
119 protected:
121  std::vector<T> mySchemes;
122 
123 };
124 
127 
128 #endif
129 
130 /****************************************************************************/
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
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.
void save(OutputDevice &dev) const
bool operator==(const GUIPropertySchemeStorage &c) const
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
virtual ~GUIPropertySchemeStorage()
Destructor.