SUMO - Simulation of Urban MObility
GUINet.h
Go to the documentation of this file.
00001 /****************************************************************************/
00009 // A MSNet extended by some values for usage within the gui
00010 /****************************************************************************/
00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00013 /****************************************************************************/
00014 //
00015 //   This file is part of SUMO.
00016 //   SUMO is free software: you can redistribute it and/or modify
00017 //   it under the terms of the GNU General Public License as published by
00018 //   the Free Software Foundation, either version 3 of the License, or
00019 //   (at your option) any later version.
00020 //
00021 /****************************************************************************/
00022 #ifndef GUINet_h
00023 #define GUINet_h
00024 
00025 
00026 // ===========================================================================
00027 // included modules
00028 // ===========================================================================
00029 #ifdef _MSC_VER
00030 #include <windows_config.h>
00031 #else
00032 #include <config.h>
00033 #endif
00034 
00035 #include <string>
00036 #include <utility>
00037 #include <microsim/MSNet.h>
00038 #include <utils/geom/Boundary.h>
00039 #include <utils/geom/Position.h>
00040 #include <foreign/rtree/SUMORTree.h>
00041 #include <utils/geom/PositionVector.h>
00042 #include <utils/gui/globjects/GUIGlObjectStorage.h>
00043 #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
00044 #include <utils/gui/globjects/GUIGlObject.h>
00045 #include <utils/gui/globjects/GUIGlObject_AbstractAdd.h>
00046 
00047 
00048 // ===========================================================================
00049 // class declarations
00050 // ===========================================================================
00051 class MSEdgeControl;
00052 class MSJunctionControl;
00053 class MSRouteLoaderControl;
00054 class MSTLLogicControl;
00055 class MSTrafficLightLogic;
00056 class MSLink;
00057 class GUIJunctionWrapper;
00058 class GUIDetectorWrapper;
00059 class GUITrafficLightLogicWrapper;
00060 class RGBColor;
00061 class GUIEdge;
00062 class OutputDevice;
00063 class GUIVehicle;
00064 class MSVehicleControl;
00065 
00066 
00067 // ===========================================================================
00068 // class definitions
00069 // ===========================================================================
00085 class GUINet : public MSNet, public GUIGlObject {
00086 
00087     friend class GUITrafficLightLogicWrapper; // see createTLWrapper
00088 
00089 public:
00097     GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
00098            MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents) ;
00099 
00100 
00102     ~GUINet() ;
00103 
00104 
00105 
00107 
00108 
00116     GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app,
00117                                        GUISUMOAbstractView& parent) ;
00118 
00119 
00127     GUIParameterTableWindow* getParameterWindow(
00128         GUIMainWindow& app, GUISUMOAbstractView& parent) ;
00129 
00130 
00136     Boundary getCenteringBoundary() const ;
00137 
00138 
00143     void drawGL(const GUIVisualizationSettings& s) const ;
00145 
00146 
00148     const Boundary& getBoundary() const;
00149 
00151     Position getJunctionPosition(const std::string& name) const;
00152 
00154     bool vehicleExists(const std::string& name) const;
00155 
00157     Boundary getEdgeBoundary(const std::string& name) const;
00158 
00160     void guiSimulationStep();
00161 
00162 
00165 
00169     unsigned int getWholeDuration() const ;
00170 
00171 
00175     unsigned int getSimDuration() const ;
00176 
00177 
00179     SUMOReal getRTFactor() const;
00180 
00182     SUMOReal getUPS() const;
00183 
00185     SUMOReal getMeanRTFactor(int duration) const;
00186 
00188     SUMOReal getMeanUPS() const;
00189 
00190     // Returns the duration of the last step's visualisation part (in ms)
00191     //int getVisDuration() const;
00192 
00194     unsigned int getIdleDuration() const ;
00195 
00197     void setSimDuration(int val);
00198 
00199     // Sets the duration of the last step's visualisation part
00200     //void setVisDuration(int val);
00201 
00203     void setIdleDuration(int val);
00204     //}
00205 
00206 
00209     unsigned int getLinkTLID(MSLink* link) const;
00210 
00213     int getLinkTLIndex(MSLink* link) const;
00214 
00215 
00217 
00218 
00219     /* @brief Returns the gl-ids of all junctions within the net
00220      * @param[in] includeInternal Whether to include ids of internal junctions
00221      */
00222     std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
00223 
00225     std::vector<GUIGlID> getTLSIDs() const;
00227 
00228 
00230     void initGUIStructures();
00231 
00232 
00236     SUMORTree& getVisualisationSpeedUp() {
00237         return myGrid;
00238     }
00239 
00240 
00244     const SUMORTree& getVisualisationSpeedUp() const {
00245         return myGrid;
00246     }
00247 
00252     static GUINet* getGUIInstance();
00253 
00254 
00255 private:
00257     void initTLMap();
00258 
00260     GUIGlID createTLWrapper(MSTrafficLightLogic* tll);
00261 
00262     friend class GUIOSGBuilder;
00263 
00264 protected:
00266     SUMORTree myGrid;
00267 
00269     Boundary myBoundary;
00270 
00272     std::vector<GUIEdge*> myEdgeWrapper;
00273 
00275     std::vector<GUIJunctionWrapper*> myJunctionWrapper;
00276 
00278     std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
00279 
00281     std::vector<GUIDetectorWrapper*> myDetectorDict;
00282 
00283 
00285     typedef std::map<MSLink*, std::string> Links2LogicMap;
00287     Links2LogicMap myLinks2Logic;
00288 
00289 
00291     typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
00293     Logics2WrapperMap myLogics2Wrapper;
00294 
00295 
00297     unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
00298 
00299     long myLastVehicleMovementCount, myOverallVehicleCount;
00300     long myOverallSimDuration;
00301 
00302 };
00303 
00304 
00305 #endif
00306 
00307 /****************************************************************************/
00308 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines