Eclipse SUMO - Simulation of Urban MObility
ShapeContainer Class Reference

Storage for geometrical objects. More...

#include <ShapeContainer.h>

Inheritance diagram for ShapeContainer:
[legend]
Collaboration diagram for ShapeContainer:
[legend]

Public Types

typedef NamedObjectCont< PointOfInterest * > POIs
 
typedef NamedObjectCont< SUMOPolygon * > Polygons
 containers More...
 

Public Member Functions

virtual bool addPOI (const std::string &id, const std::string &type, const RGBColor &color, const Position &pos, bool geo, const std::string &lane, double posOverLane, bool friendlyPos, double posLat, const std::string &icon, double layer, double angle, const std::string &imgFile, bool relativePath, double width, double height, bool ignorePruning=false)
 Builds a POI using the given values and adds it to the container. More...
 
virtual bool addPolygon (const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, bool relativePath, const PositionVector &shape, bool geo, bool fill, double lineWidth, bool ignorePruning=false, const std::string &name=Shape::DEFAULT_NAME)
 Builds a polygon using the given values and adds it to the container. More...
 
virtual PolygonDynamicsaddPolygonDynamics (double simtime, std::string polyID, SUMOTrafficObject *trackedObject, const std::vector< double > &timeSpan, const std::vector< double > &alphaSpan, bool looped, bool rotate)
 Adds dynamics (animation / tracking) to the given polygon. More...
 
