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