Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
Polygon.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2017-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/****************************************************************************/
18// C++ TraCI client API implementation
19/****************************************************************************/
20#pragma once
21#include <string>
22#include <vector>
23#include <libsumo/TraCIDefs.h>
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30#ifndef LIBTRACI
31class NamedRTree;
32class PositionVector;
33class SUMOPolygon;
35#endif
36
37
38// ===========================================================================
39// class definitions
40// ===========================================================================
41namespace LIBSUMO_NAMESPACE {
42class Polygon {
43public:
44 static std::string getType(const std::string& polygonID);
45 static libsumo::TraCIPositionVector getShape(const std::string& polygonID);
46 static libsumo::TraCIColor getColor(const std::string& polygonID);
47 static bool getFilled(const std::string& polygonID);
48 static double getLineWidth(const std::string& polygonID);
49
52
53 static void setType(const std::string& polygonID, const std::string& polygonType);
54 static void setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape);
55 static void setColor(const std::string& polygonID, const libsumo::TraCIColor& color);
56 static void add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& color, bool fill = false, const std::string& polygonType = "", int layer = 0, double lineWidth = 1);
57
58 static void addDynamics(const std::string& polygonID, const std::string& trackedObjectID = "", const std::vector<double>& timeSpan = std::vector<double>(), const std::vector<double>& alphaSpan = std::vector<double>(), bool looped = false, bool rotate = true);
59 static void remove(const std::string& polygonID, int layer = 0);
60
61 static void setFilled(std::string polygonID, bool filled);
62 static void setLineWidth(std::string polygonID, double lineWidth);
63
64#ifndef LIBTRACI
65#ifndef SWIG
66 // currently only used as a Helper function by POI and Vehicle, not part of the public API (and the clients)
67 static void addHighlightPolygon(const std::string& objectID, const int type, const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& color, bool fill, const std::string& polygonType, int layer, double lineWidth);
68
72 static NamedRTree* getTree();
73 static void cleanup();
74
79 static void storeShape(const std::string& id, PositionVector& shape);
80
81 static std::shared_ptr<VariableWrapper> makeWrapper();
82
83 static bool handleVariable(const std::string& objID, const int variable, VariableWrapper* wrapper, tcpip::Storage* paramData);
84
86 static bool exists(std::string polyID);
87
88private:
89 static SUMOPolygon* getPolygon(const std::string& id);
92 static SUMOTrafficObject* getTrafficObject(const std::string& id);
93
94
95private:
96 static SubscriptionResults mySubscriptionResults;
97 static ContextSubscriptionResults myContextSubscriptionResults;
99#endif
100#endif
101
103 Polygon() = delete;
104};
105
106
107}
#define LIBSUMO_ID_PARAMETER_API
Definition TraCIDefs.h:116
#define LIBSUMO_SUBSCRIPTION_API
Definition TraCIDefs.h:62
static bool getFilled(const std::string &polygonID)
static NamedRTree * myTree
Definition Polygon.h:98
static void setLineWidth(std::string polygonID, double lineWidth)
static double getLineWidth(const std::string &polygonID)
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
static std::string getType(const std::string &polygonID)
static libsumo::TraCIPositionVector getShape(const std::string &polygonID)
static void setColor(const std::string &polygonID, const libsumo::TraCIColor &color)
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static SUMOPolygon * getPolygon(const std::string &id)
static void addDynamics(const std::string &polygonID, const std::string &trackedObjectID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
static void add(const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &color, bool fill=false, const std::string &polygonType="", int layer=0, double lineWidth=1)
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
static libsumo::TraCIColor getColor(const std::string &polygonID)
static void addHighlightPolygon(const std::string &objectID, const int type, const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &color, bool fill, const std::string &polygonType, int layer, double lineWidth)
static void remove(const std::string &polygonID, int layer=0)
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
static ContextSubscriptionResults myContextSubscriptionResults
Definition Polygon.h:97
LIBSUMO_ID_PARAMETER_API static LIBSUMO_SUBSCRIPTION_API void setType(const std::string &polygonID, const std::string &polygonType)
static void setFilled(std::string polygonID, bool filled)
static void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape)
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
Polygon()=delete
invalidated standard constructor
static std::shared_ptr< VariableWrapper > makeWrapper()
static SubscriptionResults mySubscriptionResults
Definition Polygon.h:96
A RT-tree for efficient storing of SUMO's Named objects.
Definition NamedRTree.h:61
A list of positions.
Representation of a vehicle, person, or container.
A list of positions.
Definition TraCIDefs.h:234