Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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
75 virtual bool addPolygon(const std::string& id, const std::string& type,
76 const RGBColor& color, double layer,
77 double angle, const std::string& imgFile,
78 const PositionVector& shape, bool geo,
79 bool fill, double lineWidth, bool ignorePruning = false,
80 const std::string& name = Shape::DEFAULT_NAME);
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
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, bool friendlyPos, double posLat, const std::string& icon, double layer,
123 double angle, const std::string& imgFile, 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
176 void clearState();
177
178protected:
180 virtual bool add(SUMOPolygon* poly, bool ignorePruning = false);
181
183 virtual bool add(PointOfInterest* poi, bool ignorePruning = false);
184
188 virtual void cleanupPolygonDynamics(const std::string& id);
189
195 virtual void clearHighlight(const std::string& objectID, const int type, std::string& toRemove);
198 virtual void clearHighlights(const std::string& objectID, SUMOPolygon* p);
200
201protected:
204
206 std::map<std::string, PolygonDynamics*> myPolygonDynamics;
207
209 std::map<std::string, std::map<int, std::string> > myHighlightPolygons;
211 std::map<std::string, std::string> myHighlightedObjects;
212
216 std::map<const std::string, std::set<const SUMOPolygon*> > myTrackingPolygons;
217
220
221private:
223 std::map<const std::string, ParametrisedWrappingCommand<ShapeContainer, PolygonDynamics*>*> myPolygonUpdateCommands;
224
225};
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
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.
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
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, double width, double height, bool ignorePruning=false)
Builds a POI using the given values and adds it to the container.
void clearState()
Remove all dynamics before quick-loading state.
Polygons myPolygons
stored Polygons
virtual bool addPolygon(const std::string &id, const std::string &type, const RGBColor &color, double layer, double angle, const std::string &imgFile, 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.
static const std::string DEFAULT_NAME
Definition Shape.h:50