All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TimeSliderWidget.h
Go to the documentation of this file.
1 /* Copyright (C) 2010-2013 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/slider/TimeSliderWidget.h
22 
23  \brief A widget used to alow the user to control the visualization of temporal data
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_INTERNAL_TIMESLIDERWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_INTERNAL_TIMESLIDERWIDGET_H
28 
29 //TerraLib
30 #include "../Config.h"
31 #include "../../../geometry.h"
32 #include "../../../datatype.h"
33 
34 // Qt
35 #include <QWidget>
36 #include <QAbstractAnimation>
37 #include <QDateTime>
38 #include <QUrl>
39 
40 //STL
41 #include <memory>
42 
43 namespace Ui { class TimeSliderWidgetForm; }
44 
45 class QGraphicsView;
46 class QParallelAnimationGroup;
47 class QGraphicsItem;
48 class QDateTimeEdit;
49 
50 namespace te
51 {
52  namespace dt
53  {
54  class TimePeriod;
55  class TimeInstant;
56  }
57  namespace gm
58  {
59  class Envelope;
60  }
61  namespace st
62  {
63  class TrajectoryDataSet;
64  }
65 
66  namespace qt
67  {
68  namespace widgets
69  {
70  class MapDisplay;
71  class Animation;
72  class AnimationItem;
73  class TrajectoryItem;
74  class PixmapItem;
75  class AnimationScene;
76  /*!
77  \class TimeSliderWidget
78 
79  \brief A wdiget used to control the visualization of temporal data
80  */
81  class TEQTWIDGETSEXPORT TimeSliderWidget : public QWidget
82  {
83  Q_OBJECT
84 
85  public:
86 
87  /*!
88  \brief Constructor
89 
90  It constructs a Time Slider Widget
91  */
92  TimeSliderWidget(MapDisplay* d, QWidget* parent = 0, Qt::WindowFlags f = 0);
93 
94  /*!
95  \brief Destructor
96 
97  It destructs a Time Slider Widget
98  */
100 
101  void addTemporalImages(const QString& filePath);
102 
103  te::qt::widgets::PixmapItem* getMetadata(const QString& path);
104 
105  te::qt::widgets::PixmapItem* getGoesMetadata(const QString& path);
106  te::dt::TimeInstant getGoesTime(const QString& file);
107 
108  te::qt::widgets::PixmapItem* getHidroMetadata(const QString& path);
109  te::qt::widgets::PixmapItem* getHidroCtlParameters(const QString& path);
110  void setHidroLUT(te::qt::widgets::PixmapItem* pi);
111  te::dt::TimeInstant getHidroTime(const QString& file);
112 
113  te::qt::widgets::PixmapItem* getEtaMetadata(const QString& path);
114  te::qt::widgets::PixmapItem* getEtaCtlParameters(const QString& path);
115  void setEtaLUT(te::qt::widgets::PixmapItem* pi);
116  te::dt::TimeInstant getEtaTime(const QString& file);
117 
118  te::qt::widgets::PixmapItem* getTemporalImageMetadata(const QString& path);
119  te::qt::widgets::PixmapItem* getTemporalImageCtlParameters(const QString& path);
120  te::dt::TimeInstant getTemporalImageTime(const QString& file);
121 
122 
123  /*!
124  \brief Add trajectory to animation scene.
125 
126  \param title The trajectory title.
127  \param pixmapFile The trajectory icon.
128  \param poinstFile The trajectory points.
129  */
130  void addTrajectory(const QString& title, const QString& pixmapFile, te::st::TrajectoryDataSet* dset);
131 
132  /*!
133  \brief It calculates the spatial extent.
134  */
135  void calculateSpatialExtent();
136 
137  /*!
138  \brief It calculates the temporal extent.
139  */
140  void calculateTemporalExtent();
141 
142  /*!
143  \brief Change direction.
144  */
145  void changeDirection();
146 
147  /*!
148  \brief Sets the mode of animation.
149  \param t True if the animation goes back and forth
150  */
151  void setGoAndBack(bool t);
152 
153  /*!
154  \brief Sets the animation direction.
155  \param direction The animation direction.
156  */
157  void setDirection(const QAbstractAnimation::Direction& direction);
158 
159  /*!
160  \brief Sets the animation duration.
161  \param duration The animation duration in miliseconds.
162  */
163  void setDuration(const unsigned int& duration);
164 
165  /*!
166  \brief It configures automatic pan over a animation path.
167  It toggles auto pan state.
168  \param title The animation title.
169  */
170  void setAutomaticPan(const QString& title);
171 
172  /*!
173  \brief create new pixmap.
174  */
175  void createNewPixmap();
176 
177  /*!
178  \brief Set transformation matrix and draw current animation.
179  */
180  void draw();
181 
182  /*!
183  \brief It emits, indirectly, a sign for this widget is destroyed.
184  */
185  void deleteMe();
186 
187  /*!
188  \brief It puts graphic item to front.
189 
190  \param item The graphic item.
191  */
192  void putToFront(AnimationItem* item);
193 
194  /*!
195  \brief It puts graphic item to back.
196 
197  \param item The graphic item.
198  */
199  void putToBack(AnimationItem* item);
200 
201  /*!
202  \brief It gets the initial time.
203 
204  \return The initial time.
205  */
206  te::dt::TimeInstant getInitialTime();
207 
208  /*!
209  \brief It gets the final time.
210 
211  \return The final time.
212  */
213  te::dt::TimeInstant getFinalTime();
214 
215  ///*!
216  // \brief It converts simple time string to iso time string.
217 
218  // \return The converted time string.
219  //*/
220  // QString simpleTimeString2IsoString(QString timeString);
221 
222  protected:
223 
224  /*!
225  \brief it filters the events of interest.
226  */
227  bool eventFilter(QObject*, QEvent*);
228 
229  /*!
230  \brief Update animation time.
231  */
232  void updateTimeTextEdit();
233 
234  /*!
235  \brief Updates the position of the slider with respect to time animation.
236  */
237  void updateSliderPos();
238 
239  /*!
240  \brief Play animation.
241  */
242  void play();
243 
244  /*!
245  \brief Create animations.
246  */
247  void createAnimations();
248 
249  /*!
250  \brief
251  It it gets the animation time on a time instant.
252  /param tinstant The time instant.
253 
254  \return The animation time in miliseconds.
255  */
256  int getAnimationTime(const te::dt::TimeInstant& tinstant);
257 
258  /*!
259  \brief
260  It it gets the animation time instant.
261 
262  \return The animation time instant.
263  */
264  te::dt::TimeInstant getTimeInstant();
265 
266  /*!
267  \brief
268  It Erase trajectory piece.
269  */
270  void erase(const unsigned int& curTime);
271 
272  /*!
273  \brief
274  True to erase trajectory piece perfectly.
275  Note: Perfectly clear implies loss of performance.
276  */
277  void setErasePerfectly(bool b);
278 
279  /*!
280  \brief
281  It corrects the edited date time
282 
283  /param dte DateTimeEdit to be fixed.
284  /param t The edite date time.
285  */
286  QDateTime fixDateTimeEdit(QDateTimeEdit* dte, const QDateTime& t);
287 
288  /*!
289  \brief
290  Draw the pixmap item.
291 
292  /param pi The pixmap item.
293  /param dwrect The rect of map display in world coordinates.
294  /param painter The painter.
295  */
296  void drawPixmapItem(PixmapItem* pi, const QRectF& dwrect, QPainter* painter);
297 
299 
300  /*!
301  \brief
302  Draw the trajectory icon.
303 
304  /param t The trajectory item.
305  /param pos The top left position in device coordinates.
306  /param painter The painter.
307  */
308  void drawTrajectoryIcon(const TrajectoryItem* t, const QPoint& pos, QPainter* painter);
309 
310  void openTrajectory(const QString file, const QString& leao); // so para teste
311 
312  bool alreadyExists(QPair<QString, QString>& item);
313 
314  /*!
315  \brief It initialize a property animation dialog
316  */
317  void initProperty();
318 
319  /*!
320  \brief Show Property
321 
322  \param b true = show, false = hide
323  */
324  void showPropertySection(bool b);
325 
326  /*!
327  \brief Is Setting Changed
328 
329  \return true = changed, false = not changed
330  */
331  bool isSettingChanged();
332 
333  /*!
334  \brief Remove animation item from the opacity combo box and trajectory color combo box.
335 
336  \param ai The item to be removed.
337  */
338  void removeComboItem(te::qt::widgets::AnimationItem* ai);
339 
340  void dragEnterEvent(QDragEnterEvent*);
341 
342  void dropEvent(QDropEvent*);
343 
344  protected slots:
345 
346  /*!
347  \brief it draw on display.
348  */
349  void onDisplayPaintEvent(QPainter*);
350 
351  /*!
352  \brief it opens the configuration window animation.
353  */
354  void onSettingsToolButtonnClicked();
355 
356  /*!
357  \brief Play or pause the animation.
358  */
359  void onPlayToolButtonnClicked();
360 
361  /*!
362  \brief Stop animation.
363  */
364  void onStopToolButtonnClicked();
365 
366  /*!
367  \brief It takes the necessary measures after slider move.
368  */
369  void onSliderMoved(int value);
370 
371  /*!
372  \brief It takes the necessary measures after the change of extent.
373  */
374  void onExtentChanged();
375 
376  /*!
377  \brief It takes the necessary measures after the change of extent.
378  */
379  void onSridChanged();
380 
381  /*!
382  \brief It takes the necessary measures after the end of the trajectory.
383  */
384  void onFinishAnimation();
385 
386  /*!
387  \brief It takes the necessary steps after changing the duration.
388  \param v Value of duration in miliseconds.
389  */
390  void onDurationValueChanged(int v);
391 
392  /*!
393  \brief It takes the necessary steps after changing the duration.
394  \param v Value of opacity (0 - 255).
395  */
396  void onOpacityValueChanged(int v);
397 
398  /*!
399  \brief It takes the necessary steps after changing the current time of animation.
400 
401  \param t The new current time.
402  */
403  void onDateTimeEditChanged(const QDateTime& t);
404 
405  void onAddEtaPushButtonClicked(bool);
406  void onAddHidroPushButtonClicked(bool);
407  void onAutoPanCheckBoxClicked(bool);
408  void onAddPushButtonClicked(bool b);
409  void onRemovePushButtonClicked(bool b);
410  void onFrontPushButtonClicked(bool b);
411  void onBackPushButtonClicked(bool b);
412 
413  ///*!
414  // \brief Ok button clicked.
415  //*/
416  //void onOkPushButtonClicked();
417 
418  ///*!
419  // \brief Cancel button clicked.
420  //*/
421  //void onCancelPushButtonClicked();
422 
423  ///*!
424  // \brief Help button clicked.
425  //*/
426  //void onHelpPushButtonClicked();
427 
428  /*!
429  \brief Forward radio button clicked.
430 
431  \param b True if the button is checked, or false if the button is unchecked
432  */
433  void onForwardRadioButtonClicked(bool b);
434 
435  /*!
436  \brief Backward radio button clicked.
437 
438  \param b True if the button is checked, or false if the button is unchecked
439  */
440  void onBackwardRadioButtonClicked(bool b);
441 
442  /*!
443  \brief Loop check box clicked.
444 
445  \param b True if the button is checked, or false if the button is unchecked
446  */
447  void onLoopCheckBoxClicked(bool b);
448 
449  /*!
450  \brief Forward and then backward check box clicked.
451 
452  \param b True if the button is checked, or false if the button is unchecked
453  */
454  void onGoAndBackCheckBoxClicked(bool b);
455 
456  /*!
457  \brief Apply time interval push button clicked.
458 
459  \param b True if the button is checked, or false if the button is unchecked
460  */
461  void onApplyTimeIntervalPushButtonClicked(bool b);
462 
463  /*!
464  \brief Trajectory color combo box activated.
465 
466  \param i The index of combo box.
467  */
468  void onTrajectoryColorComboBoxActivated(int i);
469 
470  /*!
471  \brief Opacity combo box activated.
472 
473  \param i The index of combo box.
474  */
475  void onOpacityComboBoxActivated(int i);
476 
477  /*!
478  \brief Reset initial time button clicked.
479  */
480  void onResetInitialTimePushButtonClicked();
481 
482  /*!
483  \brief Reset final time button clicked.
484  */
485  void onResetFinalTimePushButtonClicked();
486 
487  void dropAction();
488 
489  signals:
490 
491  /*!
492  \brief This sign warns that this widget must be destroyed.
493  */
494  void deleteTimeSliderWidget();
495 
496  private:
497 
498  bool m_loop; //!< This property holds whether the slider's animation is on loop.
499  int m_duration; //!< The animation's duration time in miliseconds
500  QAbstractAnimation::Direction m_direction; //!< QAbstractAnimation::Forward or QAbstractAnimation::Backward
501  bool m_goAndBack; //!< Forward and then backward direction
502  bool m_comingBack; //!< Flag to indicate that the trend is coming back
503  MapDisplay* m_display; //!< The map display
504  QGraphicsView* m_animationView; //!< The animation graphics view
505  AnimationScene* m_animationScene; //!< The animation scene
506  QParallelAnimationGroup* m_parallelAnimation; //!< The parallel animation
507  te::gm::Envelope m_spatialExtent; //!< Spatial extent.
508  te::dt::TimePeriod m_temporalExtent; //!< Temporal extent.
509  te::dt::TimePeriod m_temporalAnimationExtent; //!< Animation temporal extent. It is used for show animation.
510  int m_currentTime; //!< Current animation time (relative to time duration).
511  bool m_erasePerfectly; //!< flag to erase trajectory piece perfectly (default = false).
512  std::auto_ptr<Ui::TimeSliderWidgetForm> m_ui; //!< The widget form.
513  QDateTime m_oldQDateTime; //!< The old Qt date time.
514  QDateTime m_oldIQDateTime; //!< The old initial Qt date time.
515  QDateTime m_oldFQDateTime; //!< The old final Qt date time.
517  int m_maxSliderValue; //!< The max slider value.
519  QList<QPair<QString, QString> > m_itemList; //!< List of all animation items (URI, DataSetName).
520  Qt::KeyboardModifiers m_dropModifiers; //!< Control pressed to add animation with drag and drop.
521  QList<QUrl> m_dropUrls; //!< Urls to animation with drag and drop.
522  QByteArray m_dropBA; //!< Layer animation with drag and drop.
523 
524  QRectF m_initialDisplayRect; // so para teste
525 
526  };
527  } // end namespace widgets
528  } // end namespace qt
529 } // end namespace te
530 
531 #endif // __TERRALIB_QT_WIDGETS_INTERNAL_TIMESLIDERWIDGET_H
Qt::KeyboardModifiers m_dropModifiers
Control pressed to add animation with drag and drop.
QParallelAnimationGroup * m_parallelAnimation
The parallel animation.
te::dt::TimePeriod m_temporalAnimationExtent
Animation temporal extent. It is used for show animation.
std::auto_ptr< Ui::TimeSliderWidgetForm > m_ui
The widget form.
te::gm::Envelope m_spatialExtent
Spatial extent.
QIcon getImage(int type)
QAbstractAnimation::Direction m_direction
QAbstractAnimation::Forward or QAbstractAnimation::Backward.
bool m_goAndBack
Forward and then backward direction.
This class is a dialog for the Trajectory Icon Item.
QGraphicsView * m_animationView
The animation graphics view.
int m_maxSliderValue
The max slider value.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:65
QList< QUrl > m_dropUrls
Urls to animation with drag and drop.
A class to represent time instant.
Definition: TimeInstant.h:55
te::dt::TimePeriod m_temporalExtent
Temporal extent.
QByteArray m_dropBA
Layer animation with drag and drop.
bool m_comingBack
Flag to indicate that the trend is coming back.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
int m_currentTime
Current animation time (relative to time duration).
QDateTime m_oldIQDateTime
The old initial Qt date time.
MapDisplay * m_display
The map display.
A class to represent a trajectory data set.
A class to represent time period.
Definition: TimePeriod.h:54
AnimationScene * m_animationScene
The animation scene.
bool m_loop
This property holds whether the slider's animation is on loop.
QList< QPair< QString, QString > > m_itemList
List of all animation items (URI, DataSetName).
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:66
This class is a dialog for the Pixmap Item.
Definition: AnimationItem.h:57
This class is a dialog for the Animation.
QDateTime m_oldFQDateTime
The old final Qt date time.
QDateTime m_oldQDateTime
The old Qt date time.
A wdiget used to control the visualization of temporal data.
bool m_erasePerfectly
flag to erase trajectory piece perfectly (default = false).
int m_duration
The animation's duration time in miliseconds.