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  */
89  QPoint getPosInDeviceCoordinate();
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  */
128  virtual void adjustDataToAnimationTemporalExtent();
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
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:69
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:64
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.