virtual void addPolygonUpdateCommand (std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
 Register update command (for descheduling at removal) More...
 
void clearState ()
 Remove all dynamics before quick-loading state. More...
 
const POIsgetPOIs () const
 Returns all pois. More...
 
const PolygonsgetPolygons () const
 Returns all polygons. More...
 
virtual void movePOI (const std::string &id, const Position &pos)
 Assigns a new position to the named PoI. More...
 
virtual SUMOTime polygonDynamicsUpdate (SUMOTime t, PolygonDynamics *pd)
 Regular update event for updating polygon dynamics. More...
 
virtual void registerHighlight (const std::string &objectID, const int type, const std::string &polygonID)
 register highlight of the specified type if the given id More...
 
virtual bool removePOI (const std::string &id)
 Removes a PoI from the container. More...
 
virtual bool removePolygon (const std::string &id, bool useLock=true)
 Removes a polygon from the container. More...
 
virtual bool removePolygonDynamics (const std::string &polyID)
 Remove dynamics (animation / tracking) for the given polygon. More...
 
virtual void removeTrackers (std::string objectID)
 Remove all tracking polygons for the given object. More...
 
virtual void reshapePolygon (const std::string &id, const PositionVector &shape)
 Assigns a shape to the named polygon. More...
 
 ShapeContainer ()
 Constructor. More...
 
virtual ~ShapeContainer ()
 Destructor. More...
 

Protected Member Functions

virtual bool add (PointOfInterest *poi, bool ignorePruning=false)
 add poi More...
 
virtual bool add (SUMOPolygon *poly, bool ignorePruning=false)
 add polygon More...
 
virtual void cleanupPolygonDynamics (const std::string &id)
 Unschedules the removal and update commands of the given polygon. More...
 
Management of highlights. For each type, only one highlight can be active,

Remove any previously added highlight polygon of the specified type

See also
myHighlightPolygons, myHighlightedObjects
Parameters
[out]toRemovewill hold the id of any polygon that was highlighting the given object
virtual void clearHighlight (const std::string &objectID, const int type, std::string &toRemove)
 
virtual void clearHighlights (const std::string &objectID, SUMOPolygon *p)
 Clears all highlight information from the maps when the object leaves the net (Highlight polygons and dynamics are removed via removeTrackers()) More...
 

Protected Attributes

std::map< std::string, std::string > myHighlightedObjects
 inverse map to myHighlightPolygons saves the highlighted object for each polygon More...
 
std::map< std::string, std::map< int, std::string > > myHighlightPolygons
 maps objects to a map of highlight types to highlighting polygons More...
 
POIs myPOIs
 stored POIs More...
 
std::map< std::string, PolygonDynamics * > myPolygonDynamics
 stored PolygonDynamics More...
 
Polygons myPolygons
 stored Polygons More...
 
std::map< const std::string, std::set< const SUMOPolygon * > > myTrackingPolygons
 Information about tracked objects. More...
 

Private Attributes

std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > myPolygonUpdateCommands
 Command pointers for scheduled polygon update. Maps PolyID->Command. More...
 

Detailed Description

Storage for geometrical objects.

Definition at line 49 of file ShapeContainer.h.

Member Typedef Documentation

◆ POIs

◆ Polygons

containers

Definition at line 53 of file ShapeContainer.h.

Constructor & Destructor Documentation

◆ ShapeContainer()

ShapeContainer::ShapeContainer ( )

Constructor.

Definition at line 47 of file ShapeContainer.cpp.

◆ ~ShapeContainer()

ShapeContainer::~ShapeContainer ( )
virtual

Destructor.

Definition at line 49 of file ShapeContainer.cpp.

References myPolygonDynamics, and myPolygonUpdateCommands.

Member Function Documentation

◆ add() [1/2]

bool ShapeContainer::add ( PointOfInterest poi,
bool  ignorePruning = false 
)
protectedvirtual

add poi

Reimplemented in PCPolyContainer.

Definition at line 197 of file ShapeContainer.cpp.

References NamedObjectCont< T >::add(), Named::getID(), and myPOIs.

◆ add() [2/2]

bool ShapeContainer::add ( SUMOPolygon poly,
bool  ignorePruning = false 
)
protectedvirtual

add polygon

Reimplemented in PCPolyContainer.

Definition at line 187 of file ShapeContainer.cpp.

References NamedObjectCont< T >::add(), Named::getID(), and myPolygons.

Referenced by PCPolyContainer::add(), addPOI(), and addPolygon().

Here is the caller graph for this function:

◆ addPOI()

bool ShapeContainer::addPOI ( const std::string &  id,
const std::string &  type,
const RGBColor color,
const Position pos,
bool  geo,
const std::string &  lane,
double  posOverLane,
bool  friendlyPos,
double  posLat,
const std::string &  icon,
double  layer,
double  angle,
const std::string &  imgFile,
bool  relativePath,
double  width,
double  height,
bool  ignorePruning = false 
)
virtual

Builds a POI using the given values and adds it to the container.

Parameters
[in]idThe name of the POI
[in]typeThe (abstract) type of the POI
[in]colorThe color of the POI
[in]posThe position of the POI
[in[geo use GEO coordinates (lon/lat)
[in]laneThe Lane in which this POI is placed
[in]posOverLaneThe position over Lane
[in]friendlyPosenable or disable friendly position over lane
[in]posLatThe position lateral over Lane
[in]iconThe icon of the POI
[in]layerThe layer of the POI
[in]angleThe rotation of the POI
[in]imgFileThe raster image of the POI
[in]relativePathset image file as relative path
[in]widthThe width of the POI image
[in]heightThe height of the POI image
Returns
whether the poi could be added

Reimplemented in GUIShapeContainer.

Definition at line 145 of file ShapeContainer.cpp.

References add().

Referenced by LIBSUMO_NAMESPACE::POI::add(), and ShapeHandler::addPOI().

Here is the caller graph for this function:

◆ addPolygon()

bool ShapeContainer::addPolygon ( const std::string &  id,
const std::string &  type,
const RGBColor color,
double  layer,
double  angle,
const std::string &  imgFile,
bool  relativePath,
const PositionVector shape,
bool  geo,
bool  fill,
double  lineWidth,
bool  ignorePruning = false,
const std::string &  name = Shape::DEFAULT_NAME 
)
virtual

Builds a polygon using the given values and adds it to the container.

Parameters
[in]idThe name of the polygon
[in]typeThe (abstract) type of the polygon
[in]colorThe color of the polygon
[in]layerThe layer of the polygon
[in]angleThe rotation of the polygon
[in]imgFileThe raster image of the polygon
[in]relativePathset image file as relative path
[in]shapeThe shape of the polygon
[in]geospecify if shape was loaded as GEO coordinate
[in]fillWhether the polygon shall be filled
[in]lineWidthLine width when drawing unfilled polygon
Returns
whether the polygon could be added

Reimplemented in GUIShapeContainer.

Definition at line 63 of file ShapeContainer.cpp.

References add().

Referenced by LIBSUMO_NAMESPACE::Polygon::add(), NLHandler::addDistrict(), ShapeHandler::addPoly(), MSPModel_JuPedSim::preparePolygonForDrawing(), and NWWriter_OpenDrive::writeNetwork().

Here is the caller graph for this function:

◆ addPolygonDynamics()

PolygonDynamics * ShapeContainer::addPolygonDynamics ( double  simtime,
std::string  polyID,
SUMOTrafficObject trackedObject,
const std::vector< double > &  timeSpan,
const std::vector< double > &  alphaSpan,
bool  looped,
bool  rotate 
)
virtual

Adds dynamics (animation / tracking) to the given polygon.

Parameters
polyIDID of the polygon which should become dynamic
Returns
true if the operation was successful, false if not.
See also
PolygonDynamics()

Reimplemented in GUIShapeContainer.

Definition at line 73 of file ShapeContainer.cpp.

References NamedObjectCont< T >::get(), PolygonDynamics::getTrackedObjectID(), myPolygonDynamics, myPolygons, myTrackingPolygons, and removePolygonDynamics().

Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics(), and GUIShapeContainer::addPolygonDynamics().

Here is the caller graph for this function:

◆ addPolygonUpdateCommand()

void ShapeContainer::addPolygonUpdateCommand ( std::string  polyID,
ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *  cmd 
)
virtual

Register update command (for descheduling at removal)

Definition at line 287 of file ShapeContainer.cpp.

References myPolygonUpdateCommands.

Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics().

Here is the caller graph for this function:

◆ cleanupPolygonDynamics()

void ShapeContainer::cleanupPolygonDynamics ( const std::string &  id)
protectedvirtual

Unschedules the removal and update commands of the given polygon.

Parameters
[in]idThe id of the polygon

Definition at line 214 of file ShapeContainer.cpp.

References myPolygonUpdateCommands.

Referenced by removePolygonDynamics().

Here is the caller graph for this function:

◆ clearHighlight()

void ShapeContainer::clearHighlight ( const std::string &  objectID,
const int  type,
std::string &  toRemove 
)
protectedvirtual

Definition at line 252 of file ShapeContainer.cpp.

References myHighlightedObjects, and myHighlightPolygons.

Referenced by registerHighlight().

Here is the caller graph for this function:

◆ clearHighlights()

void ShapeContainer::clearHighlights ( const std::string &  objectID,
SUMOPolygon p 
)
protectedvirtual

Clears all highlight information from the maps when the object leaves the net (Highlight polygons and dynamics are removed via removeTrackers())

Definition at line 268 of file ShapeContainer.cpp.

References Named::getID(), and myHighlightPolygons.

Referenced by removePolygonDynamics().

Here is the caller graph for this function:

◆ clearState()

void ShapeContainer::clearState ( )

Remove all dynamics before quick-loading state.

Definition at line 206 of file ShapeContainer.cpp.

References myPolygonUpdateCommands.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ getPOIs()

const POIs& ShapeContainer::getPOIs ( ) const
inline

Returns all pois.

Definition at line 157 of file ShapeContainer.h.

References myPOIs.

Referenced by LIBSUMO_NAMESPACE::POI::add(), ShapeHandler::addPOI(), LIBSUMO_NAMESPACE::POI::getPoI(), GUIShapeContainer::getPOIIds(), LIBSUMO_NAMESPACE::POI::getTree(), PCLoaderVisum::load(), NWWriter_OpenDrive::mapmatchRoadObjects(), LIBSUMO_NAMESPACE::POI::remove(), NWWriter_OpenDrive::writeRoadObjects(), and NWWriter_OpenDrive::writeSignals().

Here is the caller graph for this function:

◆ getPolygons()

◆ movePOI()

void ShapeContainer::movePOI ( const std::string &  id,
const Position pos 
)
virtual

Assigns a new position to the named PoI.

Parameters
[in]idThe id of the PoI to move
[in]posThe PoI's new position

Reimplemented in GUIShapeContainer.

Definition at line 169 of file ShapeContainer.cpp.

References NamedObjectCont< T >::get(), and myPOIs.

Referenced by LIBSUMO_NAMESPACE::POI::setPosition().

Here is the caller graph for this function:

◆ polygonDynamicsUpdate()

SUMOTime ShapeContainer::polygonDynamicsUpdate ( SUMOTime  t,
PolygonDynamics pd 
)
virtual

Regular update event for updating polygon dynamics.

Parameters
[in]tThe time at which the update is called
[in]pdThe dynamics to be updated
Returns
zero If dynamics has expired, next update time otherwise

Reimplemented in GUIShapeContainer.

Definition at line 224 of file ShapeContainer.cpp.

References PolygonDynamics::getPolygonID(), myPolygonUpdateCommands, removePolygon(), and PolygonDynamics::update().

Referenced by LIBSUMO_NAMESPACE::Polygon::addDynamics(), and GUIShapeContainer::polygonDynamicsUpdate().

Here is the caller graph for this function:

◆ registerHighlight()

void ShapeContainer::registerHighlight ( const std::string &  objectID,
const int  type,
const std::string &  polygonID 
)
virtual

register highlight of the specified type if the given id

Definition at line 236 of file ShapeContainer.cpp.

References clearHighlight(), myHighlightedObjects, myHighlightPolygons, and removePolygon().

Referenced by LIBSUMO_NAMESPACE::Polygon::addHighlightPolygon().

Here is the caller graph for this function:

◆ removePOI()

bool ShapeContainer::removePOI ( const std::string &  id)
virtual

Removes a PoI from the container.

Parameters
[in]idThe id of the PoI
Returns
Whether the poi could be removed

Reimplemented in GUIShapeContainer.

Definition at line 163 of file ShapeContainer.cpp.

References myPOIs, and NamedObjectCont< T >::remove().

Referenced by LIBSUMO_NAMESPACE::POI::remove().

Here is the caller graph for this function:

◆ removePolygon()

bool ShapeContainer::removePolygon ( const std::string &  id,
bool  useLock = true 
)
virtual

Removes a polygon from the container.

Parameters
[in]idThe id of the polygon
Returns
Whether the polygon could be removed

Reimplemented in GUIShapeContainer.

Definition at line 153 of file ShapeContainer.cpp.

References myPolygons, NamedObjectCont< T >::remove(), and removePolygonDynamics().

Referenced by polygonDynamicsUpdate(), registerHighlight(), LIBSUMO_NAMESPACE::Polygon::remove(), GUIShapeContainer::removePolygon(), MSPModel_JuPedSim::removePolygonFromDrawing(), and removeTrackers().

Here is the caller graph for this function:

◆ removePolygonDynamics()

bool ShapeContainer::removePolygonDynamics ( const std::string &  polyID)
virtual

Remove dynamics (animation / tracking) for the given polygon.

Parameters
polyIDID of the polygon for which dynamics shall be removed
Returns
true if the operation was successful (dynamics existed for the polygon), false if not.

Definition at line 113 of file ShapeContainer.cpp.

References cleanupPolygonDynamics(), clearHighlights(), NamedObjectCont< T >::get(), myPolygonDynamics, myPolygons, and myTrackingPolygons.

Referenced by addPolygonDynamics(), and removePolygon().

Here is the caller graph for this function:

◆ removeTrackers()

void ShapeContainer::removeTrackers ( std::string  objectID)
virtual

Remove all tracking polygons for the given object.

Definition at line 293 of file ShapeContainer.cpp.

References myTrackingPolygons, and removePolygon().

Referenced by MSDynamicShapeUpdater::vehicleStateChanged().

Here is the caller graph for this function:

◆ reshapePolygon()

void ShapeContainer::reshapePolygon ( const std::string &  id,
const PositionVector shape 
)
virtual

Assigns a shape to the named polygon.

Parameters
[in]idThe id of the polygon to reshape
[in]shapeThe polygon's new shape

Reimplemented in GUIShapeContainer.

Definition at line 178 of file ShapeContainer.cpp.

References NamedObjectCont< T >::get(), myPolygons, and SUMOPolygon::setShape().

Referenced by LIBSUMO_NAMESPACE::Polygon::setShape().

Here is the caller graph for this function:

Field Documentation

◆ myHighlightedObjects

std::map<std::string, std::string> ShapeContainer::myHighlightedObjects
protected

inverse map to myHighlightPolygons saves the highlighted object for each polygon

Definition at line 213 of file ShapeContainer.h.

Referenced by clearHighlight(), and registerHighlight().

◆ myHighlightPolygons

std::map<std::string, std::map<int, std::string> > ShapeContainer::myHighlightPolygons
protected

maps objects to a map of highlight types to highlighting polygons

Definition at line 211 of file ShapeContainer.h.

Referenced by clearHighlight(), clearHighlights(), and registerHighlight().

◆ myPOIs

◆ myPolygonDynamics

std::map<std::string, PolygonDynamics*> ShapeContainer::myPolygonDynamics
protected

stored PolygonDynamics

Definition at line 208 of file ShapeContainer.h.

Referenced by addPolygonDynamics(), removePolygonDynamics(), and ~ShapeContainer().

◆ myPolygons

◆ myPolygonUpdateCommands

std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> ShapeContainer::myPolygonUpdateCommands
private

Command pointers for scheduled polygon update. Maps PolyID->Command.

Definition at line 225 of file ShapeContainer.h.

Referenced by addPolygonUpdateCommand(), cleanupPolygonDynamics(), clearState(), polygonDynamicsUpdate(), and ~ShapeContainer().

◆ myTrackingPolygons

std::map<const std::string, std::set<const SUMOPolygon*> > ShapeContainer::myTrackingPolygons
protected

Information about tracked objects.

Note
Maps tracked object IDs to set of polygons, which are tracking the object. Needed at object removal to cancel tacking (i.e. remove tracking poly).

Definition at line 218 of file ShapeContainer.h.

Referenced by addPolygonDynamics(), removePolygonDynamics(), and removeTrackers().


The documentation for this class was generated from the following files: