35 const std::vector<double>& timeSpan,
36 const std::vector<double>& alphaSpan,
41 myLastUpdateTime(creationTime),
42 animated(!timeSpan.empty()),
44 tracking(trackedObject != nullptr),
46 myTrackedObject(trackedObject),
47 myTrackedObjectID(
""),
48 myTrackedObjectsInitialPositon(nullptr),
49 myTrackedObjectsInitialAngle(-1),
50 myOriginalShape(nullptr),
56 myTimeSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(timeSpan));
60#ifdef DEBUG_DYNAMIC_SHAPES
62 for (
unsigned int i = 1; i <
myTimeSpan->size(); ++i) {
70#ifdef DEBUG_DYNAMIC_SHAPES
84 if (!alphaSpan.empty()) {
85 myAlphaSpan = std::unique_ptr<std::vector<double> >(
new std::vector<double>(alphaSpan));
99#ifdef DEBUG_DYNAMIC_SHAPES
100 std::cout << t <<
" PolygonDynamics::update() for polygon '" <<
myPolygon->
getID() <<
"'" << std::endl;
119#ifdef DEBUG_DYNAMIC_SHAPES
120 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' is on the road. Tracked position=" << objPos << std::endl;
127#ifdef DEBUG_DYNAMIC_SHAPES
128 std::cout <<
" Relative rotation wrt original rotation: " << relRotation << std::endl;
131 newShape.
add(objPos);
134#ifdef DEBUG_DYNAMIC_SHAPES
141#ifdef DEBUG_DYNAMIC_SHAPES
144 std::cout <<
" Tracked object '" <<
myTrackedObject->
getID() <<
"' hasn't entered the network since tracking was started." << std::endl;
172#ifdef DEBUG_DYNAMIC_SHAPES
173 std::cout <<
" animation: dt=" << dt
180#ifdef DEBUG_DYNAMIC_SHAPES
181 if (resetAnimation) {
182 std::cout <<
" (resetting animation!)";
185 if (resetAnimation) {
204#ifdef DEBUG_DYNAMIC_SHAPES
205 std::cout <<
" (animation elapsed!)";
216#ifdef DEBUG_DYNAMIC_SHAPES
217 std::cout <<
", previous anchor alpha: " << *
myPrevAlpha
221#ifdef DEBUG_DYNAMIC_SHAPES
222 std::cout <<
", theta=" << theta << std::endl;
237#ifdef DEBUG_DYNAMIC_SHAPES
247#ifdef DEBUG_DYNAMIC_SHAPES
248 std::cout <<
"\n DynamicPolygon::setAlpha() Converted alpha=" << alpha <<
" into myAlpha=" << a << std::endl;
const std::string & getID() const
Returns the id.
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.
bool tracking
Whether this polygon tracks an object.
std::string myTrackedObjectID
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.
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.
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 point in 2D or 3D with translation and scaling methods.
static const Position INVALID
used to indicate that a position is valid
void rotate2D(double angle)
void add(double xoff, double yoff, double zoff)
const PositionVector & getShape() const
Returns the shape of the polygon.
virtual void setShape(const PositionVector &shape)
Sets the shape of the polygon.
Representation of a vehicle, person, or container.
virtual double getAngle() const =0
Returns the object's angle in degrees.
virtual Position getPosition(const double offset=0) const =0
Return current position (x/y, cartesian)
void setShapeAlpha(unsigned char alpha)
Sets a new alpha value.