SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUINet.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A MSNet extended by some values for usage within the gui
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUINet_h
23 #define GUINet_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 <string>
36 #include <utility>
37 #include <microsim/MSNet.h>
38 #include <utils/geom/Boundary.h>
39 #include <utils/geom/Position.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSEdgeControl;
52 class MSJunctionControl;
54 class MSTLLogicControl;
56 class MSLink;
57 class GUIJunctionWrapper;
58 class GUIDetectorWrapper;
60 class RGBColor;
61 class GUIEdge;
62 class OutputDevice;
63 class GUIVehicle;
64 class MSVehicleControl;
65 
66 
67 // ===========================================================================
68 // class definitions
69 // ===========================================================================
85 class GUINet : public MSNet, public GUIGlObject {
86 
87  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
88 
89 public:
97  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
98  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents) ;
99 
100 
102  ~GUINet() ;
103 
104 
105 
107 
108 
117  GUISUMOAbstractView& parent) ;
118 
119 
128  GUIMainWindow& app, GUISUMOAbstractView& parent) ;
129 
130 
137 
138 
143  void drawGL(const GUIVisualizationSettings& s) const ;
145 
146 
148  const Boundary& getBoundary() const;
149 
151  Position getJunctionPosition(const std::string& name) const;
152 
154  bool vehicleExists(const std::string& name) const;
155 
157  Boundary getEdgeBoundary(const std::string& name) const;
158 
160  void guiSimulationStep();
161 
162 
165 
169  unsigned int getWholeDuration() const ;
170 
171 
175  unsigned int getSimDuration() const ;
176 
177 
179  SUMOReal getRTFactor() const;
180 
182  SUMOReal getUPS() const;
183 
185  SUMOReal getMeanRTFactor(int duration) const;
186 
188  SUMOReal getMeanUPS() const;
189 
190  // Returns the duration of the last step's visualisation part (in ms)
191  //int getVisDuration() const;
192 
194  unsigned int getIdleDuration() const ;
195 
197  void setSimDuration(int val);
198 
199  // Sets the duration of the last step's visualisation part
200  //void setVisDuration(int val);
201 
203  void setIdleDuration(int val);
204  //}
205 
206 
209  unsigned int getLinkTLID(MSLink* link) const;
210 
213  int getLinkTLIndex(MSLink* link) const;
214 
215 
217 
218 
219  /* @brief Returns the gl-ids of all junctions within the net
220  * @param[in] includeInternal Whether to include ids of internal junctions
221  */
222  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
223 
225  std::vector<GUIGlID> getTLSIDs() const;
227 
228 
230  void initGUIStructures();
231 
232 
237  return myGrid;
238  }
239 
240 
245  return myGrid;
246  }
247 
252  static GUINet* getGUIInstance();
253 
254 
255 private:
257  void initTLMap();
258 
261 
262  friend class GUIOSGBuilder;
263 
264 protected:
267 
270 
272  std::vector<GUIEdge*> myEdgeWrapper;
273 
275  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
276 
278  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
279 
281  std::vector<GUIDetectorWrapper*> myDetectorDict;
282 
283 
285  typedef std::map<MSLink*, std::string> Links2LogicMap;
288 
289 
291  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
294 
295 
297  unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
298 
301 
302 };
303 
304 
305 #endif
306 
307 /****************************************************************************/
308