Eclipse SUMO - Simulation of Urban MObility
PolygonDynamics.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // A polygon, which holds a timeSpan for displaying dynamic properties
16 /****************************************************************************/
17 
18 
19 #ifndef UTILS_SHAPES_POLYGONDYNAMICS_H_
20 #define UTILS_SHAPES_POLYGONDYNAMICS_H_
21 
22 #include <memory>
23 #include "SUMOPolygon.h"
24 #include "utils/common/SUMOTime.h"
25 
26 class SUMOTrafficObject;
27 class ShapeContainer;
28 class SUMORTree;
29 
31 public:
46  PolygonDynamics(double creationTime,
47  SUMOPolygon* p,
48  SUMOTrafficObject* trackedObject,
49  const std::vector<double>& timeSpan,
50  const std::vector<double>& alphaSpan,
51  bool looped,
52  bool rotate);
53  virtual ~PolygonDynamics();
54 
55  const std::string& getPolygonID() const {
56  return myPolygon->getID();
57  }
58 
60  return myPolygon;
61  }
62 
63  inline const std::string& getTrackedObjectID() const {
64  return myTrackedObjectID;
65  }
66 
71 
73  void setRTree(SUMORTree* rtree) {
74  myVis = rtree;
75  }
76 
77 private:
78 
80  void setAlpha(double alpha);
81 
83  void initTrackedPosition();
84 
87 
89  double myCurrentTime;
90 
93 
96  bool animated;
97 
99  bool looped;
100 
102  bool tracking;
103 
105  bool rotate;
106 
109  std::string myTrackedObjectID;
110 
112  std::unique_ptr<Position> myTrackedObjectsInitialPositon;
113 
116 
120  std::unique_ptr<PositionVector> myOriginalShape;
121 
124  std::unique_ptr<std::vector<double> > myTimeSpan;
125 
128  std::vector<double>::const_iterator myPrevTime;
129  std::vector<double>::const_iterator myNextTime;
130 
132  std::unique_ptr<std::vector<double> > myAlphaSpan;
135  std::vector<double>::const_iterator myPrevAlpha;
136  std::vector<double>::const_iterator myNextAlpha;
137 
140 
141 };
142 
143 #endif /* UTILS_SHAPES_POLYGONDYNAMICS_H_ */
long long int SUMOTime
Definition: SUMOTime.h:35
const std::string & getTrackedObjectID() const
std::unique_ptr< Position > myTrackedObjectsInitialPositon
Initial position of the tracked object.
virtual ~PolygonDynamics()
std::vector< double >::const_iterator myPrevTime
Pointer to the next time points in timeSpan.
bool rotate
Whether this polygon should be rotated with the tracked object.
const std::string & getPolygonID() const
Storage for geometrical objects.
void initTrackedPosition()
Initialize the object&#39;s position.
const std::string & getID() const
Returns the id.
Definition: Named.h:77
double myCurrentTime
Current time.
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:69
void setRTree(SUMORTree *rtree)
Set the RTree.
bool tracking
Whether this polygon tracks an object.
bool looped
Whether animation should be looped.
std::unique_ptr< std::vector< double > > myTimeSpan
Time points corresponding to the anchor values of the dynamic properties.
SUMORTree * myVis
RTree will be supplied in case of GUI simulation to be updated on move.
std::vector< double >::const_iterator myNextTime
bool animated
Whether this polygon is animated, i.e., whether timelines should be used to control properties...
std::vector< double >::const_iterator myNextAlpha
double myLastUpdateTime
The last time the animation has been updated.
SUMOTime update(SUMOTime t)
Updates the polygon according to its timeSpan and follows the tracked object.
SUMOPolygon * getPolygon() const
double myTrackedObjectsInitialAngle
Initial angle of the tracked object.
Representation of a vehicle or person.
SUMOTrafficObject * myTrackedObject
An object tracked by the shape, deletion by caller.
std::string myTrackedObjectID
void setAlpha(double alpha)
Sets the alpha value for the shape&#39;s color.
std::unique_ptr< PositionVector > myOriginalShape
the original shape of the polygon (in case of tracking another object, this is converted to relative ...
std::vector< double >::const_iterator myPrevAlpha
Pointer to the next alpha points in alphaSpan.
SUMOPolygon * myPolygon
The polygon this dynamics acts upon.
std::unique_ptr< std::vector< double > > myAlphaSpan
Alpha values corresponding to.
PolygonDynamics(double creationTime, SUMOPolygon *p, SUMOTrafficObject *trackedObject, const std::vector< double > &timeSpan, const std::vector< double > &alphaSpan, bool looped, bool rotate)
Constructor that takes a SUMOPolygon and adds timelines for the properties to be modified dynamically...