AnimationItem.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/st/AnimationItem.h
22 
23  \brief This file defines a class for a Animation Item.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_ANIMATION_ITEM_H
27 #define __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_ANIMATION_ITEM_H
28 
29 // TerraLib
30 #include "../Config.h"
31 #ifndef Q_MOC_RUN
32 #include "../../../geometry.h"
33 #include "../../../datatype.h"
34 #endif
35 
36 // Qt
37 #include <QGraphicsPixmapItem>
38 #include <QAbstractAnimation>
39 
40 namespace te
41 {
42  namespace dt
43  {
44  class DateTimeInstant;
45  class TimePeriod;
46  }
47 
48  namespace qt
49  {
50  namespace widgets
51  {
52  class MapDisplay;
53  class Animation;
54 
55  /*!
56  \class AnimationItem
57 
58  \brief An abstract class for Animation Item.
59 
60  It is the base class that stores data of time and route.
61 
62  \sa ImageItem, TrajectoryItem
63  */
64  class TEQTWIDGETSEXPORT AnimationItem : public QObject, public QGraphicsPixmapItem
65  {
66  Q_OBJECT
67  Q_PROPERTY(QPointF pos READ pos WRITE setPos)
68 
69  public:
70 
71  /*!
72  \brief Constructor
73  It constructs a Animation Item.
74  \param title The Animation Item title.
75  \param display Where the Animation Item is displayed.
76  */
77  AnimationItem(const QString& title, te::qt::widgets::MapDisplay* display);
78 
79  /*!
80  \brief Destructor
81  It destructs a Animation Item.
82  */
83  virtual ~AnimationItem();
84 
85  /*!
86  \brief It returns the Animation Item position in device coordinate.
87  \return Position in device coordinate.
88  */
90 
91  /*!
92  \brief Paint a Animation Item.
93  */
94  virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) = 0;
95 
96  /*!
97  \brief Sets the Animation Item duration.
98  \param duration The Animation Item duration.
99  */
100  void setDuration(const unsigned int& duration);
101 
102  /*!
103  \brief Gets the Animation Item duration.
104  \return The Animation Item duration.
105  */
106  unsigned int getDuration();
107 
108  /*!
109  \brief Sets the Animation Item direction.
110  \param direction The Animation Item direction.
111  */
112  void setDirection(const QAbstractAnimation::Direction& direction);
113 
114  /*!
115  \brief Gets the Animation Item direction.
116  \return The Animation Item direction.
117  */
118  QAbstractAnimation::Direction getDirection();
119 
120  /*!
121  \brief If draw item.
122  */
123  virtual void draw() = 0;
124 
125  /*!
126  \brief Adjust data for a given time animation period.
127  */
129 
130  /*!
131  \brief It draws a piece of tracktrajectory trail or draws the current pixmap item.
132 
133  \paran curTime The Animation Item current time.
134  */
135  virtual void drawForward(const unsigned int& curTime) = 0;
136 
137  /*!
138  \brief It erases a piece of tracktrajectory trail or draws the current pixmap item.
139 
140  \paran curTime The Animation Item current time.
141  */
142  virtual void erase(const unsigned int& curTime) = 0;
143 
144  public:
145  QString m_title; //!< The icon item title.
146  te::qt::widgets::MapDisplay* m_display; //!< Indicates where the icon item is displayed.
147  int m_SRID; //!< The input route srid.
148  QPointF m_pos; //!< The icon position.
149  QVector<te::dt::TimeInstant> m_time; //!< The input time.
150  QVector<te::dt::TimeInstant> m_animationTime; //!< The animation time. It contains only the portions to be animated.
151  te::gm::LineString* m_route; //!< The input path in world coordenates.
152  QVector<QPointF> m_animationRoute; //!< It contains only the portions to be animated.
153  QMatrix m_matrix; //!< The display transformation matrix.
154  bool m_automaticPan; //!< True if automatic pan over this item.
155  double m_panFactor; //!< the range is between 0.002 and 0.5
156  unsigned int m_curTimeDuration; //!< Current time (ms). Its value is between 0 and the total duration.
157  double m_norInitialTime; //!< Normalized initial time (between 0 and 1).
158  double m_norFinalTime; //!< Normalized final time (between 0 and 1).
159  Animation* m_animation; //!< The animation this item.
160  unsigned int m_duration; //!< The duration this item.
161  QAbstractAnimation::Direction m_direction; //!< The direction
162  int m_opacity; //!< Opacity.
163  };
164  } // end namespace widgets
165  } // end namespace qt
166 } // end namespace te
167 
168 #endif // __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_ANIMATION_ITEM_H
te::qt::widgets::AnimationItem::m_display
te::qt::widgets::MapDisplay * m_display
Indicates where the icon item is displayed.
Definition: AnimationItem.h:146
te::qt::widgets::AnimationItem
An abstract class for Animation Item.
Definition: AnimationItem.h:65
te::qt::widgets::AnimationItem::setDuration
void setDuration(const unsigned int &duration)
Sets the Animation Item duration.
te::qt::widgets::AnimationItem::m_SRID
int m_SRID
The input route srid.
Definition: AnimationItem.h:147
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::qt::widgets::AnimationItem::~AnimationItem
virtual ~AnimationItem()
Destructor It destructs a Animation Item.
te::qt::widgets::AnimationItem::AnimationItem
AnimationItem(const QString &title, te::qt::widgets::MapDisplay *display)
Constructor It constructs a Animation Item.
te::qt::widgets::AnimationItem::m_animationTime
QVector< te::dt::TimeInstant > m_animationTime
The animation time. It contains only the portions to be animated.
Definition: AnimationItem.h:150
te::qt::widgets::MapDisplay
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
te::qt::widgets::AnimationItem::m_pos
QPointF m_pos
The icon position.
Definition: AnimationItem.h:148
te::qt::widgets::AnimationItem::getDuration
unsigned int getDuration()
Gets the Animation Item duration.
te::qt::widgets::AnimationItem::m_duration
unsigned int m_duration
The duration this item.
Definition: AnimationItem.h:160
te::qt::widgets::AnimationItem::m_norInitialTime
double m_norInitialTime
Normalized initial time (between 0 and 1).
Definition: AnimationItem.h:157
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::qt::widgets::AnimationItem::setDirection
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the Animation Item direction.
te::qt::widgets::AnimationItem::m_norFinalTime
double m_norFinalTime
Normalized final time (between 0 and 1).
Definition: AnimationItem.h:158
te::qt::widgets::AnimationItem::m_title
QString m_title
The icon item title.
Definition: AnimationItem.h:145
te::qt::widgets::AnimationItem::getPosInDeviceCoordinate
QPoint getPosInDeviceCoordinate()
It returns the Animation Item position in device coordinate.
te::qt::widgets::AnimationItem::paint
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *)=0
Paint a Animation Item.
te::qt::widgets::AnimationItem::adjustDataToAnimationTemporalExtent
virtual void adjustDataToAnimationTemporalExtent()
Adjust data for a given time animation period.
te::qt::widgets::AnimationItem::m_direction
QAbstractAnimation::Direction m_direction
The direction.
Definition: AnimationItem.h:161
te::qt::widgets::AnimationItem::m_automaticPan
bool m_automaticPan
True if automatic pan over this item.
Definition: AnimationItem.h:154
te::qt::widgets::AnimationItem::drawForward
virtual void drawForward(const unsigned int &curTime)=0
It draws a piece of tracktrajectory trail or draws the current pixmap item.
te::gm::LineString
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
te::qt::widgets::AnimationItem::m_animation
Animation * m_animation
The animation this item.
Definition: AnimationItem.h:159
te::qt::widgets::AnimationItem::m_matrix
QMatrix m_matrix
The display transformation matrix.
Definition: AnimationItem.h:153
te::qt::widgets::AnimationItem::m_opacity
int m_opacity
Opacity.
Definition: AnimationItem.h:162
te::qt::widgets::AnimationItem::m_time
QVector< te::dt::TimeInstant > m_time
The input time.
Definition: AnimationItem.h:149
te::qt::widgets::AnimationItem::draw
virtual void draw()=0
If draw item.
te::qt::widgets::AnimationItem::erase
virtual void erase(const unsigned int &curTime)=0
It erases a piece of tracktrajectory trail or draws the current pixmap item.
te::qt::widgets::AnimationItem::m_route
te::gm::LineString * m_route
The input path in world coordenates.
Definition: AnimationItem.h:151
te::qt::widgets::AnimationItem::m_curTimeDuration
unsigned int m_curTimeDuration
Current time (ms). Its value is between 0 and the total duration.
Definition: AnimationItem.h:156
te::qt::widgets::AnimationItem::m_animationRoute
QVector< QPointF > m_animationRoute
It contains only the portions to be animated.
Definition: AnimationItem.h:152
te::qt::widgets::AnimationItem::m_panFactor
double m_panFactor
the range is between 0.002 and 0.5
Definition: AnimationItem.h:155
te::qt::widgets::Animation
Definition: Animation.h:60
te::qt::widgets::AnimationItem::getDirection
QAbstractAnimation::Direction getDirection()
Gets the Animation Item direction.