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-2020 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 // A polygon, which holds a timeSpan for displaying dynamic properties
19 /****************************************************************************/
20 
21 
22 #pragma once
23 
24 #include <memory>
25 #include "SUMOPolygon.h"
26 #include "utils/common/SUMOTime.h"
27 
28 class SUMOTrafficObject;
29 class ShapeContainer;
30 class SUMORTree;
31 
33 public:
48  PolygonDynamics(double creationTime,
49  SUMOPolygon* p,
50  SUMOTrafficObject* trackedObject,
51  const std::vector<double>& timeSpan,
52  const std::vector<double>& alphaSpan,
53  bool looped,
54  bool rotate);
55  virtual ~PolygonDynamics();
56 
57  const std::string& getPolygonID() const {
58  return myPolygon->getID();
59  }
60 
62  return myPolygon;
63  }
64 
65  inline const std::string& getTrackedObjectID() const {
66  return myTrackedObjectID;
67  }
68 
73 
75  void setRTree(SUMORTree* rtree) {
76  myVis = rtree;
77  }
78 
79 private:
80 
82  void setAlpha(double alpha);
83 
85  void initTrackedPosition();
86 
89 
91  double myCurrentTime;
92 
95 
98  bool animated;
99 
101  bool looped;
102 
104  bool tracking;
105 
107  bool rotate;
108 
111  std::string myTrackedObjectID;
112 
114  std::unique_ptr<Position> myTrackedObjectsInitialPositon;
115 
118 
122  std::unique_ptr<PositionVector> myOriginalShape;
123 
126  std::unique_ptr<std::vector<double> > myTimeSpan;
127 
130  std::vector<double>::const_iterator myPrevTime;
131  std::vector<double>::const_iterator myNextTime;
132 
134  std::unique_ptr<std::vector<double> > myAlphaSpan;
137  std::vector<double>::const_iterator myPrevAlpha;
138  std::vector<double>::const_iterator myNextAlpha;
139 
142 
143 };
144 
long long int SUMOTime
Definition: SUMOTime.h:31
const std::string & getID() const
Returns the id.
Definition: Named.h:73
std::vector< double >::const_iterator myNextAlpha
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...
std::unique_ptr< Position > myTrackedObjectsInitialPositon
Initial position of the tracked object.
bool looped
Whether animation should be looped.
virtual ~PolygonDynamics()
void initTrackedPosition()
Initialize the object's position.
void setRTree(SUMORTree *rtree)
Set the RTree.
bool tracking
Whether this polygon tracks an object.
const std::string & getPolygonID() const
std::string myTrackedObjectID
const std::string & getTrackedObjectID() const
double myTrackedObjectsInitialAngle
Initial angle of the tracked object.
std::unique_ptr< std::vector< double > > myTimeSpan
Time points corresponding to the anchor values of the dynamic properties.
std::vector< double >::const_iterator myNextTime
void setAlpha(double alpha)
Sets the alpha value for the shape's color.
bool animated
Whether this polygon is animated, i.e., whether timelines should be used to control properties.
double myCurrentTime
Current time.
SUMOTime update(SUMOTime t)
Updates the polygon according to its timeSpan and follows the tracked object.
SUMOTrafficObject * myTrackedObject
An object tracked by the shape, deletion by caller.
std::vector< double >::const_iterator myPrevTime
Pointer to the next time points in timeSpan.
SUMOPolygon * myPolygon
The polygon this dynamics acts upon.
bool rotate
Whether this polygon should be rotated with the tracked object.
SUMOPolygon * getPolygon() const
std::unique_ptr< PositionVector > myOriginalShape
the original shape of the polygon (in case of tracking another object, this is converted to relative ...
std::unique_ptr< std::vector< double > > myAlphaSpan
Alpha values corresponding to.
SUMORTree * myVis
RTree will be supplied in case of GUI simulation to be updated on move.
double myLastUpdateTime
The last time the animation has been updated.
std::vector< double >::const_iterator myPrevAlpha
Pointer to the next alpha points in alphaSpan.
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:66
Representation of a vehicle, person, or container.
Storage for geometrical objects.