AnimationItem.cpp
Go to the documentation of this file.
1 // TerraLib
2 #include "AnimationItem.h"
3 #include "AnimationScene.h"
4 #include "Animation.h"
5 #include "../canvas/MapDisplay.h"
6 #include "../canvas/Canvas.h"
7 
8 // Qt
9 #include <QtCore/QPropertyAnimation>
10 #include <QtGui/QPainter>
11 #include <QtCore/QVector>
12 
14  const QString& title, te::qt::widgets::MapDisplay* display)
15  : m_title(title),
16  m_display(display),
17  m_SRID(-1),
18  m_pos(QPoint(0, 0)),
19  m_automaticPan(false),
20  m_panFactor(.01),
21  m_curTimeDuration(0),
22  m_animation(nullptr),
23  m_opacity(255)
24 {
25 }
26 
28 {
29  delete m_route;
30 }
31 
33 {
34  QPointF p = m_pos;
36  {
37  te::gm::Point point(p.x(), p.y(), m_SRID);
38  point.transform(m_display->getSRID());
39  p.setX(point.getX());
40  p.setY(point.getY());
41  }
42  return m_matrix.map(p).toPoint();
43 }
44 
45 void te::qt::widgets::AnimationItem::setDuration(const unsigned int& duration)
46 {
47  m_duration = duration;
48  m_animation->setDuration(m_duration);
49  if(m_direction == QAbstractAnimation::Forward)
51  else
53 }
54 
55 void te::qt::widgets::AnimationItem::setDirection(const QAbstractAnimation::Direction& direction)
56 {
57  m_direction = direction;
59 }
60 
62 {
63  return m_duration;
64 }
65 
66 QAbstractAnimation::Direction te::qt::widgets::AnimationItem::getDirection()
67 {
68  return m_direction;
69 }
70 
72 {
75 
76  size_t ini = 0;
77  size_t size = m_time.count();
78  size_t fim = size;
79  for(int i = 0; i < (int)size; ++i)
80  {
81  if(m_time[i] == iTime || m_time[i] > iTime)
82  {
83  ini = (size_t)i;
84  break;
85  }
86  }
87  for(int i = (int)size-1; i >= 0; --i)
88  {
89  if (m_time[i] == fTime || m_time[i] < fTime)
90  {
91  fim = (size_t)i;
92  break;
93  }
94  }
95  size = 1 + fim - ini;
96  size_t tfim = ini + size;
97 
98  m_animationRoute.clear();
99  m_animationTime.clear();
100 
102  {
103  for(size_t i = ini; i < tfim; ++i)
104  {
105  std::unique_ptr<te::gm::Point> p(m_route->getPointN(i));
106  m_animationRoute.push_back(QPointF(p->getX(), p->getY()));
107  m_animationTime.push_back(m_time[(int)i]);
108  }
109  }
110  else
111  {
112  for(size_t i = ini; i < tfim; ++i)
113  {
114  std::unique_ptr<te::gm::Point> p(m_route->getPointN(i));
115  m_animationRoute.push_back(QPointF(p->getX(), p->getY()));
116  m_animationTime.push_back(m_time[(int)i]);
117  }
118  }
119 }
120 
QPointF m_pos
The icon position.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
AnimationItem(const QString &title, te::qt::widgets::MapDisplay *display)
Constructor It constructs a Animation Item.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
A widget to control the display of a set of layers.
te::qt::widgets::MapDisplay * m_display
Indicates where the icon item is displayed.
A class to represent time instant.
Definition: TimeInstant.h:55
Animation * m_animation
The animation this item.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
This file defines a class for a Animation Scene.
A point with x and y coordinate values.
Definition: Point.h:50
This file defines a class for a Animation Item.
virtual void adjustDataToAnimationTemporalExtent()
Adjust data for a given time animation period.
TimeInstant getFinalTimeInstant() const
It gets the final time instant.
Definition: TimePeriod.cpp:50
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
TimeInstant getInitialTimeInstant() const
It gets the initial time instant.
Definition: TimePeriod.cpp:45
void transform(int srid) _NOEXCEPT_OP(false)
It converts the coordinate values of the point to the new spatial reference system.
QAbstractAnimation::Direction m_direction
The direction.
te::gm::Polygon * p
unsigned int m_curTimeDuration
Current time (ms). Its value is between 0 and the total duration.
virtual ~AnimationItem()
Destructor It destructs a Animation Item.
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the Animation Item direction.
QPoint getPosInDeviceCoordinate()
It returns the Animation Item position in device coordinate.
This file defines a class for a Trajectory Animation.
QVector< te::dt::TimeInstant > m_animationTime
The animation time. It contains only the portions to be animated.
QAbstractAnimation::Direction getDirection()
Gets the Animation Item direction.
te::gm::LineString * m_route
The input path in world coordenates.
QMatrix m_matrix
The display transformation matrix.
void setDuration(const unsigned int &duration)
Sets the Animation Item duration.
QVector< QPointF > m_animationRoute
It contains only the portions to be animated.
int m_SRID
The input route srid.
te::dt::TimePeriod m_temporalAnimationExtent
Temporal animation extent. It can be a portion of the total or greater than the total.
Definition: Animation.h:111
unsigned int getDuration()
Gets the Animation Item duration.
unsigned int m_duration
The duration this item.
QVector< te::dt::TimeInstant > m_time
The input time.