 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
47 std::vector<std::string>
49 std::vector<std::string> ids;
125 if (!shapeCont.
addPolygon(polygonID, polygonType, col, (
double)layer,
Shape::DEFAULT_ANGLE,
Shape::DEFAULT_IMG_FILE,
Shape::DEFAULT_RELATIVEPATH, pShape,
false, fill, lineWidth)) {
126 throw TraCIException(
"Could not add polygon '" + polygonID +
"'");
133 add(polygonID, shape, color, fill, polygonType, layer, lineWidth);
139 Polygon::addDynamics(
const std::string& polygonID,
const std::string& trackedID,
const std::vector<double>& timeSpan,
const std::vector<double>& alphaSpan,
bool looped,
bool rotate) {
140 if (timeSpan.empty()) {
141 if (trackedID ==
"") {
142 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': dynamics underspecified (either a tracked object ID or a time span have to be provided).");
145 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': looped==true requires time line of positive length.");
148 if (timeSpan.size() == 1) {
149 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': time span cannot have length one.");
150 }
else if (timeSpan.size() > 0 && timeSpan[0] != 0.0) {
151 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': first element of time span must be zero.");
153 if (timeSpan.size() != alphaSpan.size() && alphaSpan.size() != 0) {
154 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': alpha span must have length zero or equal to time span length.");
156 if (timeSpan.size() >= 2) {
157 for (
unsigned int i = 1; i < timeSpan.size(); ++i) {
158 if (timeSpan[i - 1] > timeSpan[i]) {
159 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': entries of time span must be ordered ascendingly.");
168 throw TraCIException(
"Could not add polygon dynamics for polygon '" + polygonID +
"': polygon doesn't exist.");
188 throw TraCIException(
"Could not remove polygon '" + polygonID +
"'");
224 if (sumoVehicle !=
nullptr) {
228 if (transportable !=
nullptr) {
251 Boundary b = i.second->getShape().getBoxBoundary();
252 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
253 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
254 t->
Insert(cmin, cmax, i.second);
266 std::shared_ptr<VariableWrapper>
void setShapeType(const std::string &type)
Sets a new type.
Representation of a vehicle or person.
static void setColor(const std::string &polygonID, const TraCIColor &c)
static void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill=false, const std::string &polygonType="", int layer=0, double lineWidth=1)
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static void addDynamics(const std::string &polygonID, const std::string &trackedID="", const std::vector< double > &timeSpan=std::vector< double >(), const std::vector< double > &alphaSpan=std::vector< double >(), bool looped=false, bool rotate=true)
virtual bool wrapString(const std::string &objID, const int variable, const std::string &value)=0
static std::vector< std::string > getIDList()
static TraCIColor makeTraCIColor(const RGBColor &color)
double ymin() const
Returns minimum y-coordinate.
void insertIDs(std::vector< std::string > &into) const
ShapeContainer & getShapeContainer()
Returns the shapes container.
virtual SUMOTime polygonDynamicsUpdate(SUMOTime t, PolygonDynamics *pd)
Regular update event for updating polygon dynamics.
TRACI_CONST int VAR_COLOR
Interface for objects listening to vehicle state changes.
The simulated network and simulation perfomer.
static PositionVector makePositionVector(const TraCIPositionVector &vector)
static RGBColor makeRGBColor(const TraCIColor &color)
static SUMOPolygon * getPolygon(const std::string &id)
TRACI_CONST int VAR_WIDTH
Representation of a vehicle.
static std::string getParameter(const std::string &polygonID, const std::string &key)
static void remove(const std::string &polygonID, int layer=0)
double xmax() const
Returns maximum x-coordinate.
Storage for geometrical objects.
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
virtual void reshapePolygon(const std::string &id, const PositionVector &shape)
Assigns a shape to the named polygon.
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
const std::string & getPolygonID() const
static ContextSubscriptionResults myContextSubscriptionResults
const RGBColor & getShapeColor() const
Returns the color of the Shape.
static void setShape(const std::string &polygonID, const TraCIPositionVector &shape)
virtual bool wrapColor(const std::string &objID, const int variable, const TraCIColor &value)=0
const std::string getParameter(const std::string &key, const std::string &defaultValue="") const
Returns the value for a given key.
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
static const bool DEFAULT_RELATIVEPATH
virtual bool wrapDouble(const std::string &objID, const int variable, const double value)=0
static SUMOTrafficObject * getTrafficObject(const std::string &id)
Obtain a traffic object with the given id if one exists.
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
double xmin() const
Returns minimum x-coordinate.
void Insert(const float a_min[2], const float a_max[2], Named *const &a_data)
Insert entry.
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
static TraCIColor getColor(const std::string &polygonID)
virtual bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)=0
static LIBSUMO_SUBSCRIPTION_API void addHighlightPolygon(const std::string &objectID, const int type, const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &color, bool fill, const std::string &polygonType, int layer, double lineWidth)
static double getLineWidth(const std::string &polygonID)
A class that stores a 2D geometrical boundary.
static void storeShape(const std::string &id, PositionVector &shape)
Saves the shape of the requested object in the given container.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
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.
static void setFilled(std::string polygonID, bool filled)
static TraCIPositionVector makeTraCIPositionVector(const PositionVector &positionVector)
helper functions
TRACI_CONST int TRACI_ID_LIST
const std::string & getShapeType() const
Returns the (abstract) type of the Shape.
#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
const PositionVector & getShape() const
Returns whether the shape of the polygon.
void setFill(bool fill)
Sets whether the polygon shall be filled.
static std::string getType(const std::string &polygonID)
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.
virtual void registerHighlight(const std::string &objectID, const int type, const std::string &polygonID)
register highlight of the specified type if the given id
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool exists(std::string polyID)
Checks if a polygon of the given name exists already in the simulation.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
static void setParameter(const std::string &polygonID, const std::string &key, const std::string &value)
static void setType(const std::string &polygonID, const std::string &setType)
void setLineWidth(double lineWidth)
virtual bool wrapInt(const std::string &objID, const int variable, const int value)=0
A wrapper for a Command function with parameter.
T get(const std::string &id) const
Retrieves an item.
static TraCIPositionVector getShape(const std::string &polygonID)
void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A RT-tree for efficient storing of SUMO's Named objects.
static bool getFilled(const std::string &polygonID)
virtual bool removePolygon(const std::string &id, bool useLock=true)
Removes a polygon from the container.
static const double DEFAULT_ANGLE
static std::shared_ptr< VariableWrapper > makeWrapper()
bool getFill() const
Returns whether the polygon is filled.
const Polygons & getPolygons() const
Returns all polygons.
static const std::string DEFAULT_IMG_FILE
static SubscriptionResults mySubscriptionResults
static void setLineWidth(std::string polygonID, double lineWidth)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
void setShapeColor(const RGBColor &col)
Sets a new color.
double getLineWidth() const
Returns whether the polygon is filled.
double ymax() const
Returns maximum y-coordinate.
virtual void addPolygonUpdateCommand(std::string polyID, ParametrisedWrappingCommand< ShapeContainer, PolygonDynamics * > *cmd)
Register update command (for descheduling at removal)