TimeSliderWidget.cpp
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.cpp
22 
23  \brief A widget used to alow the user to controle the visualization of temporal data
24 */
25 
26 //Terralib
27 #include "../../../common/TreeItem.h"
28 #include "../../../geometry/Point.h"
29 #include "../../../st/maptools/TrajectoryDataSetLayer.h"
30 #include "../../../st/core/trajectory/TrajectoryDataSet.h"
31 #include "../../../qt/widgets/layer/explorer/LayerItem.h"
32 #include "../canvas/MapDisplay.h"
33 #include "../utils/ScopedCursor.h"
34 #include "AnimationView.h"
35 #include "Animation.h"
36 #include "AnimationScene.h"
37 #include "TrajectoryItem.h" // for animation of TRAJECTORIES
38 #include "Eta5kmItem.h" // for animation of ETA forecast images
39 #include "HidroItem.h" // for animation of HIDRO forecast images
40 #include "GoesItem.h" // for animation of GOES images
41 #include "QtKnowItem.h" // for animation of known images by QT, loadables by QT
42 // include here your other temporal image animations.
43 //#include ".....
44 #include "TimeSliderWidget.h"
45 #include "SliderPropertiesDialog.h"
46 #include "ui_TimeSliderWidgetForm.h"
47 #include "ui_SliderPropertiesDialogForm.h"
48 
49 //QT
50 #include <QGraphicsEffect>
51 #include <QSlider>
52 #include <QGraphicsView>
53 #include <QMimeData>
54 #include <QParallelAnimationGroup>
55 #include <QPropertyAnimation>
56 #include <QTimer>
57 #include <QThread>
58 #include <QTextStream>
59 #include <QContextMenuEvent>
60 #include <QMessageBox>
61 #include <QInputDialog>
62 #include <QDateTimeEdit>
63 #include <QColorDialog>
64 #include <QListWidget>
65 #include <QMap>
66 #include <QUrl>
67 #include <QFileDialog>
68 
70  : QWidget(parent, f),
71  m_duration(10000),
72  m_display(md),
73  m_erasePerfectly(false),
74  m_ui(new Ui::TimeSliderWidgetForm),
75  m_maxSliderValue(1000000000),
76  m_finished(false),
77  m_panFactor(.01)
78 {
79  te::qt::widgets::ScopedCursor scopedCursor(Qt::WaitCursor);
80  m_ui->setupUi(this);
81  setFocusPolicy(Qt::StrongFocus);
82  setMouseTracking(true);
83  setAcceptDrops(true);
84 
85  //QColor wc(50, 50, 200, 80);
86  //QBrush wbrush(wc);
87  //QPalette wpalette(wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush);
88  //setPalette(wpalette);
89  //setAutoFillBackground(true);
90  //setBackgroundRole(QPalette::Window);
91 
92  m_spd = new SliderPropertiesDialog(this);
93 
94  // slider normalized between 0 and m_maxSliderValue
95  m_ui->m_TemporalHorizontalSlider->setMinimum(0);
96  m_ui->m_TemporalHorizontalSlider->setMaximum(m_maxSliderValue);
97 
98  m_ui->m_durationSpinBox->setMinimum(100);
99  m_ui->m_durationSpinBox->setMaximum(100000000);
100  m_ui->m_durationSpinBox->setValue(m_duration);
101  m_ui->m_durationSpinBox->setSingleStep(10000);
102 
103  m_spd->m_ui->m_initialTimeLineEdit->setEnabled(false);
104  m_spd->m_ui->m_finalTimeLineEdit->setEnabled(false);
105 
106  m_spd->m_ui->m_opacitySpinBox->setMinimum(0);
107  m_spd->m_ui->m_opacitySpinBox->setMaximum(255);
108  m_spd->m_ui->m_opacitySpinBox->setValue(255);
109  m_spd->m_ui->m_opacitySpinBox->setSingleStep(5);
110 
111  m_spd->m_ui->m_panFactorDoubleSpinBox->setValue(m_panFactor);
112  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.01);
113  m_spd->m_ui->m_panFactorDoubleSpinBox->setCorrectionMode(QAbstractSpinBox::CorrectToPreviousValue);
114 
115 
116  //setAutoFillBackground(true);
117  //QPalette palette;
118  //palette.setColor(QPalette::Background, Qt::white);
119  //setPalette(palette);
120 
121  //The opacity used to fade the widget if the mouse is not over it
122  //QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect;
123  //opacityEffect->setOpacity(0.85);
124  //this->setGraphicsEffect(opacityEffect);
125 
126  //Adjusting the icons and the graphic effects
127  m_ui->m_settingsToolButton->setIcon(QIcon::fromTheme("preferences-system"));
128  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
129  m_ui->m_stopToolButton->setIcon(QIcon::fromTheme("media-playback-stop"));
130 
131  // connect signal and slots
132  connect(m_ui->m_dateTimeEdit, SIGNAL(dateTimeChanged(const QDateTime&) ), this, SLOT(onDateTimeEditChanged(const QDateTime&)));
133  connect(m_ui->m_durationSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onDurationValueChanged(int)));
134  connect(m_ui->m_settingsToolButton, SIGNAL(clicked()), this, SLOT(onSettingsToolButtonnClicked()));
135  connect(m_ui->m_playToolButton, SIGNAL(clicked()), this, SLOT(onPlayToolButtonnClicked()));
136  connect(m_ui->m_stopToolButton, SIGNAL(clicked()), this, SLOT(onStopToolButtonnClicked()));
137  connect(m_ui->m_TemporalHorizontalSlider, SIGNAL(sliderMoved (int)), this, SLOT(onSliderMoved(int)));
138 
139  setAttribute(Qt::WA_DeleteOnClose, true);
140 
141  m_loop = true; //By default, the animation not will be looping.
142  m_duration = 10000; //By default, the animation journey time will be 10000 miliseconds.
143  m_ui->m_durationSpinBox->setValue(m_duration);
144  m_direction = QAbstractAnimation::Forward; //By default, the animation direction will be forward.
145  setGoAndBack(true); //By default, the animation is forward and then backward.
146 
147  m_spd->m_ui->m_forwardRadioButton->setCheckable(true);
148 
150  m_animationView->setWindowFlags(Qt::Widget);
151  QBrush brush(Qt::transparent);
152  QPalette palette(brush, brush, brush, brush, brush, brush, brush, brush, brush);
153  m_animationView->setPalette(palette);
154  m_parallelAnimation = new QParallelAnimationGroup();
157  m_animationView->show();
158  m_animationView->resize(4000, 2200);
159  m_animationView->move(0, 0);
160 
161  raise();
162 
163  connect(m_display, SIGNAL(displaySridChanged()), this, SLOT(onSridChanged()));
164  connect(m_display, SIGNAL(extentChanged()), this, SLOT(onExtentChanged()));
165  connect(m_display, SIGNAL(displayPaintEvent(QPainter*)), this, SLOT(onDisplayPaintEvent(QPainter*)));
166  connect(m_animationView, SIGNAL(animationDragEnterEvent(QDragEnterEvent*)), this, SLOT(onAnimationDragEnterEvent(QDragEnterEvent*)));
167  connect(m_animationView, SIGNAL(animationDropEvent(QDropEvent*)), this, SLOT(onAnimationDropEvent(QDropEvent*)));
168 
169  connect(m_parallelAnimation, SIGNAL(finished()), this, SLOT(onFinishAnimation()));
170 
171  m_spd->m_ui->m_forwardColorPushButton->installEventFilter(this);
172  m_spd->m_ui->m_backwardColorPushButton->installEventFilter(this);
173  m_spd->m_ui->m_iconPushButton->installEventFilter(this);
174  m_ui->m_dateTimeEdit->installEventFilter(this);
175 
176  m_ui->m_dateTimeEdit->setDisplayFormat("dd/MMM/yyyy hh:mm:ss");
177 
178  if(m_animationScene->items().isEmpty())
179  {
180  m_ui->m_durationSpinBox->setEnabled(false);
181  m_ui->m_settingsToolButton->setEnabled(false);
182  m_ui->m_playToolButton->setEnabled(false);
183  m_ui->m_stopToolButton->setEnabled(false);
184  m_ui->m_dateTimeEdit->setEnabled(false);
185  m_ui->m_TemporalHorizontalSlider->setEnabled(false);
186  m_ui->label->setEnabled(false);
187  m_ui->label_2->setEnabled(false);
188  m_spd->hide();
189  }
190  else
191  {
192  m_ui->m_durationSpinBox->setEnabled(true);
193  m_ui->m_settingsToolButton->setEnabled(true);
194  m_ui->m_playToolButton->setEnabled(true);
195  m_ui->m_stopToolButton->setEnabled(true);
196 
197  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
198  m_ui->m_dateTimeEdit->setEnabled(true);
199  else
200  m_ui->m_dateTimeEdit->setEnabled(false);
201 
202  m_ui->m_TemporalHorizontalSlider->setEnabled(true);
203  m_ui->label->setEnabled(true);
204  m_ui->label_2->setEnabled(true);
205  }
206 
207  if(m_display->getExtent().isValid() == false)
208  {
209  QRectF r = m_animationScene->sceneRect();
210  te::gm::Envelope e(r.left(), r.top(), r.right(), r.bottom());
211  m_display->setExtent(e);
212  }
213  if(m_display->getSRID() <= 0)
214  {
215  QList<QGraphicsItem*> list = m_animationScene->items();
216  QList<QGraphicsItem*>::iterator it = list.begin();
217  if(it != list.end())
218  {
219  AnimationItem* ai = (AnimationItem*)(*it);
220  int srid = ai->m_SRID;
221  m_display->setSRID(srid);
222  }
223  }
224 }
225 
227 {
228  m_parallelAnimation->stop(); // should be before clear
229  m_parallelAnimation->clear();
230  delete m_parallelAnimation;
231  delete m_animationScene;
232 
233  bool b = m_animationView->testAttribute(Qt::WA_DeleteOnClose);
234  m_animationView->close();
235  if(b == false)
236  delete m_animationView;
237 }
238 
240  te::map::AbstractLayerPtr /*layer*/)
241 {
242  //setCurrentLayer(layer);
243 }
244 
246 {
247  if(layer->getType() == "TRAJECTORYDATASETLAYER")
248  {
249  te::st::TrajectoryDataSetLayer* tl = dynamic_cast<te::st::TrajectoryDataSetLayer*>(layer.get());
250  QString title(tl->getTitle().c_str());
251  QString layerId(tl->getId().c_str());
252  QPair<QString, QString> p(title, layerId);
254  QMessageBox::information(this, title + " already exists", title + " is already being animated!");
255  else
256  addTrajectory(tl, "");
257  if(isHidden())
258  show();
259  }
260 }
261 
263 {
264  if(layer->getType() == "TRAJECTORYDATASETLAYER")
265  {
266  QString id(layer->getId().c_str());
267 
268  int ind = 0;
269  QList<QString>::Iterator it;
270  for (it = m_animationIdList.begin(); it != m_animationIdList.end(); ++it)
271  {
272  if (*it == id)
273  break;
274  ++ind;
275  }
276  if (it != m_animationIdList.end())
277  removeAnimation(ind);
278  }
279 }
280 
282 {
283  te::qt::widgets::TrajectoryItem* ti = nullptr;
284  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
285  QString id = m_animationIdList.value(ind);
286 
287  QList<QGraphicsItem*> list = m_animationScene->items();
288  QList<QGraphicsItem*>::iterator it;
289 
290  for (it = list.begin(); it != list.end(); ++it)
291  {
293  if (ai->pixmap().isNull() == false)
294  {
295  ti = dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai);
296  if (ti->m_layerId == id)
297  {
298  ti->m_drawTrail = b;
299  break;
300  }
301  }
302  }
303 }
304 
306 {
307  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
308  if(ind != -1)
309  removeAnimation(ind);
310 }
311 
313 {
314  while(m_spd->m_ui->m_animationComboBox->count() != 0)
315  {
316  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
317  removeAnimation(ind);
318  }
319 }
320 
322 {
323  QString aid = m_animationIdList.takeAt(ind);
324  QString title = m_spd->m_ui->m_animationComboBox->itemText(ind);
325 
326  QList<QGraphicsItem*> list = m_animationScene->items();
327  QList<QGraphicsItem*>::iterator it;
328 
329  for (it = list.begin(); it != list.end(); ++it)
330  {
332  te::qt::widgets::ImageItem* ii = nullptr;
333  te::qt::widgets::TrajectoryItem* ti = nullptr;
334  QString id;
335 
336  if (ai->pixmap().isNull()) // image
337  {
338  ii = dynamic_cast<te::qt::widgets::ImageItem*>(ai);
339  id = ii->m_dir.absolutePath();
340  }
341  else // trajectory
342  {
343  ti = dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai);
344  id = ti->m_layerId;
345  }
346 
347  if (id == aid)
348  {
349  if (list.count() == 1)
350  {
353  m_parallelAnimation->removeAnimation(ai->m_animation);
354  delete ai->m_animation;
355  delete ai;
356  m_ui->m_TemporalHorizontalSlider->setValue(0);
357  m_parallelAnimation->setCurrentTime(0);
358  m_ui->m_settingsToolButton->setEnabled(false);
359  m_ui->m_playToolButton->setEnabled(false);
360  m_ui->m_stopToolButton->setEnabled(false);
361  m_ui->m_durationSpinBox->setEnabled(false);
362  m_ui->m_dateTimeEdit->setEnabled(false);
363  m_ui->m_TemporalHorizontalSlider->setEnabled(false);
364  m_ui->label->setEnabled(false);
365  m_ui->label_2->setEnabled(false);
366  m_display->update();
367  m_spd->m_ui->m_animationComboBox->removeItem(ind);
368  size_t size = m_spd->m_ui->m_animationComboBox->count();
369  if (size)
370  m_spd->m_ui->m_animationComboBox->setCurrentIndex(0);
371  initProperty();
372  return;
373  }
374 
375  bool running = false;
376  int state = m_parallelAnimation->state();
377  if (state == QAbstractAnimation::Running)
378  {
379  running = true;;
381  }
382 
383  m_currentTime = m_parallelAnimation->currentTime();
385  m_parallelAnimation->removeAnimation(ai->m_animation);
386  if (ti)
387  {
389  {
390  m_animationScene->m_mutex.lock();
391  m_animationScene->m_trajectoryPixmap->fill(Qt::transparent);
392  m_animationScene->m_mutex.unlock();
393  draw();
394  }
395  }
396  delete ai->m_animation;
397  delete ai;
398 
404 
405  if (running)
406  {
408  m_parallelAnimation->setCurrentTime(m_currentTime);
409  }
410 
411  break;
412  }
413  }
414  m_spd->m_ui->m_animationComboBox->removeItem(ind);
415  size_t size = m_spd->m_ui->m_animationComboBox->count();
416  if (size)
417  m_spd->m_ui->m_animationComboBox->setCurrentIndex(0);
418  initProperty();
419 }
420 
422 {
423  bool accept = false;
424 
425  const QMimeData* mdata = e->mimeData();
426  QList<QUrl> urls = mdata->urls();
427  if (urls.empty())
428  {
429  QByteArray ba = mdata->data("application/x-terralib;value=\"DraggedItems\"");
430  if (ba.count() != 0)
431  {
432  QString s(ba);
433  std::vector<te::qt::widgets::TreeItem*>* draggedItems = reinterpret_cast<std::vector<te::qt::widgets::TreeItem*>*>(s.toULongLong());
434 
435  for (std::vector<te::qt::widgets::TreeItem*>::iterator it = draggedItems->begin(); it != draggedItems->end(); ++it)
436  {
438  te::map::AbstractLayer* layer = dynamic_cast<te::map::AbstractLayer*>(lItem->getLayer().get());
439  std::string ltype = layer->getType();
440 
441  if (ltype == "TRAJECTORYDATASETLAYER")
442  accept = true;
443  }
444  }
445  }
446  else
447  {
448  e->setDropAction(Qt::LinkAction);
449 
450  QString path = urls.begin()->path();
451  size_t pos = path.indexOf("/");
452  if (pos == 0)
453  path.remove(0, 1);
454  QDir dir(path);
455  QStringList nameFilter;
456  nameFilter.append("*.ctl");
457  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
458  if (files.empty() == false)
459  {
460  QString file(path + "/" + files.first());
461  FILE* fp = fopen(te::core::CharEncoding::fromUTF8(file.toUtf8().data()).c_str(), "r");
462  char buf[2000];
463  size_t c = fread(buf, sizeof(char), 2000, fp);
464  fclose(fp);
465  buf[c] = 0;
466  QString s(buf);
467  if (s.contains("undef", Qt::CaseInsensitive))
468  accept = true;
469  }
470  else
471  {
472  nameFilter.clear();
473  nameFilter.append("S1123*.jpg");
474  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
475  if (files.empty() == false && files.first().length() == 26)
476  accept = true;
477  else
478  {
479  nameFilter.clear();
480  nameFilter.append("S1118*.jpg");
481  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
482  if (files.empty() == false && files.first().length() == 26)
483  accept = true;
484  }
485  }
486  }
488  a->m_dragDropAccepted = accept;
489  e->setAccepted(a->m_dragDropAccepted);
490 }
491 
493 {
494  m_dropModifiers = e->keyboardModifiers();
495  const QMimeData* mdata = e->mimeData();
496  m_dropUrls = mdata->urls();
497  m_dropBA = mdata->data("application/x-terralib;value=\"DraggedItems\"");
498  QTimer::singleShot(10, this, SLOT(dropAction()));
499 }
500 
502 {
503  te::qt::widgets::ScopedCursor scopedCursor(Qt::WaitCursor);
504  int state = m_parallelAnimation->state();
505  int tempo = m_currentTime;
506  if(state == QAbstractAnimation::Running)
507  onPlayToolButtonnClicked(); // put to paused state
508 
509  if(m_dropModifiers == Qt::NoModifier)
510  {
512  m_spd->m_ui->m_animationComboBox->clear();
513  m_animationIdList.clear();
514  m_ui->m_TemporalHorizontalSlider->setValue(0);
515  m_parallelAnimation->setCurrentTime(0);
516  m_ui->m_settingsToolButton->setEnabled(false);
517  m_ui->m_playToolButton->setEnabled(false);
518  m_ui->m_stopToolButton->setEnabled(false);
519  m_ui->m_durationSpinBox->setEnabled(false);
520  m_ui->m_dateTimeEdit->setEnabled(false);
521  m_ui->m_TemporalHorizontalSlider->setEnabled(false);
522  m_ui->label->setEnabled(false);
523  m_ui->label_2->setEnabled(false);
524 
525  QList<QGraphicsItem*> list = m_animationScene->items();
526  QList<QGraphicsItem*>::iterator it;
527  for(it = list.begin(); it != list.end(); ++it)
528  {
531  m_parallelAnimation->removeAnimation(ai->m_animation);
532  delete ai->m_animation;
533  delete ai;
534  }
535 
536  m_spd->m_ui->m_animationComboBox->clear();
537  m_display->update();
538  }
539 
540  if(m_dropUrls.empty())
541  {
542  if(m_dropBA.count() != 0)
543  {
544  QString s(m_dropBA);
545  //unsigned long v = s.toULongLong();
546  std::vector<te::qt::widgets::TreeItem*>* draggedItems = reinterpret_cast<std::vector<te::qt::widgets::TreeItem*>*>(s.toULongLong());
547 
548  for (std::vector<te::qt::widgets::TreeItem*>::iterator it = draggedItems->begin(); it != draggedItems->end(); ++it)
549  {
551  te::map::AbstractLayer* layer = dynamic_cast<te::map::AbstractLayer*>(lItem->getLayer().get());
552  std::string ltype = layer->getType();
553 
554  if (ltype == "TRAJECTORYDATASETLAYER")
555  {
556  te::st::TrajectoryDataSetLayer* tl = dynamic_cast<te::st::TrajectoryDataSetLayer*>(lItem->getLayer().get());
557  QString layerId(tl->getId().c_str());
558  QString title(tl->getTitle().c_str());
559  QPair<QString, QString> p(title, layerId);
561  QMessageBox::information(this, "animation already exists", title + " is already being animated!");
562  else
563  addTrajectory(tl, "");
564  }
565  }
566  }
567  }
568  else
569  {
570  QList<QUrl>::iterator it;
571  for(it = m_dropUrls.begin(); it != m_dropUrls.end(); ++it)
572  {
573  QString path = it->path();
574  QDir dir(path);
575  QString title = dir.dirName();
576  path.remove(0, 1);
577 
578  QPair<QString, QString> p(title, path);
579 
580  if(coverageAlreadyExists(p))
581  QMessageBox::information(this, "animation already exists", title + " is already being animated!");
582  else
583  addTemporalImages(path);
584  }
585  }
586 
587  if(state == QAbstractAnimation::Running || m_dropModifiers == Qt::NoModifier)
588  {
589  m_currentTime = tempo;
591  m_parallelAnimation->setCurrentTime(m_currentTime);
592  }
593  if (isHidden())
594  show();
595 }
596 
598 {
599  AnimationItem* ai;
600  QList<QGraphicsItem*> list = m_animationScene->items();
601  QList<QGraphicsItem*>::iterator it;
602  for (it = list.begin(); it != list.end(); ++it)
603  {
604  ai = dynamic_cast<AnimationItem*>(*it);
605  if (ai->pixmap().isNull() == false && ai->m_title == item.first)
606  {
608  if (ti->m_layerId == item.second)
609  return true;
610  }
611  }
612  return false;
613 }
614 
616 {
617  AnimationItem* ai;
618  QList<QGraphicsItem*> list = m_animationScene->items();
619  QList<QGraphicsItem*>::iterator it;
620  for (it = list.begin(); it != list.end(); ++it)
621  {
622  ai = dynamic_cast<AnimationItem*>(*it);
623  if (ai->pixmap().isNull() && ai->m_title == item.first)
624  {
626  if (ii->m_dir.absolutePath() == item.second)
627  return true;
628  }
629  }
630  return false;
631 }
632 
634  te::st::TrajectoryDataSetLayer* tl, const QString& /*pixmapFile*/)
635 {
636  int state = m_parallelAnimation->state();
637 
638  QString title(tl->getTitle().c_str());
639  QString layerId(tl->getId().c_str());
640  TrajectoryItem* ti = new TrajectoryItem(title, layerId, m_display, QString(), QSize());
642  Animation* animation = new Animation(ti, "pos");
643  animation->setEasingCurve(QEasingCurve::Linear);
644 
645  te::st::TrajectoryDataSet* dset = tl->getTrajectoryDataset().release();
646  animation->m_temporalExtent = *static_cast<te::dt::TimePeriod*>(dset->getTemporalExtent()->clone());
647 
648  ti->m_SRID = tl->getSRID();
649 
650  QVector<QPointF> points;
651  te::dt::TimeInstant tiraRepetido;
652  size_t i = 0;
653  while(dset->moveNext())
654  {
655  std::unique_ptr<te::dt::DateTime> time = dset->getTime();
656  te::dt::TimeInstant* tinstant = static_cast<te::dt::TimeInstant*>(time.get());
657  if(tiraRepetido == *tinstant)
658  continue;
659  tiraRepetido = *tinstant;
660  ti->m_time.push_back(te::dt::TimeInstant(tinstant->getTimeInstant()));
661 
662  std::unique_ptr<te::gm::Geometry> geom = dset->getGeometry();
663  const te::gm::Point* p = static_cast<const te::gm::Point*>(geom.get());
664  points.push_back(QPointF(p->getX(), p->getY()));
665  ++i;
666  }
667  delete dset;
668 
669  if(i == 0)
670  return;
671 
672  ti->m_route = new te::gm::LineString(i, te::gm::LineStringType, ti->m_SRID);
673 
674  QVector<QPointF>::iterator it;
675  i = 0;
676  for (it = points.begin(); it != points.end(); ++it)
677  {
678  te::gm::Point p(te::gm::PointType, (*it).x(), (*it).y());
679  ti->m_route->setPointN(i++, p);
680  }
681 
682  ti->m_route->computeMBR(true);
683  te::gm::Envelope e(*ti->m_route->getMBR());
684  animation->m_spatialExtent = e;
685 
686  m_parallelAnimation->addAnimation(animation);
692 
693  if(state == QAbstractAnimation::Running)
694  {
696  m_parallelAnimation->setCurrentTime(m_currentTime);
697  }
698  if(m_animationScene->items().isEmpty() == false)
699  {
700  m_ui->m_durationSpinBox->setEnabled(true);
701  m_ui->m_settingsToolButton->setEnabled(true);
702  m_ui->m_playToolButton->setEnabled(true);
703  m_ui->m_stopToolButton->setEnabled(true);
704 
705  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
706  m_ui->m_dateTimeEdit->setEnabled(true);
707  else
708  m_ui->m_dateTimeEdit->setEnabled(false);
709 
710  m_ui->m_TemporalHorizontalSlider->setEnabled(true);
711  m_ui->label->setEnabled(true);
712  m_ui->label_2->setEnabled(true);
713  }
714 
715  initProperty();
716 
717  m_spd->m_ui->m_animationComboBox->addItem(title);
718  m_animationIdList.append(ti->m_layerId);
719  int count = m_spd->m_ui->m_animationComboBox->count();
720  m_spd->m_ui->m_animationComboBox->setCurrentIndex(count-1);
722 }
723 
725 {
726  if(m_animationScene->items().isEmpty())
727  m_ui->m_durationSpinBox->setValue(m_duration);
728 
729  int state = m_parallelAnimation->state();
730  m_currentTime = m_parallelAnimation->currentTime();
731  if(state == QAbstractAnimation::Running)
733 
735  if(pi == nullptr)
736  {
737  QMessageBox::information(this, "Error", "Load error: " + filePath);
738  return;
739  }
741  m_parallelAnimation->addAnimation(pi->m_animation);
742 
748  if(state == QAbstractAnimation::Running)
749  {
751  m_parallelAnimation->setCurrentTime(m_currentTime);
752  }
753  if(m_animationScene->items().isEmpty() == false)
754  {
755  m_ui->m_durationSpinBox->setEnabled(true);
756  m_ui->m_settingsToolButton->setEnabled(true);
757  m_ui->m_playToolButton->setEnabled(true);
758  m_ui->m_stopToolButton->setEnabled(true);
759  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
760  m_ui->m_dateTimeEdit->setEnabled(true);
761  else
762  m_ui->m_dateTimeEdit->setEnabled(false);
763  m_ui->m_TemporalHorizontalSlider->setEnabled(true);
764  m_ui->label->setEnabled(true);
765  m_ui->label_2->setEnabled(true);
766  }
767 
768  QDir dir(filePath);
769  initProperty();
770 
771  m_spd->m_ui->m_animationComboBox->addItem(dir.dirName());
772  m_animationIdList.append(pi->m_dir.absolutePath());
773  int count = m_spd->m_ui->m_animationComboBox->count();
774  m_spd->m_ui->m_animationComboBox->setCurrentIndex(count-1);
776 }
777 
779 {
780  QList<QGraphicsItem*> list = m_animationScene->items();
781  if (list.empty())
782  return;
783 
784  if (m_display->getExtent().isValid() == false)
785  return;
786 
787  // each animation has its SRID and they may differ from each other
788  // Then, using the map display projection to update scene rect
790  QList<QGraphicsItem*>::iterator it;
791  AnimationItem* ai;
792  for(it = list.begin(); it != list.end(); ++it)
793  {
794  ai = dynamic_cast<AnimationItem*>(*it);
795  if(m_display->getSRID() != TE_UNKNOWN_SRS && m_display->getSRID() != ai->m_SRID)
796  {
798  e.transform(ai->m_SRID, m_display->getSRID());
800  }
801  else
803  }
805  m_animationScene->setSceneRect(rect);
806  m_animationView->setSceneRect(rect);
807 }
808 
810 {
811  te::dt::TimeInstant initial, final, t_initial, t_final;
812 
813  QList<QGraphicsItem*> list = m_animationScene->items();
814  QList<QGraphicsItem*>::iterator it = list.begin();
815  if(it != list.end())
816  {
817  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
820  ++it;
821  }
822 
823  while(it != list.end())
824  {
825  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
827  if(initial < t_initial)
828  t_initial = initial;
829 
831  if(final > t_final)
832  t_final = final;
833  ++it;
834  }
835 
836  m_temporalExtent = te::dt::TimePeriod(t_initial, t_final);
837  te::dt::TimePeriod tp(t_initial, t_final);
838  if(list.count() == 1)
839  {
841 
842  for(it = list.begin(); it != list.end(); ++it)
843  {
844  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
846  }
847  }
848 }
849 
851 {
852  size_t i;
853  QVector<te::dt::TimePeriod> times;
854  QVector<te::gm::Envelope> envelopes;
855  QList<QGraphicsItem*> list = m_animationScene->items();
856  QList<QGraphicsItem*>::iterator it;
857  for(it = list.begin(); it != list.end(); ++it)
858  {
859  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
860  times.push_back(ai->m_animation->m_temporalExtent);
861  envelopes.push_back(ai->m_animation->m_spatialExtent);
862  }
863 
864  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
865  m_parallelAnimation->clear();
866  else
867  {
868  int cur = m_parallelAnimation->currentTime();
869  m_parallelAnimation->stop();
870  m_parallelAnimation->clear();
871  m_parallelAnimation->setCurrentTime(cur);
872  }
873 
874  for(it = list.begin(), i = 0 ; it != list.end(); ++it, ++i)
875  {
876  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
878  a->m_spatialExtent = envelopes[(int)i];
879  a->m_temporalExtent = times[(int)i];
882  m_parallelAnimation->addAnimation(a);
883  }
884 }
885 
887 {
888  boost::posix_time::ptime pTime = timeInstant.getTimeInstant();
889 
890  // total time duration
891  boost::posix_time::ptime iTime = m_temporalAnimationExtent.getInitialTimeInstant().getTimeInstant();
892  boost::posix_time::ptime fTime = m_temporalAnimationExtent.getFinalTimeInstant().getTimeInstant();
893  boost::posix_time::time_duration diff = fTime - iTime;
894  double totalSeconds = diff.total_seconds();
895 
896  diff = pTime - iTime;
897  double seconds = diff.total_seconds();
898  // normalizing the time
899  double t = seconds / totalSeconds;
900  int ret = qRound(t * (double)m_duration);
901  return ret;
902 }
903 
905 {
906  double t = m_parallelAnimation->currentTime();
907  double trel = t / (double)m_duration;
908 
909  // total time duration
910  boost::posix_time::ptime iTime = m_temporalAnimationExtent.getInitialTimeInstant().getTimeInstant();
911  boost::posix_time::ptime fTime = m_temporalAnimationExtent.getFinalTimeInstant().getTimeInstant();
912  boost::posix_time::time_duration diff = fTime - iTime;
913  double totalSeconds = diff.total_seconds();
914 
915  int secs = qRound(totalSeconds * trel);
916  boost::posix_time::time_duration td = boost::posix_time::seconds(secs);
917  boost::posix_time::ptime time = iTime + td;
918  te::dt::TimeInstant timei(time);
919  return timei;
920 }
921 
923 {
924  if(m_animationScene->items().isEmpty())
925  return;
926  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
927  return;
928 
930  if(m_ui->m_dateTimeEdit->isEnabled() == false)
931  t = getTimeInstant();
932  else
933  {
934  QDateTime d = m_ui->m_dateTimeEdit->dateTime();
935  t = te::dt::TimeInstant(te::dt::Date(d.date().year(), d.date().month(), d.date().day()),
936  te::dt::TimeDuration(d.time().hour(), d.time().minute(), d.time().second(), 0));
937  }
938 
939  QList<QGraphicsItem*> list = m_animationScene->items();
940  QList<QGraphicsItem*>::iterator it;
941 
942  if(m_animationScene->m_numberOfCoverages) // has images
943  {
944  // draw pixmap items
945  for(it = list.begin(); it != list.end(); ++it)
946  {
947  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
948  if(ai->pixmap().isNull())
949  {
950  //// draw only the items that are within the time frame
951  //te::dt::TimeInstant tini = ai->m_animationTime.first();
952  //te::dt::TimeInstant tfim = ai->m_animationTime.last();
953  //if(t < tini || t > tfim)
954  // outOfTime = true;
955 
956  // draw pixmap itens
957  ImageItem* pi = dynamic_cast<ImageItem*>(ai);
958  QRect r(pi->getRect());
959  QRect dr(m_display->rect());
960  if (dr.intersects(r))
961  {
962  pi->loadCurrentImage();
963  pi->drawCurrentImage(painter);
964  }
965  }
966  }
967  }
968 
969  if(m_animationScene->m_numberOfTrajectories) // has trajectories
970  {
971  // is there any trajectory in the current time?
972  for (it = list.begin(); it != list.end(); ++it)
973  {
974  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
975  if (ai->pixmap().isNull() == false)
976  {
977  // draw only the items that are within the time frame
978  TrajectoryItem* ti = dynamic_cast<TrajectoryItem*>(ai);
979  te::dt::TimeInstant tini = ti->m_animationTime.first();
980  te::dt::TimeInstant tfim = ti->m_animationTime.last();
981  if (t > tini || t < tfim)
982  break; // yes
983  }
984  }
985  if (it != list.end())
986  {
987  // draw trail trajectories
988  m_animationScene->m_mutex.lock();
989  QPixmap* pixt = (dynamic_cast<AnimationScene*>(m_animationScene))->m_trajectoryPixmap;
990  painter->drawPixmap(0, 0, *pixt);
991  m_animationScene->m_mutex.unlock();
992 
993  // draw icon trajectories
994  for(it = list.begin(); it != list.end(); ++it)
995  {
996  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
997  if(ai->pixmap().isNull() == false)
998  {
999  // draw only the items that are within the time frame
1000  TrajectoryItem* ti = dynamic_cast<TrajectoryItem*>(ai);
1001  te::dt::TimeInstant tini = ti->m_animationTime.first();
1002  te::dt::TimeInstant tfim = ti->m_animationTime.last();
1003  if(t < tini || t > tfim)
1004  continue;
1005 
1006  ti->drawIcon(painter);
1007  }
1008  }
1009  }
1010  }
1011 
1012  updateSliderPos();
1013 }
1014 
1016 {
1017  m_goAndBack = v;
1018  m_comingBack = !v;
1019 }
1020 
1021 void te::qt::widgets::TimeSliderWidget::setDirection(const QAbstractAnimation::Direction& direction)
1022 {
1023  m_direction = direction;
1024  m_parallelAnimation->setDirection(m_direction);
1025 
1026  unsigned int count = m_parallelAnimation->animationCount();
1027  for(unsigned int i = 0; i < count; ++i)
1028  {
1029  QPropertyAnimation* a = dynamic_cast<QPropertyAnimation*>(m_parallelAnimation->animationAt(i));
1030  AnimationItem* ai = dynamic_cast<AnimationItem*>(a->targetObject());
1032  ai->setDuration(m_duration);
1033  }
1034 }
1035 
1036 void te::qt::widgets::TimeSliderWidget::setDuration(const unsigned int& duration)
1037 {
1038  m_animationScene->setDuration(duration);
1039 }
1040 
1042 {
1044 }
1045 
1047 {
1050 }
1051 
1053 {
1054  double ss = m_spd->m_ui->m_panFactorDoubleSpinBox->singleStep();
1055  if (ss == .1)
1056  v = (double)((int)(v * 10. + .5)) / 10.;
1057  else if (ss == .01)
1058  v = (double)((int)(v * 100. + .5)) / 100.;
1059  else
1060  v = (double)((int)(v * 1000. + .5)) / 1000.;
1061 
1062  if (v <= 0)
1063  {
1064  if (m_panFactor >= .1 && m_panFactor <= .5)
1065  {
1066  m_panFactor = .09;
1067  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.01);
1068  }
1069  else if (m_panFactor >= .01 && m_panFactor < .1)
1070  {
1071  m_panFactor = .009;
1072  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.001);
1073  }
1074  m_spd->m_ui->m_panFactorDoubleSpinBox->setValue(m_panFactor);
1075  }
1076  else
1077  {
1078  if (m_panFactor >= .1 && v <= .5)
1079  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.1);
1080  else if (v >= .01 && v < .1)
1081  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.01);
1082  else
1083  m_spd->m_ui->m_panFactorDoubleSpinBox->setSingleStep(.001);
1084 
1085  if (v < m_panFactor)
1086  m_panFactor -= ss;
1087  else if (v > m_panFactor)
1088  m_panFactor += ss;
1089  else
1090  return;
1091 
1092  if (ss == .1)
1093  m_panFactor = (double)((int)(m_panFactor * 10. + .5)) / 10.;
1094  else if (ss == .01)
1095  m_panFactor = (double)((int)(m_panFactor * 100. + .5)) / 100.;
1096  else
1097  m_panFactor = (double)((int)(m_panFactor * 1000. + .5)) / 1000.;
1098 
1099  m_spd->m_ui->m_panFactorDoubleSpinBox->setValue(m_panFactor);
1100  }
1101 
1102  QList<QGraphicsItem*> list = m_animationScene->items();
1103  QList<QGraphicsItem*>::iterator it;
1104  for(it = list.begin(); it != list.end(); ++it)
1105  {
1106  AnimationItem* ai = dynamic_cast<AnimationItem*>(*it);
1107  ai->m_panFactor = m_panFactor;
1108  }
1109 }
1110 
1112 {
1113  if(m_animationScene->items().isEmpty())
1114  return QObject::eventFilter(obj, e);
1115 
1116  te::qt::widgets::TrajectoryItem* ti = nullptr;
1117  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
1118  QString id = m_animationIdList.value(ind);
1119 
1120  QList<QGraphicsItem*> list = m_animationScene->items();
1121  QList<QGraphicsItem*>::iterator it;
1122 
1123  for (it = list.begin(); it != list.end(); ++it)
1124  {
1126  if (ai->pixmap().isNull() == false)
1127  {
1128  ti = dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai);
1129  if (ti->m_layerId == id)
1130  break;
1131  }
1132  }
1133 
1134  te::qt::widgets::ImageItem* ii = nullptr;
1135  for (it = list.begin(); it != list.end(); ++it)
1136  {
1138  if (ai->pixmap().isNull())
1139  {
1140  ii = dynamic_cast<te::qt::widgets::ImageItem*>(ai);
1141  if (ii->m_dir.absolutePath() == id)
1142  break;
1143  }
1144  }
1145 
1146  if(obj == m_spd->m_ui->m_forwardColorPushButton)
1147  {
1148  if(e->type() == QEvent::Paint)
1149  {
1150  QPainter painter(m_spd->m_ui->m_forwardColorPushButton);
1151  QBrush brush(m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window));
1152  painter.fillRect(m_spd->m_ui->m_forwardColorPushButton->rect(), brush);
1153  return true;
1154  }
1155  else if(e->type() == QEvent::MouseButtonPress)
1156  {
1157  QColor cor = QColorDialog::getColor(m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window), this, "Forward Color", QColorDialog::ShowAlphaChannel);
1158  if(cor.isValid() == false)
1159  return true;
1160  else if(cor == m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window))
1161  return true;
1162 
1163  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(cor));
1164 
1165  if(ti != nullptr)
1166  ti->m_forwardColor = cor;
1167  return true;
1168  }
1169  }
1170  else if(obj == m_spd->m_ui->m_backwardColorPushButton)
1171  {
1172  if(e->type() == QEvent::Paint)
1173  {
1174  QPainter painter(m_spd->m_ui->m_backwardColorPushButton);
1175  QBrush brush(m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window));
1176  painter.fillRect(m_spd->m_ui->m_backwardColorPushButton->rect(), brush);
1177  return true;
1178  }
1179  else if(e->type() == QEvent::MouseButtonPress)
1180  {
1181  QColor cor = QColorDialog::getColor(m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window), this, "Forward Color", QColorDialog::ShowAlphaChannel);
1182  if(cor.isValid() == false)
1183  return true;
1184  else if(cor == m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window))
1185  return true;
1186 
1187  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(cor));
1188 
1189  if(ti != nullptr)
1190  ti->m_backwardColor = cor;
1191  return true;
1192  }
1193  }
1194  else if(ti != nullptr && obj == m_spd->m_ui->m_iconPushButton)
1195  {
1196  if(e->type() == QEvent::Paint)
1197  {
1198  QPainter painter(m_spd->m_ui->m_iconPushButton);
1199  painter.fillRect(m_spd->m_ui->m_iconPushButton->rect(), QBrush(Qt::white));
1200  QPixmap pix = ti->pixmap();
1201  QRect r = pix.rect();
1202  r.moveCenter(m_spd->m_ui->m_iconPushButton->rect().center());
1203  painter.drawPixmap(r, pix, pix.rect());
1204  painter.end();
1205  return true;
1206  }
1207  else if(e->type() == QEvent::MouseButtonPress)
1208  {
1209  QString fileName = QFileDialog::getOpenFileName(this, tr("Select File"), "C:/", tr("Images (*.png *.xpm *.jpg *.gif)"));
1210  if(fileName.isNull())
1211  return true;
1212 
1213  QPixmap pix(fileName);
1214  if(pix.isNull())
1215  {
1216  QMessageBox::information(this, "Pixmap Error", "Invalid File");
1217  return true;
1218  }
1219  QPixmap pp(ti->m_iconSize);
1220  pp.fill(Qt::transparent);
1221  QPainter painter(&pp);
1222  painter.drawPixmap(pp.rect(), pix, pix.rect());
1223  painter.end();
1224  ti->m_iconFile = fileName;
1225  ti->setPixmap(pp);
1226  ti->m_iconSize = pp.size();
1227  m_spd->m_ui->m_iconPushButton->update();
1228  return true;
1229  }
1230  }
1231  else if(obj == m_ui->m_dateTimeEdit)
1232  {
1233  if(e->type() == QEvent::MouseButtonRelease)
1234  {
1235  QDateTime d = m_ui->m_dateTimeEdit->dateTime();
1237  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1238  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1239 
1241  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1242  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1243  if(d <= minimum)
1244  d = minimum;
1245  else if(d >= maximun)
1246  d = maximun;
1247  else if(d == m_oldQDateTime)
1248  d = fixDateTimeEdit(m_ui->m_dateTimeEdit, d);
1249 
1250  m_ui->m_dateTimeEdit->setDateTime(d);
1251  m_oldQDateTime = d;
1252 
1253  if(d == minimum)
1255  return false;
1256  }
1257  }
1258  else if(obj == m_spd->m_ui->m_initialAnimationDateTimeEdit)
1259  {
1260  if(e->type() == QEvent::MouseButtonRelease)
1261  {
1262  QDateTime d = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
1264  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1265  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1266 
1268  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1269  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1270  if(d <= minimum)
1271  d = minimum;
1272  else if(d >= maximun)
1273  d = maximun;
1274  else if(d == m_oldQDateTime)
1275  d = fixDateTimeEdit(m_spd->m_ui->m_initialAnimationDateTimeEdit, d);
1276 
1277  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(d);
1278  m_oldQDateTime = d;
1279  return false;
1280  }
1281  }
1282  else if(obj == m_spd->m_ui->m_finalAnimationDateTimeEdit)
1283  {
1284  if(e->type() == QEvent::MouseButtonRelease)
1285  {
1286  QDateTime d = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
1288  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1289  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1290 
1292  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1293  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1294  if(d <= minimum)
1295  d = minimum;
1296  else if(d >= maximun)
1297  d = maximun;
1298  else if(d == m_oldQDateTime)
1299  d = fixDateTimeEdit(m_spd->m_ui->m_finalAnimationDateTimeEdit, d);
1300 
1301  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(d);
1302  m_oldQDateTime = d;
1303  return false;
1304  }
1305  }
1306 
1307  return QObject::eventFilter(obj, e);
1308 }
1309 
1311 {
1312  if(m_spd->isHidden())
1313  m_spd->show();
1314  else
1315  m_spd->hide();
1316 }
1317 
1319 {
1320  if(m_animationScene->items().isEmpty())
1321  return;
1322 
1323  int state = m_parallelAnimation->state();
1324  if(state == QAbstractAnimation::Running)
1325  {
1326  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
1327  m_parallelAnimation->pause();
1328  m_ui->m_dateTimeEdit->setEnabled(true);
1329  m_paused = true;
1330  }
1331  else
1332  {
1333  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-pause"));
1334  if(m_comingBack == false)
1335  {
1336  if(m_spd->m_ui->m_forwardRadioButton->isChecked())
1338  if(m_spd->m_ui->m_backwardRadioButton->isChecked())
1340  }
1341  if(m_spd->m_ui->m_loopCheckBox->isChecked())
1342  onLoopCheckBoxClicked(true);
1343  if(m_spd->m_ui->m_goAndBackCheckBox->isChecked())
1345 
1346  if(m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1347  {
1348  if(m_ui->m_TemporalHorizontalSlider->value() == m_maxSliderValue)
1349  {
1350  m_parallelAnimation->setCurrentTime(0);
1351  m_ui->m_TemporalHorizontalSlider->setValue(0);
1352  }
1353  }
1354  else
1355  {
1356  if(m_ui->m_TemporalHorizontalSlider->value() == 0)
1357  {
1358  m_parallelAnimation->setCurrentTime(m_duration);
1359  m_ui->m_TemporalHorizontalSlider->setValue(m_maxSliderValue);
1360  }
1361  }
1362  m_ui->m_dateTimeEdit->setEnabled(false);
1363  m_paused = false;
1364  play();
1365  }
1366 }
1367 
1369 {
1370  if(m_animationScene->items().isEmpty())
1371  return;
1372 
1373  m_parallelAnimation->stop();
1374  m_ui->m_dateTimeEdit->setEnabled(false);
1375  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
1376 
1377  if(m_goAndBack)
1378  {
1379  if(m_comingBack)
1380  {
1381  changeDirection();
1382  m_comingBack = false;
1383  }
1384  }
1385 
1386  if(m_finished == false)
1387  {
1388  if(m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1389  {
1390  m_ui->m_TemporalHorizontalSlider->setValue(0);
1391  m_parallelAnimation->setCurrentTime(0);
1392  }
1393  else
1394  {
1395  m_ui->m_TemporalHorizontalSlider->setValue(m_maxSliderValue);
1396  m_parallelAnimation->setCurrentTime(m_parallelAnimation->duration());
1397  }
1398  updateSliderPos();
1399  m_display->update();
1400  }
1401  m_finished = false;
1402 }
1403 
1405 {
1406  int state = m_parallelAnimation->state();
1407  if(state == QAbstractAnimation::Running)
1408  {
1409  m_parallelAnimation->pause();
1410  draw();
1411  m_parallelAnimation->resume();
1412  }
1413  else
1414  {
1415  draw();
1416  }
1417 }
1418 
1420 {
1421  int state = m_parallelAnimation->state();
1422  if(state == QAbstractAnimation::Running)
1423  {
1425  createAnimations();
1426  draw();
1427  m_display->update();
1428  m_parallelAnimation->start();
1429  }
1430  else
1431  {
1433  createAnimations();
1434  draw();
1435  m_display->update();
1436  }
1437 }
1438 
1440 {
1441  if(m_animationScene->items().isEmpty())
1442  return;
1443 
1444  int state = m_parallelAnimation->state();
1445  if(state == QAbstractAnimation::Stopped)
1446  {
1447  createNewPixmap();
1448  m_parallelAnimation->start();
1449  }
1450  else if(state == QAbstractAnimation::Paused)
1451  {
1452  m_parallelAnimation->resume();
1453  }
1454 }
1455 
1457 {
1458  int oldCurTime = m_parallelAnimation->currentTime();
1459 
1460  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
1461  {
1463  return;
1464  }
1465 
1466  double v = (double)value / (double)m_maxSliderValue;
1467 
1468  int curTime = qRound(v * (double)m_parallelAnimation->duration());
1469 
1470  if(curTime >= m_parallelAnimation->duration())
1471  curTime = m_parallelAnimation->duration();
1472 
1473  bool erase = false;
1474  if(m_goAndBack == true)
1475  {
1476  if(m_comingBack == false && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1477  erase = true;
1478  else if(m_comingBack == false && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1479  erase = true;
1480  else if(m_comingBack == true && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1481  erase = true;
1482  else if(m_comingBack == true && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1483  erase = true;
1484  }
1485  else
1486  {
1487  if(m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1488  erase = true;
1489  else if(m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1490  erase = true;
1491  }
1492 
1493  m_parallelAnimation->setCurrentTime(curTime);
1494  if(erase)
1495  this->erase(curTime);
1496 
1497  m_currentTime = curTime;
1498 
1499  if(m_currentTime == 0 || m_currentTime == m_parallelAnimation->duration())
1501 
1502  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
1503  m_display->update();
1504 
1505  te::dt::TimeInstant tinstant = getTimeInstant();
1506  QDate qdate(tinstant.getDate().getYear(), tinstant.getDate().getMonth(), tinstant.getDate().getDay());
1507  QTime qtime(tinstant.getTime().getHours(), tinstant.getTime().getMinutes(), tinstant.getTime().getSeconds());
1508  QDateTime qdatetime(qdate, qtime);
1509  m_ui->m_dateTimeEdit->setDateTime(qdatetime);
1510 }
1511 
1513 {
1514  QAbstractAnimation::Direction direction = m_parallelAnimation->direction();
1515  if(direction == QAbstractAnimation::Forward)
1516  direction = QAbstractAnimation::Backward;
1517  else
1518  direction = QAbstractAnimation::Forward;
1519  setDirection(direction);
1520 }
1521 
1523 {
1524  if(m_paused)
1525  {
1526  if(m_currentTime >= m_duration && m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1527  {
1529  changeDirection();
1530  m_comingBack = true;
1531  m_parallelAnimation->setCurrentTime(m_currentTime);
1532  }
1533  else if(m_currentTime <= 0 && m_parallelAnimation->direction() == QAbstractAnimation::Backward)
1534  {
1535  m_currentTime = 0;
1536  changeDirection();
1537  m_comingBack = false;
1538  m_parallelAnimation->setCurrentTime(m_currentTime);
1539  }
1540  play();
1541  m_parallelAnimation->pause();
1542  updateSliderPos();
1543  return;
1544  }
1545 
1546  m_finished = true;
1547  if(m_goAndBack)
1548  {
1549  changeDirection();
1551  if(m_comingBack)
1552  {
1553  play();
1554  updateSliderPos();
1555  return;
1556  }
1557 
1558  if(m_loop)
1559  {
1560  m_currentTime = 0;
1561  m_parallelAnimation->setCurrentTime(m_currentTime);
1562  play();
1563  }
1564  else
1565  {
1566  if(m_comingBack == false)
1568  }
1569  }
1570  else
1571  {
1572  if(m_loop)
1573  {
1574  play();
1575  }
1576  else
1578  }
1579 }
1580 
1582 {
1583  m_currentTime = m_parallelAnimation->currentTime();
1584  int v = qRound((double)m_maxSliderValue * (double)m_currentTime/(double)m_duration);
1585 
1586  m_ui->m_TemporalHorizontalSlider->setValue(v);
1587 
1589 }
1590 
1592 {
1593  if(m_ui->m_dateTimeEdit->isEnabled() == false && m_animationScene->items().isEmpty() == false)
1594  {
1595  te::dt::TimeInstant tinstant = getTimeInstant();
1596  QDate qdate(tinstant.getDate().getYear(), tinstant.getDate().getMonth(), tinstant.getDate().getDay());
1597  QTime qtime(tinstant.getTime().getHours(), tinstant.getTime().getMinutes(), tinstant.getTime().getSeconds());
1598  QDateTime qdatetime(qdate, qtime);
1599  m_ui->m_dateTimeEdit->setDateTime(qdatetime);
1600  }
1601 }
1602 
1604 {
1605  emit deleteTimeSliderWidget();
1606 }
1607 
1609 {
1610  int state = m_parallelAnimation->state();
1611  if(state == QAbstractAnimation::Running)
1613 
1614  QList<QGraphicsItem*> list = m_animationScene->items(Qt::AscendingOrder); // get a copy of animation list
1615  int i = list.indexOf(item);
1616  list.takeAt(i);
1617  list.prepend(item); // put to last item
1618 
1619  // remove all animations of the scene
1620  QList<QGraphicsItem*>::iterator it = list.begin();
1621  while(it != list.end())
1622  {
1625  }
1626 
1627  // reinicialiaze the scene in correct order
1628  while(list.isEmpty() == false)
1629  {
1630  te::qt::widgets::AnimationItem* ai = dynamic_cast<te::qt::widgets::AnimationItem*>(list.takeFirst());
1632  }
1633 
1635 }
1636 
1638 {
1639  int state = m_parallelAnimation->state();
1640  if(state == QAbstractAnimation::Running)
1642 
1643  QList<QGraphicsItem*> list = m_animationScene->items(Qt::AscendingOrder);
1644  int i = list.indexOf(item);
1645  list.takeAt(i);
1646  list.append(item); // put to first item
1647 
1648  // remove all animations of the scene
1649  QList<QGraphicsItem*>::iterator it = list.begin();
1650  while(it != list.end())
1651  {
1654  }
1655 
1656  // reinicialiaze the scene in correct order
1657  while (list.isEmpty() == false)
1658  {
1659  te::qt::widgets::AnimationItem* ai = dynamic_cast<te::qt::widgets::AnimationItem*>(list.takeFirst());
1661  }
1662 
1664 }
1665 
1667 {
1668  te::qt::widgets::TrajectoryItem* ti = nullptr;
1669  te::qt::widgets::ImageItem* ii = nullptr;
1670  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
1671  QString id = m_animationIdList.value(ind);
1672 
1673  QList<QGraphicsItem*> list = m_animationScene->items();
1674  QList<QGraphicsItem*>::iterator it;
1675 
1676  for (it = list.begin(); it != list.end(); ++it)
1677  {
1679  if (ai->pixmap().isNull() == false)
1680  {
1681  ti = dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai);
1682  if (ti->m_layerId == id)
1683  {
1684  putToFront(ai);
1685  break;
1686  }
1687  }
1688  else
1689  {
1690  ii = dynamic_cast<te::qt::widgets::ImageItem*>(ai);
1691  if (ii->m_dir.absolutePath() == id)
1692  {
1693  putToFront(ai);
1694  break;
1695  }
1696  }
1697  }
1698 }
1699 
1701 {
1702  te::qt::widgets::TrajectoryItem* ti = nullptr;
1703  te::qt::widgets::ImageItem* ii = nullptr;
1704  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
1705  QString id = m_animationIdList.value(ind);
1706 
1707  QList<QGraphicsItem*> list = m_animationScene->items();
1708  QList<QGraphicsItem*>::iterator it;
1709 
1710  for (it = list.begin(); it != list.end(); ++it)
1711  {
1713  if (ai->pixmap().isNull() == false)
1714  {
1715  ti = dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai);
1716  if (ti->m_layerId == id)
1717  {
1718  putToBack(ai);
1719  break;
1720  }
1721  }
1722  else
1723  {
1724  ii = dynamic_cast<te::qt::widgets::ImageItem*>(ai);
1725  if (ii->m_dir.absolutePath() == id)
1726  {
1727  putToBack(ai);
1728  break;
1729  }
1730  }
1731  }
1732 }
1733 
1734 void te::qt::widgets::TimeSliderWidget::erase(const unsigned int& curTime)
1735 {
1736  QList<QGraphicsItem*> list = m_animationScene->items();
1737  QList<QGraphicsItem*>::iterator it;
1738  for(it = list.begin(); it != list.end(); ++it)
1739  {
1741  if(ai->pixmap().isNull() == false)
1742  (dynamic_cast<te::qt::widgets::TrajectoryItem*>(ai))->m_erasePerfectly = m_erasePerfectly;
1743  }
1744 
1745  if(m_erasePerfectly)
1746  {
1747  m_parallelAnimation->setCurrentTime(curTime);
1748  draw();
1749  }
1750  else
1751  m_parallelAnimation->setCurrentTime(curTime);
1752 
1753  m_currentTime = curTime;
1754 }
1755 
1757 {
1758  m_currentTime = m_parallelAnimation->currentTime();
1759  double relativeTimePos = double(m_currentTime) / (double)m_duration;
1760 
1761  int ss = m_ui->m_durationSpinBox->singleStep();
1762  int nss = ss;
1763  if (m_duration == ss) // incremented or decremented by mouse (special cases)
1764  {
1765  if (val < m_duration)
1766  {
1767  nss = ss / 10;
1768  m_duration -= nss;
1769  }
1770  else
1771  m_duration += nss;
1772  }
1773  else if (val == m_duration + ss || val == m_duration - ss) // incremented or decremented by mouse
1774  {
1775  nss = (int)log10((double)val);
1776  nss = (int)pow(10., (double)nss);
1777  if ((val % nss) == 0)
1778  m_duration = val;
1779  else
1780  {
1781  m_duration = nss * (int)(m_duration / nss);
1782  if (val > m_duration)
1783  m_duration += nss;
1784  }
1785  }
1786  else // edited by keyboard
1787  {
1788  nss = (int)log10((double)val);
1789  nss = (int)pow(10., (double)nss);
1790  m_duration = val;
1791  }
1792 
1793  if (m_duration <= m_ui->m_durationSpinBox->minimum())
1794  {
1795  m_duration = m_ui->m_durationSpinBox->minimum();
1796  nss = m_ui->m_durationSpinBox->minimum();
1797  }
1798  else if (m_duration >= m_ui->m_durationSpinBox->maximum())
1799  {
1800  m_duration = m_ui->m_durationSpinBox->maximum();
1801  nss = m_ui->m_durationSpinBox->maximum() / 10;
1802  }
1803 
1804  m_ui->m_durationSpinBox->setSingleStep(nss);
1805  m_ui->m_durationSpinBox->setValue(m_duration);
1806 
1807  bool running = false;
1808  if (m_parallelAnimation->state() == QAbstractAnimation::Running)
1809  {
1810  running = true;;
1812  }
1813 
1814  m_currentTime = qRound(relativeTimePos * (double)m_duration);
1815  m_animationScene->m_mutex.lock();
1816  m_animationScene->m_trajectoryPixmap->fill(Qt::transparent);
1817  m_animationScene->m_mutex.unlock();
1818  setDuration(m_duration);
1819  m_parallelAnimation->setCurrentTime(m_currentTime);
1820  draw();
1821  if (running)
1823 }
1824 
1826 {
1827  if(m_ui->m_dateTimeEdit->isEnabled() == false)
1828  return;
1829 
1830  QDateTime t(qdt);
1831  int oldCurTime = m_parallelAnimation->currentTime();
1832 
1834  unsigned long totalSecs = m_temporalAnimationExtent.getTimePeriod().length().total_seconds();
1835 
1836  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
1837  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
1838  te::dt::TimeInstant time(date, duration);
1839 
1840  te::dt::TimePeriod tp(tini, time);
1841  unsigned long secs = tp.getTimePeriod().length().total_seconds();
1842 
1843  double v = (double)secs / (double)totalSecs;
1844  int curTime = qRound(v * (double)m_parallelAnimation->duration());
1845 
1846  if(curTime > m_parallelAnimation->duration())
1847  curTime = m_parallelAnimation->duration();
1848 
1849  bool erase = false;
1850  if(m_goAndBack == true)
1851  {
1852  if(m_comingBack == false && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1853  erase = true;
1854  else if(m_comingBack == false && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1855  erase = true;
1856  else if(m_comingBack == true && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1857  erase = true;
1858  else if(m_comingBack == true && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1859  erase = true;
1860  }
1861  else
1862  {
1863  if(m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1864  erase = true;
1865  else if(m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1866  erase = true;
1867  }
1868 
1869  m_currentTime = curTime;
1870  m_parallelAnimation->setCurrentTime(curTime);
1871  if(erase)
1872  this->erase(curTime);
1873 
1874  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
1875  m_display->update();
1876 }
1877 
1878 QDateTime te::qt::widgets::TimeSliderWidget::fixDateTimeEdit(QDateTimeEdit* dte, const QDateTime& qdt)
1879 {
1880  QDateTime t(qdt);
1881  QDateTimeEdit::Section section = dte->currentSection();
1882  if(section == QDateTimeEdit::SecondSection)
1883  {
1884  int sec = t.time().second();
1885  if(sec == 0)
1886  t = t.addSecs(-1);
1887  else
1888  t = t.addSecs(1);
1889  }
1890  else if(section == QDateTimeEdit::MinuteSection)
1891  {
1892  int min = t.time().minute();
1893  if(min == 0)
1894  t = t.addSecs(-60);
1895  else
1896  t = t.addSecs(60);
1897  }
1898  else if(section == QDateTimeEdit::HourSection)
1899  {
1900  int hour = t.time().hour();
1901  if(hour == 0)
1902  t = t.addSecs(-3600);
1903  else
1904  t = t.addSecs(3600);
1905  }
1906  else if(section == QDateTimeEdit::DaySection)
1907  {
1908  int day = t.date().day();
1909  if(day == 1)
1910  t = t.addDays(-1);
1911  else
1912  t = t.addDays(1);
1913  }
1914  else if(section == QDateTimeEdit::MonthSection)
1915  {
1916  int month = t.date().month();
1917  if(month == 1)
1918  t = t.addMonths(-1);
1919  else
1920  t = t.addMonths(1);
1921  }
1922 
1923  return t;
1924 }
1925 
1927 {
1928  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
1929  QString id = m_animationIdList.value(ind);
1930 
1931  QList<QGraphicsItem*> list = m_animationScene->items();
1932  QList<QGraphicsItem*>::iterator it;
1933 
1934  te::qt::widgets::AnimationItem* ai = nullptr;
1935  for (it = list.begin(); it != list.end(); ++it)
1936  {
1937  ai = dynamic_cast<AnimationItem*>(*it);
1938  if (ai->pixmap().isNull())
1939  {
1940  te::qt::widgets::ImageItem* ii = dynamic_cast<te::qt::widgets::ImageItem*>(ai);
1941  if (ii->m_dir.absolutePath() == id)
1942  break;
1943  }
1944  else
1945  {
1947  if (ti->m_layerId == id)
1948  break;
1949  }
1950  }
1951  if (it != list.end())
1952  {
1953  ai->m_opacity = v;
1954  m_display->update();
1955  }
1956 }
1957 
1959 {
1960  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
1961  QString id = m_animationIdList.value(ind);
1962 
1963  QList<QGraphicsItem*> list = m_animationScene->items();
1964  QList<QGraphicsItem*>::iterator it;
1965 
1966  for (it = list.begin(); it != list.end(); ++it)
1967  {
1969  if (ai->pixmap().isNull() == false)
1970  {
1972  if (ti->m_layerId == id)
1973  {
1974  QPixmap pix = ai->pixmap();
1975  QPixmap pn(m_spd->m_ui->m_widthSpinBox->value(), m_spd->m_ui->m_heightSpinBox->value());
1976  pn.fill(Qt::transparent);
1977  if (pix.isNull() == false)
1978  {
1980  QString file = ti->m_iconFile;
1981  if (file.isEmpty() == false)
1982  {
1983  QFile f(file);
1984  if (f.exists())
1985  {
1986  QPixmap pf(file);
1987  QPainter painter(&pn);
1988  painter.drawPixmap(pn.rect(), pf, pf.rect());
1989  painter.end();
1990  ti->setPixmap(pn);
1991  ti->m_iconSize = pn.size();
1992  m_spd->m_ui->m_iconPushButton->update();
1993  m_display->update();
1994  break;
1995  }
1996  }
1997 
1998  QPainter painter(&pn);
1999  QBrush b(Qt::red);
2000  painter.setBrush(b);
2001  QPen p(Qt::red);
2002  painter.setPen(p);
2003  painter.drawEllipse(pn.rect());
2004  painter.end();
2005  m_spd->m_ui->m_iconPushButton->update();
2006  ti->setPixmap(pn);
2007  ti->m_iconSize = pn.size();
2008  }
2009  m_display->update();
2010  break;
2011  }
2012  }
2013  }
2014 }
2015 
2017 {
2019  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
2020  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
2021  QDateTime qdatetimei(qdatei, qtimei);
2022  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetimei);
2023 
2025  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
2026  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
2027  QDateTime qdatetimef(qdatef, qtimef);
2028  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetimef);
2029 
2030  if(m_direction == QAbstractAnimation::Forward)
2031  {
2032  if(m_spd->m_ui->m_forwardRadioButton->isChecked() == false)
2033  m_spd->m_ui->m_forwardRadioButton->toggle();
2034  }
2035 
2036  if(m_loop)
2037  m_spd->m_ui->m_loopCheckBox->setChecked(true);
2038  if(m_goAndBack)
2039  m_spd->m_ui->m_goAndBackCheckBox->setChecked(true);
2040 
2041  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
2043 }
2044 
2046 {
2047  QDateTime t = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2048  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
2049  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
2050  te::dt::TimeInstant time(date, duration);
2051  return time;
2052 }
2053 
2055 {
2056  QDateTime t = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2057  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
2058  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
2059  te::dt::TimeInstant time(date, duration);
2060  return time;
2061 }
2062 
2064 {
2066  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2067  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2068  QDateTime qdatetime(qdate, qtime);
2069  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetime);
2070 }
2071 
2073 {
2075  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2076  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2077  QDateTime qdatetime(qdate, qtime);
2078  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetime);
2079 }
2080 
2082 {
2083  if(b==false && m_spd->m_ui->m_propertyWidget->isHidden())
2084  return;
2085  if(b==true && m_spd->m_ui->m_propertyWidget->isHidden()==false)
2086  return;
2087 
2088  int h = m_spd->m_ui->m_propertyWidget->height();
2089 
2090  if(b == false)
2091  {
2092  m_spd->m_ui->m_propertyWidget->hide();
2093  resize(width(), height()-h);
2094  }
2095  else
2096  {
2097  m_spd->m_ui->m_propertyWidget->show();
2098  resize(width(), height()+h);
2099  }
2100 }
2101 
2103 {
2105  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
2106  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
2107  QDateTime qdatetimei(qdatei, qtimei);
2108  QDateTime qdi = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2109  if(qdatetimei != qdi)
2110  return true;
2111 
2113  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
2114  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
2115  QDateTime qdatetimef(qdatef, qtimef);
2116  QDateTime qdf = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2117  if(qdatetimef != qdf)
2118  return true;
2119 
2120  if(m_spd->m_ui->m_forwardRadioButton->isChecked() && m_direction != QAbstractAnimation::Forward)
2121  return true;
2122  if(m_spd->m_ui->m_forwardRadioButton->isChecked() == false && m_direction != QAbstractAnimation::Backward)
2123  return true;
2124  if(m_spd->m_ui->m_loopCheckBox->isChecked() != m_loop)
2125  return true;
2126  if(m_spd->m_ui->m_goAndBackCheckBox->isChecked() != m_goAndBack)
2127  return true;
2128 
2129  return false;
2130 }
2131 
2133 {
2134  if(m_direction == QAbstractAnimation::Forward)
2135  {
2136  if(m_comingBack)
2137  m_comingBack = false;
2138  }
2139  else
2140  changeDirection();
2141 }
2142 
2144 {
2145  if(m_direction == QAbstractAnimation::Backward)
2146  {
2147  if(m_comingBack)
2148  m_comingBack = false;
2149  }
2150  else
2151  changeDirection();
2152 }
2153 
2155 {
2156  m_loop = b;
2157 }
2158 
2160 {
2161  if(m_goAndBack != b)
2162  {
2163  if(m_comingBack)
2164  {
2165  changeDirection();
2166  m_comingBack = false;
2167  }
2168  }
2169 
2170  m_goAndBack = b;
2171 }
2172 
2174  bool /*b*/)
2175 {
2178  if(ti > tf || ti == tf)
2179  {
2180  QMessageBox::warning(this, "Time Extent Error", "Initial time can not be larger than the end time!", QMessageBox::Ok);
2181  return;
2182  }
2183 
2185  boost::posix_time::ptime btinst = tinst.getTimeInstant();
2186 
2188  QDate qdatei(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2189  QTime qtimei(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2190  QDateTime qdatetimei(qdatei, qtimei);
2191  QDateTime qdi = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2192  boost::posix_time::ptime iTime = t.getTimeInstant();
2193 
2195  QDate qdatef(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2196  QTime qtimef(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2197  QDateTime qdatetimef(qdatef, qtimef);
2198  QDateTime qdf = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2199  boost::posix_time::ptime fTime = t.getTimeInstant();
2200  if(qdatetimei == qdi && qdatetimef == qdf)
2201  return;
2202 
2203  boost::posix_time::ptime niTime = ti.getTimeInstant();
2204  boost::posix_time::ptime nfTime = tf.getTimeInstant();
2205  boost::posix_time::time_duration ndiff = nfTime - niTime;
2206  double ntotalSeconds = ndiff.total_seconds();
2207 
2208  boost::posix_time::time_duration diff = fTime - iTime;
2209  double totalSeconds = diff.total_seconds();
2210  double rel = m_duration / totalSeconds;
2211 
2212  int nduration = qRound(rel * ntotalSeconds);
2213 
2214  m_currentTime = 0;
2215  if(btinst >= niTime && btinst <= nfTime)
2216  {
2217  boost::posix_time::time_duration d = btinst - niTime;
2218  double tot = d.total_seconds();
2219  m_currentTime = qRound(nduration * tot / ntotalSeconds);
2220  }
2221  else
2222  m_currentTime = nduration;
2223 
2224  int state = m_parallelAnimation->state();
2225  if(state == QAbstractAnimation::Running)
2227 
2228  QDateTime dt = m_ui->m_dateTimeEdit->dateTime();
2230 
2232 
2233  createNewPixmap();
2235  createAnimations();
2236  m_duration = nduration;
2237  m_ui->m_durationSpinBox->setValue(m_duration);
2240 
2241  if(state == QAbstractAnimation::Running)
2242  {
2244  m_parallelAnimation->setCurrentTime(m_currentTime);
2245  m_parallelAnimation->start();
2246  }
2247  else
2248  {
2249  m_parallelAnimation->setCurrentTime(m_currentTime);
2250  m_parallelAnimation->start();
2251  if(state == QAbstractAnimation::Paused)
2252  m_parallelAnimation->pause();
2253  }
2254 
2255  if (tp == m_temporalAnimationExtent)
2257  else
2258  {
2259  // calculate single step on duration spin box widget.
2260  int i = 1;
2261  while ((m_duration / i) > 10)
2262  i *= 10;
2263  m_ui->m_durationSpinBox->setSingleStep(i);
2264  }
2265 }
2266 
2268 {
2269  QString id = m_animationIdList.value(ind);
2270 
2271  QList<QGraphicsItem*> list = m_animationScene->items();
2272  QList<QGraphicsItem*>::iterator it;
2273 
2274  for (it = list.begin(); it != list.end(); ++it)
2275  {
2277  if (ai->pixmap().isNull() == false)
2278  {
2280  if (ti->m_layerId == id)
2281  {
2282  int op = ai->m_opacity;
2283  m_spd->m_ui->m_opacitySpinBox->setValue(op);
2284  te::dt::TimeInstant tini = ai->m_time.first();
2285  QString sini = getDateString(tini);
2286  te::dt::TimeInstant tfim = ai->m_time.last();
2287  QString sfim = getDateString(tfim);
2288  m_spd->m_ui->m_initialTimeLineEdit->setText(sini);
2289  m_spd->m_ui->m_finalTimeLineEdit->setText(sfim);
2290 
2292  break;
2293  }
2294  }
2295  }
2296 }
2297 
2299 {
2300  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2301  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2302  QDateTime qdatetime(qdate, qtime);
2303  return qdatetime.toString("dd/MMM/yyyy hh:mm:ss");
2304 }
2305 
2307 {
2308  QPixmap pix = ai->pixmap();
2309  if(pix.isNull()) // is temporal image
2310  {
2311  m_spd->m_ui->m_trajectoryGroupBox->setEnabled(false);
2312  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(Qt::gray));
2313  m_spd->m_ui->m_forwardColorPushButton->update();
2314  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(Qt::gray));
2315  m_spd->m_ui->m_backwardColorPushButton->update();
2316  m_spd->m_ui->m_autoPanCheckBox->setChecked(false);
2317  m_spd->m_ui->m_drawTrailCheckBox->setChecked(false);
2318  }
2319  else // is trajectory
2320  {
2321  m_spd->m_ui->m_trajectoryGroupBox->setEnabled(true);
2323  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(ti->m_forwardColor));
2324  m_spd->m_ui->m_forwardColorPushButton->update();
2325  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(ti->m_backwardColor));
2326  m_spd->m_ui->m_backwardColorPushButton->update();
2327  m_spd->m_ui->m_autoPanCheckBox->setChecked(ti->m_automaticPan);
2328  ti->m_panFactor = m_panFactor;
2329  m_spd->m_ui->m_drawTrailCheckBox->setChecked(ti->m_drawTrail);
2330 
2331  m_spd->m_ui->m_iconRotateCheckBox->setChecked(ti->m_doIconRotate);
2332  QPixmap pix = ti->pixmap();
2333  m_spd->m_ui->m_widthSpinBox->setValue(pix.width());
2334  m_spd->m_ui->m_heightSpinBox->setValue(pix.height());
2335  m_spd->m_ui->m_iconPushButton->update();
2336  }
2337 }
2338 
2340 {
2341  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
2342  QString id = m_animationIdList.value(ind);
2343 
2344  QList<QGraphicsItem*> list = m_animationScene->items();
2345  QList<QGraphicsItem*>::iterator it;
2346 
2347  for (it = list.begin(); it != list.end(); ++it)
2348  {
2350  if (ai->pixmap().isNull() == false)
2351  {
2353  if (ti->m_layerId == id)
2354  {
2355  ti->m_doIconRotate = b;
2356  break;
2357  }
2358  }
2359  }
2360 }
2361 
2363 {
2364  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
2365  QString id = m_animationIdList.value(ind);
2366 
2367  QList<QGraphicsItem*> list = m_animationScene->items();
2368  QList<QGraphicsItem*>::iterator it;
2369 
2370  for (it = list.begin(); it != list.end(); ++it)
2371  {
2373  if (ai->pixmap().isNull() == false)
2374  {
2376  if (ti->m_layerId == id)
2377  ai->m_automaticPan = b;
2378  else
2379  ai->m_automaticPan = !b;
2380  }
2381  }
2382 }
2383 
2385 {
2386  QDir dir(path);
2387  QString d = dir.dirName();
2388 
2389  te::qt::widgets::ImageItem* pi = nullptr;
2390  QString type(getTemporalImageType(path));
2391 
2392  if(type == "HIDRO_TYPE")
2393  pi = new te::qt::widgets::HidroItem(d, path, m_display);
2394  else if (type == "ETA5KM_TYPE")
2395  pi = new te::qt::widgets::Eta5kmItem(d, path, m_display);
2396  else if (type == "GOES_TYPE")
2397  pi = new te::qt::widgets::GoesItem(d, path, m_display);
2398  else if (type == "QTKNOW_TYPE")
2399  pi = new te::qt::widgets::QtKnowItem(d, path, m_display);
2400  // edit here to add a new temporal image type
2401 
2402  if (pi)
2403  {
2404  if (pi->loadData() == false)
2405  {
2406  delete pi;
2407  return nullptr;
2408  }
2409  }
2410  return pi;
2411 }
2412 
2414 {
2415  QDir dir(path);
2416  QString d = dir.dirName();
2417  QStringList nameFilter;
2418  nameFilter.append("*.ctl");
2419  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
2420  QString ctlFile = files.first();
2421 
2422  if (ctlFile == "racc.ctl")
2423  return "HIDRO_TYPE";
2424  else if (ctlFile == "Prec5km.ctl")
2425  return "ETA5KM_TYPE";
2426 
2427  files.clear();
2428  nameFilter.clear();
2429  nameFilter.append("S11*.jpg");
2430  files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
2431  if (files.empty() == false && files.first().length() == 26)
2432  return "GOES_TYPE";
2433  else
2434  return "QTKNOW_TYPE";
2435 
2436  // edit here to add a new temporal image.
2437  // you must find a way to discover its kind and return your type.
2438 
2439  return "";
2440 }
2441 
2443 {
2444  if (b)
2445  {
2447  show();
2448  }
2449  else
2450  {
2452  hide();
2453  }
2454 }
2455 
2457 {
2458 }
static te::dt::TimeDuration td(20, 30, 50, 11)
void addTemporalImages(const QString &filePath)
bool m_doIconRotate
do automatic icon rotate
Qt::KeyboardModifiers m_dropModifiers
Control pressed to add animation with drag and drop.
virtual const std::string & getId() const
It returns the layer id.
std::unique_ptr< te::st::TrajectoryDataSet > getTrajectoryDataset(te::common::TraverseType travType=te::common::FORWARDONLY) const
void onResetFinalTimePushButtonClicked()
Reset final time button clicked.
QParallelAnimationGroup * m_parallelAnimation
The parallel animation.
te::dt::TimePeriod m_temporalAnimationExtent
Animation temporal extent. It is used for show animation.
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 ...
void onFinishAnimation()
It takes the necessary measures after the end of the trajectory.
virtual void layerRemoved(te::map::AbstractLayerPtr layer)
This method is used to remove a layer.
void onBackwardRadioButtonClicked(bool b)
Backward radio button clicked.
virtual void drawCurrentImage(QPainter *p)
Get current image.
Definition: ImageItem.cpp:244
void addTrajectory(te::st::TrajectoryDataSetLayer *tl, const QString &pixmapFile)
Add trajectory to animation scene.
const te::dt::DateTimePeriod * getTemporalExtent() const
It returns the temporal extent of the trajectory observations.
void onDurationValueChanged(int v)
It takes the necessary steps after changing the duration.
void onDateTimeEditChanged(const QDateTime &t)
It takes the necessary steps after changing the current time of animation.
void onOpacityValueChanged(int v)
It takes the necessary steps after changing the duration.
te::gm::Envelope m_spatialExtent
Spatial extent.
void createAnimations()
Create animations.
void onSettingsToolButtonnClicked()
it opens the configuration window animation.
This is the base class for layers.
Definition: AbstractLayer.h:77
void drawIcon(QPainter *painter)
draw tracktrajectory icon.
void draw()
Set transformation matrix and draw current animation.
int getAnimationTime(const te::dt::TimeInstant &tinstant)
It it gets the animation time on a time instant. /param tinstant The time instant.
An item that contains a te::map::AbstractLayerPtr.
Definition: LayerItem.h:51
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
virtual const std::string & getTitle() const
It returns the layer title.
virtual const std::string & getType() const =0
It returns the layer type.
void onApplyTimeIntervalPushButtonClicked(bool b)
Apply time interval push button clicked.
QPixmap * m_trajectoryPixmap
QPixmap where all the trajectory item are drawn.
void onRemoveAllPushButtonClicked(bool)
Remove all animations.
void setDuration(const int &duration)
It sets the trajectory duration.
void onResetInitialTimePushButtonClicked()
Reset initial time button clicked.
QAbstractAnimation::Direction m_direction
QAbstractAnimation::Forward or QAbstractAnimation::Backward.
te::map::AbstractLayerPtr getLayer() const
Returns the layer contained in the item.
Definition: LayerItem.cpp:140
long getSeconds() const
It returns the seconds of a minute - from 0 to 59.
Definition: TimeDuration.h:105
void onRemovePushButtonClicked(bool)
Remove item animation.
void calculateAllTemporalExtent()
It calculates the temporal extent.
void addItem(AnimationItem *item)
Add item.
bool m_goAndBack
Forward and then backward direction.
te::gm::Envelope m_spatialExtent
Spatial extent.
Definition: Animation.h:109
te::dt::TimeInstant getFinalTime()
It gets the final time.
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
Definition: Date.h:111
void removeItem(AnimationItem *item)
Remove item.
bool m_automaticPan
True if automatic pan over this item.
QGraphicsView * m_animationView
The animation graphics view.
double getWidth() const
It returns the envelope width.
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
Definition: Date.h:97
virtual void loadCurrentImage()
Get current image.
Definition: ImageItem.cpp:188
void onHelpPushButtonClicked()
Help button clicked.
int m_maxSliderValue
The max slider value.
QDateTime fixDateTimeEdit(QDateTimeEdit *dte, const QDateTime &t)
It corrects the edited date time.
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 ...
This class is a animation view.
Definition: AnimationView.h:45
A widget to control the display of a set of layers.
void adjustPropertyDialog(te::qt::widgets::AnimationItem *)
virtual bool loadData()
Load temporal raster data.
Definition: ImageItem.cpp:54
void deleteMe()
It emits, indirectly, a sign for this widget is destroyed.
void onLoopCheckBoxClicked(bool b)
Loop check box clicked.
static std::string fromUTF8(const std::string &src)
Convert a string in UTF-8 to the current locale encoding.
QString m_iconFile
file that generated the pixmap
void onGoAndBackCheckBoxClicked(bool b)
Forward and then backward check box clicked.
const boost::posix_time::ptime & getTimeInstant() const
It returns the boost time instant type.
Definition: TimeInstant.h:92
void onExtentChanged()
It takes the necessary measures after the change of extent.
te::dt::TimeInstant getInitialTime()
It gets the initial time.
int m_numberOfCoverages
Number of coverage items.
void Union(const Envelope &rhs)
It updates the envelop with coordinates of another envelope.
QList< QUrl > m_dropUrls
Urls to animation with drag and drop.
A class to represent time instant.
Definition: TimeInstant.h:55
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the animation direction.
QColor m_backwardColor
The backward trail color.
Animation * m_animation
The animation this item.
te::dt::TimePeriod m_temporalExtent
Temporal extent.
QByteArray m_dropBA
Layer animation with drag and drop.
void createNewPixmap()
Create a new clear pixmap.
void draw(const int &curTime)
It draws the animation item.
int b
Definition: TsRtree.cpp:32
SliderPropertiesDialog * m_spd
Slider Properties Dialog.
void updateTimeTextEdit()
Update animation time.
double m_llx
Lower left corner x-coordinate.
bool trajectoryAlreadyExists(QPair< QString, QString > &item)
This file defines a class for a Animation Scene.
bool m_paused
flag to signal animation pause.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
This file defines a class for a Eta5kmItem.
TimeSliderWidget(MapDisplay *d, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
Date getDate() const
It returns the date associated to time instant.
Definition: TimeInstant.h:106
void onAnimationDragEnterEvent(QDragEnterEvent *e)
Drag enter event on display.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
bool m_comingBack
Flag to indicate that the trend is coming back.
void onDrawTrailCheckBoxClicked(bool b)
Draw track check box clicked.
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
A base class for date data types.
Definition: Date.h:53
QMutex m_mutex
To not use m_trajectoryPixmap simultaneously.
TimeInstant getFinalTimeInstant() const
It gets the final time instant.
Definition: TimePeriod.cpp:50
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
bool eventFilter(QObject *, QEvent *)
it filters the events of interest.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
TimeInstant getInitialTimeInstant() const
It gets the initial time instant.
Definition: TimePeriod.cpp:45
void onDisplayPaintEvent(QPainter *p)
it draw on display.
void onSliderMoved(int value)
It takes the necessary measures after slider move.
static te::dt::TimeDuration dt(20, 30, 50, 11)
QColor m_forwardColor
The forward trail color.
std::unique_ptr< te::dt::DateTime > getTime() const
It returns the time pointed by the internal cursor.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
std::complex< double > times(std::complex< double > lhs, std::complex< double > rhs)
int m_currentTime
Current animation time (relative to time duration).
bool m_finished
flag to signal animation finish.
te::gm::Polygon * p
void erase(const unsigned int &curTime)
It Erase trajectory piece.
QRect getRect()
It gets image rect in device coordinate.
Definition: ImageItem.cpp:491
virtual AbstractData * clone() const =0
It returns a clone of this object.
MapDisplay * m_display
The map display.
void onForwardRadioButtonClicked(bool b)
Forward radio button clicked.
bool coverageAlreadyExists(QPair< QString, QString > &item)
void onSridChanged()
It takes the necessary measures after the change of extent.
void updateSliderPos()
Updates the position of the slider with respect to time animation.
QString m_title
The icon item title.
QDir m_dir
The image data directory.
Definition: ImageItem.h:192
void putToBack(AnimationItem *item)
It puts graphic item to back.
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the Animation Item direction.
double m_lly
Lower left corner y-coordinate.
A class to represent a trajectory data set.
A class to represent time period.
Definition: TimePeriod.h:54
This file defines a class for a Trajectory Animation.
This file defines a class for image files knowed by QT.
AnimationScene * m_animationScene
The animation scene.
bool isSettingChanged()
Is Setting Changed.
te::dt::TimeInstant getTimeInstant()
It it gets the animation time instant.
std::unique_ptr< te::gm::Geometry > getGeometry() const
It returns the geometry pointed by the internal cursor.
void setDuration(const unsigned int &duration)
Sets the animation duration.
const boost::posix_time::time_period & getTimePeriod() const
Assignment operator.
Definition: TimePeriod.h:86
void computeMBR(bool cascade) const
It computes the minimum bounding rectangle for the curve polygon.
bool m_loop
This property holds whether the slider&#39;s animation is on loop.
te::dt::TimePeriod m_temporalExtent
Total temporal extent.
Definition: Animation.h:110
void changeDirection()
Change direction.
void deleteTimeSliderWidget()
This sign warns that this widget must be destroyed.
A class to represent time duration with nano-second/micro-second resolution.
Definition: TimeDuration.h:51
This file defines a class for a Trajectory Item.
TimeDuration getTime() const
It returns the time duration associated to time instant.
Definition: TimeInstant.cpp:49
A layer with reference to a dataset that contains trajectories.
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
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
void createNewPixmap()
create new pixmap.
void initProperty()
It initialize a property animation dialog.
double m_panFactor
the range is between 0.002 and 0.5
This class allows to add multiple trajectories and temporal image.
void putToFront(AnimationItem *item)
It puts graphic item to front.
std::unique_ptr< Ui::TimeSliderWidgetForm > m_ui
The widget form.
std::unique_ptr< Ui::SliderPropertiesDialogForm > m_ui
It takes the necessary steps after changing the duration.
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
Definition: TimeDuration.h:98
virtual void layerSelected(te::map::AbstractLayerPtr layer)
This method is used to set current layer.
void showPropertySection(bool b)
Show Property.
void onPlayToolButtonnClicked()
Play or pause the animation.
virtual void setSRID(const int &srid, bool doRefresh=true)
It sets a new Spatial Reference System to be used by the Map Display.
QString m_layerId
trajectory layer Id
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
QList< QString > m_animationIdList
List containing the shadow of m_ui->m_animationComboBox.
int m_numberOfTrajectories
Number of trajectory items.
void setDuration(const unsigned int &duration)
Sets the Animation Item duration.
QDateTime m_oldQDateTime
The old Qt date time.
virtual void setExtent(te::gm::Envelope &e, bool doRefresh=true)
It sets the world visible area and refreshes the contents in the map display.
double getHeight() const
It returns the envelope height.
void calculateAllSpatialExtent()
It calculates the spatial extent.
int m_SRID
The input route srid.
boost::gregorian::greg_month getMonth() const
It returns the gregorian month - from 1 to 12.
Definition: Date.h:104
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
void adjustDataToAnimationTemporalExtent(const te::dt::TimePeriod &period)
It adjust animation data for a given period; /param period The temporal period.
Definition: Animation.cpp:13
void onAnimationComboBoxActivated(int i)
Opacity combo box activated.
QString getDateString(const te::dt::TimeInstant &t)
bool isValid() const
It tells if the rectangle is valid or not.
te::dt::TimePeriod m_temporalAnimationExtent
Temporal animation extent. It can be a portion of the total or greater than the total.
Definition: Animation.h:111
long getHours() const
It returns the hours of a day - from 0 to 23.
Definition: TimeDuration.h:91
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
virtual void layerAdded(te::map::AbstractLayerPtr layer)
This method is used to add a new layer.
An object that when created shows a cursor during its scope.
Definition: ScopedCursor.h:48
bool m_erasePerfectly
flag to erase trajectory piece perfectly (default = false).
QVector< te::dt::TimeInstant > m_time
The input time.
void onStopToolButtonnClicked()
Stop animation.
int m_duration
The animation&#39;s duration time in miliseconds.
bool m_drawTrail
flag to draw trail
void setGoAndBack(bool t)
Sets the mode of animation.