#include <NLGeomShapeBuilder.h>

Definition at line 57 of file NLGeomShapeBuilder.h.
Public Member Functions | |
| virtual void | addPoint (const std::string &name, int layer, const std::string &type, const RGBColor &c, SUMOReal x, SUMOReal y, const std::string &lane, SUMOReal posOnLane) throw (InvalidArgument) |
| Adds the described PointOfInterest to the geometry container. | |
| NLGeomShapeBuilder (MSNet &net) throw () | |
| Constructor. | |
| virtual void | polygonBegin (const std::string &name, int layer, const std::string &type, const RGBColor &c, bool fill) throw () |
| Called when a polygon begins. | |
| virtual void | polygonEnd (const Position2DVector &shape) throw (InvalidArgument) |
| Ends the parsing of the polygon allocating it. | |
| virtual | ~NLGeomShapeBuilder () throw () |
| Destructor. | |
Protected Member Functions | |
| Position2D | getPointPosition (SUMOReal x, SUMOReal y, const std::string &laneID, SUMOReal posOnLane) const throw (InvalidArgument) |
| Determines the position of a poi to use. | |
Protected Attributes | |
| ShapeContainer & | myShapeContainer |
| The shape container. | |
Temporary stored values of the currently parsed polygon | |
| RGBColor | myCurrentColor |
| The current polygon's color. | |
| int | myCurrentLayer |
| The layer thepolygon shall be added to. | |
| std::string | myCurrentName |
| The current polygon's name. | |
| std::string | myCurrentType |
| The current polygon's type. | |
| bool | myFillPoly |
| Information whether the polygon shall be filled. | |
| NLGeomShapeBuilder::NLGeomShapeBuilder | ( | MSNet & | net | ) | throw () |
Constructor.
Retrieves the net's shape container and stores him in "myShapeContainer"
| [in] | net | The network to get the shape container from |
Definition at line 50 of file NLGeomShapeBuilder.cpp.
00051 : myShapeContainer(net.getShapeContainer()) {}
| NLGeomShapeBuilder::~NLGeomShapeBuilder | ( | ) | throw () [virtual] |
| void NLGeomShapeBuilder::addPoint | ( | const std::string & | name, | |
| int | layer, | |||
| const std::string & | type, | |||
| const RGBColor & | c, | |||
| SUMOReal | x, | |||
| SUMOReal | y, | |||
| const std::string & | lane, | |||
| SUMOReal | posOnLane | |||
| ) | throw (InvalidArgument) [virtual] |
Adds the described PointOfInterest to the geometry container.
Determines the position to use using "getPointPosition" throwing an InvalidArgument if this fails. Builds a PointOfInterest. Tries to add it to the container and throws an InvalidArgument if a pos with the same id already exists therein.
| [in] | name | The name (ID) of the poi |
| [in] | layer | The layer the poi shall be placed in |
| [in] | type | The abstract type of the poi |
| [in] | c | The color of the poi |
| [in] | x | The x-position of the poi |
| [in] | y | The y-position of the poi |
| [in] | lane | The id of the lane the poi shall be placed at |
| [in] | posOnLane | Position on the lane the poi shall be placed at |
| InvalidArgument | If a poi with the same id already exists or the position of the poi is invalid |
Reimplemented in GUIGeomShapeBuilder.
Definition at line 83 of file NLGeomShapeBuilder.cpp.
References ShapeContainer::add(), getPointPosition(), and myShapeContainer.
Referenced by NLHandler::addPOI().
00088 { 00089 Position2D pos = getPointPosition(x, y, lane, posOnLane); 00090 PointOfInterest *p = new PointOfInterest(name, type, pos, c); 00091 if (!myShapeContainer.add(layer, p)) { 00092 delete p; 00093 throw InvalidArgument("A duplicate of the POI '" + name + "' occured."); 00094 } 00095 }
| Position2D NLGeomShapeBuilder::getPointPosition | ( | SUMOReal | x, | |
| SUMOReal | y, | |||
| const std::string & | laneID, | |||
| SUMOReal | posOnLane | |||
| ) | const throw (InvalidArgument) [protected] |
Determines the position of a poi to use.
If x- and y-positions are not INVALID_POSITION, then this position is returned. Otherwise, the lane is tried to be obtained and the position resulting from the lane's geometry and the lane position information is computed. Throws an InvalidArgument if the lane is not known.
| [in] | x | The x-position of the poi |
| [in] | y | The y-position of the poi |
| [in] | laneID | The id of the lane the poi shall be placed at |
| [in] | posOnLane | Position on the lane the poi shall be placed at |
Definition at line 99 of file NLGeomShapeBuilder.cpp.
References MSLane::dictionary(), MSLane::getLength(), MSLane::getShape(), INVALID_POSITION, and Position2DVector::positionAtLengthPosition().
Referenced by addPoint(), and GUIGeomShapeBuilder::addPoint().
00101 { 00102 if (x!=INVALID_POSITION&&y!=INVALID_POSITION) { 00103 return Position2D(x,y); 00104 } 00105 MSLane *lane = MSLane::dictionary(laneID); 00106 if (lane==0) { 00107 throw InvalidArgument("Lane '" + laneID + "' to place a poi on is not known."); 00108 } 00109 if (posOnLane<0) { 00110 posOnLane = lane->getLength() + posOnLane; 00111 } 00112 return lane->getShape().positionAtLengthPosition(posOnLane); 00113 }
| void NLGeomShapeBuilder::polygonBegin | ( | const std::string & | name, | |
| int | layer, | |||
| const std::string & | type, | |||
| const RGBColor & | c, | |||
| bool | fill | |||
| ) | throw () [virtual] |
Called when a polygon begins.
The values are stored in order to allocate the complete polygon after the shape has been parsed, too.
| [in] | name | The name (ID) of the polygon |
| [in] | layer | The layer the polygon shall be placed in |
| [in] | type | The abstract type of the polygon |
| [in] | c | The color of the polygon |
| [in] | fill | Whether this polygon shall be filled |
Definition at line 58 of file NLGeomShapeBuilder.cpp.
References myCurrentColor, myCurrentLayer, myCurrentName, myCurrentType, and myFillPoly.
Referenced by NLHandler::addPoly().
00062 { 00063 myCurrentName = name; 00064 myCurrentType = type; 00065 myCurrentColor = c; 00066 myCurrentLayer = layer; 00067 myFillPoly = fill; 00068 }
| void NLGeomShapeBuilder::polygonEnd | ( | const Position2DVector & | shape | ) | throw (InvalidArgument) [virtual] |
Ends the parsing of the polygon allocating it.
Builds a Polygon2D. Tries to add it to the container and throws an InvalidArgument if a polygon with the same id already exists therein.
| [in] | shape | The shape of the polygon |
| InvalidArgument | If a polygon with the same id already exists |
Reimplemented in GUIGeomShapeBuilder.
Definition at line 72 of file NLGeomShapeBuilder.cpp.
References ShapeContainer::add(), myCurrentColor, myCurrentLayer, myCurrentName, myCurrentType, myFillPoly, and myShapeContainer.
Referenced by NLHandler::addPoly(), and NLHandler::myCharacters().
00072 { 00073 Polygon2D *p = 00074 new Polygon2D(myCurrentName, myCurrentType, myCurrentColor, shape, myFillPoly); 00075 if (!myShapeContainer.add(myCurrentLayer, p)) { 00076 delete p; 00077 throw InvalidArgument("A duplicate of the polygon '" + myCurrentName + "' occured."); 00078 } 00079 }
RGBColor NLGeomShapeBuilder::myCurrentColor [protected] |
The current polygon's color.
Definition at line 154 of file NLGeomShapeBuilder.h.
Referenced by polygonBegin(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
int NLGeomShapeBuilder::myCurrentLayer [protected] |
The layer thepolygon shall be added to.
Definition at line 157 of file NLGeomShapeBuilder.h.
Referenced by polygonBegin(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
std::string NLGeomShapeBuilder::myCurrentName [protected] |
The current polygon's name.
Definition at line 148 of file NLGeomShapeBuilder.h.
Referenced by polygonBegin(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
std::string NLGeomShapeBuilder::myCurrentType [protected] |
The current polygon's type.
Definition at line 151 of file NLGeomShapeBuilder.h.
Referenced by polygonBegin(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
bool NLGeomShapeBuilder::myFillPoly [protected] |
Information whether the polygon shall be filled.
Definition at line 160 of file NLGeomShapeBuilder.h.
Referenced by polygonBegin(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
ShapeContainer& NLGeomShapeBuilder::myShapeContainer [protected] |
The shape container.
Definition at line 165 of file NLGeomShapeBuilder.h.
Referenced by addPoint(), GUIGeomShapeBuilder::addPoint(), polygonEnd(), and GUIGeomShapeBuilder::polygonEnd().
1.5.6