Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GUIShapeContainer Class Reference

Storage for geometrical objects extended by mutexes. More...

#include <GUIShapeContainer.h>

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

Public Types

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

Public Member Functions

void addInactivePolygonTypes (std::set< std::string > inactivePolygonTypes)
 Adds new polygon types to the set of inactive ones.
 
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) override
 Builds a POI using the given values and adds it to the container.
 
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) override
 Builds a polygon using the given values and adds it to the container.
 
PolygonDynamicsaddPolygonDynamics (double simtime, std::string polyID, SUMOTrafficObject *trackedObject, const std::vector< double > &timeSpan, const std::vector< double > &alphaSpan, bool looped, bool rotate) override
 Adds dynamics to the given Polygon,.
 
virtual void addPolygonUpdateCommand (std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
 Register update command (for descheduling at removal)
 
void allowReplacement ()
 allow replacement
 
void clearState ()
 Remove all dynamics before quick-loading state.
 
const std::set< std::string > & getInactiveTypes (void) const
 
std::vector< GUIGlIDgetPOIIds () const
 Returns the gl-ids of all pois.
 
const POIsgetPOIs () const
 Returns all pois.
 
std::vector< GUIGlIDgetPolygonIDs () const
 Returns the gl-ids of all polygons.
 
const PolygonsgetPolygons () const
 Returns all polygons.
 
 GUIShapeContainer (SUMORTree &vis)
 Constructor.
 
virtual void movePOI (const std::string &id, const Position &pos) override
 Assigns a new position to the named PoI.
 
SUMOTime polygonDynamicsUpdate (SUMOTime t, PolygonDynamics *pd) override
 Update PolygonDynamics,.
 
virtual void registerHighlight (const std::string &objectID, const int type, const std::string &polygonID)
 register highlight of the specified type if the given id
 
void removeInactivePolygonTypes (std::set< std::string > inactivePolygonTypes)
 Remove some polygon types that were deemed as inactive.
 
virtual bool removePOI (const std::string &id) override
 Removes a PoI from the container.
 
virtual bool removePolygon (const std::string &id, bool useLock=true) override
 Removes a polygon from the container.
 
virtual bool removePolygonDynamics (const std::string &polyID)
 Remove dynamics (animation / tracking) for the given polygon.
 
virtual void removeTrackers (std::string objectID)
 Remove all tracking polygons for the given object.
 
virtual void reshapePolygon (const std::string &id, const PositionVector &shape) override
 Assigns a shape to the named polygon.
 
void setInactivePolygonTypes (std::set< std::string > inactivePolygonTypes)
 Sets polygon types that define which one is active or not.
 
virtual ~GUIShapeContainer ()
 Destructor.
 

Protected Member Functions

virtual bool add (PointOfInterest *poi, bool ignorePruning=false)
 add poi
 
virtual bool add (SUMOPolygon *poly, bool ignorePruning=false)
 add polygon
 
virtual void cleanupPolygonDynamics (const std::string &id)
 Unschedules the removal and update commands of the given polygon.
 
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())
 

Protected Attributes

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

Private Member Functions

void computeActivePolygons (void)
 Determine which polygons are active based on their type.
 

Private Attributes

bool myAllowReplacement
 whether existing ids shall be replaced
 
std::set< std::string > myInactivePolygonTypes
 The polygon types that define the inactive polygons.
 
FXMutex myLock
 The mutex for adding/removing operations.
 
std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > myPolygonUpdateCommands
 Command pointers for scheduled polygon update. Maps PolyID->Command.
 
SUMORTreemyVis
 The RTree structure to add and remove visualization elements.
 

Detailed Description

Storage for geometrical objects extended by mutexes.

See also
ShapeContainer

Definition at line 45 of file GUIShapeContainer.h.

Member Typedef Documentation

◆ POIs

Definition at line 54 of file ShapeContainer.h.

◆ Polygons

containers

Definition at line 53 of file ShapeContainer.h.

Constructor & Destructor Documentation

