#include <GUIGeomShapeBuilder.h>

The main distinction to NLGeomShapeBuilder is that objects in gui-mode need an additional gl-id in order to make them clickable. This is retrieved from the stored GUIGlObjectStorage.
Definition at line 55 of file GUIGeomShapeBuilder.h.
Public Member Functions | |
| 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. | |
| GUIGeomShapeBuilder (MSNet &net, GUIGlObjectStorage &idStorage) 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. | |
| void | polygonEnd (const Position2DVector &shape) throw (InvalidArgument) |
| Ends the parsing of the polygon allocating it. | |
| ~GUIGeomShapeBuilder () 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 | |
| GUIGlObjectStorage & | myIdStorage |
| The id storage to retrieve gl-ids from. | |
| 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. | |
| GUIGeomShapeBuilder::GUIGeomShapeBuilder | ( | MSNet & | net, | |
| GUIGlObjectStorage & | idStorage | |||
| ) | throw () |
Constructor.
| [in] | net | The network to get the shape container from |
| [in] | idStorage | The storage to obtain new gl-ids from |
Definition at line 49 of file GUIGeomShapeBuilder.cpp.
00051 : NLGeomShapeBuilder(net), myIdStorage(idStorage) {}
| GUIGeomShapeBuilder::~GUIGeomShapeBuilder | ( | ) | throw () |
| void GUIGeomShapeBuilder::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 GUIPointOfInterest. 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 from NLGeomShapeBuilder.
Definition at line 70 of file GUIGeomShapeBuilder.cpp.
References ShapeContainer::add(), NLGeomShapeBuilder::getPointPosition(), myIdStorage, and NLGeomShapeBuilder::myShapeContainer.
00073 { 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 }
| Position2D NLGeomShapeBuilder::getPointPosition | ( | SUMOReal | x, | |
| SUMOReal | y, | |||
| const std::string & | laneID, | |||
| SUMOReal | posOnLane | |||
| ) | const throw (InvalidArgument) [protected, inherited] |
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 NLGeomShapeBuilder::addPoint(), and 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, inherited] |
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 NLGeomShapeBuilder::myCurrentColor, NLGeomShapeBuilder::myCurrentLayer, NLGeomShapeBuilder::myCurrentName, NLGeomShapeBuilder::myCurrentType, and NLGeomShapeBuilder::myFillPoly.
Referenced by NLHandler::addPoly().
00062 { 00063 myCurrentName = name; 00064 myCurrentType = type; 00065 myCurrentColor = c; 00066 myCurrentLayer = layer; 00067 myFillPoly = fill; 00068 }
| void GUIGeomShapeBuilder::polygonEnd | ( | const Position2DVector & | shape | ) | throw (InvalidArgument) [virtual] |
Ends the parsing of the polygon allocating it.
Builds a GUIPolygon2D. 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 from NLGeomShapeBuilder.
Definition at line 58 of file GUIGeomShapeBuilder.cpp.
References ShapeContainer::add(), NLGeomShapeBuilder::myCurrentColor, NLGeomShapeBuilder::myCurrentLayer, NLGeomShapeBuilder::myCurrentName, NLGeomShapeBuilder::myCurrentType, NLGeomShapeBuilder::myFillPoly, myIdStorage, and NLGeomShapeBuilder::myShapeContainer.
00058 { 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 }
RGBColor NLGeomShapeBuilder::myCurrentColor [protected, inherited] |
The current polygon's color.
Definition at line 154 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::polygonBegin(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
int NLGeomShapeBuilder::myCurrentLayer [protected, inherited] |
The layer thepolygon shall be added to.
Definition at line 157 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::polygonBegin(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
std::string NLGeomShapeBuilder::myCurrentName [protected, inherited] |
The current polygon's name.
Definition at line 148 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::polygonBegin(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
std::string NLGeomShapeBuilder::myCurrentType [protected, inherited] |
The current polygon's type.
Definition at line 151 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::polygonBegin(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
bool NLGeomShapeBuilder::myFillPoly [protected, inherited] |
Information whether the polygon shall be filled.
Definition at line 160 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::polygonBegin(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
GUIGlObjectStorage& GUIGeomShapeBuilder::myIdStorage [protected] |
The id storage to retrieve gl-ids from.
Definition at line 105 of file GUIGeomShapeBuilder.h.
Referenced by addPoint(), and polygonEnd().
ShapeContainer& NLGeomShapeBuilder::myShapeContainer [protected, inherited] |
The shape container.
Definition at line 165 of file NLGeomShapeBuilder.h.
Referenced by NLGeomShapeBuilder::addPoint(), addPoint(), NLGeomShapeBuilder::polygonEnd(), and polygonEnd().
1.5.6