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-2016 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(int scheme) {
73  if (scheme < (int)mySchemes.size()) {
74  myActiveScheme = scheme;
75  }
76  }
77 
78  int 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  const std::vector<T>& getSchemes() const {
91  return mySchemes;
92  }
93 
94  T* getSchemeByName(std::string name) {
95  for (typename std::vector<T>::iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
96  if ((*i).getName() == name) {
97  return &(*i);
98  }
99  }
100  return 0;
101  }
102 
103  void save(OutputDevice& dev) const {
104  for (typename std::vector<T>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
105  i->save(dev);
106  }
107  }
108 
109  bool operator==(const GUIPropertySchemeStorage& c) const {
110  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
111  }
112 
113 
114  void addScheme(T scheme) {
115  mySchemes.push_back(scheme);
116  }
117 
118  int size() const {
119  return (int)mySchemes.size();
120  }
121 
122 
123 protected:
125  std::vector<T> mySchemes;
126 
127 };
128 
131 
132 #endif
133 
134 /****************************************************************************/
Base class for coloring. Allows changing the used colors and sets the used color in dependence to a v...
GUIPropertySchemeStorage< GUIScaleScheme > GUIScaler
const std::vector< T > & getSchemes() const
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.