◆ GUIShapeContainer()

GUIShapeContainer::GUIShapeContainer ( SUMORTree vis)

Constructor.

Definition at line 35 of file GUIShapeContainer.cpp.

◆ ~GUIShapeContainer()

GUIShapeContainer::~GUIShapeContainer ( )
virtual

Destructor.

Definition at line 41 of file GUIShapeContainer.cpp.

Member Function Documentation

◆ add() [1/2]

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

add poi

Reimplemented in PCPolyContainer.

Definition at line 197 of file ShapeContainer.cpp.

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

◆ add() [2/2]

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

add polygon

Reimplemented in PCPolyContainer.

Definition at line 187 of file ShapeContainer.cpp.

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

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

Here is the caller graph for this function:

◆ addInactivePolygonTypes()

void GUIShapeContainer::addInactivePolygonTypes ( std::set< std::string >  inactivePolygonTypes)

Adds new polygon types to the set of inactive ones.

Parameters
inactivePolygonTypesSome set of inactive polygon types.

Definition at line 217 of file GUIShapeContainer.cpp.

References computeActivePolygons(), and myInactivePolygonTypes.

Referenced by GUIViewTraffic::drawPedestrianNetwork().

Here is the caller graph for this function:

◆ addPOI()

bool GUIShapeContainer::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 
)
overridevirtual

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 from ShapeContainer.

Definition at line 45 of file GUIShapeContainer.cpp.

References NamedObjectCont< T >::add(), SUMORTree::addAdditionalGLObject(), NamedObjectCont< T >::get(), myAllowReplacement, myLock, ShapeContainer::myPOIs, myVis, NamedObjectCont< T >::remove(), SUMORTree::removeAdditionalGLObject(), TL, and WRITE_WARNINGF.

◆ addPolygon()

bool GUIShapeContainer::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 
)
overridevirtual

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 from ShapeContainer.

Definition at line 70 of file GUIShapeContainer.cpp.

References GUIPolygon::activate(), NamedObjectCont< T >::add(), SUMORTree::addAdditionalGLObject(), NamedObjectCont< T >::get(), myAllowReplacement, myInactivePolygonTypes, myLock, ShapeContainer::myPolygons, myVis, NamedObjectCont< T >::remove(), SUMORTree::removeAdditionalGLObject(), TL, and WRITE_WARNINGF.

◆ addPolygonDynamics()

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

Adds dynamics to the given Polygon,.

See also
ShapeContainer addPolygonDynamics
Note
Supplies the visualisation RTree to the dynamics for updating the object when moving

Reimplemented from ShapeContainer.

Definition at line 97 of file GUIShapeContainer.cpp.

References ShapeContainer::addPolygonDynamics(), myVis, and PolygonDynamics::setRTree().

◆ addPolygonUpdateCommand()

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

Register update command (for descheduling at removal)

Definition at line 287 of file ShapeContainer.cpp.

References ShapeContainer::myPolygonUpdateCommands.

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

Here is the caller graph for this function:

◆ allowReplacement()

void GUIShapeContainer::allowReplacement ( )

allow replacement

Definition at line 204 of file GUIShapeContainer.cpp.

References myAllowReplacement.

◆ cleanupPolygonDynamics()

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

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 ShapeContainer::myPolygonUpdateCommands.

Referenced by ShapeContainer::removePolygonDynamics().

Here is the caller graph for this function:

◆ clearHighlight()

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

Definition at line 252 of file ShapeContainer.cpp.

References ShapeContainer::myHighlightedObjects, and ShapeContainer::myHighlightPolygons.

Referenced by ShapeContainer::registerHighlight().

Here is the caller graph for this function:

◆ clearHighlights()

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

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 ShapeContainer::myHighlightPolygons.

Referenced by ShapeContainer::removePolygonDynamics().

Here is the caller graph for this function:

◆ clearState()

void ShapeContainer::clearState ( )
inherited

Remove all dynamics before quick-loading state.

