Loading...
Searching...
No Matches
TimeSliderWidget.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/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#ifndef Q_MOC_RUN
32#include "../../../geometry.h"
33#include "../../../datatype.h"
34#include "../InterfaceController.h"
36#endif
37
38// Qt
39#include <QWidget>
40#include <QAbstractAnimation>
41#include <QDateTime>
42#include <QUrl>
43
44//STL
45#include <memory>
46
47namespace Ui { class TimeSliderWidgetForm; }
48
49class QGraphicsView;
50class QParallelAnimationGroup;
51class QGraphicsItem;
52class QDateTimeEdit;
53
54namespace te
55{
56 namespace dt
57 {
58 class TimePeriod;
59 class TimeInstant;
60 }
61 namespace gm
62 {
63 class Envelope;
64 }
65 namespace st
66 {
67 class TrajectoryDataSet;
68 class TrajectoryDataSetLayer;
69 }
70
71 namespace qt
72 {
73 namespace widgets
74 {
75 class MapDisplay;
76 class Animation;
77 class AnimationItem;
78 class TrajectoryItem;
79 class ImageItem;
80 class AnimationScene;
81
82 /*!
83 \class TimeSliderWidget
84
85 \brief A wdiget used to control the visualization of temporal data
86 */
88 {
89 Q_OBJECT
90
92 public:
93
94 /*!
95 \brief Constructor
96
97 It constructs a Time Slider Widget
98 */
99 TimeSliderWidget(MapDisplay* d, QWidget* parent = 0, Qt::WindowFlags f = 0);
100
101 /*!
102 \brief Destructor
103
104 It destructs a Time Slider Widget
105 */
107
108 /*!
109 \brief This method is used to set current layer
110
111 */
113
114 /*!
115 \brief This method is used to add a new layer
116
117 */
119
120 /*!
121 \brief This method is used to remove a layer
122
123 */
125
126 void addTemporalImages(const QString& filePath);
127
128 /*!
129 \brief This method is used to load a temporal image data.
130 NOTE: It should be edited to enter with new types of temporal images.
131
132 Param path The folder that has temporal images and the control file.
133 */
135 /*!
136 \brief This method is used to find out the type of temporal image has the folder.
137 NOTE: It should be edited to enter with new types of temporal images.
138 NOTE: You must find a way to discover its kind.
139
140 \param path The folder that has temporal images and the control file.
141 \return The temporal image type.
142 */
143 QString getTemporalImageType(const QString& path);
144
145 /*!
146 \brief Add trajectory to animation scene.
147
148 \param title The trajectory title.
149 \param pixmapFile The trajectory icon.
150 \param poinstFile The trajectory points.
151 */
152 void addTrajectory(te::st::TrajectoryDataSetLayer* tl, const QString& pixmapFile);
153
154 /*!
155 \brief It calculates the spatial extent.
156 */
158
159 /*!
160 \brief It calculates the temporal extent.
161 */
163
164 /*!
165 \brief Change direction.
166 */
168
169 /*!
170 \brief Sets the mode of animation.
171 \param t True if the animation goes back and forth
172 */
173 void setGoAndBack(bool t);
174
175 /*!
176 \brief Sets the animation direction.
177 \param direction The animation direction.
178 */
179 void setDirection(const QAbstractAnimation::Direction& direction);
180
181 /*!
182 \brief Sets the animation duration.
183 \param duration The animation duration in miliseconds.
184 */
185 void setDuration(const unsigned int& duration);
186
187 /*!
188 \brief create new pixmap.
189 */
191
192 /*!
193 \brief Set transformation matrix and draw current animation.
194 */
195 void draw();
196
197 /*!
198 \brief It emits, indirectly, a sign for this widget is destroyed.
199 */
200 void deleteMe();
201
202 /*!
203 \brief It puts graphic item to front.
204
205 \param item The graphic item.
206 */
208
209 /*!
210 \brief It puts graphic item to back.
211
212 \param item The graphic item.
213 */
215
216 /*!
217 \brief It gets the initial time.
218
219 \return The initial time.
220 */
222
223 /*!
224 \brief It gets the final time.
225
226 \return The final time.
227 */
229
230 void showWidget(const bool& b);
231
232 protected:
233
234 /*!
235 \brief it filters the events of interest.
236 */
237 bool eventFilter(QObject*, QEvent*);
238
239 /*!
240 \brief Update animation time.
241 */
243
244 /*!
245 \brief Updates the position of the slider with respect to time animation.
246 */
248
249 /*!
250 \brief Play animation.
251 */
252 void play();
253
254 /*!
255 \brief Create animations.
256 */
258
259 /*!
260 \brief
261 It it gets the animation time on a time instant.
262 /param tinstant The time instant.
263
264 \return The animation time in miliseconds.
265 */
267
268 /*!
269 \brief
270 It it gets the animation time instant.
271
272 \return The animation time instant.
273 */
275
276 /*!
277 \brief
278 It Erase trajectory piece.
279 */
280 void erase(const unsigned int& curTime);
281
282 /*!
283 \brief
284 True to erase trajectory piece perfectly.
285 Note: Perfectly clear implies loss of performance.
286 */
287 void setErasePerfectly(bool b);
288
289 /*!
290 \brief
291 It corrects the edited date time
292
293 /param dte DateTimeEdit to be fixed.
294 /param t The edite date time.
295 */
296 QDateTime fixDateTimeEdit(QDateTimeEdit* dte, const QDateTime& t);
297
298 void loadAnimation(const QString& title);
299
300 void removeAnimation(const int& ind);
301 //void removeAnimation(const QString& title);
302
303 //void removeOnPropertieCombo(const QString& title);
304
305 bool trajectoryAlreadyExists(QPair<QString, QString>& item);
306 bool coverageAlreadyExists(QPair<QString, QString>& item);
307
308 /*!
309 \brief It initialize a property animation dialog
310 */
312
313 /*!
314 \brief Show Property
315
316 \param b true = show, false = hide
317 */
319
320 /*!
321 \brief Is Setting Changed
322
323 \return true = changed, false = not changed
324 */
326
328
330
331
332 protected slots:
333
334 /*!
335 \brief it draw on display.
336 \param p Pointer to QPainter.
337 */
338 void onDisplayPaintEvent(QPainter* p);
339
340 /*!
341 \brief Drag enter event on display.
342 \param e The drag enter event.
343 */
344 void onAnimationDragEnterEvent(QDragEnterEvent* e);
345
346 void onAnimationDropEvent(QDropEvent*);
347 /*!
348 \brief it opens the configuration window animation.
349 */
351
352 /*!
353 \brief Play or pause the animation.
354 */
356
357 /*!
358 \brief Stop animation.
359 */
361
362 /*!
363 \brief It takes the necessary measures after slider move.
364 \param e The slider value.
365 */
366 void onSliderMoved(int value);
367
368 /*!
369 \brief It takes the necessary measures after the change of extent.
370 */
372
373 /*!
374 \brief It takes the necessary measures after the change of extent.
375 */
377
378 /*!
379 \brief It takes the necessary measures after the end of the trajectory.
380 */
382
383 /*!
384 \brief It takes the necessary steps after changing the duration.
385 \param v Value of duration in miliseconds.
386 */
388
389 /*!
390 \brief It takes the necessary steps after changing the duration.
391 \param v Value of opacity (0 - 255).
392 */
394
395 /*!
396 \brief It takes the necessary steps after changing the current time of animation.
397 \param t The new current time.
398 */
399 void onDateTimeEditChanged(const QDateTime& t);
400
405
406 /*!
407 \brief Help button clicked.
408 */
410
411 /*!
412 \brief Draw track check box clicked.
413
414 \param b True if the button is checked, or false if the button is unchecked
415 */
417
418 /*!
419 \brief Forward radio button clicked.
420
421 \param b True if the button is checked, or false if the button is unchecked
422 */
424
425 /*!
426 \brief Backward radio button clicked.
427
428 \param b True if the button is checked, or false if the button is unchecked
429 */
431
432 /*!
433 \brief Loop check box clicked.
434
435 \param b True if the button is checked, or false if the button is unchecked
436 */
438
439 /*!
440 \brief Forward and then backward check box clicked.
441
442 \param b True if the button is checked, or false if the button is unchecked
443 */
445
446 /*!
447 \brief Apply time interval push button clicked.
448
449 \param b True if the button is checked, or false if the button is unchecked
450 */
452
453 /*!
454 \brief Opacity combo box activated.
455
456 \param i The index of combo box.
457 */
459
460 /*!
461 \brief Remove item animation.
462 */
464
465 /*!
466 \brief Remove all animations.
467 */
469
470 /*!
471 \brief Reset initial time button clicked.
472 */
474
475 /*!
476 \brief Reset final time button clicked.
477 */
479
481
483
485
486 signals:
487
488 /*!
489 \brief This sign warns that this widget must be destroyed.
490 */
492
493 private:
494
495 //struct AnimationAuxInfo
496 //{
497 // QString type;
498 // QString title;
499 // unsigned char opacity;
500 // bool drawTrail;
501 // bool autoPan;
502 // QColor forwardColor;
503 // QColor backwardColor;
504 //};
505
506 bool m_loop; //!< This property holds whether the slider's animation is on loop.
507 int m_duration; //!< The animation's duration time in miliseconds
508 QAbstractAnimation::Direction m_direction; //!< QAbstractAnimation::Forward or QAbstractAnimation::Backward
509 bool m_goAndBack; //!< Forward and then backward direction
510 bool m_comingBack; //!< Flag to indicate that the trend is coming back
511 MapDisplay* m_display; //!< The map display
512 QGraphicsView* m_animationView; //!< The animation graphics view
513 AnimationScene* m_animationScene; //!< The animation scene
514 QParallelAnimationGroup* m_parallelAnimation; //!< The parallel animation
515 te::gm::Envelope m_spatialExtent; //!< Spatial extent.
517 te::dt::TimePeriod m_temporalAnimationExtent; //!< Animation temporal extent. It is used for show animation.
518 int m_currentTime; //!< Current animation time (relative to time duration).
519 bool m_erasePerfectly; //!< flag to erase trajectory piece perfectly (default = false).
520 std::unique_ptr<Ui::TimeSliderWidgetForm> m_ui; //!< The widget form.
521 QDateTime m_oldQDateTime; //!< The old Qt date time.
522 QDateTime m_oldIQDateTime; //!< The old initial Qt date time.
523 QDateTime m_oldFQDateTime; //!< The old final Qt date time.
524 bool m_dateTimeChanged; //!< flag to signal change in animation time.
525 int m_maxSliderValue; //!< The max slider value.
526 bool m_finished; //!< flag to signal animation finish.
527 bool m_paused; //!< flag to signal animation pause.
528 QList<QPair<QString, te::st::TrajectoryDataSetLayer*> > m_trajectoryItemList; //!< List of all trajectory items (title, layer).
529 QList<QPair<QString, QString> > m_coverageItemList; //!< List of all animation items (title, path).
530 Qt::KeyboardModifiers m_dropModifiers; //!< Control pressed to add animation with drag and drop.
531 QList<QUrl> m_dropUrls; //!< Urls to animation with drag and drop.
532 QByteArray m_dropBA; //!< Layer animation with drag and drop.
533 SliderPropertiesDialog* m_spd; //!< Slider Properties Dialog.
534 QList<QString> m_animationIdList; //!< List containing the shadow of m_ui->m_animationComboBox
535 double m_panFactor; //!< the range is between 0.002 and 0.5
536 };
537 } // end namespace widgets
538 } // end namespace qt
539} // end namespace te
540
541#endif // __TERRALIB_QT_WIDGETS_INTERNAL_TIMESLIDERWIDGET_H
A class to represent time instant.
Definition: TimeInstant.h:56
A class to represent time period.
Definition: TimePeriod.h:55
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
An abstract class for Animation Item.
Definition: AnimationItem.h:65
This class allows to add multiple trajectories and temporal image.
A virtual class for non modal interfaces.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
A dialog used to configure the behaviour of the SliderSliderWidget.
A wdiget used to control the visualization of temporal data.
void onOpacityValueChanged(int v)
It takes the necessary steps after changing the duration.
QByteArray m_dropBA
Layer animation with drag and drop.
void initProperty()
It initialize a property animation dialog.
void onDisplayPaintEvent(QPainter *p)
it draw on display.
void onPlayToolButtonnClicked()
Play or pause the animation.
QList< QPair< QString, QString > > m_coverageItemList
List of all animation items (title, path).
void onResetInitialTimePushButtonClicked()
Reset initial time button clicked.
void onDrawTrailCheckBoxClicked(bool b)
Draw track check box clicked.
QList< QString > m_animationIdList
List containing the shadow of m_ui->m_animationComboBox.
void loadAnimation(const QString &title)
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the animation direction.
QDateTime m_oldQDateTime
The old Qt date time.
void changeDirection()
Change direction.
void onRemoveAllPushButtonClicked(bool)
Remove all animations.
MapDisplay * m_display
The map display.
SliderPropertiesDialog * m_spd
Slider Properties Dialog.
void onAnimationDropEvent(QDropEvent *)
Qt::KeyboardModifiers m_dropModifiers
Control pressed to add animation with drag and drop.
bool m_goAndBack
Forward and then backward direction.
void showWidget(const bool &b)
virtual void layerRemoved(te::map::AbstractLayerPtr layer)
This method is used to remove a layer.
void deleteTimeSliderWidget()
This sign warns that this widget must be destroyed.
void addTemporalImages(const QString &filePath)
bool coverageAlreadyExists(QPair< QString, QString > &item)
void onSettingsToolButtonnClicked()
it opens the configuration window animation.
void onLoopCheckBoxClicked(bool b)
Loop check box clicked.
te::dt::TimeInstant getFinalTime()
It gets the final time.
te::dt::TimePeriod m_temporalExtent
Temporal extent.
void erase(const unsigned int &curTime)
It Erase trajectory piece.
QAbstractAnimation::Direction m_direction
QAbstractAnimation::Forward or QAbstractAnimation::Backward.
void updateSliderPos()
Updates the position of the slider with respect to time animation.
void draw()
Set transformation matrix and draw current animation.
QString getTemporalImageType(const QString &path)
This method is used to find out the type of temporal image has the folder. NOTE: It should be edited ...
void onDateTimeEditChanged(const QDateTime &t)
It takes the necessary steps after changing the current time of animation.
te::gm::Envelope m_spatialExtent
Spatial extent.
double m_panFactor
the range is between 0.002 and 0.5
void showPropertySection(bool b)
Show Property.
virtual void layerAdded(te::map::AbstractLayerPtr layer)
This method is used to add a new layer.
bool eventFilter(QObject *, QEvent *)
it filters the events of interest.
void onForwardRadioButtonClicked(bool b)
Forward radio button clicked.
TimeSliderWidget(MapDisplay *d, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
virtual void layerSelected(te::map::AbstractLayerPtr layer)
This method is used to set current layer.
void createAnimations()
Create animations.
void setDuration(const unsigned int &duration)
Sets the animation duration.
void adjustPropertyDialog(te::qt::widgets::AnimationItem *)
bool m_comingBack
Flag to indicate that the trend is coming back.
bool m_loop
This property holds whether the slider's animation is on loop.
void calculateAllTemporalExtent()
It calculates the temporal extent.
QString getDateString(const te::dt::TimeInstant &t)
te::dt::TimeInstant getTimeInstant()
It it gets the animation time instant.
void onSridChanged()
It takes the necessary measures after the change of extent.
void removeAnimation(const int &ind)
std::unique_ptr< Ui::TimeSliderWidgetForm > m_ui
The widget form.
void onRemovePushButtonClicked(bool)
Remove item animation.
void setErasePerfectly(bool b)
True to erase trajectory piece perfectly. Note: Perfectly clear implies loss of performance.
void play()
Play animation.
bool m_dateTimeChanged
flag to signal change in animation time.
void onGoAndBackCheckBoxClicked(bool b)
Forward and then backward check box clicked.
QParallelAnimationGroup * m_parallelAnimation
The parallel animation.
bool m_erasePerfectly
flag to erase trajectory piece perfectly (default = false).
void createNewPixmap()
create new pixmap.
QDateTime m_oldFQDateTime
The old final Qt date time.
void onSliderMoved(int value)
It takes the necessary measures after slider move.
void onAnimationDragEnterEvent(QDragEnterEvent *e)
Drag enter event on display.
void onDurationValueChanged(int v)
It takes the necessary steps after changing the duration.
QList< QUrl > m_dropUrls
Urls to animation with drag and drop.
void onResetFinalTimePushButtonClicked()
Reset final time button clicked.
te::qt::widgets::ImageItem * loadImageData(const QString &path)
This method is used to load a temporal image data. NOTE: It should be edited to enter with new types ...
int getAnimationTime(const te::dt::TimeInstant &tinstant)
It it gets the animation time on a time instant. /param tinstant The time instant.
QDateTime fixDateTimeEdit(QDateTimeEdit *dte, const QDateTime &t)
It corrects the edited date time.
void onHelpPushButtonClicked()
Help button clicked.
QList< QPair< QString, te::st::TrajectoryDataSetLayer * > > m_trajectoryItemList
List of all trajectory items (title, layer).
void onBackwardRadioButtonClicked(bool b)
Backward radio button clicked.
void calculateAllSpatialExtent()
It calculates the spatial extent.
void putToBack(AnimationItem *item)
It puts graphic item to back.
te::dt::TimePeriod m_temporalAnimationExtent
Animation temporal extent. It is used for show animation.
bool m_paused
flag to signal animation pause.
void onAnimationComboBoxActivated(int i)
Opacity combo box activated.
void updateTimeTextEdit()
Update animation time.
void onApplyTimeIntervalPushButtonClicked(bool b)
Apply time interval push button clicked.
void onFinishAnimation()
It takes the necessary measures after the end of the trajectory.
int m_currentTime
Current animation time (relative to time duration).
int m_duration
The animation's duration time in miliseconds.
void addTrajectory(te::st::TrajectoryDataSetLayer *tl, const QString &pixmapFile)
Add trajectory to animation scene.
bool isSettingChanged()
Is Setting Changed.
bool trajectoryAlreadyExists(QPair< QString, QString > &item)
int m_maxSliderValue
The max slider value.
void putToFront(AnimationItem *item)
It puts graphic item to front.
te::dt::TimeInstant getInitialTime()
It gets the initial time.
AnimationScene * m_animationScene
The animation scene.
void onStopToolButtonnClicked()
Stop animation.
QGraphicsView * m_animationView
The animation graphics view.
void deleteMe()
It emits, indirectly, a sign for this widget is destroyed.
QDateTime m_oldIQDateTime
The old initial Qt date time.
void onExtentChanged()
It takes the necessary measures after the change of extent.
bool m_finished
flag to signal animation finish.
void setGoAndBack(bool t)
Sets the mode of animation.
A layer with reference to a dataset that contains trajectories.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
TerraLib.
#define slots
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63