All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "SliderPropertiesDialog.h"
29 #include "../canvas/MapDisplay.h"
30 #include "AnimationView.h"
31 #include "Animation.h"
32 #include "AnimationScene.h"
33 #include "TrajectoryItem.h"
34 #include "PixmapItem.h"
35 #include "TimeSliderWidget.h"
36 #include "ui_TimeSliderWidgetForm.h"
37 #include "ui_SliderPropertiesDialogForm.h"
38 #include <terralib/dataaccess.h>
39 #include <terralib/stmemory.h>
40 #include <terralib/st.h>
43 #include <terralib/qt/widgets.h>
44 #include <terralib/maptools.h>
45 #include <terralib/dataaccess.h>
46 
47 //QT
48 #include <QGraphicsEffect>
49 #include <QSlider>
50 #include <QGraphicsView>
51 #include <QMimeData>
52 #include <QParallelAnimationGroup>
53 #include <QPropertyAnimation>
54 #include <QTimer>
55 #include <QThread>
56 #include <QTextStream>
57 #include <QContextMenuEvent>
58 #include <QMessageBox>
59 #include <QInputDialog>
60 #include <QDateTimeEdit>
61 #include <QColorDialog>
62 #include <QListWidget>
63 #include <QMap>
64 #include <QUrl>
65 #include <QFileDialog>
66 
68  : QWidget(parent, f),
69  m_display(md),
70  m_erasePerfectly(false),
71  m_ui(new Ui::TimeSliderWidgetForm),
72  m_maxSliderValue(1000000000),
73  m_finished(false)
74 {
75  te::qt::widgets::ScopedCursor scopedCursor(Qt::WaitCursor);
76  m_ui->setupUi(this);
77  setFocusPolicy(Qt::StrongFocus);
78  setMouseTracking(true);
79  setAcceptDrops(true);
80 
81  //QColor wc(50, 50, 200, 80);
82  //QBrush wbrush(wc);
83  //QPalette wpalette(wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush, wbrush);
84  //setPalette(wpalette);
85  //setAutoFillBackground(true);
86  //setBackgroundRole(QPalette::Window);
87 
88  m_spd = new SliderPropertiesDialog(this);
89 
90  // slider normalized between 0 and m_maxSliderValue
91  m_ui->m_TemporalHorizontalSlider->setMinimum(0);
92  m_ui->m_TemporalHorizontalSlider->setMaximum(m_maxSliderValue);
93 
94  m_ui->m_durationSpinBox->setMinimum(100);
95  m_ui->m_durationSpinBox->setMaximum(100000000);
96  m_ui->m_durationSpinBox->setValue(10000);
97  m_ui->m_durationSpinBox->setSingleStep(10000);
98 
99  m_spd->m_ui->m_initialTimeLineEdit->setEnabled(false);
100  m_spd->m_ui->m_finalTimeLineEdit->setEnabled(false);
101 
102  m_spd->m_ui->m_opacitySpinBox->setMinimum(0);
103  m_spd->m_ui->m_opacitySpinBox->setMaximum(255);
104  m_spd->m_ui->m_opacitySpinBox->setValue(255);
105  m_spd->m_ui->m_opacitySpinBox->setSingleStep(5);
106 
107  //setAutoFillBackground(true);
108  //QPalette palette;
109  //palette.setColor(QPalette::Background, Qt::white);
110  //setPalette(palette);
111 
112  //The opacity used to fade the widget if the mouse is not over it
113  //QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect;
114  //opacityEffect->setOpacity(0.85);
115  //this->setGraphicsEffect(opacityEffect);
116 
117  //Adjusting the icons and the graphic effects
118  m_ui->m_settingsToolButton->setIcon(QIcon::fromTheme("preferences-system"));
119  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
120  m_ui->m_stopToolButton->setIcon(QIcon::fromTheme("media-playback-stop"));
121 
122  // connect signal and slots
123  connect(m_ui->m_dateTimeEdit, SIGNAL(dateTimeChanged(const QDateTime&) ), this, SLOT(onDateTimeEditChanged(const QDateTime&)));
124  connect(m_ui->m_durationSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onDurationValueChanged(int)));
125  connect(m_ui->m_settingsToolButton, SIGNAL(clicked()), this, SLOT(onSettingsToolButtonnClicked()));
126  connect(m_ui->m_playToolButton, SIGNAL(clicked()), this, SLOT(onPlayToolButtonnClicked()));
127  connect(m_ui->m_stopToolButton, SIGNAL(clicked()), this, SLOT(onStopToolButtonnClicked()));
128  connect(m_ui->m_TemporalHorizontalSlider, SIGNAL(sliderMoved (int)), this, SLOT(onSliderMoved(int)));
129 
130  setAttribute(Qt::WA_DeleteOnClose, true);
131 
132  m_loop = true; //By default, the animation not will be looping.
133  m_duration = 10000; //By default, the animation journey time will be 10000 miliseconds.
134  m_ui->m_durationSpinBox->setValue(m_duration);
135  m_direction = QAbstractAnimation::Forward; //By default, the animation direction will be forward.
136  setGoAndBack(true); //By default, the animation is forward and then backward.
137 
138  m_spd->m_ui->m_forwardRadioButton->setCheckable(true);
139 
141  m_animationView->setWindowFlags(Qt::Widget);
142  QBrush brush(Qt::transparent);
143  QPalette palette(brush, brush, brush, brush, brush, brush, brush, brush, brush);
144  m_animationView->setPalette(palette);
145  m_parallelAnimation = new QParallelAnimationGroup();
148  m_animationView->show();
149  m_animationView->resize(4000, 2200);
150  m_animationView->move(0, 0);
151 
152  raise();
153 
154  connect(m_display, SIGNAL(displaySridChanged()), this, SLOT(onSridChanged()));
155  connect(m_display, SIGNAL(extentChanged()), this, SLOT(onExtentChanged()));
156  connect(m_display, SIGNAL(displayPaintEvent(QPainter*)), this, SLOT(onDisplayPaintEvent(QPainter*)));
157  connect(m_animationView, SIGNAL(animationDragEnterEvent(QDragEnterEvent*)), this, SLOT(onAnimationDragEnterEvent(QDragEnterEvent*)));
158  connect(m_animationView, SIGNAL(animationDropEvent(QDropEvent*)), this, SLOT(onAnimationDropEvent(QDropEvent*)));
159 
160  connect(m_parallelAnimation, SIGNAL(finished()), this, SLOT(onFinishAnimation()));
161 
162  m_spd->m_ui->m_forwardColorPushButton->installEventFilter(this);
163  m_spd->m_ui->m_backwardColorPushButton->installEventFilter(this);
164  m_spd->m_ui->m_iconPushButton->installEventFilter(this);
165  m_ui->m_dateTimeEdit->installEventFilter(this);
166 
167  m_ui->m_dateTimeEdit->setDisplayFormat("dd/MMM/yyyy hh:mm:ss");
168 
169  if(m_animationScene->items().isEmpty())
170  {
171  m_ui->m_durationSpinBox->setEnabled(false);
172  m_ui->m_settingsToolButton->setEnabled(false);
173  m_ui->m_playToolButton->setEnabled(false);
174  m_ui->m_stopToolButton->setEnabled(false);
175  m_ui->m_dateTimeEdit->setEnabled(false);
176  m_spd->hide();
177  }
178  else
179  {
180  m_ui->m_durationSpinBox->setEnabled(true);
181  m_ui->m_settingsToolButton->setEnabled(true);
182  m_ui->m_playToolButton->setEnabled(true);
183  m_ui->m_stopToolButton->setEnabled(true);
184  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
185  m_ui->m_dateTimeEdit->setEnabled(true);
186  else
187  m_ui->m_dateTimeEdit->setEnabled(false);
188  }
189 
190  if(m_display->getExtent().isValid() == false)
191  {
192  QRectF r = m_animationScene->sceneRect();
193  te::gm::Envelope e(r.left(), r.top(), r.right(), r.bottom());
194  m_display->setExtent(e);
195  }
196  if(m_display->getSRID() <= 0)
197  {
198  QList<QGraphicsItem*> list = m_animationScene->items();
199  QList<QGraphicsItem*>::iterator it = list.begin();
200  if(it != list.end())
201  {
202  AnimationItem* ai = (AnimationItem*)(*it);
203  int srid = ai->m_SRID;
204  m_display->setSRID(srid);
205  }
206  }
207 }
208 
210 {
211  m_parallelAnimation->stop(); // should be before clear
212  m_parallelAnimation->clear();
213  delete m_parallelAnimation;
214  delete m_animationScene;
215 
216  bool b = m_animationView->testAttribute(Qt::WA_DeleteOnClose);
217  m_animationView->close();
218  if(b == false)
219  delete m_animationView;
220 }
221 
223 {
224  //setCurrentLayer(layer);
225 }
226 
228 {
229  if(layer->getType() == "TRAJECTORYDATASETLAYER")
230  {
231  te::st::TrajectoryDataSetLayer* tl = dynamic_cast<te::st::TrajectoryDataSetLayer*>(layer.get());
232  QString title(tl->getTitle().c_str());
233  QPair<QString, te::st::TrajectoryDataSetLayer*> p(title, tl);
234  if(trajectoryAlreadyExists(p))
235  QMessageBox::information(this, title + " already exists", "This item is already being animated!");
236  else
237  addTrajectory(tl, "");
238  if(isHidden())
239  show();
240  }
241 }
242 
244 {
245  if(layer->getType() == "TRAJECTORYDATASETLAYER")
246  {
247  QString title = layer->getTitle().c_str();
248  removeAnimation(title);
249 
250  //size_t size = m_spd->m_ui->m_animationItemListWidget->count();
251  //for(size_t i = 0; i < size; ++i)
252  //{
253  // QString t = m_spd->m_ui->m_animationItemListWidget->item(i)->text();
254  // if(t == title)
255  // {
256  // QListWidgetItem* li = m_spd->m_ui->m_animationItemListWidget->takeItem(i);
257  // delete li;
258  // break;
259  // }
260  //}
261  }
262 }
263 
265 {
266  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
267 
268  QList<QGraphicsItem*> list = m_animationScene->items();
269  QList<QGraphicsItem*>::iterator it;
270 
271  for(it = list.begin(); it != list.end(); ++it)
272  {
274 
275  QString title = ti->m_title;
276  if(title == titlecb)
277  {
278  ti->m_drawTrail = b;
279  //setAuxInfo(ti);
280  break;
281  }
282  }
283 }
284 
285 //void te::qt::widgets::TimeSliderWidget::onApplyAnimationItemPushButtonClicked(bool)
286 //{
287 // int animationState = m_parallelAnimation->state();
288 //
289 // QList<QGraphicsItem*>::iterator it;
290 //
291 // int size = m_spd->m_ui->m_animationItemListWidget->count();
292 // for(int i = 0; i < size; ++i)
293 // {
294 // QListWidgetItem* item = m_spd->m_ui->m_animationItemListWidget->item(i);
295 // QString iTitle = item->text();
296 // Qt::CheckState state = item->checkState();
297 // QList<QGraphicsItem*> list = m_animationScene->items();
298 // if(state == Qt::Checked)
299 // {
300 // for(it = list.begin(); it != list.end(); ++it)
301 // {
302 // te::qt::widgets::AnimationItem* ai = (AnimationItem*)(*it);
303 // QString title = ai->m_title;
304 // if(title == iTitle)
305 // break;
306 // }
307 // if(it == list.end()) // load animation
308 // loadAnimation(iTitle);
309 // }
310 // else if(state == Qt::Unchecked)
311 // {
312 // for(it = list.begin(); it != list.end(); ++it)
313 // {
314 // te::qt::widgets::AnimationItem* ai = (AnimationItem*)(*it);
315 // QString title = ai->m_title;
316 // if(title == iTitle)
317 // removeAnimation(iTitle);
318 // }
319 // }
320 // }
321 //
322 // if(animationState == QAbstractAnimation::Stopped)
323 // {
324 // QList<QGraphicsItem*> list = m_animationScene->items();
325 // if(list.count())
326 // {
327 // m_ui->m_settingsToolButton->setEnabled(true);
328 // m_ui->m_playToolButton->setEnabled(true);
329 // m_ui->m_stopToolButton->setEnabled(true);
330 // m_ui->m_durationSpinBox->setEnabled(true);
331 // m_ui->m_dateTimeEdit->setEnabled(true);
332 //
333 // onPlayToolButtonnClicked();
334 // }
335 // }
336 //}
337 
338 //void te::qt::widgets::TimeSliderWidget::loadAnimation(const QString& title)
339 //{
340 // QList<QPair<QString, te::st::TrajectoryDataSetLayer*> >::iterator it;
341 // QList<QPair<QString, QString> >::iterator cit;
342 //
343 // for(it = m_trajectoryItemList.begin(); it != m_trajectoryItemList.end(); ++it)
344 // {
345 // if(it->first == title)
346 // {
347 // addTrajectory(it->second, "");
348 // return;
349 // }
350 // }
351 //
352 // for(cit = m_coverageItemList.begin(); cit != m_coverageItemList.end(); ++cit)
353 // {
354 // if(cit->first == title)
355 // {
356 // addTemporalImages(cit->second);
357 // return;
358 // }
359 // }
360 //}
361 
363 {
364  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
365  if(ind != -1)
366  {
367  QString title = m_spd->m_ui->m_animationComboBox->currentText();
368  removeAnimation(title);
369  }
370 }
371 
373 {
374  while(true)
375  {
376  int ind = m_spd->m_ui->m_animationComboBox->currentIndex();
377  if(ind == -1)
378  break;
379  QString title = m_spd->m_ui->m_animationComboBox->currentText();
380  removeAnimation(title);
381  }
382 }
383 
385 {
386  QList<QGraphicsItem*> list = m_animationScene->items();
387  QList<QGraphicsItem*>::iterator it;
388 
389  for(it = list.begin(); it != list.end(); ++it)
390  {
392  QString atitle = ai->m_title;
393  if(atitle == title)
394  {
395  if(list.count() == 1)
396  {
397  onStopToolButtonnClicked();
398  m_animationScene->removeItem(ai);
399  m_parallelAnimation->removeAnimation(ai->m_animation);
400  delete ai->m_animation;
401  delete ai;
402  m_ui->m_TemporalHorizontalSlider->setValue(0);
403  m_parallelAnimation->setCurrentTime(0);
404  m_ui->m_settingsToolButton->setEnabled(false);
405  m_ui->m_playToolButton->setEnabled(false);
406  m_ui->m_stopToolButton->setEnabled(false);
407  m_ui->m_durationSpinBox->setEnabled(false);
408  m_ui->m_dateTimeEdit->setEnabled(false);
409  m_display->update();
410  removeOnPropertieCombo(title);
411  initProperty();
412  return;
413  }
414 
415  bool running = false;
416  int state = m_parallelAnimation->state();
417  if(state == QAbstractAnimation::Running)
418  {
419  running = true;;
420  onPlayToolButtonnClicked();
421  }
422 
423  m_currentTime = m_parallelAnimation->currentTime();
424  m_animationScene->removeItem(ai);
425  m_parallelAnimation->removeAnimation(ai->m_animation);
426  if(ai->pixmap().isNull() == false)
427  {
428  if(m_animationScene->m_numberOfTrajectories)
429  {
430  m_animationScene->m_mutex.lock();
431  m_animationScene->m_trajectoryPixmap->fill(Qt::transparent);
432  m_animationScene->m_mutex.unlock();
433  draw();
434  }
435  }
436  delete ai->m_animation;
437  delete ai;
438 
439  calculateSpatialExtent();
440  calculateTemporalExtent();
441  createAnimations();
442  setDuration(m_duration);
443  setDirection(m_direction);
444 
445  if(running)
446  {
447  onPlayToolButtonnClicked();
448  m_parallelAnimation->setCurrentTime(m_currentTime);
449  }
450 
451  break;
452  }
453  }
454  removeOnPropertieCombo(title);
455  initProperty();
456 }
457 
459 {
460  size_t i;
461  size_t size = m_spd->m_ui->m_animationComboBox->count();
462  for(i = 0; i < size; ++i)
463  {
464  QString ititle = m_spd->m_ui->m_animationComboBox->itemText(i);
465  if(ititle == title)
466  {
467  m_spd->m_ui->m_animationComboBox->removeItem(i);
468  if(i > 0)
469  onAnimationComboBoxActivated(i-1);
470  else if(m_spd->m_ui->m_animationComboBox->count() > 0)
471  onAnimationComboBoxActivated(0);
472  break;
473  }
474  }
475 }
476 
478 {
479  bool accept = false;
480  const QMimeData* mdata = e->mimeData();
481  QList<QUrl> urls = mdata->urls();
482  if(urls.empty())
483  {
484  QByteArray ba = mdata->data("application/x-terralib;value=\"DraggedItems\"");
485  if(ba.count() != 0)
486  {
487  QString s(ba);
488  std::vector<te::qt::widgets::AbstractTreeItem*>* ditems = (std::vector<AbstractTreeItem*>*)s.toULongLong();
489  std::vector<te::qt::widgets::AbstractTreeItem*>::iterator it;
490  for(it = ditems->begin(); it != ditems->end(); ++it)
491  {
493  std::string ltype = ati->getLayer()->getType();
494  if(ltype == "TRAJECTORYDATASETLAYER")
495  accept = true;
496  }
497  }
498  }
499  else
500  {
501  e->setDropAction(Qt::LinkAction);
502 
503  QString path = urls.begin()->path();
504  size_t pos = path.indexOf("/");
505  if(pos == 0)
506  path.remove(0, 1);
507  QDir dir(path);
508  QStringList nameFilter;
509  nameFilter.append("*.ctl");
510  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
511  if(files.empty() == false)
512  {
513  QString file(path + "/" + files.first());
514  FILE* fp = fopen(file.toStdString().c_str(), "r");
515  char buf[2000];
516  int c = fread(buf, sizeof(char), 2000, fp);
517  fclose(fp);
518  buf[c] = 0;
519  QString s(buf);
520  if(s.contains("undef", Qt::CaseInsensitive))
521  accept = true;
522  }
523  else
524  {
525  nameFilter.clear();
526  nameFilter.append("S1123*.jpg");
527  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
528  if(files.empty() == false && files.first().length() == 26)
529  accept = true;
530  else
531  {
532  nameFilter.clear();
533  nameFilter.append("S1118*.jpg");
534  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
535  if(files.empty() == false && files.first().length() == 26)
536  accept = true;
537  }
538  }
539  }
541  a->m_dragDropAccepted = accept;
542  e->setAccepted(a->m_dragDropAccepted);
543 }
544 
546 {
547  m_dropModifiers = e->keyboardModifiers();
548  const QMimeData* mdata = e->mimeData();
549  m_dropUrls = mdata->urls();
550  m_dropBA = mdata->data("application/x-terralib;value=\"DraggedItems\"");
551  QTimer::singleShot(10, this, SLOT(dropAction()));
552 }
553 
555 {
556  te::qt::widgets::ScopedCursor scopedCursor(Qt::WaitCursor);
557  int state = m_parallelAnimation->state();
558  int tempo = m_currentTime;
559  if(state == QAbstractAnimation::Running)
560  onPlayToolButtonnClicked(); // put to paused state
561 
562  if(m_dropModifiers == Qt::NoModifier)
563  {
564  onStopToolButtonnClicked();
565  m_spd->m_ui->m_animationComboBox->clear();
566  m_spd->m_ui->m_animationComboBox->clear();
567  m_ui->m_TemporalHorizontalSlider->setValue(0);
568  m_parallelAnimation->setCurrentTime(0);
569  m_ui->m_settingsToolButton->setEnabled(false);
570  m_ui->m_playToolButton->setEnabled(false);
571  m_ui->m_stopToolButton->setEnabled(false);
572  m_ui->m_durationSpinBox->setEnabled(false);
573  m_ui->m_dateTimeEdit->setEnabled(false);
574 
575  QList<QGraphicsItem*> list = m_animationScene->items();
576  QList<QGraphicsItem*>::iterator it;
577  for(it = list.begin(); it != list.end(); ++it)
578  {
580  m_animationScene->removeItem(ai);
581  m_parallelAnimation->removeAnimation(ai->m_animation);
582  delete ai->m_animation;
583  delete ai;
584  }
585 
586  //size_t size = m_spd->m_ui->m_animationItemListWidget->count();
587  //for(size_t i = 0; i < size; ++i)
588  // m_spd->m_ui->m_animationItemListWidget->item(i)->setCheckState(Qt::Unchecked);
589  m_spd->m_ui->m_animationComboBox->clear();
590  //m_coverageItemList.clear();
591  //m_trajectoryItemList.clear();
592  m_display->update();
593  }
594 
595  if(m_dropUrls.empty())
596  {
597  if(m_dropBA.count() != 0)
598  {
599  QString s(m_dropBA);
600  std::vector<te::qt::widgets::AbstractTreeItem*>* ditems = (std::vector<AbstractTreeItem*>*)s.toULongLong();
601  std::vector<te::qt::widgets::AbstractTreeItem*>::iterator it;
602  for(it = ditems->begin(); it != ditems->end(); ++it)
603  {
605  std::string ltype = ati->getLayer()->getType();
606  if(ltype == "TRAJECTORYDATASETLAYER")
607  {
609  QString title(tl->getTitle().c_str());
610  QPair<QString, te::st::TrajectoryDataSetLayer*> p(title, tl);
611  if(trajectoryAlreadyExists(p))
612  QMessageBox::information(this, title + " already exists", "This item is already being animated!");
613  else
614  addTrajectory(tl, "");
615  }
616  }
617  }
618  }
619  else
620  {
621  QList<QUrl>::iterator it;
622  for(it = m_dropUrls.begin(); it != m_dropUrls.end(); ++it)
623  {
624  QString path = it->path();
625  QDir dir(path);
626  QString title = dir.dirName();
627  path.remove(0, 1);
628 
629  QPair<QString, QString> p(title, path);
630 
631  if(coverageAlreadyExists(p))
632  QMessageBox::information(this, "animation already exists", "This item is already being animated!");
633  else
634  addTemporalImages(path);
635  }
636  }
637 
638  if(state == QAbstractAnimation::Running || m_dropModifiers == Qt::NoModifier)
639  {
640  m_currentTime = tempo;
641  onPlayToolButtonnClicked();
642  m_parallelAnimation->setCurrentTime(m_currentTime);
643  }
644 }
645 
646 bool te::qt::widgets::TimeSliderWidget::trajectoryAlreadyExists(QPair<QString, te::st::TrajectoryDataSetLayer*>& item)
647 {
648  for(int i = 0; i < m_spd->m_ui->m_animationComboBox->count(); ++i)
649  {
650  if(item.first == m_spd->m_ui->m_animationComboBox->itemText(i))
651  return true;
652  }
653  return false;
654  //QString title = item.first;
655  //int ind = m_spd->m_ui->m_animationComboBox->findText(title);
656  //if(ind != -1)
657  // return false;
658  //return true;
659 
660  //QList<QPair<QString, te::st::TrajectoryDataSetLayer*> >::iterator it;
661  //for(it = m_trajectoryItemList.begin(); it != m_trajectoryItemList.end(); ++it)
662  //{
663  // if(*it == item)
664  // return true;
665  //}
666  //m_trajectoryItemList.append(item);
667  //return false;
668 }
669 
671 {
672  for(int i = 0; i < m_spd->m_ui->m_animationComboBox->count(); ++i)
673  {
674  if(item.first == m_spd->m_ui->m_animationComboBox->itemText(i))
675  return true;
676  }
677  return false;
678  //QString title = item.first;
679  //int ind = m_spd->m_ui->m_animationComboBox->findText(title);
680  //if(ind != -1)
681  // return false;
682  //return true;
683 
684  //QList<QPair<QString, QString> >::iterator it;
685  //for(it = m_coverageItemList.begin(); it != m_coverageItemList.end(); ++it)
686  //{
687  // if(*it == item)
688  // return true;
689  //}
690  //m_coverageItemList.append(item);
691  //return false;
692 }
693 
695 {
696  int state = m_parallelAnimation->state();
697 
698  QString title = tl->getTitle().c_str();
699  TrajectoryItem* ti = new TrajectoryItem(title, m_display, QString(), QSize());
700  m_animationScene->addItem(ti);
701  Animation* animation = new Animation(ti, "pos");
702  animation->setEasingCurve(QEasingCurve::Linear);
703 
704  te::st::TrajectoryDataSet* dset = tl->getTrajectoryDataset().release();
705  //animation->m_spatialExtent = *dynamic_cast<te::gm::Envelope*>(dset->getSpatialExtent()->clone());
706  animation->m_temporalExtent = *static_cast<te::dt::TimePeriod*>(dset->getTemporalExtent()->clone());
707 
708  size_t size = dset->size();
709  ti->m_SRID = tl->getSRID();
710 
711  QPointF pf;
712  if(size > 0)
713  {
714  te::dt::TimeInstant tiraRepetido;
716  size_t i = 0;
717  while(dset->moveNext())
718  {
719  std::auto_ptr<te::dt::DateTime> time = dset->getTime();
720  te::dt::TimeInstant* tinstant = static_cast<te::dt::TimeInstant*>(time.get());
721  if(tiraRepetido == *tinstant)
722  continue;
723  tiraRepetido = *tinstant;
724 
725  ti->m_time.push_back(te::dt::TimeInstant(tinstant->getTimeInstant()));
726 
727  std::auto_ptr<te::gm::Geometry> geom = dset->getGeometry();
728  const te::gm::Point* p = static_cast<const te::gm::Point*>(geom.get());
729  te::gm::Point pp(*p);
730  ti->m_route->setPointN(i++, pp);
731  }
732  }
733  delete dset;
734 
735  m_parallelAnimation->addAnimation(animation);
736  calculateSpatialExtent();
737  calculateTemporalExtent();
738  createAnimations();
739  setDuration(m_duration);
740  setDirection(m_direction);
741 
742  if(state == QAbstractAnimation::Running)
743  {
744  onPlayToolButtonnClicked();
745  m_parallelAnimation->setCurrentTime(m_currentTime);
746  }
747  if(m_animationScene->items().isEmpty() == false)
748  {
749  m_ui->m_durationSpinBox->setEnabled(true);
750  m_ui->m_settingsToolButton->setEnabled(true);
751  m_ui->m_playToolButton->setEnabled(true);
752  m_ui->m_stopToolButton->setEnabled(true);
753  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
754  m_ui->m_dateTimeEdit->setEnabled(true);
755  else
756  m_ui->m_dateTimeEdit->setEnabled(false);
757  }
758 
759  //size = m_spd->m_ui->m_animationItemListWidget->count();
760  //size_t i;
761  //for(i = 0; i < size; ++i)
762  //{
763  // QListWidgetItem* item = m_spd->m_ui->m_animationItemListWidget->item(i);
764  // QString iTitle = item->text();
765  // if(iTitle == title)
766  // {
767  // getAuxInfo(ti, i);
768  // break;
769  // }
770  //}
771  //if(i == size)
772  //{
773  // QListWidgetItem* item = new QListWidgetItem(title);
774  // item->setCheckState(Qt::Checked);
775  // m_spd->m_ui->m_animationItemListWidget->addItem(item);
776  // AnimationAuxInfo info;
777  // info.type = "Trajectory";
778  // info.title = title;
779  // m_auxInfo[i] = info;
780  // setAuxInfo(ti, i);
781  //}
782 
783  initProperty();
784 
785  m_spd->m_ui->m_animationComboBox->addItem(title);
786  int count = m_spd->m_ui->m_animationComboBox->count();
787  m_spd->m_ui->m_animationComboBox->setCurrentIndex(count-1);
788  //onTrajectoryColorComboBoxActivated(count-1);
789 
790  //m_spd->m_ui->m_animationComboBox->addItem(title);
791  //count = m_spd->m_ui->m_animationComboBox->count();
792  //m_spd->m_ui->m_animationComboBox->setCurrentIndex(count-1);
793  onAnimationComboBoxActivated(count-1);
794 }
795 
797 {
798  if(m_animationScene->items().isEmpty())
799  m_ui->m_durationSpinBox->setValue(m_duration);
800 
801  int state = m_parallelAnimation->state();
802  m_currentTime = m_parallelAnimation->currentTime();
803  if(state == QAbstractAnimation::Running)
804  onPlayToolButtonnClicked();
805 
806  te::qt::widgets::PixmapItem* pi = getMetadata(filePath);
807  if(pi == 0)
808  {
809  QMessageBox::information(this, "Error", "Load error: " + filePath);
810  //m_coverageItemList.pop_back();
811  return;
812  }
813 
814  calculateSpatialExtent();
815  calculateTemporalExtent();
816  createAnimations();
817  setDuration(m_duration);
818  setDirection(m_direction);
819  if(state == QAbstractAnimation::Running)
820  {
821  onPlayToolButtonnClicked();
822  m_parallelAnimation->setCurrentTime(m_currentTime);
823  }
824  if(m_animationScene->items().isEmpty() == false)
825  {
826  m_ui->m_durationSpinBox->setEnabled(true);
827  m_ui->m_settingsToolButton->setEnabled(true);
828  m_ui->m_playToolButton->setEnabled(true);
829  m_ui->m_stopToolButton->setEnabled(true);
830  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
831  m_ui->m_dateTimeEdit->setEnabled(true);
832  else
833  m_ui->m_dateTimeEdit->setEnabled(false);
834  }
835 
836  QDir dir(filePath);
837  //size_t size = m_spd->m_ui->m_animationItemListWidget->count();
838  //size_t i;
839  //for(i = 0; i < size; ++i)
840  //{
841  // QListWidgetItem* item = m_spd->m_ui->m_animationItemListWidget->item(i);
842  // QString iTitle = item->text();
843  // if(iTitle == dir.dirName())
844  // {
845  // getAuxInfo(pi, i);
846  // break;
847  // }
848  //}
849  //if(i == size)
850  //{
851  // QListWidgetItem* item = new QListWidgetItem(dir.dirName());
852  // item->setCheckState(Qt::Checked);
853  // m_spd->m_ui->m_animationItemListWidget->addItem(item);
854  // AnimationAuxInfo info;
855  // info.type = "Coverage";
856  // info.title = dir.dirName();
857  // m_auxInfo[i] = info;
858  // setAuxInfo(pi, i);
859  //}
860 
861  initProperty();
862 
863  m_spd->m_ui->m_animationComboBox->addItem(dir.dirName());
864  int count = m_spd->m_ui->m_animationComboBox->count();
865  m_spd->m_ui->m_animationComboBox->setCurrentIndex(count-1);
866  onAnimationComboBoxActivated(count-1);
867 }
868 
869 //void te::qt::widgets::TimeSliderWidget::getAuxInfo(te::qt::widgets::AnimationItem* ai, int index)
870 //{
871 // if(index == -1)
872 // {
873 // QMap<int, AnimationAuxInfo>::iterator it;
874 // int i = 0;
875 // for(it = m_auxInfo.begin(); it != m_auxInfo.end(); ++it)
876 // {
877 // AnimationAuxInfo info = *it;
878 // QString t = info.title;
879 // if(t == ai->m_title)
880 // {
881 // index = i;
882 // break;
883 // }
884 // ++i;
885 // }
886 // }
887 // if(index == -1)
888 // return;
889 //
890 // AnimationAuxInfo info = m_auxInfo[index];
891 // ai->m_opacity = info.opacity;
892 // if(info.type == "Trajectory")
893 // {
894 // te::qt::widgets::TrajectoryItem* ti = (te::qt::widgets::TrajectoryItem*)ai;
895 // ti->m_forwardColor = info.forwardColor;
896 // ti->m_backwardColor = info.backwardColor;
897 // ti->m_drawTrail = info.drawTrail;
898 // if(info.autoPan)
899 // setAutomaticPan(ai->m_title);
900 // }
901 //}
902 
903 //void te::qt::widgets::TimeSliderWidget::setAuxInfo(te::qt::widgets::AnimationItem* ai, int index)
904 //{
905  //if(index == -1)
906  //{
907  // QMap<int, AnimationAuxInfo>::iterator it;
908  // int i = 0;
909  // for(it = m_auxInfo.begin(); it != m_auxInfo.end(); ++it)
910  // {
911  // AnimationAuxInfo info = *it;
912  // QString t = info.title;
913  // if(t == ai->m_title)
914  // {
915  // index = i;
916  // break;
917  // }
918  // ++i;
919  // }
920  //}
921  //if(index == -1)
922  // return;
923 
924  //AnimationAuxInfo& info = m_auxInfo[index];
925  //info.opacity = ai->m_opacity;
926  //if(info.type == "Trajectory")
927  //{
928  // te::qt::widgets::TrajectoryItem* ti = (te::qt::widgets::TrajectoryItem*)ai;
929  // info.forwardColor = ti->m_forwardColor;
930  // info.backwardColor = ti->m_backwardColor;
931  // info.drawTrail = ti->m_drawTrail;
932  // info.autoPan = ti->m_automaticPan;
933  //}
934 //}
935 
937 {
938  PixmapItem* pi = getTemporalImageCtlParameters(path);
939  if(pi == 0)
940  return 0;
941 
942  m_animationScene->addItem(pi);
943  Animation* animation = new Animation(pi, "pos");
944  animation->m_spatialExtent = te::gm::Envelope(pi->m_imaRect.x(), pi->m_imaRect.y(), pi->m_imaRect.right(), pi->m_imaRect.bottom());
945  animation->setEasingCurve(QEasingCurve::Linear);
946  m_parallelAnimation->addAnimation(animation);
947 
948  QString suffix = "." + pi->m_suffix;
949  QStringList nameFilter;
950  nameFilter.append("*" + suffix);
951  QDir dir(path);
952  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
953  size_t count = files.count();
954 
955  // get time extent
956  te::dt::TimeInstant ti = getGoesTime(path + "/" + files.first());
957  te::dt::TimeInstant tf = getGoesTime(path + "/" + files.last());
958  animation->m_temporalExtent = te::dt::TimePeriod(ti, tf);
959 
960  // set data
962  for(size_t i = 0; i < count; ++i)
963  {
964  QString f = files[i];
965  t = getGoesTime(f);
966  pi->m_time.push_back(t);
967  pi->m_files.push_back(f);
968  }
969 
971 
972  // crie valores não repetitivos e nem muito grandes ou pequenos
973  QPointF pos(animation->m_spatialExtent.m_llx, animation->m_spatialExtent.m_lly);
974  double w = animation->m_spatialExtent.getWidth();
975  double h = animation->m_spatialExtent.getHeight();
976  for(size_t i = 0; i < count; ++i)
977  {
978  if(i & 1)
979  pos -= QPointF(w, h);
980  else
981  pos += QPointF(w, h);
982 
983  pi->m_route->setPoint(i, pos.x(), pos.y());
984  }
985 
986  return pi;
987 }
988 
990 {
991  int srid = -1;
992  m_spatialExtent = te::gm::Envelope();
993 
994  QList<QGraphicsItem*> list = m_animationScene->items();
995  QList<QGraphicsItem*>::iterator it;
996 
997  for(it = list.begin(); it != list.end(); ++it)
998  {
999  AnimationItem* ai = (AnimationItem*)(*it);
1000  srid = ai->m_SRID;
1001  if(m_display->getSRID() != TE_UNKNOWN_SRS && m_display->getSRID() != ai->m_SRID)
1002  {
1004  e.transform(ai->m_SRID, m_display->getSRID());
1005  m_spatialExtent.Union(e);
1006  }
1007  else
1008  m_spatialExtent.Union(ai->m_animation->m_spatialExtent);
1009  }
1010  QRectF rect(m_spatialExtent.m_llx, m_spatialExtent.m_lly, m_spatialExtent.getWidth(), m_spatialExtent.getHeight());
1011  m_animationScene->setSceneRect(rect);
1012  m_animationView->setSceneRect(rect);
1013  m_animationView->fitInView(rect);
1014 
1015  //QRectF nullRect;
1016  //m_animationScene->setSceneRect(nullRect);
1017  //m_animationView->setSceneRect(nullRect);
1018 }
1019 
1021 {
1022  te::dt::TimeInstant initial, final, t_initial, t_final;
1023 
1024  QList<QGraphicsItem*> list = m_animationScene->items();
1025  QList<QGraphicsItem*>::iterator it = list.begin();
1026  if(it != list.end())
1027  {
1028  AnimationItem* ai = (AnimationItem*)(*it);
1031  ++it;
1032  }
1033 
1034  while(it != list.end())
1035  {
1036  AnimationItem* ai = (AnimationItem*)(*it);
1038  if(initial < t_initial)
1039  t_initial = initial;
1040 
1042  if(final > t_final)
1043  t_final = final;
1044  ++it;
1045  }
1046 
1047  m_temporalExtent = te::dt::TimePeriod(t_initial, t_final);
1048  te::dt::TimePeriod tp(t_initial, t_final);
1049  if(list.count() == 1)
1050  {
1051  m_temporalAnimationExtent = tp;
1052 
1053  for(it = list.begin(); it != list.end(); ++it)
1054  {
1055  AnimationItem* ai = (AnimationItem*)(*it);
1056  ai->m_animation->m_temporalAnimationExtent = m_temporalExtent;
1057  }
1058  }
1059 }
1060 
1062 {
1063  size_t i;
1064  QVector<te::dt::TimePeriod> times;
1065  QVector<te::gm::Envelope> envelopes;
1066  QList<QGraphicsItem*> list = m_animationScene->items();
1067  QList<QGraphicsItem*>::iterator it;
1068  for(it = list.begin(); it != list.end(); ++it)
1069  {
1070  AnimationItem* ai = (AnimationItem*)(*it);
1071  times.push_back(ai->m_animation->m_temporalExtent);
1072  envelopes.push_back(ai->m_animation->m_spatialExtent);
1073  }
1074 
1075  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
1076  m_parallelAnimation->clear();
1077  else
1078  {
1079  int cur = m_parallelAnimation->currentTime();
1080  m_parallelAnimation->stop();
1081  m_parallelAnimation->clear();
1082  m_parallelAnimation->setCurrentTime(cur);
1083  }
1084 
1085  for(it = list.begin(), i = 0 ; it != list.end(); ++it, ++i)
1086  {
1087  AnimationItem* ai = (AnimationItem*)(*it);
1089  a->m_spatialExtent = envelopes[i];
1090  a->m_temporalExtent = times[i];
1091  a->m_temporalAnimationExtent = m_temporalAnimationExtent;
1092  a->createAnimationDataInDisplayProjection(m_temporalAnimationExtent);
1093  m_parallelAnimation->addAnimation(a);
1094  }
1095 }
1096 
1098 {
1099  boost::posix_time::ptime pTime = timeInstant.getTimeInstant();
1100 
1101  // total time duration
1102  boost::posix_time::ptime iTime = m_temporalAnimationExtent.getInitialTimeInstant().getTimeInstant();
1103  boost::posix_time::ptime fTime = m_temporalAnimationExtent.getFinalTimeInstant().getTimeInstant();
1104  boost::posix_time::time_duration diff = fTime - iTime;
1105  double totalSeconds = diff.total_seconds();
1106 
1107  diff = pTime - iTime;
1108  double seconds = diff.total_seconds();
1109  // normalizing the time
1110  double t = seconds / totalSeconds;
1111  int ret = qRound(t * (double)m_duration);
1112  return ret;
1113 }
1114 
1116 {
1117  double t = m_parallelAnimation->currentTime();
1118  double trel = t / (double)m_duration;
1119 
1120  // total time duration
1121  boost::posix_time::ptime iTime = m_temporalAnimationExtent.getInitialTimeInstant().getTimeInstant();
1122  boost::posix_time::ptime fTime = m_temporalAnimationExtent.getFinalTimeInstant().getTimeInstant();
1123  boost::posix_time::time_duration diff = fTime - iTime;
1124  double totalSeconds = diff.total_seconds();
1125 
1126  int secs = qRound(totalSeconds * trel);
1127  boost::posix_time::time_duration td = boost::posix_time::seconds(secs);
1128  boost::posix_time::ptime time = iTime + td;
1129  te::dt::TimeInstant timei(time);
1130  return timei;
1131 }
1132 
1134 {
1135  if(m_animationScene->items().isEmpty())
1136  return;
1137  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
1138  return;
1139 
1140  te::gm::Envelope env = m_display->getExtent();
1141  QRectF drect(env.m_llx, env.m_lly, env.getWidth(), env.getHeight());
1142 
1144  if(m_ui->m_dateTimeEdit->isEnabled() == false)
1145  t = getTimeInstant();
1146  else
1147  {
1148  QDateTime d = m_ui->m_dateTimeEdit->dateTime();
1149  t = te::dt::TimeInstant(te::dt::Date(d.date().year(), d.date().month(), d.date().day()),
1150  te::dt::TimeDuration(d.time().hour(), d.time().minute(), d.time().second(), 0));
1151  }
1152 
1153  QList<QGraphicsItem*> list = m_animationScene->items();
1154  QList<QGraphicsItem*>::iterator it;
1155 
1156  if(m_animationScene->m_numberOfCoverages) // has images
1157  {
1158  // draw pixmap items
1159  for(it = list.begin(); it != list.end(); ++it)
1160  {
1161  AnimationItem* ai = (AnimationItem*)(*it);
1162  if(ai->pixmap().isNull())
1163  {
1164  // draw only the items that are within the time frame
1165  te::dt::TimeInstant tini = ai->m_animationTime.first();
1166  te::dt::TimeInstant tfim = ai->m_animationTime.last();
1167  if(t < tini || t > tfim)
1168  continue;
1169 
1170  // draw pixmap itens
1171  PixmapItem* pi = (PixmapItem*)ai;
1172  drawPixmapItem(pi, drect, painter);
1173  }
1174  }
1175  }
1176 
1177  if(m_animationScene->m_numberOfTrajectories) // has trajectories
1178  {
1179  // draw trail trajectories
1180  m_animationScene->m_mutex.lock();
1181  QPixmap* pixt = ((AnimationScene*)(m_animationScene))->m_trajectoryPixmap;
1182  painter->drawPixmap(0, 0, *pixt);
1183  m_animationScene->m_mutex.unlock();
1184 
1185  // draw icon trajectories
1186  for(it = list.begin(); it != list.end(); ++it)
1187  {
1188  AnimationItem* ai = (AnimationItem*)(*it);
1189  if(ai->pixmap().isNull() == false)
1190  {
1191  // draw only the items that are within the time frame
1192  te::dt::TimeInstant tini = ai->m_animationTime.first();
1193  te::dt::TimeInstant tfim = ai->m_animationTime.last();
1194  if(t < tini || t > tfim)
1195  continue;
1196 
1197  // draw trajectory icons
1198  QPoint p = ai->getPosInDeviceCoordinate();
1199  QRect r = ai->pixmap().rect();
1200  r.moveCenter(p);
1201  QRect dr = m_display->rect();
1202  if(dr.intersects(r))
1203  drawTrajectoryIcon((te::qt::widgets::TrajectoryItem*)ai, r.topLeft(), painter);
1204  }
1205  }
1206  }
1207 
1208  updateSliderPos();
1209 }
1210 
1212 {
1213  m_goAndBack = v;
1214  m_comingBack = !v;
1215 }
1216 
1217 void te::qt::widgets::TimeSliderWidget::setDirection(const QAbstractAnimation::Direction& direction)
1218 {
1219  m_direction = direction;
1220  m_parallelAnimation->setDirection(m_direction);
1221 
1222  unsigned int count = m_parallelAnimation->animationCount();
1223  for(unsigned int i = 0; i < count; ++i)
1224  {
1225  QPropertyAnimation* a = (QPropertyAnimation*)m_parallelAnimation->animationAt(i);
1226  AnimationItem* ai = (AnimationItem*)a->targetObject();
1227  ai->setDirection(m_direction);
1228  ai->setDuration(m_duration);
1229  }
1230 }
1231 
1232 void te::qt::widgets::TimeSliderWidget::setDuration(const unsigned int& duration)
1233 {
1234  m_animationScene->setDuration(duration);
1235 }
1236 
1238 {
1239  m_animationScene->createNewPixmap();
1240 }
1241 
1243 {
1244  m_animationScene->createNewPixmap();
1245  m_animationScene->setMatrix();
1246  m_animationScene->draw(m_currentTime);
1247 }
1248 
1250 {
1251  m_animationScene->setAutomaticPan(title);
1252 
1253  //QList<QGraphicsItem*> list = m_animationScene->items();
1254  //QList<QGraphicsItem*>::iterator it;
1255  //for(it = list.begin(); it != list.end(); ++it)
1256  //{
1257  // AnimationItem* ai = (AnimationItem*)(*it);
1258  // if(title == ai->m_title)
1259  // break;
1260  //}
1261 
1262  //if(it != list.end())
1263  // m_spd->m_ui->m_panFactorDoubleSpinBox->setEnabled(true);
1264  //else
1265  // m_spd->m_ui->m_panFactorDoubleSpinBox->setEnabled(false);
1266 }
1267 
1269 {
1270  QList<QGraphicsItem*> list = m_animationScene->items();
1271  QList<QGraphicsItem*>::iterator it;
1272  for(it = list.begin(); it != list.end(); ++it)
1273  {
1274  AnimationItem* ai = (AnimationItem*)(*it);
1275  ai->m_panFactor = v;
1276  }
1277 }
1278 
1280 {
1281  //if(obj == m_animationView)
1282  //{
1283  // //if(e->type() == QEvent::Close)
1284  // //{
1285  // // e->ignore();
1286  // // return true;
1287  // //}
1288  // //else
1289  // return false;
1290  //}
1291  //if(obj == m_animationScene)
1292  //{
1293  // int type = e->type();
1294  // if(type == QEvent::DragEnter)
1295  // return false;
1296  // else if(e->type() == QEvent::MouseButtonPress)
1297  // return false;
1298  // else if(e->type() == QEvent::MouseMove)
1299  // return false;
1300  // else if(e->type() == QEvent::MouseButtonRelease)
1301  // return false;
1302  // else if(e->type() == QEvent::MouseButtonDblClick)
1303  // return false;
1304  // else if(e->type() == QEvent::Enter)
1305  // return false;
1306  //}
1307  if(obj == m_spd->m_ui->m_forwardColorPushButton)
1308  {
1309  if(e->type() == QEvent::Paint)
1310  {
1311  QPainter painter(m_spd->m_ui->m_forwardColorPushButton);
1312  QBrush brush(m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window));
1313  painter.fillRect(m_spd->m_ui->m_forwardColorPushButton->rect(), brush);
1314  return true;
1315  }
1316  else if(e->type() == QEvent::MouseButtonPress)
1317  {
1318  QColor cor = QColorDialog::getColor(m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window), this, "Forward Color", QColorDialog::ShowAlphaChannel);
1319  if(cor.isValid() == false)
1320  return true;
1321  else if(cor == m_spd->m_ui->m_forwardColorPushButton->palette().color(QPalette::Window))
1322  return true;
1323 
1324  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(cor));
1325 
1326  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
1327 
1328  QList<QGraphicsItem*> list = m_animationScene->items();
1329  QList<QGraphicsItem*>::iterator it;
1331 
1332  for(it = list.begin(); it != list.end(); ++it)
1333  {
1334  ti = (te::qt::widgets::TrajectoryItem*)(*it);
1335  QString title = ti->m_title;
1336  if(title == titlecb)
1337  break;
1338  }
1339  if(ti != 0)
1340  {
1341  ti->m_forwardColor = cor;
1342  //setAuxInfo(ti);
1343  }
1344  return true;
1345  }
1346  }
1347  else if(obj == m_spd->m_ui->m_backwardColorPushButton)
1348  {
1349  if(e->type() == QEvent::Paint)
1350  {
1351  QPainter painter(m_spd->m_ui->m_backwardColorPushButton);
1352  QBrush brush(m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window));
1353  painter.fillRect(m_spd->m_ui->m_backwardColorPushButton->rect(), brush);
1354  return true;
1355  }
1356  else if(e->type() == QEvent::MouseButtonPress)
1357  {
1358  QColor cor = QColorDialog::getColor(m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window), this, "Forward Color", QColorDialog::ShowAlphaChannel);
1359  if(cor.isValid() == false)
1360  return true;
1361  else if(cor == m_spd->m_ui->m_backwardColorPushButton->palette().color(QPalette::Window))
1362  return true;
1363 
1364  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(cor));
1365 
1366  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
1367 
1368  QList<QGraphicsItem*> list = m_animationScene->items();
1369  QList<QGraphicsItem*>::iterator it;
1371 
1372  for(it = list.begin(); it != list.end(); ++it)
1373  {
1374  ti = (te::qt::widgets::TrajectoryItem*)(*it);
1375  QString title = ti->m_title;
1376  if(title == titlecb)
1377  break;
1378  }
1379  if(ti != 0)
1380  {
1381  ti->m_backwardColor = cor;
1382  //setAuxInfo(ti);
1383  }
1384  return true;
1385  }
1386  }
1387  else if(obj == m_spd->m_ui->m_iconPushButton)
1388  {
1389  if(e->type() == QEvent::Paint)
1390  {
1391  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
1392 
1393  QList<QGraphicsItem*> list = m_animationScene->items();
1394  QList<QGraphicsItem*>::iterator it;
1396 
1397  for(it = list.begin(); it != list.end(); ++it)
1398  {
1400  QPixmap pix = ai->pixmap();
1401  if(pix.isNull() == false)
1402  {
1404  QString title = ti->m_title;
1405  if(title == titlecb)
1406  break;
1407  }
1408  }
1409  if(ti != 0)
1410  {
1411  QPainter painter(m_spd->m_ui->m_iconPushButton);
1412  painter.fillRect(m_spd->m_ui->m_iconPushButton->rect(), QBrush(Qt::white));
1413  QPixmap pix = ti->pixmap();
1414  QRect r = pix.rect();
1415  r.moveCenter(m_spd->m_ui->m_iconPushButton->rect().center());
1416  painter.drawPixmap(r, pix, pix.rect());
1417  painter.end();
1418  }
1419  return true;
1420  }
1421  else if(e->type() == QEvent::MouseButtonPress)
1422  {
1423  QString fileName = QFileDialog::getOpenFileName(this, tr("Select File"), "C:/", tr("Images (*.png *.xpm *.jpg *.gif)"));
1424  if(fileName.isNull())
1425  return true;
1426 
1427  QPixmap pix(fileName);
1428  if(pix.isNull())
1429  {
1430  QMessageBox::information(this, "Pixmap Error", "Invalid File");
1431  return true;
1432  }
1433 
1434  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
1435 
1436  QList<QGraphicsItem*> list = m_animationScene->items();
1437  QList<QGraphicsItem*>::iterator it;
1439 
1440  for(it = list.begin(); it != list.end(); ++it)
1441  {
1443  if(ai->pixmap().isNull() == false)
1444  {
1446  QString title = ti->m_title;
1447  if(title == titlecb)
1448  break;
1449  }
1450  }
1451  if(ti != 0)
1452  {
1453  QPixmap pp(ti->m_iconSize);
1454  pp.fill(Qt::transparent);
1455  QPainter painter(&pp);
1456  painter.drawPixmap(pp.rect(), pix, pix.rect());
1457  painter.end();
1458  ti->m_iconFile = fileName;
1459  ti->setPixmap(pp);
1460  ti->m_iconSize = pp.size();
1461  m_spd->m_ui->m_iconPushButton->update();
1462  }
1463  return true;
1464  }
1465  }
1466  else if(obj == m_ui->m_dateTimeEdit)
1467  {
1468  if(e->type() == QEvent::MouseButtonRelease)
1469  {
1470  QDateTime d = m_ui->m_dateTimeEdit->dateTime();
1471  te::dt::TimeInstant tmin = m_temporalAnimationExtent.getInitialTimeInstant();
1472  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1473  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1474 
1475  te::dt::TimeInstant tmax = m_temporalAnimationExtent.getFinalTimeInstant();
1476  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1477  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1478  if(d <= minimum)
1479  d = minimum;
1480  else if(d >= maximun)
1481  d = maximun;
1482  else if(d == m_oldQDateTime)
1483  d = fixDateTimeEdit(m_ui->m_dateTimeEdit, d);
1484 
1485  m_ui->m_dateTimeEdit->setDateTime(d);
1486  m_oldQDateTime = d;
1487 
1488  if(d == minimum)
1489  onFinishAnimation();
1490  return false;
1491  }
1492  }
1493  else if(obj == m_spd->m_ui->m_initialAnimationDateTimeEdit)
1494  {
1495  if(e->type() == QEvent::MouseButtonRelease)
1496  {
1497  QDateTime d = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
1498  te::dt::TimeInstant tmin = m_temporalExtent.getInitialTimeInstant();
1499  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1500  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1501 
1502  te::dt::TimeInstant tmax = m_temporalExtent.getFinalTimeInstant();
1503  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1504  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1505  if(d <= minimum)
1506  d = minimum;
1507  else if(d >= maximun)
1508  d = maximun;
1509  else if(d == m_oldQDateTime)
1510  d = fixDateTimeEdit(m_spd->m_ui->m_initialAnimationDateTimeEdit, d);
1511 
1512  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(d);
1513  m_oldQDateTime = d;
1514  return false;
1515  }
1516  }
1517  else if(obj == m_spd->m_ui->m_finalAnimationDateTimeEdit)
1518  {
1519  if(e->type() == QEvent::MouseButtonRelease)
1520  {
1521  QDateTime d = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
1522  te::dt::TimeInstant tmin = m_temporalExtent.getInitialTimeInstant();
1523  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1524  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1525 
1526  te::dt::TimeInstant tmax = m_temporalExtent.getFinalTimeInstant();
1527  QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1528  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1529  if(d <= minimum)
1530  d = minimum;
1531  else if(d >= maximun)
1532  d = maximun;
1533  else if(d == m_oldQDateTime)
1534  d = fixDateTimeEdit(m_spd->m_ui->m_finalAnimationDateTimeEdit, d);
1535 
1536  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(d);
1537  m_oldQDateTime = d;
1538  return false;
1539  }
1540  }
1541  return QObject::eventFilter(obj, e);
1542 
1543 
1544  //if(e->type() == QEvent::Close)
1545  //{
1546  // if(obj == this)
1547  // {
1548  // e->ignore();
1549  // onStopToolButtonnClicked();
1550  // m_display->update();
1551 
1552  // hide();
1553  // deleteMe();
1554  // return true;
1555  // }
1556  // else if(obj == m_animationView)
1557  // {
1558  // e->ignore();
1559  // return true;
1560  // }
1561  //}
1562  //else if(e->type() == QEvent::Show)
1563  //{
1564  // if(obj == this)
1565  // return true;
1566  //}
1567  //else if(e->type() == QEvent::Enter)
1568  //{
1569  // if(obj == this)
1570  // {
1571  // if(graphicsEffect())
1572  // graphicsEffect()->setEnabled(false);
1573  // return true;
1574  // }
1575  //}
1576  //else if(e->type() == QEvent::Leave)
1577  //{
1578  // if(obj == this)
1579  // {
1580  // if(graphicsEffect())
1581  // graphicsEffect()->setEnabled(true);
1582  // return true;
1583  // }
1584  //}
1585  //else if(e->type() == QEvent::MouseButtonRelease)
1586  //if(e->type() == QEvent::MouseButtonRelease)
1587  //{
1588  // if(obj == m_ui->m_dateTimeEdit)
1589  // {
1590  // QDateTime d = m_ui->m_dateTimeEdit->dateTime();
1591  // te::dt::TimeInstant tmin = m_temporalAnimationExtent.getInitialTimeInstant();
1592  // QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1593  // QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1594 
1595  // te::dt::TimeInstant tmax = m_temporalAnimationExtent.getFinalTimeInstant();
1596  // QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1597  // QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1598  // if(d <= minimum)
1599  // d = minimum;
1600  // else if(d >= maximun)
1601  // d = maximun;
1602  // else if(d == m_oldQDateTime)
1603  // d = fixDateTimeEdit(m_ui->m_dateTimeEdit, d);
1604 
1605  // m_ui->m_dateTimeEdit->setDateTime(d);
1606  // m_oldQDateTime = d;
1607 
1608  // if(d == minimum)
1609  // onFinishAnimation();
1610  // return false;
1611  // }
1612  // else if(obj == m_spd->m_ui->m_initialAnimationDateTimeEdit)
1613  // {
1614  // QDateTime d = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
1615  // te::dt::TimeInstant tmin = m_temporalExtent.getInitialTimeInstant();
1616  // QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1617  // QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1618 
1619  // te::dt::TimeInstant tmax = m_temporalExtent.getFinalTimeInstant();
1620  // QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1621  // QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1622  // if(d <= minimum)
1623  // d = minimum;
1624  // else if(d >= maximun)
1625  // d = maximun;
1626  // else if(d == m_oldQDateTime)
1627  // d = fixDateTimeEdit(m_spd->m_ui->m_initialAnimationDateTimeEdit, d);
1628 
1629  // m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(d);
1630  // m_oldQDateTime = d;
1631  // return false;
1632  // }
1633  // else if(obj == m_spd->m_ui->m_finalAnimationDateTimeEdit)
1634  // {
1635  // QDateTime d = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
1636  // te::dt::TimeInstant tmin = m_temporalExtent.getInitialTimeInstant();
1637  // QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
1638  // QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
1639 
1640  // te::dt::TimeInstant tmax = m_temporalExtent.getFinalTimeInstant();
1641  // QDateTime maximun(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
1642  // QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
1643  // if(d <= minimum)
1644  // d = minimum;
1645  // else if(d >= maximun)
1646  // d = maximun;
1647  // else if(d == m_oldQDateTime)
1648  // d = fixDateTimeEdit(m_spd->m_ui->m_finalAnimationDateTimeEdit, d);
1649 
1650  // m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(d);
1651  // m_oldQDateTime = d;
1652  // return false;
1653  // }
1654  //}
1655  //return QWidget::eventFilter(obj, e);
1656 }
1657 
1659 {
1660  if(m_spd->isHidden())
1661  m_spd->show();
1662  else
1663  m_spd->hide();
1664 }
1665 
1667 {
1668  if(m_animationScene->items().isEmpty())
1669  return;
1670 
1671  int state = m_parallelAnimation->state();
1672  if(state == QAbstractAnimation::Running)
1673  {
1674  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
1675  m_parallelAnimation->pause();
1676  m_ui->m_dateTimeEdit->setEnabled(true);
1677  m_paused = true;
1678  }
1679  else
1680  {
1681  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-pause"));
1682  if(m_comingBack == false)
1683  {
1684  if(m_spd->m_ui->m_forwardRadioButton->isChecked())
1685  onForwardRadioButtonClicked(true);
1686  if(m_spd->m_ui->m_backwardRadioButton->isChecked())
1687  onBackwardRadioButtonClicked(true);
1688  }
1689  if(m_spd->m_ui->m_loopCheckBox->isChecked())
1690  onLoopCheckBoxClicked(true);
1691  if(m_spd->m_ui->m_goAndBackCheckBox->isChecked())
1692  onGoAndBackCheckBoxClicked(true);
1693 
1694  if(m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1695  {
1696  if(m_ui->m_TemporalHorizontalSlider->value() == m_maxSliderValue)
1697  {
1698  m_parallelAnimation->setCurrentTime(0);
1699  m_ui->m_TemporalHorizontalSlider->setValue(0);
1700  }
1701  }
1702  else
1703  {
1704  if(m_ui->m_TemporalHorizontalSlider->value() == 0)
1705  {
1706  m_parallelAnimation->setCurrentTime(m_duration);
1707  m_ui->m_TemporalHorizontalSlider->setValue(m_maxSliderValue);
1708  }
1709  }
1710  m_ui->m_dateTimeEdit->setEnabled(false);
1711  m_paused = false;
1712  play();
1713  }
1714 }
1715 
1717 {
1718  if(m_animationScene->items().isEmpty())
1719  return;
1720 
1721  m_parallelAnimation->stop();
1722  m_ui->m_dateTimeEdit->setEnabled(false);
1723  m_ui->m_playToolButton->setIcon(QIcon::fromTheme("media-playback-start"));
1724 
1725  if(m_goAndBack)
1726  {
1727  if(m_comingBack)
1728  {
1729  changeDirection();
1730  m_comingBack = false;
1731  }
1732  }
1733 
1734  if(m_finished == false)
1735  {
1736  if(m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1737  {
1738  m_ui->m_TemporalHorizontalSlider->setValue(0);
1739  m_parallelAnimation->setCurrentTime(0);
1740  }
1741  else
1742  {
1743  m_ui->m_TemporalHorizontalSlider->setValue(m_maxSliderValue);
1744  m_parallelAnimation->setCurrentTime(m_parallelAnimation->duration());
1745  }
1746  updateSliderPos();
1747  m_display->update();
1748  }
1749  m_finished = false;
1750 }
1751 
1753 {
1754  int state = m_parallelAnimation->state();
1755  if(state == QAbstractAnimation::Running)
1756  {
1757  m_parallelAnimation->pause();
1758  createNewPixmap();
1759  draw();
1760  m_display->update();
1761  m_parallelAnimation->resume();
1762  }
1763  else
1764  {
1765  createNewPixmap();
1766  draw();
1767  m_display->update();
1768  }
1769 }
1770 
1772 {
1773  int state = m_parallelAnimation->state();
1774  if(state == QAbstractAnimation::Running)
1775  {
1776  createNewPixmap();
1777  calculateSpatialExtent();
1778  createAnimations();
1779  draw();
1780  m_display->update();
1781  m_parallelAnimation->start();
1782  }
1783  else
1784  {
1785  createNewPixmap();
1786  calculateSpatialExtent();
1787  createAnimations();
1788  draw();
1789  m_display->update();
1790  }
1791 }
1792 
1794 {
1795  if(m_animationScene->items().isEmpty())
1796  return;
1797 
1798  int state = m_parallelAnimation->state();
1799  if(state == QAbstractAnimation::Stopped)
1800  {
1801  createNewPixmap();
1802  m_parallelAnimation->start();
1803  }
1804  else if(state == QAbstractAnimation::Paused)
1805  {
1806  m_parallelAnimation->resume();
1807  }
1808 }
1809 
1811 {
1812  int oldCurTime = m_parallelAnimation->currentTime();
1813 
1814  if(m_parallelAnimation->state() == QAbstractAnimation::Stopped)
1815  {
1816  onStopToolButtonnClicked();
1817  return;
1818  }
1819 
1820  double v = (double)value / (double)m_maxSliderValue;
1821 
1822  int curTime = qRound(v * (double)m_parallelAnimation->duration());
1823 
1824  if(curTime >= m_parallelAnimation->duration())
1825  curTime = m_parallelAnimation->duration();
1826 
1827  bool erase = false;
1828  if(m_goAndBack == true)
1829  {
1830  if(m_comingBack == false && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1831  erase = true;
1832  else if(m_comingBack == false && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1833  erase = true;
1834  else if(m_comingBack == true && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1835  erase = true;
1836  else if(m_comingBack == true && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1837  erase = true;
1838  }
1839  else
1840  {
1841  if(m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
1842  erase = true;
1843  else if(m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
1844  erase = true;
1845  }
1846 
1847  m_parallelAnimation->setCurrentTime(curTime);
1848  if(erase)
1849  this->erase(curTime);
1850 
1851  m_currentTime = curTime;
1852 
1853  if(m_currentTime == 0 || m_currentTime == m_parallelAnimation->duration())
1854  onFinishAnimation();
1855 
1856  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
1857  m_display->update();
1858 
1859  te::dt::TimeInstant tinstant = getTimeInstant();
1860  QDate qdate(tinstant.getDate().getYear(), tinstant.getDate().getMonth(), tinstant.getDate().getDay());
1861  QTime qtime(tinstant.getTime().getHours(), tinstant.getTime().getMinutes(), tinstant.getTime().getSeconds());
1862  QDateTime qdatetime(qdate, qtime);
1863  m_ui->m_dateTimeEdit->setDateTime(qdatetime);
1864 }
1865 
1867 {
1868  QAbstractAnimation::Direction direction = m_parallelAnimation->direction();
1869  if(direction == QAbstractAnimation::Forward)
1870  direction = QAbstractAnimation::Backward;
1871  else
1872  direction = QAbstractAnimation::Forward;
1873  setDirection(direction);
1874 }
1875 
1877 {
1878  if(m_paused)
1879  {
1880  if(m_currentTime >= m_duration && m_parallelAnimation->direction() == QAbstractAnimation::Forward)
1881  {
1882  m_currentTime = m_duration;
1883  changeDirection();
1884  m_comingBack = true;
1885  m_parallelAnimation->setCurrentTime(m_currentTime);
1886  }
1887  else if(m_currentTime <= 0 && m_parallelAnimation->direction() == QAbstractAnimation::Backward)
1888  {
1889  m_currentTime = 0;
1890  changeDirection();
1891  m_comingBack = false;
1892  m_parallelAnimation->setCurrentTime(m_currentTime);
1893  }
1894  //m_parallelAnimation->setCurrentTime(m_currentTime);
1895  play();
1896  m_parallelAnimation->pause();
1897  updateSliderPos();
1898  return;
1899  }
1900 
1901  m_finished = true;
1902  if(m_goAndBack)
1903  {
1904  changeDirection();
1905  m_comingBack = !m_comingBack;
1906  if(m_comingBack)
1907  {
1908  play();
1909  updateSliderPos();
1910  return;
1911  }
1912 
1913  if(m_loop)
1914  {
1915  m_currentTime = 0;
1916  m_parallelAnimation->setCurrentTime(m_currentTime);
1917  play();
1918  }
1919  else
1920  {
1921  if(m_comingBack == false)
1922  onStopToolButtonnClicked();
1923  }
1924  }
1925  else
1926  {
1927  if(m_loop)
1928  {
1929  play();
1930  }
1931  else
1932  onStopToolButtonnClicked();
1933  }
1934 }
1935 
1937 {
1938  m_currentTime = m_parallelAnimation->currentTime();
1939  int v = qRound((double)m_maxSliderValue * (double)m_currentTime/(double)m_duration);
1940 
1941  m_ui->m_TemporalHorizontalSlider->setValue(v);
1942 
1943  updateTimeTextEdit();
1944 }
1945 
1947 {
1948  if(m_ui->m_dateTimeEdit->isEnabled() == false && m_animationScene->items().isEmpty() == false)
1949  {
1950  te::dt::TimeInstant tinstant = getTimeInstant();
1951  QDate qdate(tinstant.getDate().getYear(), tinstant.getDate().getMonth(), tinstant.getDate().getDay());
1952  QTime qtime(tinstant.getTime().getHours(), tinstant.getTime().getMinutes(), tinstant.getTime().getSeconds());
1953  QDateTime qdatetime(qdate, qtime);
1954  m_ui->m_dateTimeEdit->setDateTime(qdatetime);
1955  }
1956 }
1957 
1959 {
1960  emit deleteTimeSliderWidget();
1961 }
1962 
1964 {
1965  int state = m_parallelAnimation->state();
1966  if(state == QAbstractAnimation::Running)
1967  onPlayToolButtonnClicked();
1968 
1969  QList<QGraphicsItem*> list = m_animationScene->items();
1970  int i = list.indexOf(item);
1971  list.takeAt(i);
1972  list.prepend(item); // put to last item
1973 
1974  QList<QGraphicsItem*>::iterator it = list.begin();
1975  while(it != list.end())
1976  {
1978  m_animationScene->removeItem(ai);
1979  }
1980 
1981  while(list.isEmpty() == false)
1982  {
1984  m_animationScene->addItem(ai);
1985  }
1986 
1987  onPlayToolButtonnClicked();
1988 }
1989 
1991 {
1992  int state = m_parallelAnimation->state();
1993  if(state == QAbstractAnimation::Running)
1994  onPlayToolButtonnClicked();
1995 
1996  QList<QGraphicsItem*> list = m_animationScene->items();
1997  int i = list.indexOf(item);
1998  list.takeAt(i);
1999  list.append(item); // put to first item
2000 
2001  QList<QGraphicsItem*>::iterator it = list.begin();
2002  while(it != list.end())
2003  {
2005  m_animationScene->removeItem(ai);
2006  }
2007 
2008  while(list.isEmpty() == false)
2009  {
2011  m_animationScene->addItem(ai);
2012  }
2013 
2014  onPlayToolButtonnClicked();
2015 }
2016 
2018 {
2019  QString title = m_spd->m_ui->m_animationComboBox->currentText();
2020 
2021  QList<QGraphicsItem*> list = m_animationScene->items();
2022  QList<QGraphicsItem*>::iterator it;
2023 
2024  for(it = list.begin(); it != list.end(); ++it)
2025  {
2027  QString atitle = ai->m_title;
2028  if(title == atitle)
2029  {
2030  putToFront(ai);
2031  break;
2032  }
2033  }
2034 }
2035 
2037 {
2038  QString title = m_spd->m_ui->m_animationComboBox->currentText();
2039 
2040  QList<QGraphicsItem*> list = m_animationScene->items();
2041  QList<QGraphicsItem*>::iterator it;
2042 
2043  for(it = list.begin(); it != list.end(); ++it)
2044  {
2046  QString atitle = ai->m_title;
2047  if(title == atitle)
2048  {
2049  putToBack(ai);
2050  break;
2051  }
2052  }
2053 }
2054 
2055 void te::qt::widgets::TimeSliderWidget::erase(const unsigned int& curTime)
2056 {
2057  QList<QGraphicsItem*> list = m_animationScene->items();
2058  QList<QGraphicsItem*>::iterator it;
2059  for(it = list.begin(); it != list.end(); ++it)
2060  {
2062  if(ai->pixmap().isNull() == false)
2063  ((te::qt::widgets::TrajectoryItem*)ai)->m_erasePerfectly = m_erasePerfectly;
2064  }
2065 
2066  if(m_erasePerfectly)
2067  {
2068  m_parallelAnimation->setCurrentTime(curTime);
2069  draw();
2070  }
2071  else
2072  m_parallelAnimation->setCurrentTime(curTime);
2073 
2074  m_currentTime = curTime;
2075 }
2076 
2078 {
2079  if(val == m_duration)
2080  return;
2081 
2082  m_currentTime = m_parallelAnimation->currentTime();
2083  double f = double(m_currentTime) / (double)m_duration;
2084 
2085  int step = m_ui->m_durationSpinBox->singleStep();
2086  int v = val;
2087  if(v == 100)
2088  v = 0;
2089 
2090  if(v == 0 || v == m_duration + step || v == m_duration - step)
2091  {
2092  if(step == 100)
2093  {
2094  if(v < step/10)
2095  v = 100;
2096  else if(v > step*10)
2097  {
2098  step *= 10;
2099  v = m_duration + step;
2100  }
2101  }
2102  else if(step == 1000)
2103  {
2104  if(v < step/10)
2105  {
2106  step /= 10;
2107  v = m_duration - step;
2108  }
2109  else if(v > step*10)
2110  {
2111  step *= 10;
2112  v = m_duration + step;
2113  }
2114  }
2115  else if(step == 10000)
2116  {
2117  if(v < step/10)
2118  {
2119  step /= 10;
2120  v = m_duration - step;
2121  }
2122  else if(v > step*10)
2123  {
2124  step *= 10;
2125  v = m_duration + step;
2126  }
2127  }
2128  else if(step == 100000)
2129  {
2130  if(v < step/10)
2131  {
2132  step /= 10;
2133  v = m_duration - step;
2134  }
2135  else if(v > step*10)
2136  {
2137  step *= 10;
2138  v = m_duration + step;
2139  }
2140  }
2141  else if(step == 1000000)
2142  {
2143  if(v < step/10)
2144  {
2145  step /= 10;
2146  v = m_duration - step;
2147  }
2148  else if(v > step*10)
2149  {
2150  step *= 10;
2151  v = m_duration + step;
2152  }
2153  }
2154 
2155  m_duration = (v / step) * step;
2156  m_ui->m_durationSpinBox->setValue(m_duration);
2157  m_ui->m_durationSpinBox->setSingleStep(step);
2158  }
2159  else
2160  m_duration = val;
2161 
2162  bool running = false;
2163  if(m_parallelAnimation->state() == QAbstractAnimation::Running)
2164  {
2165  running = true;;
2166  onPlayToolButtonnClicked();
2167  }
2168 
2169  m_currentTime = qRound(f * (double)m_duration);
2170  m_animationScene->m_mutex.lock();
2171  m_animationScene->m_trajectoryPixmap->fill(Qt::transparent);
2172  m_animationScene->m_mutex.unlock();
2173  setDuration(m_duration);
2174  m_parallelAnimation->setCurrentTime(m_currentTime);
2175  draw();
2176  if(running)
2177  onPlayToolButtonnClicked();
2178 }
2179 
2181 {
2182  if(m_ui->m_dateTimeEdit->isEnabled() == false)
2183  return;
2184 
2185  QDateTime t(qdt);
2186  int oldCurTime = m_parallelAnimation->currentTime();
2187 
2188  te::dt::TimeInstant tini = m_temporalAnimationExtent.getInitialTimeInstant();
2189  unsigned long totalSecs = m_temporalAnimationExtent.getTimePeriod().length().total_seconds();
2190 
2191  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
2192  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
2193  te::dt::TimeInstant time(date, duration);
2194 
2195  te::dt::TimePeriod tp(tini, time);
2196  unsigned long secs = tp.getTimePeriod().length().total_seconds();
2197 
2198  double v = (double)secs / (double)totalSecs;
2199  int curTime = qRound(v * (double)m_parallelAnimation->duration());
2200 
2201  if(curTime > m_parallelAnimation->duration())
2202  curTime = m_parallelAnimation->duration();
2203 
2204  bool erase = false;
2205  if(m_goAndBack == true)
2206  {
2207  if(m_comingBack == false && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
2208  erase = true;
2209  else if(m_comingBack == false && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
2210  erase = true;
2211  else if(m_comingBack == true && m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
2212  erase = true;
2213  else if(m_comingBack == true && m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
2214  erase = true;
2215  }
2216  else
2217  {
2218  if(m_direction == QAbstractAnimation::Forward && curTime < oldCurTime)
2219  erase = true;
2220  else if(m_direction == QAbstractAnimation::Backward && curTime > oldCurTime)
2221  erase = true;
2222  }
2223 
2224  m_currentTime = curTime;
2225  m_parallelAnimation->setCurrentTime(curTime);
2226  if(erase)
2227  this->erase(curTime);
2228 
2229  if(m_parallelAnimation->state() == QAbstractAnimation::Paused)
2230  m_display->update();
2231 }
2232 
2233 QDateTime te::qt::widgets::TimeSliderWidget::fixDateTimeEdit(QDateTimeEdit* dte, const QDateTime& qdt)
2234 {
2235  QDateTime t(qdt);
2236  QDateTimeEdit::Section section = dte->currentSection();
2237  if(section == QDateTimeEdit::SecondSection)
2238  {
2239  int sec = t.time().second();
2240  if(sec == 0)
2241  t = t.addSecs(-1);
2242  else
2243  t = t.addSecs(1);
2244  }
2245  else if(section == QDateTimeEdit::MinuteSection)
2246  {
2247  int min = t.time().minute();
2248  if(min == 0)
2249  t = t.addSecs(-60);
2250  else
2251  t = t.addSecs(60);
2252  }
2253  else if(section == QDateTimeEdit::HourSection)
2254  {
2255  int hour = t.time().hour();
2256  if(hour == 0)
2257  t = t.addSecs(-3600);
2258  else
2259  t = t.addSecs(3600);
2260  }
2261  else if(section == QDateTimeEdit::DaySection)
2262  {
2263  int day = t.date().day();
2264  if(day == 1)
2265  t = t.addDays(-1);
2266  else
2267  t = t.addDays(1);
2268  }
2269  else if(section == QDateTimeEdit::MonthSection)
2270  {
2271  int month = t.date().month();
2272  if(month == 1)
2273  t = t.addMonths(-1);
2274  else
2275  t = t.addMonths(1);
2276  }
2277 
2278  return t;
2279 }
2280 
2281 void te::qt::widgets::TimeSliderWidget::drawPixmapItem(te::qt::widgets::PixmapItem* pi, const QRectF& dwrect, QPainter* painter)
2282 {
2283  if(pi->m_currentImageFile.isEmpty())
2284  return;
2285 
2286  QRectF rec = pi->m_imaRect;
2287  if(dwrect.intersects(rec))
2288  {
2289  QRect r = pi->m_matrix.mapRect(rec).toRect();
2290  QImage* ima = getImage(pi);
2291 
2292  if(pi->m_opacity == 255)
2293  painter->drawImage(r, *ima);
2294  else
2295  {
2296  QSize size = ima->size();
2297  int width = size.width();
2298  int height = size.height();
2299 
2300  if(ima->format() == QImage::Format_ARGB32)
2301  {
2302  for(int i = 0; i < height; ++i)
2303  {
2304  unsigned char* u = ima->scanLine(i);
2305  for(int j = 0; j < width; ++j)
2306  {
2307  QRgb* v = (QRgb*)(u + (j << 2));
2308  if(qAlpha(*v) > 50)
2309  *v = qRgba(qRed(*v), qGreen(*v), qBlue(*v) , pi->m_opacity);
2310  }
2311  }
2312  painter->drawImage(r, *ima);
2313  }
2314  else
2315  {
2316  QImage img(size, QImage::Format_ARGB32);
2317  for(int i = 0; i < height; ++i)
2318  {
2319  unsigned char* u = ima->scanLine(i);
2320  unsigned char* uu = img.scanLine(i);
2321 
2322  for(int j = 0; j < width; ++j)
2323  {
2324  QRgb* v = (QRgb*)(u + (j << 2));
2325  QRgb* uv = (QRgb*)(uu + (j << 2));
2326  if(qAlpha(*v) > 50)
2327  *uv = qRgba(qRed(*v), qGreen(*v), qBlue(*v) , pi->m_opacity);
2328  }
2329  }
2330  painter->drawImage(r, img);
2331  }
2332  }
2333  delete ima;
2334  }
2335 }
2336 
2338 {
2339  if(t->m_opacity == 255)
2340  painter->drawPixmap(pos, t->pixmap());
2341  else
2342  {
2343  QSize size = t->pixmap().size();
2344  int width = size.width();
2345  int height = size.height();
2346  QImage ima = t->pixmap().toImage();
2347 
2348  if(ima.format() == QImage::Format_ARGB32)
2349  {
2350  for(int i = 0; i < height; ++i)
2351  {
2352  unsigned char* u = ima.scanLine(i);
2353  for(int j = 0; j < width; ++j)
2354  {
2355  QRgb* v = (QRgb*)(u + (j << 2));
2356  if(qAlpha(*v) < 50)
2357  *v = qRgba(255, 255, 255 , 0);
2358  else
2359  *v = qRgba(qRed(*v), qGreen(*v), qBlue(*v) , t->m_opacity);
2360  }
2361  }
2362  painter->drawImage(pos, ima);
2363  }
2364  else
2365  {
2366  QImage img(size, QImage::Format_ARGB32);
2367  for(int i = 0; i < height; ++i)
2368  {
2369  unsigned char* u = ima.scanLine(i);
2370  unsigned char* uu = img.scanLine(i);
2371 
2372  for(int j = 0; j < width; ++j)
2373  {
2374  QRgb* v = (QRgb*)(u + (j << 2));
2375  QRgb* uv = (QRgb*)(uu + (j << 2));
2376  if(qAlpha(*v) < 50)
2377  *uv = qRgba(255, 255, 255 , 0);
2378  else
2379  *uv = qRgba(qRed(*v), qGreen(*v), qBlue(*v) , t->m_opacity);
2380  }
2381  }
2382  painter->drawImage(pos, img);
2383  }
2384  }
2385 }
2386 
2388 {
2389  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
2390 
2391  QList<QGraphicsItem*> list = m_animationScene->items();
2392  QList<QGraphicsItem*>::iterator it;
2393 
2394  for(it = list.begin(); it != list.end(); ++it)
2395  {
2397  QString title = ai->m_title;
2398  if(title.contains(titlecb))
2399  {
2400  ai->m_opacity = v;
2401  //setAuxInfo(ai);
2402  m_display->update();
2403  break;
2404  }
2405  }
2406 }
2407 
2409 {
2410  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
2411 
2412  QList<QGraphicsItem*> list = m_animationScene->items();
2413  QList<QGraphicsItem*>::iterator it;
2414 
2415  for(it = list.begin(); it != list.end(); ++it)
2416  {
2418  QString title = ai->m_title;
2419  if(title.contains(titlecb))
2420  {
2421  QPixmap pix = ai->pixmap();
2422 
2423  QPixmap pn(m_spd->m_ui->m_widthSpinBox->value(), m_spd->m_ui->m_heightSpinBox->value());
2424  pn.fill(Qt::transparent);
2425  if(pix.isNull() == false)
2426  {
2428  QString file = ti->m_iconFile;
2429  if(file.isEmpty() == false)
2430  {
2431  QFile f(file);
2432  if(f.exists())
2433  {
2434  QPixmap pf(file);
2435  QPainter painter(&pn);
2436  painter.drawPixmap(pn.rect(), pf, pf.rect());
2437  painter.end();
2438  ti->setPixmap(pn);
2439  ti->m_iconSize = pn.size();
2440  m_spd->m_ui->m_iconPushButton->update();
2441  m_display->update();
2442  break;
2443  }
2444  }
2445 
2446  pn.fill(Qt::transparent);
2447  QPainter painter(&pn);
2448  QBrush b(Qt::red);
2449  painter.setBrush(b);
2450  QPen p(Qt::red);
2451  painter.setPen(p);
2452  painter.drawEllipse(QRect(1, 1, 18, 18));
2453  painter.end();
2454  ti->setPixmap(pn);
2455  ti->m_iconSize = pn.size();
2456  m_spd->m_ui->m_iconPushButton->update();
2457  }
2458  m_display->update();
2459  break;
2460  }
2461  }
2462 }
2463 
2465 {
2466  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
2467 
2468  QList<QGraphicsItem*> list = m_animationScene->items();
2469  QList<QGraphicsItem*>::iterator it;
2470 
2471  for(it = list.begin(); it != list.end(); ++it)
2472  {
2474  QString title = ai->m_title;
2475  if(title.contains(titlecb))
2476  {
2477  QPixmap pix = ai->pixmap();
2478  QPixmap pn(m_spd->m_ui->m_widthSpinBox->value(), m_spd->m_ui->m_heightSpinBox->value());
2479  pn.fill(Qt::transparent);
2480  if(pix.isNull() == false)
2481  {
2483  QString file = ti->m_iconFile;
2484  if(file.isEmpty() == false)
2485  {
2486  QFile f(file);
2487  if(f.exists())
2488  {
2489  QPixmap pf(file);
2490  QPainter painter(&pn);
2491  painter.drawPixmap(pn.rect(), pf, pf.rect());
2492  painter.end();
2493  ti->setPixmap(pn);
2494  ti->m_iconSize = pn.size();
2495  m_spd->m_ui->m_iconPushButton->update();
2496  m_display->update();
2497  break;
2498  }
2499  }
2500 
2501  QPainter painter(&pn);
2502  QBrush b(Qt::red);
2503  painter.setBrush(b);
2504  QPen p(Qt::red);
2505  painter.setPen(p);
2506  painter.drawEllipse(QRect(1, 1, 18, 18));
2507  painter.end();
2508  m_spd->m_ui->m_iconPushButton->update();
2509  ti->setPixmap(pn);
2510  ti->m_iconSize = pn.size();
2511  }
2512  m_display->update();
2513  break;
2514  }
2515  }
2516 }
2517 
2519 {
2520  te::dt::TimeInstant ti = m_temporalAnimationExtent.getInitialTimeInstant();
2521  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
2522  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
2523  QDateTime qdatetimei(qdatei, qtimei);
2524  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetimei);
2525 
2526  te::dt::TimeInstant tf = m_temporalAnimationExtent.getFinalTimeInstant();
2527  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
2528  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
2529  QDateTime qdatetimef(qdatef, qtimef);
2530  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetimef);
2531 
2532  if(m_direction == QAbstractAnimation::Forward)
2533  {
2534  if(m_spd->m_ui->m_forwardRadioButton->isChecked() == false)
2535  m_spd->m_ui->m_forwardRadioButton->toggle();
2536  }
2537 
2538  if(m_loop)
2539  m_spd->m_ui->m_loopCheckBox->setChecked(true);
2540  if(m_goAndBack)
2541  m_spd->m_ui->m_goAndBackCheckBox->setChecked(true);
2542 }
2543 
2545 {
2546  QDateTime t = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2547  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
2548  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
2549  te::dt::TimeInstant time(date, duration);
2550  return time;
2551 }
2552 
2554 {
2555  QDateTime t = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2556  te::dt::Date date(t.date().year(), t.date().month(), t.date().day());
2557  te::dt::TimeDuration duration(t.time().hour(), t.time().minute(), t.time().second());
2558  te::dt::TimeInstant time(date, duration);
2559  return time;
2560 }
2561 
2563 {
2564  te::dt::TimeInstant t = m_temporalExtent.getInitialTimeInstant();
2565  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2566  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2567  QDateTime qdatetime(qdate, qtime);
2568  m_spd->m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetime);
2569 }
2570 
2572 {
2573  te::dt::TimeInstant t = m_temporalExtent.getFinalTimeInstant();
2574  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2575  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2576  QDateTime qdatetime(qdate, qtime);
2577  m_spd->m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetime);
2578 }
2579 
2581 {
2582  if(b==false && m_spd->m_ui->m_propertyWidget->isHidden())
2583  return;
2584  if(b==true && m_spd->m_ui->m_propertyWidget->isHidden()==false)
2585  return;
2586 
2587  int h = m_spd->m_ui->m_propertyWidget->height();
2588 
2589  if(b == false)
2590  {
2591  m_spd->m_ui->m_propertyWidget->hide();
2592  resize(width(), height()-h);
2593  }
2594  else
2595  {
2596  m_spd->m_ui->m_propertyWidget->show();
2597  resize(width(), height()+h);
2598  }
2599 }
2600 
2602 {
2603  te::dt::TimeInstant ti = m_temporalAnimationExtent.getInitialTimeInstant();
2604  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
2605  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
2606  QDateTime qdatetimei(qdatei, qtimei);
2607  QDateTime qdi = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2608  if(qdatetimei != qdi)
2609  return true;
2610 
2611  te::dt::TimeInstant tf = m_temporalAnimationExtent.getFinalTimeInstant();
2612  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
2613  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
2614  QDateTime qdatetimef(qdatef, qtimef);
2615  QDateTime qdf = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2616  if(qdatetimef != qdf)
2617  return true;
2618 
2619  if(m_spd->m_ui->m_forwardRadioButton->isChecked() && m_direction != QAbstractAnimation::Forward)
2620  return true;
2621  if(m_spd->m_ui->m_forwardRadioButton->isChecked() == false && m_direction != QAbstractAnimation::Backward)
2622  return true;
2623  if(m_spd->m_ui->m_loopCheckBox->isChecked() != m_loop)
2624  return true;
2625  if(m_spd->m_ui->m_goAndBackCheckBox->isChecked() != m_goAndBack)
2626  return true;
2627 
2628  return false;
2629 }
2630 
2632 {
2633  if(m_direction == QAbstractAnimation::Forward)
2634  {
2635  if(m_comingBack)
2636  m_comingBack = false;
2637  }
2638  else
2639  changeDirection();
2640 }
2641 
2643 {
2644  if(m_direction == QAbstractAnimation::Backward)
2645  {
2646  if(m_comingBack)
2647  m_comingBack = false;
2648  }
2649  else
2650  changeDirection();
2651 }
2652 
2654 {
2655  m_loop = b;
2656 }
2657 
2659 {
2660  if(m_goAndBack != b)
2661  {
2662  if(m_comingBack)
2663  {
2664  changeDirection();
2665  m_comingBack = false;
2666  }
2667  }
2668 
2669  m_goAndBack = b;
2670 }
2671 
2673 {
2674  te::dt::TimeInstant ti = getInitialTime();
2675  te::dt::TimeInstant tf = getFinalTime();
2676  if(ti > tf || ti == tf)
2677  {
2678  QMessageBox::warning(this, "Time Extent Error", "Initial time can not be larger than the end time!", QMessageBox::Ok);
2679  return;
2680  }
2681 
2682  te::dt::TimeInstant tinst = getTimeInstant();
2683  boost::posix_time::ptime btinst = tinst.getTimeInstant();
2684 
2685  te::dt::TimeInstant t = m_temporalAnimationExtent.getInitialTimeInstant();
2686  QDate qdatei(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2687  QTime qtimei(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2688  QDateTime qdatetimei(qdatei, qtimei);
2689  QDateTime qdi = m_spd->m_ui->m_initialAnimationDateTimeEdit->dateTime();
2690  boost::posix_time::ptime iTime = t.getTimeInstant();
2691 
2692  t = m_temporalAnimationExtent.getFinalTimeInstant();
2693  QDate qdatef(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2694  QTime qtimef(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2695  QDateTime qdatetimef(qdatef, qtimef);
2696  QDateTime qdf = m_spd->m_ui->m_finalAnimationDateTimeEdit->dateTime();
2697  boost::posix_time::ptime fTime = t.getTimeInstant();
2698  if(qdatetimei == qdi && qdatetimef == qdf)
2699  return;
2700 
2701  boost::posix_time::ptime niTime = ti.getTimeInstant();
2702  boost::posix_time::ptime nfTime = tf.getTimeInstant();
2703  boost::posix_time::time_duration ndiff = nfTime - niTime;
2704  double ntotalSeconds = ndiff.total_seconds();
2705 
2706  boost::posix_time::time_duration diff = fTime - iTime;
2707  double totalSeconds = diff.total_seconds();
2708  double rel = m_duration / totalSeconds;
2709 
2710  int nduration = qRound(rel * ntotalSeconds);
2711 
2712  //m_currentTime = m_parallelAnimation->currentTime();
2713  m_currentTime = 0;
2714  if(btinst >= niTime && btinst <= nfTime)
2715  {
2716  boost::posix_time::time_duration d = btinst - niTime;
2717  double tot = d.total_seconds();
2718  m_currentTime = qRound(nduration * tot / ntotalSeconds);
2719  }
2720  else
2721  m_currentTime = nduration;
2722 
2723  int state = m_parallelAnimation->state();
2724  if(state == QAbstractAnimation::Running)
2725  onPlayToolButtonnClicked();
2726 
2727  QDateTime dt = m_ui->m_dateTimeEdit->dateTime();
2728  te::dt::TimePeriod tp = m_temporalAnimationExtent;
2729 
2730  m_temporalAnimationExtent = te::dt::TimePeriod(ti, tf);
2731 
2732  createNewPixmap();
2733  calculateSpatialExtent();
2734  createAnimations();
2735  m_duration = nduration;
2736  m_ui->m_durationSpinBox->setValue(m_duration);
2737  setDuration(m_duration);
2738  setDirection(m_direction);
2739 
2740  if(state == QAbstractAnimation::Running)
2741  {
2742  onPlayToolButtonnClicked();
2743  m_parallelAnimation->setCurrentTime(m_currentTime);
2744  m_parallelAnimation->start();
2745  }
2746  else
2747  {
2748  m_parallelAnimation->setCurrentTime(m_currentTime);
2749  m_parallelAnimation->start();
2750  if(state == QAbstractAnimation::Paused)
2751  m_parallelAnimation->pause();
2752  }
2753 
2754  if(tp == m_temporalAnimationExtent)
2755  onDateTimeEditChanged(dt);
2756 }
2757 
2758 //void te::qt::widgets::TimeSliderWidget::onTrajectoryColorComboBoxActivated(int i)
2759 //{
2760 // QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
2761 //
2762 // QList<QGraphicsItem*> list = m_animationScene->items();
2763 // QList<QGraphicsItem*>::iterator it;
2764 // te::qt::widgets::TrajectoryItem* ti = 0;
2765 //
2766 // for(it = list.begin(); it != list.end(); ++it)
2767 // {
2768 // ti = (te::qt::widgets::TrajectoryItem*)(*it);
2769 // QString title = ti->m_title;
2770 // if(title == titlecb)
2771 // break;
2772 // }
2773 // if(ti == 0)
2774 // return;
2775 //
2776 // m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(ti->m_forwardColor));
2777 // m_spd->m_ui->m_forwardColorPushButton->update();
2778 // m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(ti->m_backwardColor));
2779 // m_spd->m_ui->m_backwardColorPushButton->update();
2780 // m_spd->m_ui->m_autoPanCheckBox->setChecked(ti->m_automaticPan);
2781 // m_spd->m_ui->m_drawTrailCheckBox->setChecked(ti->m_drawTrail);
2782 //}
2783 
2785 {
2786  QString titlecb = m_spd->m_ui->m_animationComboBox->currentText();
2787 
2788  QList<QGraphicsItem*> list = m_animationScene->items();
2789  QList<QGraphicsItem*>::iterator it;
2790 
2791  for(it = list.begin(); it != list.end(); ++it)
2792  {
2794  QString title = ai->m_title;
2795  if(title.contains(titlecb))
2796  {
2797  int op = ai->m_opacity;
2798  m_spd->m_ui->m_opacitySpinBox->setValue(op);
2799  te::dt::TimeInstant tini = ai->m_time.first();
2800  QString sini = getDateString(tini);
2801  te::dt::TimeInstant tfim = ai->m_time.last();
2802  QString sfim = getDateString(tfim);
2803  m_spd->m_ui->m_initialTimeLineEdit->setText(sini);
2804  m_spd->m_ui->m_finalTimeLineEdit->setText(sfim);
2805 
2806  adjustTrajectoryGroupBox(ai);
2807  break;
2808  }
2809  }
2810 }
2811 
2813 {
2814  QDate qdate(t.getDate().getYear(), t.getDate().getMonth(), t.getDate().getDay());
2815  QTime qtime(t.getTime().getHours(), t.getTime().getMinutes(), t.getTime().getSeconds());
2816  QDateTime qdatetime(qdate, qtime);
2817  return qdatetime.toString("dd/MMM/yyyy hh:mm:ss");
2818 }
2819 
2821 {
2822  QPixmap pix = ai->pixmap();
2823  if(pix.isNull()) // is temporal image
2824  {
2825  m_spd->m_ui->m_trajectoryGroupBox->setEnabled(false);
2826  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(Qt::gray));
2827  m_spd->m_ui->m_forwardColorPushButton->update();
2828  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(Qt::gray));
2829  m_spd->m_ui->m_backwardColorPushButton->update();
2830  m_spd->m_ui->m_autoPanCheckBox->setChecked(false);
2831  m_spd->m_ui->m_drawTrailCheckBox->setChecked(false);
2832  }
2833  else // is trajectory
2834  {
2835  m_spd->m_ui->m_trajectoryGroupBox->setEnabled(true);
2837  m_spd->m_ui->m_forwardColorPushButton->setPalette(QPalette(ti->m_forwardColor));
2838  m_spd->m_ui->m_forwardColorPushButton->update();
2839  m_spd->m_ui->m_backwardColorPushButton->setPalette(QPalette(ti->m_backwardColor));
2840  m_spd->m_ui->m_backwardColorPushButton->update();
2841  m_spd->m_ui->m_autoPanCheckBox->setChecked(ti->m_automaticPan);
2842  m_spd->m_ui->m_panFactorDoubleSpinBox->setValue(ti->m_panFactor);
2843  m_spd->m_ui->m_drawTrailCheckBox->setChecked(ti->m_drawTrail);
2844 
2845  QPixmap pix = ti->pixmap();
2846  m_spd->m_ui->m_widthSpinBox->setValue(pix.width());
2847  m_spd->m_ui->m_heightSpinBox->setValue(pix.height());
2848  m_spd->m_ui->m_iconPushButton->update();
2849  }
2850 }
2851 
2852 //void te::qt::widgets::TimeSliderWidget::removeComboItem(te::qt::widgets::AnimationItem* ai)
2853 //{
2854 // QString title = ai->m_title;
2855 // int index = m_spd->m_ui->m_animationComboBox->findText(title);
2856 // m_spd->m_ui->m_animationComboBox->removeItem(index);
2857 // onAnimationComboBoxActivated(m_spd->m_ui->m_animationComboBox->currentIndex());
2858 //
2859 // //index = m_spd->m_ui->m_animationComboBox->findText(title);
2860 // //m_spd->m_ui->m_animationComboBox->removeItem(index);
2861 // //onTrajectoryColorComboBoxActivated(m_spd->m_ui->m_animationComboBox->currentIndex());
2862 //}
2863 
2865 {
2866  QString file(fileName);
2867  int ind = file.indexOf("_");
2868  if(file.indexOf("_", ind+1) != -1)
2869  ind = file.indexOf("_", ind+1);
2870  file.remove(0, ind+1);
2871  QString ano(file), mes(file), dia(file), hour(file), min(file);
2872  ano.remove(4, ano.length()-4);
2873  mes.remove(0, 4);
2874  mes.remove(2, mes.length()-2);
2875  dia.remove(0, 6);
2876  dia.remove(2, dia.length()-2);
2877  hour.remove(0, 8);
2878  hour.remove(2, hour.length()-2);
2879  min.remove(0, 10);
2880  min.remove(2, min.length()-2);
2881 
2882  te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
2883  te::dt::TimeDuration dur(hour.toInt(), min.toInt(), 0);
2884  return te::dt::TimeInstant(date, dur);
2885 }
2886 
2888 {
2889  QString title = m_spd->m_ui->m_animationComboBox->currentText();
2890  setAutomaticPan(title);
2891 }
2892 
2894 {
2895  char buf[2000];
2896  QString file(path + "/racc.ctl");
2897  FILE* fp = fopen(file.toStdString().c_str(), "r");
2898  if(fp == 0)
2899  return 0;
2900 
2901  fread(buf, 2000, sizeof(char), fp);
2902  fclose(fp);
2903  QString ss(QString(buf).simplified());
2904 
2905  // validation
2906  if(!(ss.contains("undef ", Qt::CaseInsensitive) && ss.contains("title", Qt::CaseInsensitive) &&
2907  ss.contains("xdef", Qt::CaseInsensitive) && ss.contains("ydef", Qt::CaseInsensitive) &&
2908  ss.contains("linear", Qt::CaseInsensitive) && ss.contains("zdef", Qt::CaseInsensitive)))
2909  return 0;
2910 
2911  QString s;
2912  QDir dir(path);
2913  te::qt::widgets::PixmapItem* pi = new PixmapItem(dir.dirName(), path, m_display);
2914 
2915  // CHUTE SRID 4326 WGS84
2916  pi->m_SRID = 4326;
2917 
2918  // get UNDEF value
2919  size_t pos = ss.indexOf("UNDEF ", Qt::CaseInsensitive) + strlen("UNDEF ");
2920  ss.remove(0, pos);
2921  pos = ss.indexOf("TITLE", Qt::CaseInsensitive);
2922  s = ss.left(pos);
2923  pi->m_undef = atoi(s.toStdString().c_str());
2924  ss.remove(0, pos);
2925 
2926  // get XDEF ulx and resX values
2927  pos = ss.indexOf("XDEF ", Qt::CaseInsensitive) + strlen("XDEF ");
2928  ss.remove(0, pos);
2929  pos = ss.indexOf(" ");
2930  s = ss.left(pos);
2931  pi->m_ncols = atoi(s.toStdString().c_str());
2932  ss.remove(0, pos);
2933 
2934  pos = ss.indexOf("LINEAR ", Qt::CaseInsensitive) + strlen("LINEAR ");
2935  ss.remove(0, pos);
2936  pos = ss.indexOf(" ");
2937  s = ss.left(pos);
2938  double llx = atof(s.toStdString().c_str()) - 360.;
2939  ss.remove(0, pos);
2940  pos = ss.indexOf("YDEF ", Qt::CaseInsensitive);
2941  s = ss.left(pos);
2942  double resX = atof(s.toStdString().c_str());
2943  ss.remove(0, pos);
2944 
2945  // get YDEF uly and resY values
2946  pos = ss.indexOf("YDEF ", Qt::CaseInsensitive) + strlen("YDEF ");
2947  ss.remove(0, pos);
2948  pos = ss.indexOf(" ");
2949  s = ss.left(pos);
2950  pi->m_nlines = atoi(s.toStdString().c_str());
2951  ss.remove(0, pos);
2952 
2953  pos = ss.indexOf("LINEAR ", Qt::CaseInsensitive) + strlen("LINEAR ");
2954  ss.remove(0, pos);
2955  pos = ss.indexOf(" ");
2956  s = ss.left(pos);
2957  double lly = atof(s.toStdString().c_str());
2958  ss.remove(0, pos);
2959  pos = ss.indexOf("ZDEF ", Qt::CaseInsensitive);
2960  s = ss.left(pos);
2961  double resY = atof(s.toStdString().c_str());
2962  ss.remove(0, pos);
2963 
2964  double w = (double)pi->m_ncols * resX;
2965  double h = (double)pi->m_nlines * resY;
2966  pi->m_imaRect = QRectF(llx, lly, w, h);
2967 
2968  return pi;
2969 }
2970 
2972 {
2973  std::vector<std::pair<int, QColor> > tab;
2974  int i = 0;
2975  tab.push_back(std::pair<int, QColor>(i+=3, QColor(2, 1, 201, 255)));
2976  tab.push_back(std::pair<int, QColor>(i+=3, QColor(1, 71, 254, 255)));
2977  tab.push_back(std::pair<int, QColor>(i+=3, QColor(3, 148, 250, 255)));
2978  tab.push_back(std::pair<int, QColor>(i+=3, QColor(5, 200, 251, 255)));
2979  tab.push_back(std::pair<int, QColor>(i+=3, QColor(2, 254, 233, 255)));
2980  tab.push_back(std::pair<int, QColor>(i+=3, QColor(1, 254, 151, 255)));
2981  tab.push_back(std::pair<int, QColor>(i+=3, QColor(2, 254, 4, 255)));
2982  tab.push_back(std::pair<int, QColor>(i+=3, QColor(99, 254, 2, 255)));
2983  tab.push_back(std::pair<int, QColor>(i+=3, QColor(200, 255, 1, 255)));
2984  tab.push_back(std::pair<int, QColor>(i+=3, QColor(237, 255, 0, 255)));
2985  tab.push_back(std::pair<int, QColor>(i+=3, QColor(251, 232, 2, 255)));
2986  tab.push_back(std::pair<int, QColor>(i+=3, QColor(254, 199, 2, 255)));
2987  tab.push_back(std::pair<int, QColor>(i+=3, QColor(252, 179, 2, 255)));
2988  tab.push_back(std::pair<int, QColor>(i+=3, QColor(254, 147, 4, 255)));
2989  tab.push_back(std::pair<int, QColor>(i+=3, QColor(253, 99, 2, 255)));
2990  tab.push_back(std::pair<int, QColor>(i+=3, QColor(254, 1, 2, 255)));
2991  tab.push_back(std::pair<int, QColor>(i+=3, QColor(254, 0, 49, 255)));
2992  tab.push_back(std::pair<int, QColor>(i+=3, QColor(255, 5, 1, 255)));
2993 
2994  pi->setLUT(tab);
2995 }
2996 
2998 {
2999  char buf[2000];
3000  QString file(path + "/Prec5km.ctl");
3001  FILE* fp = fopen(file.toStdString().c_str(), "r");
3002  if(fp == 0)
3003  return 0;
3004 
3005  fread(buf, 2000, sizeof(char), fp);
3006  fclose(fp);
3007  QString ss(QString(buf).simplified());
3008 
3009  // validation
3010  if(!(ss.contains("undef ", Qt::CaseInsensitive) && ss.contains("xdef", Qt::CaseInsensitive)
3011  && ss.contains("ydef", Qt::CaseInsensitive) && ss.contains("linear", Qt::CaseInsensitive)
3012  && ss.contains("zdef", Qt::CaseInsensitive)))
3013  return 0;
3014 
3015  QString s;
3016  QDir dir(path);
3017  te::qt::widgets::PixmapItem* pi = new PixmapItem(dir.dirName(), path, m_display);
3018 
3019  // CHUTE SRID 4326 WGS84
3020  pi->m_SRID = 4326;
3021 
3022  // get UNDEF value
3023  size_t pos = ss.indexOf("undef ", Qt::CaseInsensitive) + strlen("undef ");
3024  ss.remove(0, pos);
3025  pos = ss.indexOf("xdef", Qt::CaseInsensitive);
3026  s = ss.left(pos);
3027  pi->m_undef = atof(s.toStdString().c_str());
3028  ss.remove(0, pos);
3029 
3030  // get XDEF ulx and resX values
3031  pos = ss.indexOf("xdef ", Qt::CaseInsensitive) + strlen("xdef ");
3032  ss.remove(0, pos);
3033  pos = ss.indexOf(" ");
3034  s = ss.left(pos);
3035  pi->m_ncols = atoi(s.toStdString().c_str());
3036  ss.remove(0, pos);
3037 
3038  pos = ss.indexOf("linear ", Qt::CaseInsensitive) + strlen("linear ");
3039  ss.remove(0, pos);
3040  pos = ss.indexOf(" ");
3041  s = ss.left(pos);
3042  double llx = atof(s.toStdString().c_str());
3043  ss.remove(0, pos);
3044  pos = ss.indexOf("ydef ", Qt::CaseInsensitive);
3045  s = ss.left(pos);
3046  double resX = atof(s.toStdString().c_str());
3047  ss.remove(0, pos);
3048 
3049  // get YDEF uly and resY values
3050  pos = ss.indexOf("ydef ", Qt::CaseInsensitive) + strlen("ydef ");
3051  ss.remove(0, pos);
3052  pos = ss.indexOf(" ");
3053  s = ss.left(pos);
3054  pi->m_nlines = atoi(s.toStdString().c_str());
3055  ss.remove(0, pos);
3056 
3057  pos = ss.indexOf("linear ", Qt::CaseInsensitive) + strlen("linear ");
3058  ss.remove(0, pos);
3059  pos = ss.indexOf(" ");
3060  s = ss.left(pos);
3061  double lly = atof(s.toStdString().c_str());
3062  ss.remove(0, pos);
3063  pos = ss.indexOf("zdef ", Qt::CaseInsensitive);
3064  s = ss.left(pos);
3065  double resY = atof(s.toStdString().c_str());
3066  ss.remove(0, pos);
3067 
3068  double w = (double)pi->m_ncols * resX;
3069  double h = (double)pi->m_nlines * resY;
3070  pi->m_imaRect = QRectF(llx, lly, w, h);
3071 
3072  return pi;
3073 }
3074 
3076 {
3077  std::vector<std::pair<int, QColor> > tab;
3078  int i = 0;
3079  tab.push_back(std::pair<int, QColor>(i+=1, QColor(2, 1, 201, 255)));
3080  tab.push_back(std::pair<int, QColor>(i+=1, QColor(2, 18, 213, 255)));
3081  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 24, 220, 255)));
3082  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 36, 227, 255)));
3083  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 54, 240, 255)));
3084  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 71, 254, 255)));
3085  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 90, 252, 255)));
3086  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 106, 251, 255)));
3087  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 130, 253, 255)));
3088  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 148, 250, 255)));
3089  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 160, 250, 255)));
3090  tab.push_back(std::pair<int, QColor>(i+=1, QColor(4, 174, 250, 255)));
3091  tab.push_back(std::pair<int, QColor>(i+=1, QColor(4, 186, 250, 255)));
3092  tab.push_back(std::pair<int, QColor>(i+=1, QColor(5, 200, 251, 255)));
3093  tab.push_back(std::pair<int, QColor>(i+=1, QColor(5, 214, 246, 255)));
3094  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 227, 241, 255)));
3095  tab.push_back(std::pair<int, QColor>(i+=1, QColor(3, 240, 237, 255)));
3096  tab.push_back(std::pair<int, QColor>(i+=1, QColor(2, 254, 233, 255)));
3097  tab.push_back(std::pair<int, QColor>(i+=1, QColor(2, 254, 212, 255)));
3098  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 190, 255)));
3099  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 170, 255)));
3100  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 160, 255)));
3101  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 151, 255)));
3102  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 105, 255)));
3103  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 72, 255)));
3104  tab.push_back(std::pair<int, QColor>(i+=1, QColor(1, 254, 37, 255)));
3105  tab.push_back(std::pair<int, QColor>(i+=1, QColor(2, 254, 4, 255)));
3106  tab.push_back(std::pair<int, QColor>(i+=1, QColor(25, 254, 4, 255)));
3107  tab.push_back(std::pair<int, QColor>(i+=1, QColor(56, 254, 3, 255)));
3108  tab.push_back(std::pair<int, QColor>(i+=1, QColor(71, 254, 3, 255)));
3109  tab.push_back(std::pair<int, QColor>(i+=1, QColor(99, 254, 2, 255)));
3110  tab.push_back(std::pair<int, QColor>(i+=1, QColor(125, 254, 2, 255)));
3111  tab.push_back(std::pair<int, QColor>(i+=1, QColor(150, 254, 2, 255)));
3112  tab.push_back(std::pair<int, QColor>(i+=1, QColor(175, 254, 2, 255)));
3113  tab.push_back(std::pair<int, QColor>(i+=1, QColor(200, 255, 1, 255)));
3114  tab.push_back(std::pair<int, QColor>(i+=1, QColor(209, 255, 1, 255)));
3115  tab.push_back(std::pair<int, QColor>(i+=1, QColor(218, 255, 1, 255)));
3116  tab.push_back(std::pair<int, QColor>(i+=1, QColor(229, 255, 1, 255)));
3117  tab.push_back(std::pair<int, QColor>(i+=1, QColor(237, 255, 0, 255)));
3118  tab.push_back(std::pair<int, QColor>(i+=1, QColor(240, 248, 0, 255)));
3119  tab.push_back(std::pair<int, QColor>(i+=1, QColor(244, 241, 0, 255)));
3120  tab.push_back(std::pair<int, QColor>(i+=1, QColor(250, 237, 0, 255)));
3121  tab.push_back(std::pair<int, QColor>(i+=1, QColor(251, 232, 2, 255)));
3122  tab.push_back(std::pair<int, QColor>(i+=1, QColor(251, 226, 2, 255)));
3123  tab.push_back(std::pair<int, QColor>(i+=1, QColor(252, 215, 2, 255)));
3124  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 208, 2, 255)));
3125  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 199, 2, 255)));
3126  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 194, 2, 255)));
3127  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 190, 2, 255)));
3128  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 184, 2, 255)));
3129  tab.push_back(std::pair<int, QColor>(i+=1, QColor(252, 179, 2, 255)));
3130  tab.push_back(std::pair<int, QColor>(i+=1, QColor(252, 172, 2, 255)));
3131  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 164, 2, 255)));
3132  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 155, 2, 255)));
3133  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 147, 4, 255)));
3134  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 136, 4, 255)));
3135  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 125, 3, 255)));
3136  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 112, 3, 255)));
3137  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 99, 2, 255)));
3138  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 75, 2, 255)));
3139  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 50, 2, 255)));
3140  tab.push_back(std::pair<int, QColor>(i+=1, QColor(253, 25, 2, 255)));
3141  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 1, 2, 255)));
3142  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 1, 12, 255)));
3143  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 1, 25, 255)));
3144  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 1, 37, 255)));
3145  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 0, 49, 255)));
3146  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 2, 37, 255)));
3147  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 3, 25, 255)));
3148  tab.push_back(std::pair<int, QColor>(i+=1, QColor(254, 4, 12, 255)));
3149  tab.push_back(std::pair<int, QColor>(i+=1, QColor(255, 5, 1, 255)));
3150 
3151  pi->setLUT(tab);
3152 }
3153 
3155 {
3156  QString path = pi->m_dir.absolutePath() + "/";
3157  QString file = pi->m_currentImageFile;
3158  QFileInfo fi(file);
3159  QString baseName = fi.baseName();
3160  QImage* ima;
3161 
3162  if(pi->m_suffix == ".bin" && baseName == "racc")
3163  {
3164  size_t nchars = pi->m_ncols * 2;
3165  uchar* buf = new uchar[nchars];
3166  FILE* fp = fopen(file.toStdString().c_str(), "rb");
3167  ima = new QImage(pi->m_ncols, pi->m_nlines, QImage::Format_ARGB32);
3168  ima->fill(Qt::transparent);
3169 
3170  uchar uc[3];
3171  uc[2] = 0;
3172  for(size_t j = 0; j < pi->m_nlines; ++j)
3173  {
3174  uchar* u = ima->scanLine(j);
3175  fread(buf, nchars, sizeof(char), fp);
3176  for(size_t i = 0; i < pi->m_ncols; i++)
3177  {
3178  uc[0] = *(buf + (i<<1));
3179  uc[1] = *(buf + (1+(i<<1)));
3180  ushort b = *(ushort*)uc;
3181  if(b != pi->m_undef)
3182  {
3183  b = (b+5) / 10;
3184  QRgb* v = (QRgb*)(u + (i << 2));
3185  *v = qRgba(pi->m_lut[b].red(), pi->m_lut[b].green(), pi->m_lut[b].blue(), 255);
3186  }
3187  }
3188  }
3189  fclose(fp);
3190  delete []buf;
3191  }
3192  else if(pi->m_suffix == ".bin" && baseName.contains("Prec5km"))
3193  {
3194  QString auxFile(file);
3195  size_t pos = auxFile.indexOf(baseName);
3196  auxFile.remove(0, pos);
3197  pos = auxFile.indexOf("_");
3198  size_t pp = auxFile.indexOf(".bin");
3199  int offset = atoi(auxFile.mid(pos+1, pp-pos+1).toStdString().c_str());
3200  size_t fileSize = pi->m_nlines * pi->m_ncols * 4 + 8; // dado é float e desprepreza 4 bytes iniciais e 4 bytes finais
3201  offset *= fileSize;
3202  auxFile.remove(pos, auxFile.length()-pos);
3203  auxFile = path + auxFile + pi->m_suffix;
3204 
3205  size_t nchars = pi->m_ncols * 4;
3206  uchar* buf = new uchar[nchars];
3207  FILE* fp = fopen(auxFile.toStdString().c_str(), "rb");
3208  fseek(fp, offset, SEEK_SET);
3209  fseek(fp, 4, SEEK_CUR); // despreza 4 bytes da primeira linha
3210  ima = new QImage(pi->m_ncols, pi->m_nlines, QImage::Format_ARGB32);
3211  ima->fill(Qt::transparent);
3212 
3213  uchar uc[5];
3214  uc[4] = 0;
3215  for(size_t j = 0; j < pi->m_nlines; ++j)
3216  {
3217  uchar* u = ima->scanLine(pi->m_nlines-1-j); // origem bottom left
3218  fread(buf, nchars, sizeof(char), fp);
3219 
3220  for(size_t i = 0; i < pi->m_ncols; i++)
3221  {
3222  uc[0] = *(buf + (i<<2));
3223  uc[1] = *(buf + (1+(i<<2)));
3224  uc[2] = *(buf + (2+(i<<2)));
3225  uc[3] = *(buf + (3+(i<<2)));
3226  float b = *(float*)uc;
3227  if(b != pi->m_undef)
3228  {
3229  uchar a = (uchar) (b * 10000. + .5);
3230  QRgb* v = (QRgb*)(u + (i << 2));
3231  *v = qRgba(pi->m_lut[a].red(), pi->m_lut[a].green(), pi->m_lut[a].blue(), 255);
3232  }
3233  }
3234  }
3235  fclose(fp);
3236  delete []buf;
3237  }
3238  else
3239  ima = new QImage(file);
3240 
3241  return ima;
3242 }
3243 
3245 {
3247  QDir dir(path);
3248  QString d = dir.dirName();
3249  QStringList nameFilter;
3250  nameFilter.append("*.ctl");
3251  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
3252  QString ctlFile = files.first();
3253 
3254  if(ctlFile == "racc.ctl")
3255  pi = getHidroMetadata(path);
3256  else if(ctlFile == "Prec5km.ctl")
3257  pi = getEtaMetadata(path);
3258  else
3259  {
3260  nameFilter.clear();
3261  nameFilter.append("S11*.jpg");
3262  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
3263  if(files.empty() == false && files.first().length() == 26)
3264  pi = getGoesMetadata(path);
3265  else
3266  pi = getTemporalImageMetadata(path);
3267  }
3268 
3269  return pi;
3270 }
3271 
3273 {
3274  PixmapItem* pi = getHidroCtlParameters(path);
3275  if(pi == 0)
3276  return 0;
3277 
3278  m_animationScene->addItem(pi);
3279  Animation* animation = new Animation(pi, "pos");
3280  animation->m_spatialExtent = te::gm::Envelope(pi->m_imaRect.x(), pi->m_imaRect.y(), pi->m_imaRect.right(), pi->m_imaRect.bottom());
3281  animation->setEasingCurve(QEasingCurve::Linear);
3282  m_parallelAnimation->addAnimation(animation);
3283 
3284  QStringList nameFilter;
3285  nameFilter.append("*.bin");
3286  QDir dir(path);
3287  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
3288  size_t count = files.count();
3289 
3290  // get time extent
3291  te::dt::TimeInstant ti = getHidroTime(path + "/" + files.first());
3292  te::dt::TimeInstant tf = getHidroTime(path + "/" + files.last());
3293  animation->m_temporalExtent = te::dt::TimePeriod(ti, tf);
3294 
3295  // set data
3297  for(size_t i = 0; i < count; ++i)
3298  {
3299  QString f = files[i];
3300  t = getHidroTime(f);
3301  pi->m_time.push_back(t);
3302  pi->m_files.push_back(f);
3303  }
3304 
3306 
3307  // crie valores não repetitivos e nem muito grandes ou pequenos
3308  QPointF pos(animation->m_spatialExtent.m_llx, animation->m_spatialExtent.m_lly);
3309  double w = animation->m_spatialExtent.getWidth();
3310  double h = animation->m_spatialExtent.getHeight();
3311  double dw = w / 64;
3312  double dh = h / 64;
3313  for(size_t i = 0; i < count; ++i)
3314  {
3315  if(i & 64)
3316  pos -= QPointF(dw, dh);
3317  else
3318  pos += QPointF(dw, dh);
3319 
3320  pi->m_route->setPoint(i, pos.x(), pos.y());
3321  }
3322 
3323  setHidroLUT(pi);
3324  return pi;
3325 }
3326 
3328 {
3329  PixmapItem* pi = getEtaCtlParameters(path);
3330  if(pi == 0)
3331  return 0;
3332 
3333  m_animationScene->addItem(pi);
3334  Animation* animation = new Animation(pi, "pos");
3335  animation->m_spatialExtent = te::gm::Envelope(pi->m_imaRect.x(), pi->m_imaRect.y(), pi->m_imaRect.right(), pi->m_imaRect.bottom());
3336  animation->setEasingCurve(QEasingCurve::Linear);
3337  m_parallelAnimation->addAnimation(animation);
3338 
3339  QStringList nameFilter;
3340  nameFilter.append("*.bin");
3341  QDir dir(path);
3342  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
3343  size_t count = files.count();
3344 
3345  // get time extent
3346  te::dt::TimeInstant ti = getEtaTime(path + "/" + files.first());
3347  te::dt::TimeInstant tf = getEtaTime(path + "/" + files.last());
3348  // the file contains 3 days of data
3349  tf = te::dt::TimeInstant(tf.getTimeInstant() + boost::posix_time::seconds(60*60*24*3 - 3600));
3350  animation->m_temporalExtent = te::dt::TimePeriod(ti, tf);
3351 
3352  // set data
3353  te::dt::TimeInstant tnext, t;
3354  QString sn, fname;
3355  for(size_t i = 0; i < count; ++i)
3356  {
3357  QString f = files[i];
3358  QFileInfo fi(path + "/" + f);
3359  QString baseName = fi.baseName();
3360  t = getEtaTime(f);
3361 
3362  if(i != count-1)
3363  tnext = getEtaTime(files[i+1]);
3364  else
3365  tnext = te::dt::TimeInstant(t.getTimeInstant() + boost::posix_time::seconds(60*60*24*3));
3366 
3367  size_t n = 1;
3368  while((t < tnext || t == tnext) && n <= 72)
3369  {
3370  pi->m_time.push_back(t);
3371  t = te::dt::TimeInstant(t.getTimeInstant() + boost::posix_time::seconds(60*60));
3372  sn.setNum(n++);
3373  fname = path + "/" + baseName + "_" + sn + "." + fi.suffix();
3374  pi->m_files.push_back(fname);
3375  }
3376  }
3377 
3378  size_t tsize = pi->m_files.count();
3380 
3381  // crie valores não repetitivos e nem muito grandes ou pequenos
3382  QPointF pos(animation->m_spatialExtent.m_llx, animation->m_spatialExtent.m_lly);
3383  double w = animation->m_spatialExtent.getWidth();
3384  double h = animation->m_spatialExtent.getHeight();
3385  double dw = w / 64;
3386  double dh = h / 64;
3387  for(size_t i = 0; i < tsize; ++i)
3388  {
3389  if(i & 64)
3390  pos -= QPointF(dw, dh);
3391  else
3392  pos += QPointF(dw, dh);
3393 
3394  pi->m_route->setPoint(i, pos.x(), pos.y());
3395  }
3396 
3397  setEtaLUT(pi);
3398  return pi;
3399 }
3400 
3402 {
3403  QString file(fileName);
3404  int ind = file.indexOf("racc.") + strlen("racc.");
3405  file.remove(0, ind);
3406  QString ano = "20" + file.mid(0, 2);
3407  QString mes = file.mid(2, 2);
3408  QString dia = file.mid(4, 2);
3409  QString hour = file.mid(7, 2);
3410  QString min = file.mid(9, 2);
3411 
3412  te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
3413  te::dt::TimeDuration dur(hour.toInt(), min.toInt(), 0);
3414  return te::dt::TimeInstant(date, dur);
3415 }
3416 
3418 {
3419  QString file(fileName);
3420  int ind = file.indexOf("Prec5km") + strlen("Prec5km");
3421  file.remove(0, ind);
3422  QString ano = file.mid(0, 4);
3423  QString mes = file.mid(4, 2);
3424  QString dia = file.mid(6, 2);
3425  QString hour = file.mid(8, 2);
3426 
3427  te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
3428  te::dt::TimeDuration dur(hour.toInt() + 1, 0, 0); // tem deslocamento de 1 hora
3429  return te::dt::TimeInstant(date, dur);
3430 }
3431 
3433 {
3434  PixmapItem* pi = getTemporalImageCtlParameters(path);
3435  if(pi == 0)
3436  return 0;
3437 
3438  m_animationScene->addItem(pi);
3439  Animation* animation = new Animation(pi, "pos");
3440  animation->m_spatialExtent = te::gm::Envelope(pi->m_imaRect.x(), pi->m_imaRect.y(), pi->m_imaRect.right(), pi->m_imaRect.bottom());
3441  animation->setEasingCurve(QEasingCurve::Linear);
3442  m_parallelAnimation->addAnimation(animation);
3443 
3444  QString suffix = "." + pi->m_suffix;
3445  QStringList nameFilter;
3446  nameFilter.append("*" + suffix);
3447  QDir dir(path);
3448  QStringList files = dir.entryList(nameFilter, QDir::Files, QDir::Name);
3449  size_t count = files.count();
3450 
3451  // get time extent
3452  te::dt::TimeInstant ti = getTemporalImageTime(path + "/" + files.first());
3453  te::dt::TimeInstant tf = getTemporalImageTime(path + "/" + files.last());
3454  animation->m_temporalExtent = te::dt::TimePeriod(ti, tf);
3455 
3456  // set data
3458  for(size_t i = 0; i < count; ++i)
3459  {
3460  QString f = files[i];
3461  pi->m_files.push_back(f);
3462  t = getTemporalImageTime(f);
3463  pi->m_time.push_back(t);
3464  }
3465 
3467 
3468  // crie valores não repetitivos e nem muito grandes ou pequenos
3469  QPointF pos(animation->m_spatialExtent.m_llx, animation->m_spatialExtent.m_lly);
3470  double w = animation->m_spatialExtent.getWidth();
3471  double h = animation->m_spatialExtent.getHeight();
3472  for(size_t i = 0; i < count; ++i)
3473  {
3474  if(i & 1)
3475  pos -= QPointF(w, h);
3476  else
3477  pos += QPointF(w, h);
3478 
3479  pi->m_route->setPoint(i, pos.x(), pos.y());
3480  }
3481  return pi;
3482 }
3483 
3485 {
3486  char buf[2000];
3487  QString file(path + "/image.ctl");
3488  FILE* fp = fopen(file.toStdString().c_str(), "r");
3489  if(fp == 0)
3490  return 0;
3491 
3492  fread(buf, 2000, sizeof(char), fp);
3493  fclose(fp);
3494  QString ss(QString(buf).simplified());
3495 
3496  // validation
3497  if(!(ss.contains("suffix ", Qt::CaseInsensitive) && ss.contains("undef", Qt::CaseInsensitive) &&
3498  ss.contains("srid", Qt::CaseInsensitive) && ss.contains("llx", Qt::CaseInsensitive) &&
3499  ss.contains("lly", Qt::CaseInsensitive) && ss.contains("urx", Qt::CaseInsensitive) &&
3500  ss.contains("ury", Qt::CaseInsensitive)))
3501  return 0;
3502 
3503  QString s;
3504  QDir dir(path);
3505  te::qt::widgets::PixmapItem* pi = new PixmapItem(dir.dirName(), path, m_display);
3506 
3507  // get suffix
3508  size_t pos = ss.indexOf("suffix ", Qt::CaseInsensitive) + strlen("suffix ");
3509  ss.remove(0, pos);
3510  pos = ss.indexOf(" undef", Qt::CaseInsensitive);
3511  s = ss.left(pos);
3512  pi->m_suffix = s;
3513  ss.remove(0, pos);
3514 
3515  // get undef
3516  pos = ss.indexOf("undef ", Qt::CaseInsensitive) + strlen("undef ");
3517  ss.remove(0, pos);
3518  pos = ss.indexOf(" srid", Qt::CaseInsensitive);
3519  s = ss.left(pos);
3520  pi->m_undef = atof(s.toStdString().c_str());
3521  ss.remove(0, pos);
3522 
3523  // get srid
3524  pos = ss.indexOf("srid ", Qt::CaseInsensitive) + strlen("srid ");
3525  ss.remove(0, pos);
3526  pos = ss.indexOf(" llx", Qt::CaseInsensitive);
3527  s = ss.left(pos);
3528  pi->m_SRID = atoi(s.toStdString().c_str());
3529  ss.remove(0, pos);
3530 
3531  // get llx
3532  pos = ss.indexOf("llx ", Qt::CaseInsensitive) + strlen("llx ");
3533  ss.remove(0, pos);
3534  pos = ss.indexOf(" lly", Qt::CaseInsensitive);
3535  s = ss.left(pos);
3536  double llx = atof(s.toStdString().c_str());
3537  ss.remove(0, pos);
3538 
3539  // get lly
3540  pos = ss.indexOf("lly ", Qt::CaseInsensitive) + strlen("lly ");
3541  ss.remove(0, pos);
3542  pos = ss.indexOf(" urx", Qt::CaseInsensitive);
3543  s = ss.left(pos);
3544  double lly = atof(s.toStdString().c_str());
3545  ss.remove(0, pos);
3546 
3547  // get urx
3548  pos = ss.indexOf("urx ", Qt::CaseInsensitive) + strlen("urx ");
3549  ss.remove(0, pos);
3550  pos = ss.indexOf(" ury", Qt::CaseInsensitive);
3551  s = ss.left(pos);
3552  double urx = atof(s.toStdString().c_str());
3553  ss.remove(0, pos);
3554 
3555  // get ury
3556  pos = ss.indexOf("ury ", Qt::CaseInsensitive) + strlen("ury ");
3557  ss.remove(0, pos);
3558  double ury = atof(ss.toStdString().c_str());
3559 
3560  double w = urx - llx;
3561  double h = ury - lly;
3562  pi->m_imaRect = QRectF(llx, lly, w, h);
3563 
3564  return pi;
3565 }
3566 
3568 {
3569  QString file(fileName);
3570  int ind = file.indexOf("_") + strlen("_");
3571  file.remove(0, ind);
3572  QString ano = file.mid(0, 4);
3573  QString mes = file.mid(5, 2);
3574  QString dia = file.mid(8, 2);
3575  QString hour = file.mid(11, 2);
3576  QString min = file.mid(14, 2);
3577  QString sec = file.mid(17, 2);
3578 
3579  te::dt::Date date(ano.toInt(), mes.toInt(), dia.toInt());
3580  te::dt::TimeDuration dur(hour.toInt(), min.toInt(), sec.toInt());
3581  return te::dt::TimeInstant(date, dur);
3582 }
3583 
3585 {
3586 }
void addTemporalImages(const QString &filePath)
te::qt::widgets::PixmapItem * getMetadata(const QString &path)
void onResetFinalTimePushButtonClicked()
Reset final time button clicked.
QParallelAnimationGroup * m_parallelAnimation
The parallel animation.
std::auto_ptr< Ui::SliderPropertiesDialogForm > m_ui
It takes the necessary steps after changing the duration.
te::qt::widgets::PixmapItem * getEtaCtlParameters(const QString &path)
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.
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 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.
QVector< QString > m_files
The input files.
Definition: PixmapItem.h:140
void drawTrajectoryIcon(const TrajectoryItem *t, const QPoint &pos, QPainter *painter)
Draw the trajectory icon.
std::complex< double > times(std::complex< double > lhs, std::complex< double > rhs)
Definition: Band.cpp:580
void onApplyTimeIntervalPushButtonClicked(bool b)
Apply time interval push button clicked.
void onRemoveAllPushButtonClicked(bool)
Remove all animations.
void onResetInitialTimePushButtonClicked()
Reset initial time button clicked.
QIcon getImage(int type)
QDir m_dir
The image data directory.
Definition: PixmapItem.h:136
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
te::dt::TimeInstant getEtaTime(const QString &file)
void onRemovePushButtonClicked(bool)
Remove item animation.
void adjustTrajectoryGroupBox(te::qt::widgets::AnimationItem *)
Remove animation item from the opacity combo box and trajectory color combo box.
size_t m_ncols
number of colunms.
Definition: PixmapItem.h:138
te::gm::Envelope m_spatialExtent
Spatial extent.
Definition: Animation.h:99
te::dt::TimeInstant getFinalTime()
It gets the final time.
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
Definition: Date.h:111
This class is a dialog for the Trajectory Icon Item.
The class that represents an item in a LayerTreeModel.
void setLUT(const std::vector< std::pair< int, QColor > > &tab)
Sets the LUT. tab The LUT information.
Definition: PixmapItem.cpp:142
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.
Definition: Envelope.h:443
void calculateSpatialExtent()
It calculates the spatial extent.
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
Definition: Date.h:97
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.
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 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.
te::qt::widgets::PixmapItem * getTemporalImageMetadata(const QString &path)
bool trajectoryAlreadyExists(QPair< QString, te::st::TrajectoryDataSetLayer * > &item)
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
This file contains include headers for the TerraLib ST memory module.
void createAnimationDataInDisplayProjection(const te::dt::TimePeriod &period)
It creates animation data for a given period; /param period The temporal period.
Definition: Animation.cpp:15
te::qt::widgets::PixmapItem * getTemporalImageCtlParameters(const QString &path)
te::qt::widgets::PixmapItem * getEtaMetadata(const QString &path)
SliderPropertiesDialog * m_spd
Slider Properties Dialog.
void updateTimeTextEdit()
Update animation time.
void removeOnPropertieCombo(const QString &title)
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
void drawPixmapItem(PixmapItem *pi, const QRectF &dwrect, QPainter *painter)
Draw the pixmap item.
float m_undef
undef value.
Definition: PixmapItem.h:139
This file defines a class for a Animation Scene.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
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.
void onDrawTrailCheckBoxClicked(bool b)
Draw track check box clicked.
A point with x and y coordinate values.
Definition: Point.h:50
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Definition: LineString.cpp:353
te::dt::TimeInstant getHidroTime(const QString &file)
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
te::qt::widgets::PixmapItem * getGoesMetadata(const QString &path)
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:44
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
This file contains include headers for the TerraLib Qt widgets.
bool eventFilter(QObject *, QEvent *)
it filters the events of interest.
void setHidroLUT(te::qt::widgets::PixmapItem *pi)
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.
An object that when created shows a cursor during its scope.
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.
MapDisplay * m_display
The map display.
void onForwardRadioButtonClicked(bool b)
Apply animation items push button clicked. It Sets the visibility of animations.
bool coverageAlreadyExists(QPair< QString, QString > &item)
void onSridChanged()
It takes the necessary measures after the change of extent.
QString m_currentImageFile
Image to be displayed on paint event animation.
Definition: PixmapItem.h:142
QRectF m_imaRect
Image location.
Definition: PixmapItem.h:145
void updateSliderPos()
Updates the position of the slider with respect to time animation.
QString m_title
The icon item title.
void putToBack(AnimationItem *item)
It puts graphic item to back.
te::dt::TimeInstant getTemporalImageTime(const QString &file)
std::auto_ptr< te::gm::Geometry > getGeometry() const
It returns the geometry pointed by the internal cursor.
te::dt::TimeInstant getGoesTime(const QString &file)
void setDirection(const QAbstractAnimation::Direction &direction)
Sets the Animation Item direction.
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
A class to represent a trajectory data set.
A class to represent time period.
Definition: TimePeriod.h:54
QPoint getPosInDeviceCoordinate()
It returns the Animation Item position in device coordinate.
This file defines a class for a Trajectory Animation.
AnimationScene * m_animationScene
The animation scene.
std::map< uchar, QColor > m_lut
LUT.
Definition: PixmapItem.h:146
bool isSettingChanged()
Is Setting Changed.
void setAutomaticPan(const QString &title)
It configures automatic pan over a animation path. It toggles auto pan state.
te::dt::TimeInstant getTimeInstant()
It it gets the animation time instant.
QImage * getImage(te::qt::widgets::PixmapItem *pi)
void setDuration(const unsigned int &duration)
Sets the animation duration.
const boost::posix_time::time_period & getTimePeriod() const
Assignment operator.
Definition: TimePeriod.h:86
te::qt::widgets::PixmapItem * getHidroCtlParameters(const QString &path)
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:100
void changeDirection()
Change direction.
void setEtaLUT(te::qt::widgets::PixmapItem *pi)
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.
This file defines a class for a Pixmap Item.
This class is a dialog for the Pixmap Item.
Definition: AnimationItem.h:57
QVector< te::dt::TimeInstant > m_animationTime
The animation time. It contains only the portions to be animated.
virtual int getSRID() const
It returns the Spatial Reference System ID associated to the Layer.
This file contains include headers for the TerraLib ST module.
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
Definition: LineString.cpp:339
QString m_suffix
File suffix.
Definition: PixmapItem.h:144
void createNewPixmap()
create new pixmap.
void initProperty()
It initialize a property animation dialog.
double m_panFactor
the range is between 0.05 and 0.5
This class is a dialog for the Animation.
void putToFront(AnimationItem *item)
It puts graphic item to front.
te::qt::widgets::PixmapItem * getHidroMetadata(const QString &path)
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.
This file contains include headers for the Data Access module of TerraLib.
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.
te::gm::LineString * m_route
The input path in world coordenates.
This file contains include headers for the Map Tools module of TerraLib.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
QMatrix m_matrix
The display transformation matrix.
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.
std::size_t size() const
It returns the size of the trajectory observation set.
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
double getHeight() const
It returns the envelope height.
Definition: Envelope.h:448
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
void calculateTemporalExtent()
It calculates the temporal extent.
void onAnimationComboBoxActivated(int i)
Trajectory color 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
size_t m_nlines
number of lines.
Definition: PixmapItem.h:137
te::dt::TimePeriod m_temporalAnimationExtent
Temporal animation extent. It can be a portion of the total or greater than the total.
Definition: Animation.h:101
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
A layer with a reference to an TrajectoryDataSet.
QVector< te::dt::TimeInstant > m_time
The input time.
void onStopToolButtonnClicked()
Stop animation.
void removeAnimation(const QString &title)
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.