Definition at line 206 of file ShapeContainer.cpp.

References ShapeContainer::myPolygonUpdateCommands.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ computeActivePolygons()

void GUIShapeContainer::computeActivePolygons ( void  )
private

Determine which polygons are active based on their type.

Definition at line 233 of file GUIShapeContainer.cpp.

References GUIPolygon::activate(), Shape::getShapeType(), myInactivePolygonTypes, and ShapeContainer::myPolygons.

Referenced by addInactivePolygonTypes(), removeInactivePolygonTypes(), and setInactivePolygonTypes().

Here is the caller graph for this function:

◆ getInactiveTypes()

const std::set< std::string > & GUIShapeContainer::getInactiveTypes ( void  ) const
inline

Definition at line 143 of file GUIShapeContainer.h.

References myInactivePolygonTypes.

◆ getPOIIds()

std::vector< GUIGlID > GUIShapeContainer::getPOIIds ( ) const

Returns the gl-ids of all pois.

Definition at line 182 of file GUIShapeContainer.cpp.

References GUIGlObject::getGlID(), ShapeContainer::getPOIs(), and myLock.

◆ getPOIs()

const POIs & ShapeContainer::getPOIs ( ) const
inlineinherited

Returns all pois.

Definition at line 157 of file ShapeContainer.h.

References ShapeContainer::myPOIs.

Referenced by LIBSUMO_NAMESPACE::POI::add(), ShapeHandler::addPOI(), LIBSUMO_NAMESPACE::POI::getPoI(), 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:

◆ getPolygonIDs()

std::vector< GUIGlID > GUIShapeContainer::getPolygonIDs ( ) const

Returns the gl-ids of all polygons.

Definition at line 193 of file GUIShapeContainer.cpp.

References GUIGlObject::getGlID(), ShapeContainer::getPolygons(), and myLock.

◆ getPolygons()

◆ movePOI()

void GUIShapeContainer::movePOI ( const std::string &  id,
const Position pos 
)
overridevirtual

Assigns a new position to the named PoI.

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

Reimplemented from ShapeContainer.

Definition at line 157 of file GUIShapeContainer.cpp.

References SUMORTree::addAdditionalGLObject(), NamedObjectCont< T >::get(), myLock, ShapeContainer::myPOIs, myVis, and SUMORTree::removeAdditionalGLObject().

◆ polygonDynamicsUpdate()

SUMOTime GUIShapeContainer::polygonDynamicsUpdate ( SUMOTime  t,
PolygonDynamics pd 
)
overridevirtual

◆ registerHighlight()

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

register highlight of the specified type if the given id

Definition at line 236 of file ShapeContainer.cpp.

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

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

Here is the caller graph for this function:

◆ removeInactivePolygonTypes()

void GUIShapeContainer::removeInactivePolygonTypes ( std::set< std::string >  inactivePolygonTypes)

Remove some polygon types that were deemed as inactive.

Parameters
inactivePolygonTypesSome set of inactive polygon types.

Definition at line 224 of file GUIShapeContainer.cpp.

References computeActivePolygons(), and myInactivePolygonTypes.

Referenced by GUIViewTraffic::drawPedestrianNetwork().

Here is the caller graph for this function:

◆ removePOI()

bool GUIShapeContainer::removePOI ( const std::string &  id)
overridevirtual

Removes a PoI from the container.

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

Reimplemented from ShapeContainer.

Definition at line 145 of file GUIShapeContainer.cpp.

References NamedObjectCont< T >::get(), myLock, ShapeContainer::myPOIs, myVis, NamedObjectCont< T >::remove(), and SUMORTree::removeAdditionalGLObject().

◆ removePolygon()

bool GUIShapeContainer::removePolygon ( const std::string &  id,
bool  useLock = true 
)
overridevirtual

Removes a polygon from the container.

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

Reimplemented from ShapeContainer.

Definition at line 128 of file GUIShapeContainer.cpp.

