GUIEdgeControlBuilder.cpp
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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