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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // Storage for geometrical objects, sorted by the layers they are in
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <map>
27 #include <memory>
29 #include "PointOfInterest.h"
30 #include "SUMOPolygon.h"
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class PolygonDynamics;
36 class SUMOTrafficObject;
37 template <class T, class S>
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
48 public:
49 
53 
56 
58  virtual ~ShapeContainer();
59 
74  virtual bool addPolygon(const std::string& id, const std::string& type,
75  const RGBColor& color, double layer,
76  double angle, const std::string& imgFile,
77  bool relativePath, const PositionVector& shape, bool geo,
78  bool fill, double lineWidth, bool ignorePruning = false,
79  const std::string& name = Shape::DEFAULT_NAME);
80 
87  virtual PolygonDynamics* addPolygonDynamics(double simtime,
88  std::string polyID,
89  SUMOTrafficObject* trackedObject,
90  const std::vector<double>& timeSpan,
91  const std::vector<double>& alphaSpan,
92  bool looped,
93  bool rotate);
94 
100  virtual bool removePolygonDynamics(const std::string& polyID);
101 
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, bool friendlyPos, 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 
175  void clearState();
176 
177 protected:
179  virtual bool add(SUMOPolygon* poly, bool ignorePruning = false);
180 
182  virtual bool add(PointOfInterest* poi, bool ignorePruning = false);
183 
187  virtual void cleanupPolygonDynamics(const std::string& id);
188 
194  virtual void clearHighlight(const std::string& objectID, const int type, std::string& toRemove);
197  virtual void clearHighlights(const std::string& objectID, SUMOPolygon* p);
199 
200 protected:
203 
205  std::map<std::string, PolygonDynamics*> myPolygonDynamics;
206 
208  std::map<std::string, std::map<int, std::string> > myHighlightPolygons;
210  std::map<std::string, std::string> myHighlightedObjects;
211 
215  std::map<const std::string, std::set<const SUMOPolygon*> > myTrackingPolygons;
216 
219 
220 private:
222  std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> myPolygonUpdateCommands;
223 
224 };
long long int SUMOTime
Definition: SUMOTime.h:32
A wrapper for a Command function with parameter.
A point-of-interest.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Representation of a vehicle, person, or container.
Storage for geometrical objects.
const Polygons & getPolygons() const
Returns all polygons.
virtual bool removePolygonDynamics(const std::string &polyID)
Remove dynamics (animation / tracking) for the given polygon.
virtual void clearHighlight(const std::string &objectID, const int type, std::string &toRemove)
virtual void cleanupPolygonDynamics(const std::string &id)
Unschedules the removal and update commands of the given polygon.
virtual bool removePOI(const std::string &id)
Removes a PoI from the container.
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
std::map< std::string, std::map< int, std::string > > myHighlightPolygons
maps objects to a map of highlight types to highlighting polygons
std::map< std::string, PolygonDynamics * > myPolygonDynamics
stored PolygonDynamics
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
virtual void removeTrackers(std::string objectID)
Remove all tracking polygons for the given object.
virtual void movePOI(const std::string &id, const Position &pos)
Assigns a new position to the named PoI.
std::map< const std::string, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > * > myPolygonUpdateCommands
Command pointers for scheduled polygon update. Maps PolyID->Command.
virtual ~ShapeContainer()
Destructor.
POIs myPOIs
stored POIs
std::map< std::string, std::string > myHighlightedObjects
inverse map to myHighlightPolygons saves the highlighted object for each polygon
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.
NamedObjectCont< SUMOPolygon * > Polygons
containers
std::map< const std::string, std::set< const SUMOPolygon * > > myTrackingPolygons
Information about tracked objects.
NamedObjectCont< PointOfInterest * > POIs
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.
ShapeContainer()
Constructor.
virtual void addPolygonUpdateCommand(std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
Register update command (for descheduling at removal)
virtual bool add(SUMOPolygon *poly, bool ignorePruning=false)
add polygon
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...
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, 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.
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 clearState()
Remove all dynamics before quick-loading state.
Polygons myPolygons
stored Polygons
const POIs & getPOIs() const
Returns all pois.
static const std::string DEFAULT_NAME
Definition: Shape.h:50