Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
ShapeContainer.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2005-2024 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// ===========================================================================
34// class declarations
35// ===========================================================================
36class PolygonDynamics;
38template <class T, class S>
40
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
50public:
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 const std::string& name = Shape::DEFAULT_NAME);
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
123 virtual bool addPOI(const std::string& id, const std::string& type, const RGBColor& color, const Position& pos, bool geo,
124 const std::string& lane, double posOverLane, bool friendlyPos, double posLat, const std::string& icon, double layer,
125 double angle, const std::string& imgFile, bool relativePath, double width, double height, bool ignorePruning = false);
126
131 virtual bool removePolygon(const std::string& id, bool useLock = true);
132
137 virtual bool removePOI(const std::string& id);
138
143 virtual void movePOI(const std::string& id, const Position& pos);
144
149 virtual void reshapePolygon(const std::string& id, const PositionVector& shape);
150
152 inline const Polygons& getPolygons() const {
153 return myPolygons;
154 }
155
157 inline const POIs& getPOIs() const {
158 return myPOIs;
159 }
160
167
170
172 virtual void removeTrackers(std::string objectID);
173
175 virtual void registerHighlight(const std::string& objectID, const int type, const std::string& polygonID);
176
178 void clearState();
179
180protected:
182 virtual bool add(SUMOPolygon* poly, bool ignorePruning = false);
183
185 virtual bool add(PointOfInterest* poi, bool ignorePruning = false);
186
190 virtual void cleanupPolygonDynamics(const std::string& id);
191
197 virtual void clearHighlight(const std::string& objectID, const int type, std::string& toRemove);
200 virtual void clearHighlights(const std::string& objectID, SUMOPolygon* p);
202
203protected:
206
208 std::map<std::string, PolygonDynamics*> myPolygonDynamics;
209
211 std::map<std::string, std::map<int, std::string> > myHighlightPolygons;
213 std::map<std::string, std::string> myHighlightedObjects;
214
218 std::map<const std::string, std::set<const SUMOPolygon*> > myTrackingPolygons;
219
222
223private:
225 std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> myPolygonUpdateCommands;
226
227};
long long int SUMOTime
Definition GUI.h:36
A map of named object pointers.
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.
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.
const Polygons & getPolygons() const
Returns all polygons.
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 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.
const POIs & getPOIs() const
Returns all pois.
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 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
static const std::string DEFAULT_NAME
Definition Shape.h:51