GUIGeomShapeBuilder.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 <string>
00031 #include <utils/common/RGBColor.h>
00032 #include <utils/geom/Position2D.h>
00033 #include <utils/geom/Position2DVector.h>
00034 #include <utils/gui/globjects/GUIPolygon2D.h>
00035 #include <utils/gui/globjects/GUIPointOfInterest.h>
00036 #include <utils/shapes/ShapeContainer.h>
00037 #include <utils/common/UtilExceptions.h>
00038 #include "GUIGeomShapeBuilder.h"
00039 #include <microsim/MSNet.h>
00040
00041 #ifdef CHECK_MEMORY_LEAKS
00042 #include <foreign/nvwa/debug_new.h>
00043 #endif // CHECK_MEMORY_LEAKS
00044
00045
00046
00047
00048
00049 GUIGeomShapeBuilder::GUIGeomShapeBuilder(MSNet &net,
00050 GUIGlObjectStorage &idStorage) throw()
00051 : NLGeomShapeBuilder(net), myIdStorage(idStorage) {}
00052
00053
00054 GUIGeomShapeBuilder::~GUIGeomShapeBuilder() throw() {}
00055
00056
00057 void
00058 GUIGeomShapeBuilder::polygonEnd(const Position2DVector &shape) throw(InvalidArgument) {
00059 GUIPolygon2D *p =
00060 new GUIPolygon2D(myIdStorage, myCurrentLayer, myCurrentName, myCurrentType,
00061 myCurrentColor, shape, myFillPoly);
00062 if (!myShapeContainer.add(myCurrentLayer, p)) {
00063 delete p;
00064 throw InvalidArgument("A duplicate of the polygon '" + myCurrentName + "' occured.");
00065 }
00066 }
00067
00068
00069 void
00070 GUIGeomShapeBuilder::addPoint(const std::string &name, int layer,
00071 const std::string &type, const RGBColor &c,
00072 SUMOReal x, SUMOReal y,
00073 const std::string &lane, SUMOReal posOnLane) throw(InvalidArgument) {
00074 Position2D pos = getPointPosition(x, y, lane, posOnLane);
00075 GUIPointOfInterest *p = new GUIPointOfInterest(myIdStorage, layer, name, type, pos, c);
00076 if (!myShapeContainer.add(layer, p)) {
00077 delete p;
00078 throw InvalidArgument("A duplicate of the POI '" + name + "' occured.");
00079 }
00080 }
00081
00082
00083
00084
00085