GUIEdgeControlBuilder.cpp

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // Derivation of NLEdgeControlBuilder which build gui-edges
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 
00020 
00021 // ===========================================================================
00022 // included modules
00023 // ===========================================================================
00024 #ifdef _MSC_VER
00025 #include <windows_config.h>
00026 #else
00027 #include <config.h>
00028 #endif
00029 
00030 #include <vector>
00031 #include <string>
00032 #include <map>
00033 #include <algorithm>
00034 #include <guisim/GUIEdge.h>
00035 #include <guisim/GUINet.h>
00036 #include <guisim/GUILane.h>
00037 #include <guisim/GUIInternalLane.h>
00038 #include <microsim/MSJunction.h>
00039 #include <netload/NLBuilder.h>
00040 #include "GUIEdgeControlBuilder.h"
00041 #include <gui/GUIGlobals.h>
00042 #include <utils/gui/globjects/GUIGlObjectStorage.h>
00043 
00044 #ifdef CHECK_MEMORY_LEAKS
00045 #include <foreign/nvwa/debug_new.h>
00046 #endif // CHECK_MEMORY_LEAKS
00047 
00048 
00049 // ===========================================================================
00050 // method definitions
00051 // ===========================================================================
00052 GUIEdgeControlBuilder::GUIEdgeControlBuilder(GUIGlObjectStorage &glObjectIDStorage) throw()
00053         : NLEdgeControlBuilder(),
00054         myGlObjectIDStorage(glObjectIDStorage) {}
00055 
00056 
00057 GUIEdgeControlBuilder::~GUIEdgeControlBuilder() throw() {}
00058 
00059 
00060 MSEdge *
00061 GUIEdgeControlBuilder::closeEdge() {
00062     MSEdge *ret = NLEdgeControlBuilder::closeEdge();
00063     static_cast<GUIEdge*>(ret)->initGeometry(GUIGlObjectStorage::gIDStorage);
00064     return ret;
00065 }
00066 
00067 
00068 MSLane *
00069 GUIEdgeControlBuilder::addLane(const std::string &id,
00070                                SUMOReal maxSpeed, SUMOReal length, bool isDepart,
00071                                const Position2DVector &shape,
00072                                const std::vector<SUMOVehicleClass> &allowed,
00073                                const std::vector<SUMOVehicleClass> &disallowed) {
00074     // checks if the depart lane was set before
00075     if (isDepart&&m_pDepartLane!=0) {
00076         throw InvalidArgument("Lane's '" + id + "' edge already has a depart lane.");
00077     }
00078     MSLane *lane = 0;
00079     switch (m_Function) {
00080     case MSEdge::EDGEFUNCTION_INTERNAL:
00081         lane = new GUIInternalLane(id, maxSpeed, length, myActiveEdge,
00082                                    myCurrentNumericalLaneID++, shape, allowed, disallowed);
00083         break;
00084     case MSEdge::EDGEFUNCTION_NORMAL:
00085     case MSEdge::EDGEFUNCTION_CONNECTOR:
00086         lane = new GUILane(id, maxSpeed, length, myActiveEdge,
00087                            myCurrentNumericalLaneID++, shape, allowed, disallowed);
00088         break;
00089     default:
00090         throw InvalidArgument("A lane with an unknown type occured (" + toString(m_Function) + ")");
00091     }
00092     m_pLaneStorage->push_back(lane);
00093     if (isDepart) {
00094         m_pDepartLane = lane;
00095     }
00096     return lane;
00097 }
00098 
00099 
00100 
00101 MSEdge *
00102 GUIEdgeControlBuilder::buildEdge(const std::string &id) throw() {
00103     return new GUIEdge(id, myCurrentNumericalEdgeID++, myGlObjectIDStorage);
00104 }
00105 
00106 /****************************************************************************/
00107 

Generated on Wed May 5 00:06:29 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6