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.sourceforge.net/
13 // Copyright (C) 2001-2012 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 #ifdef _WIN32
37 #include <windows.h>
38 #endif
39 
40 #include <GL/gl.h>
41 
42 #include <vector>
43 #include <fx.h>
45 #include "GUIColorScheme.h"
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
56 class GUIColorer {
57 public:
60 
62  virtual ~GUIColorer() { }
63 
65  void fill(FXComboBox& cb) {
66  for (std::vector<GUIColorScheme>::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 
83  return mySchemes[myActiveScheme];
84  }
85 
86  const GUIColorScheme& getScheme() const {
87  return mySchemes[myActiveScheme];
88  }
89 
90  GUIColorScheme* getSchemeByName(std::string name) {
91  for (std::vector<GUIColorScheme>::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 (std::vector<GUIColorScheme>::const_iterator i = mySchemes.begin(); i != mySchemes.end(); ++i) {
101  i->save(dev);
102  }
103  }
104 
105  bool operator==(const GUIColorer& c) const {
106  return myActiveScheme == c.myActiveScheme && mySchemes == c.mySchemes;
107  }
108 
109 
110  void addScheme(GUIColorScheme scheme) {
111  mySchemes.push_back(scheme);
112  }
113 
114 
115 protected:
117  std::vector<GUIColorScheme> mySchemes;
118 
119 };
120 
121 
122 #endif
123 
124 /****************************************************************************/