Eclipse SUMO - Simulation of Urban MObility
ShapeContainer.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2005-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // Storage for geometrical objects, sorted by the layers they are in
18 /****************************************************************************/
19 #ifndef ShapeContainer_h
20 #define ShapeContainer_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <map>
30 #include <memory>
32 #include "PointOfInterest.h"
33 #include "SUMOPolygon.h"
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class PolygonDynamics;
39 class SUMOTrafficObject;
40 template <class T, class S>
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 public:
52 
56 
59 
61  virtual ~ShapeContainer();
62 
77  virtual bool addPolygon(const std::string& id, const std::string& type,
78  const RGBColor& color, double layer,
79  double angle, const std::string& imgFile,
80  bool relativePath, const PositionVector& shape, bool geo,
81  bool fill, double lineWidth, bool ignorePruning = false);
82 
89  virtual PolygonDynamics* addPolygonDynamics(double simtime,
90  std::string polyID,
91  SUMOTrafficObject* trackedObject,
92  const std::vector<double>& timeSpan,
93  const std::vector<double>& alphaSpan,
94  bool looped,
95  bool rotate);
96 
102  virtual bool removePolygonDynamics(const std::string& polyID);
103 
121  virtual bool addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
122  const std::string& lane, double posOverLane, double posLat, double layer, double angle,
123  const std::string& imgFile, bool relativePath, double width, double height, bool ignorePruning = false);
124 
129  virtual bool removePolygon(const std::string& id, bool useLock = true);
130 
135  virtual bool removePOI(const std::string& id);
136 
141  virtual void movePOI(const std::string& id, const Position& pos);
142 
147  virtual void reshapePolygon(const std::string& id, const PositionVector& shape);
148 
150  inline const Polygons& getPolygons() const {
151  return myPolygons;
152  }
153 
155  inline const POIs& getPOIs() const {
156  return myPOIs;
157  }
158 
165 
168 
170  virtual void removeTrackers(std::string objectID);
171 
173  virtual void registerHighlight(const std::string& objectID, const int type, const std::string& polygonID);
174 
175 protected:
177  virtual bool add(SUMOPolygon* poly, bool ignorePruning = false);
178 
180  virtual bool add(PointOfInterest* poi, bool ignorePruning = false);
181 
185  virtual void cleanupPolygonDynamics(const std::string& id);
186 
192  virtual void clearHighlight(const std::string& objectID, const int type, std::string& toRemove);
195  virtual void clearHighlights(const std::string& objectID, SUMOPolygon* p);
197 
198 protected:
201 
203  std::map<std::string, PolygonDynamics*> myPolygonDynamics;
204 
206  std::map<std::string, std::map<int, std::string> > myHighlightPolygons;
208  std::map<std::string, std::string> myHighlightedObjects;
209 
213  std::map<const std::string, std::set<const SUMOPolygon*> > myTrackingPolygons;
214 
217 
218 private:
220  std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> myPolygonUpdateCommands;
221 
222 };
223 
224 
225 #endif
226 
227 /****************************************************************************/
228 
ShapeContainer::cleanupPolygonDynamics
virtual void cleanupPolygonDynamics(const std::string &id)
Unschedules the removal and update commands of the given polygon.
Definition: ShapeContainer.cpp:208
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
ShapeContainer::removeTrackers
virtual void removeTrackers(std::string objectID)
Remove all tracking polygons for the given object.
Definition: ShapeContainer.cpp:287
ShapeContainer::polygonDynamicsUpdate
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
Definition: ShapeContainer.cpp:218
ShapeContainer::myPolygonDynamics
std::map< std::string, PolygonDynamics * > myPolygonDynamics
stored PolygonDynamics
Definition: ShapeContainer.h:203
ShapeContainer::myTrackingPolygons
std::map< const std::string, std::set< const SUMOPolygon * > > myTrackingPolygons
Information about tracked objects.
Definition: ShapeContainer.h:213
ShapeContainer::movePOI
virtual void movePOI(const std::string &id, const Position &pos)
Assigns a new position to the named PoI.
Definition: ShapeContainer.cpp:170
ShapeContainer::add
virtual bool add(SUMOPolygon *poly, bool ignorePruning=false)
add polygon
Definition: ShapeContainer.cpp:188
ShapeContainer::removePolygonDynamics
virtual bool removePolygonDynamics(const std::string &polyID)
Remove dynamics (animation / tracking) for the given polygon.
Definition: ShapeContainer.cpp:114
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
ShapeContainer
Storage for geometrical objects.
Definition: ShapeContainer.h:50
ShapeContainer::Polygons
NamedObjectCont< SUMOPolygon * > Polygons
containers
Definition: ShapeContainer.h:54
ShapeContainer::reshapePolygon
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
Definition: ShapeContainer.cpp:179
PositionVector
A list of positions.
Definition: PositionVector.h:46
ShapeContainer::~ShapeContainer
virtual ~ShapeContainer()
Destructor.
Definition: ShapeContainer.cpp:51
RGBColor
Definition: RGBColor.h:40
NamedObjectCont< SUMOPolygon * >
ShapeContainer::clearHighlight
virtual void clearHighlight(const std::string &objectID, const int type, std::string &toRemove)
Definition: ShapeContainer.cpp:246
ShapeContainer::myPolygonUpdateCommands
std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > myPolygonUpdateCommands
Command pointers for scheduled polygon update. Maps PolyID->Command.
Definition: ShapeContainer.h:220
ShapeContainer::addPolygonDynamics
virtual PolygonDynamics * addPolygonDynamics(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.
Definition: ShapeContainer.cpp:74
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
ShapeContainer::myPOIs
POIs myPOIs
stored POIs
Definition: ShapeContainer.h:216
ShapeContainer::myHighlightPolygons
std::map< std::string, std::map< int, std::string > > myHighlightPolygons
maps objects to a map of highlight types to highlighting polygons
Definition: ShapeContainer.h:206
ShapeContainer::POIs
NamedObjectCont< PointOfInterest * > POIs
Definition: ShapeContainer.h:55
ShapeContainer::getPOIs
const POIs & getPOIs() const
Returns all pois.
Definition: ShapeContainer.h:155
NamedObjectCont.h
ShapeContainer::addPolygon
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)
Builds a polygon using the given values and adds it to the container.
Definition: ShapeContainer.cpp:65
ShapeContainer::registerHighlight
virtual void registerHighlight(const std::string &objectID, const int type, const std::string &polygonID)
register highlight of the specified type if the given id
Definition: ShapeContainer.cpp:230
SUMOPolygon
Definition: SUMOPolygon.h:47
PointOfInterest.h
ParametrisedWrappingCommand
A wrapper for a Command function with parameter.
Definition: ParametrisedWrappingCommand.h:33
ShapeContainer::removePolygon
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
Definition: ShapeContainer.cpp:154
ShapeContainer::addPOI
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, double posLat, 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.
Definition: ShapeContainer.cpp:146
PolygonDynamics
Definition: PolygonDynamics.h:30
config.h
PointOfInterest
A point-of-interest.
Definition: PointOfInterest.h:44
ShapeContainer::removePOI
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
Definition: ShapeContainer.cpp:164
ShapeContainer::clearHighlights
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...
Definition: ShapeContainer.cpp:262
ShapeContainer::ShapeContainer
ShapeContainer()
Constructor.
Definition: ShapeContainer.cpp:49
ShapeContainer::getPolygons
const Polygons & getPolygons() const
Returns all polygons.
Definition: ShapeContainer.h:150
SUMOPolygon.h
ShapeContainer::myPolygons
Polygons myPolygons
stored Polygons
Definition: ShapeContainer.h:200
ShapeContainer::myHighlightedObjects
std::map< std::string, std::string > myHighlightedObjects
inverse map to myHighlightPolygons saves the highlighted object for each polygon
Definition: ShapeContainer.h:208
ShapeContainer::addPolygonUpdateCommand
virtual void addPolygonUpdateCommand(std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
Register update command (for descheduling at removal)
Definition: ShapeContainer.cpp:281