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 /****************************************************************************/
16 // Storage for geometrical objects, sorted by the layers they are in
17 /****************************************************************************/
18 #ifndef ShapeContainer_h
19 #define ShapeContainer_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <map>
29 #include <memory>
31 #include "PointOfInterest.h"
32 #include "SUMOPolygon.h"
33 
34 // ===========================================================================
35 // class declarations
36 // ===========================================================================
37 class PolygonDynamics;
38 class SUMOTrafficObject;
39 template <class T, class S>
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
50 public:
51 
55 
58 
60  virtual ~ShapeContainer();
61 
76  virtual bool addPolygon(const std::string& id, const std::string& type,
77  const RGBColor& color, double layer,
78  double angle, const std::string& imgFile,
79  bool relativePath, const PositionVector& shape, bool geo,
80  bool fill, double lineWidth, bool ignorePruning = false);
81 
88  virtual PolygonDynamics* addPolygonDynamics(double simtime,
89  std::string polyID,
90  SUMOTrafficObject* trackedObject,
91  const std::vector<double>& timeSpan,
92  const std::vector<double>& alphaSpan,
93  bool looped,
94  bool rotate);
95 
101  virtual bool removePolygonDynamics(const std::string& polyID);
102 
120  virtual bool addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
121  const std::string& lane, double posOverLane, double posLat, double layer, double angle,
122  const std::string& imgFile, bool relativePath, double width, double height, bool ignorePruning = false);
123 
128  virtual bool removePolygon(const std::string& id, bool useLock = true);
129 
134  virtual bool removePOI(const std::string& id);
135 
140  virtual void movePOI(const std::string& id, const Position& pos);
141 
146  virtual void reshapePolygon(const std::string& id, const PositionVector& shape);
147 
149  inline const Polygons& getPolygons() const {
150  return myPolygons;
151  }
152 
154  inline const POIs& getPOIs() const {
155  return myPOIs;
156  }
157 
164 
167 
169  virtual void removeTrackers(std::string objectID);
170 
172  virtual void registerHighlight(const std::string& objectID, const int type, const std::string& polygonID);
173 
174 protected:
176  virtual bool add(SUMOPolygon* poly, bool ignorePruning = false);
177 
179  virtual bool add(PointOfInterest* poi, bool ignorePruning = false);
180 
184  virtual void cleanupPolygonDynamics(const std::string& id);
185 
191  virtual void clearHighlight(const std::string& objectID, const int type, std::string& toRemove);
194  virtual void clearHighlights(const std::string& objectID, SUMOPolygon* p);
196 
197 protected:
200 
202  std::map<std::string, PolygonDynamics*> myPolygonDynamics;
203 
205  std::map<std::string, std::map<int, std::string> > myHighlightPolygons;
207  std::map<std::string, std::string> myHighlightedObjects;
208 
212  std::map<const std::string, std::set<const SUMOPolygon*> > myTrackingPolygons;
213 
216 
217 private:
219  std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> myPolygonUpdateCommands;
220 
221 };
222 
223 
224 #endif
225 
226 /****************************************************************************/
227 
ShapeContainer::cleanupPolygonDynamics
virtual void cleanupPolygonDynamics(const std::string &id)
Unschedules the removal and update commands of the given polygon.
Definition: ShapeContainer.cpp:207
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
ShapeContainer::removeTrackers
virtual void removeTrackers(std::string objectID)
Remove all tracking polygons for the given object.
Definition: ShapeContainer.cpp:286
ShapeContainer::polygonDynamicsUpdate
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
Definition: ShapeContainer.cpp:217
ShapeContainer::myPolygonDynamics
std::map< std::string, PolygonDynamics * > myPolygonDynamics
stored PolygonDynamics
Definition: ShapeContainer.h:202
ShapeContainer::myTrackingPolygons
std::map< const std::string, std::set< const SUMOPolygon * > > myTrackingPolygons
Information about tracked objects.
Definition: ShapeContainer.h:212
ShapeContainer::movePOI
virtual void movePOI(const std::string &id, const Position &pos)
Assigns a new position to the named PoI.
Definition: ShapeContainer.cpp:169
ShapeContainer::add
virtual bool add(SUMOPolygon *poly, bool ignorePruning=false)
add polygon
Definition: ShapeContainer.cpp:187
ShapeContainer::removePolygonDynamics
virtual bool removePolygonDynamics(const std::string &polyID)
Remove dynamics (animation / tracking) for the given polygon.
Definition: ShapeContainer.cpp:113
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
ShapeContainer
Storage for geometrical objects.
Definition: ShapeContainer.h:49
ShapeContainer::Polygons
NamedObjectCont< SUMOPolygon * > Polygons
containers
Definition: ShapeContainer.h:53
ShapeContainer::reshapePolygon
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
Definition: ShapeContainer.cpp:178
PositionVector
A list of positions.
Definition: PositionVector.h:45
ShapeContainer::~ShapeContainer
virtual ~ShapeContainer()
Destructor.
Definition: ShapeContainer.cpp:50
RGBColor
Definition: RGBColor.h:39
NamedObjectCont< SUMOPolygon * >
ShapeContainer::clearHighlight
virtual void clearHighlight(const std::string &objectID, const int type, std::string &toRemove)
Definition: ShapeContainer.cpp:245
ShapeContainer::myPolygonUpdateCommands
std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > myPolygonUpdateCommands
Command pointers for scheduled polygon update. Maps PolyID->Command.
Definition: ShapeContainer.h:219
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:73
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
ShapeContainer::myPOIs
POIs myPOIs
stored POIs
Definition: ShapeContainer.h:215
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:205
ShapeContainer::POIs
NamedObjectCont< PointOfInterest * > POIs
Definition: ShapeContainer.h:54
ShapeContainer::getPOIs
const POIs & getPOIs() const
Returns all pois.
Definition: ShapeContainer.h:154
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:64
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:229
SUMOPolygon
Definition: SUMOPolygon.h:46
PointOfInterest.h
ParametrisedWrappingCommand
A wrapper for a Command function with parameter.
Definition: ParametrisedWrappingCommand.h:32
ShapeContainer::removePolygon
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
Definition: ShapeContainer.cpp:153
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:145
PolygonDynamics
Definition: PolygonDynamics.h:29
config.h
PointOfInterest
A point-of-interest.
Definition: PointOfInterest.h:43
ShapeContainer::removePOI
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
Definition: ShapeContainer.cpp:163
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:261
ShapeContainer::ShapeContainer
ShapeContainer()
Constructor.
Definition: ShapeContainer.cpp:48
ShapeContainer::getPolygons
const Polygons & getPolygons() const
Returns all polygons.
Definition: ShapeContainer.h:149
SUMOPolygon.h
ShapeContainer::myPolygons
Polygons myPolygons
stored Polygons
Definition: ShapeContainer.h:199
ShapeContainer::myHighlightedObjects
std::map< std::string, std::string > myHighlightedObjects
inverse map to myHighlightPolygons saves the highlighted object for each polygon
Definition: ShapeContainer.h:207
ShapeContainer::addPolygonUpdateCommand
virtual void addPolygonUpdateCommand(std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
Register update command (for descheduling at removal)
Definition: ShapeContainer.cpp:280