References NamedObjectCont< T >::get(), myLock, ShapeContainer::myPolygons, myVis, SUMORTree::removeAdditionalGLObject(), and ShapeContainer::removePolygon().

◆ removePolygonDynamics()

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

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 ShapeContainer::cleanupPolygonDynamics(), ShapeContainer::clearHighlights(), NamedObjectCont< T >::get(), ShapeContainer::myPolygonDynamics, ShapeContainer::myPolygons, and ShapeContainer::myTrackingPolygons.

Referenced by ShapeContainer::addPolygonDynamics(), and ShapeContainer::removePolygon().

Here is the caller graph for this function:

◆ removeTrackers()

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

Remove all tracking polygons for the given object.

Definition at line 293 of file ShapeContainer.cpp.

References ShapeContainer::myTrackingPolygons, and ShapeContainer::removePolygon().

Referenced by MSDynamicShapeUpdater::vehicleStateChanged().

Here is the caller graph for this function:

◆ reshapePolygon()

void GUIShapeContainer::reshapePolygon ( const std::string &  id,
const PositionVector shape 
)
overridevirtual

Assigns a shape to the named polygon.

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

Reimplemented from ShapeContainer.

Definition at line 169 of file GUIShapeContainer.cpp.

References SUMORTree::addAdditionalGLObject(), NamedObjectCont< T >::get(), myLock, ShapeContainer::myPolygons, myVis, SUMORTree::removeAdditionalGLObject(), and GUIPolygon::setShape().

◆ setInactivePolygonTypes()

void GUIShapeContainer::setInactivePolygonTypes ( std::set< std::string >  inactivePolygonTypes)

Sets polygon types that define which one is active or not.

Parameters
inactivePolygonTypesThe whole set of inactive polygon types.

Definition at line 210 of file GUIShapeContainer.cpp.

References computeActivePolygons(), and myInactivePolygonTypes.

Field Documentation

◆ myAllowReplacement

bool GUIShapeContainer::myAllowReplacement
private

whether existing ids shall be replaced

Definition at line 167 of file GUIShapeContainer.h.

Referenced by addPOI(), addPolygon(), and allowReplacement().

◆ myHighlightedObjects

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

inverse map to myHighlightPolygons saves the highlighted object for each polygon

Definition at line 213 of file ShapeContainer.h.

Referenced by ShapeContainer::clearHighlight(), and ShapeContainer::registerHighlight().

◆ myHighlightPolygons

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

maps objects to a map of highlight types to highlighting polygons

Definition at line 211 of file ShapeContainer.h.

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

◆ myInactivePolygonTypes

std::set<std::string> GUIShapeContainer::myInactivePolygonTypes
private

The polygon types that define the inactive polygons.

Definition at line 170 of file GUIShapeContainer.h.

Referenced by addInactivePolygonTypes(), addPolygon(), computeActivePolygons(), getInactiveTypes(), removeInactivePolygonTypes(), and setInactivePolygonTypes().

◆ myLock

FXMutex GUIShapeContainer::myLock
mutableprivate

The mutex for adding/removing operations.

Definition at line 161 of file GUIShapeContainer.h.

Referenced by addPOI(), addPolygon(), getPOIIds(), getPolygonIDs(), movePOI(), polygonDynamicsUpdate(), removePOI(), removePolygon(), and reshapePolygon().

◆ myPOIs

◆ myPolygonDynamics

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

◆ myPolygons

◆ myPolygonUpdateCommands

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

◆ myTrackingPolygons

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

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 ShapeContainer::addPolygonDynamics(), ShapeContainer::removePolygonDynamics(), and ShapeContainer::removeTrackers().

◆ myVis

SUMORTree& GUIShapeContainer::myVis
private

The RTree structure to add and remove visualization elements.

Definition at line 164 of file GUIShapeContainer.h.

Referenced by addPOI(), addPolygon(), addPolygonDynamics(), movePOI(), polygonDynamicsUpdate(), removePOI(), removePolygon(), and reshapePolygon().


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