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 #include "../../../geometry.h"
32 #include "../../../datatype.h"
33 
34 // Qt
35 #include <QGraphicsPixmapItem>
36 #include <QAbstractAnimation>
37 
38 namespace te
39 {
40  namespace dt
41  {
42  class DateTimeInstant;
43  class TimePeriod;
44  }
45 
46  namespace qt
47  {
48  namespace widgets
49  {
50  class MapDisplay;
51  class Animation;
52 
53  /*!
54  \class AnimationItem
55 
56  \brief An abstract class for Animation Item.
57 
58  It is the base class that stores data of time and route.
59 
60  \sa ImageItem, TrajectoryItem
61  */
62  class TEQTWIDGETSEXPORT AnimationItem : public QObject, public QGraphicsPixmapItem
63  {
64  Q_OBJECT
65  Q_PROPERTY(QPointF pos READ pos WRITE setPos)
66 
67  public:
68 
69  /*!
70  \brief Constructor
71  It constructs a Animation Item.
72  \param title The Animation Item title.
73  \param display Where the Animation Item is displayed.
74  */
75  AnimationItem(const QString& title, te::qt::widgets::MapDisplay* display);
76 
77  /*!
78  \brief Destructor
79  It destructs a Animation Item.
80  */
81  virtual ~AnimationItem();
82 
83  /*!
84  \brief It returns the Animation Item position in device coordinate.
85  \return Position in device coordinate.
86  */
87  QPoint getPosInDeviceCoordinate();
88 
89  /*!
90  \brief Paint a Animation Item.
91  */
92  virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*) = 0;
93 
94  /*!
95  \brief Sets the Animation Item duration.
96  \param duration The Animation Item duration.
97  */
98  void setDuration(const unsigned int& duration);
99 
100  /*!
101  \brief Gets the Animation Item duration.
102  \return The Animation Item duration.
103  */
104  unsigned int getDuration();
105 
106  /*!
107  \brief Sets the Animation Item direction.
108  \param direction The Animation Item direction.
109  */
110  void setDirection(const QAbstractAnimation::Direction& direction);
111 
112  /*!
113  \brief Gets the Animation Item direction.
114  \return The Animation Item direction.
115  */
116  QAbstractAnimation::Direction getDirection();
117 
118  /*!
119  \brief If draw item.
120  */
121  virtual void draw() = 0;
122 
123  /*!
124  \brief Adjust data for a given time animation period.
125  */
126  virtual void adjustDataToAnimationTemporalExtent();
127 
128  /*!
129  \brief It draws a piece of tracktrajectory trail or draws the current pixmap item.
130 
131  \paran curTime The Animation Item current time.
132  */
133  virtual void drawForward(const unsigned int& curTime) = 0;
134 
135  /*!
136  \brief It erases a piece of tracktrajectory trail or draws the current pixmap item.
137 
138  \paran curTime The Animation Item current time.
139  */
140  virtual void erase(const unsigned int& curTime) = 0;
141 
142  public:
143  QString m_title; //!< The icon item title.
144  te::qt::widgets::MapDisplay* m_display; //!< Indicates where the icon item is displayed.
145  int m_SRID; //!< The input route srid.
146  QPointF m_pos; //!< The icon position.
147  QVector<te::dt::TimeInstant> m_time; //!< The input time.
148  QVector<te::dt::TimeInstant> m_animationTime; //!< The animation time. It contains only the portions to be animated.
149  te::gm::LineString* m_route; //!< The input path in world coordenates.
150  QVector<QPointF> m_animationRoute; //!< It contains only the portions to be animated.
151  QMatrix m_matrix; //!< The display transformation matrix.
152  bool m_automaticPan; //!< True if automatic pan over this item.
153  double m_panFactor; //!< the range is between 0.002 and 0.5
154  unsigned int m_curTimeDuration; //!< Current time (ms). Its value is between 0 and the total duration.
155  double m_norInitialTime; //!< Normalized initial time (between 0 and 1).
156  double m_norFinalTime; //!< Normalized final time (between 0 and 1).
157  Animation* m_animation; //!< The animation this item.
158  unsigned int m_duration; //!< The duration this item.
159  QAbstractAnimation::Direction m_direction; //!< The direction
160  int m_opacity; //!< Opacity.
161  };
162  } // end namespace widgets
163  } // end namespace qt
164 } // end namespace te
165 
166 #endif // __TERRALIB_QT_WIDGETS_SLIDER_INTERNAL_ANIMATION_ITEM_H
QPointF m_pos
The icon position.
double m_norInitialTime
Normalized initial time (between 0 and 1).
bool m_automaticPan
True if automatic pan over this item.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:66
te::qt::widgets::MapDisplay * m_display
Indicates where the icon item is displayed.
Animation * m_animation
The animation this item.
double m_norFinalTime
Normalized final time (between 0 and 1).
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
URI C++ Library.
QAbstractAnimation::Direction m_direction
The direction.
unsigned int m_curTimeDuration
Current time (ms). Its value is between 0 and the total duration.
QString m_title
The icon item title.
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
An abstract class for Animation Item.
Definition: AnimationItem.h:62
QVector< te::dt::TimeInstant > m_animationTime
The animation time. It contains only the portions to be animated.
double m_panFactor
the range is between 0.002 and 0.5
te::gm::LineString * m_route
The input path in world coordenates.
QMatrix m_matrix
The display transformation matrix.
QVector< QPointF > m_animationRoute
It contains only the portions to be animated.
int m_SRID
The input route srid.
unsigned int m_duration
The duration this item.
QVector< te::dt::TimeInstant > m_time
The input time.