SliderPropertiesDialog.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/SliderPropertiesDialog.h
22 
23  \brief A widget used to alow the user to control the visualization of temporal data
24 */
25 
26 
27 //Terralib
28 #include "../../../datatype/TimeInstant.h"
29 #include "../../../datatype/TimePeriod.h"
30 #include "SliderPropertiesDialog.h"
31 #include "ui_SliderPropertiesDialogForm.h"
32 #include "TimeSliderWidget.h"
33 
34 //QT
35 #include <QMessageBox>
36 
37 //Utility functions
38 
40 {
41  QDate qdatei(time.getDate().getYear(), time.getDate().getMonth(), time.getDate().getDay());
42  QTime qtimei(time.getTime().getHours(), time.getTime().getMinutes(), time.getTime().getSeconds());
43  QDateTime qdate(qdatei, qtimei);
44  return qdate;
45 }
46 
48 {
49  te::dt::Date date(qdate.date().year(), qdate.date().month(), qdate.date().day());
50  te::dt::TimeDuration duration(qdate.time().hour(), qdate.time().minute(), qdate.time().second());
51  te::dt::TimeInstant time(date, duration);
52  return time;
53 }
54 
56  : QDialog(parent, f),
57  m_ui(new Ui::SliderPropertiesDialogForm)
58 {
59  m_ui->setupUi(this);
60  m_tsw = (TimeSliderWidget*)parent;
61 
62  m_ui->m_opacitySpinBox->setMinimum(0);
63  m_ui->m_opacitySpinBox->setMaximum(255);
64  m_ui->m_opacitySpinBox->setValue(255);
65  m_ui->m_opacitySpinBox->setSingleStep(5);
66  m_ui->m_forwardRadioButton->setCheckable(true);
67 
68  m_ui->m_initialAnimationDateTimeEdit->installEventFilter(m_tsw);
69  m_ui->m_finalAnimationDateTimeEdit->installEventFilter(m_tsw);
70  m_ui->m_initialAnimationDateTimeEdit->setDisplayFormat("dd/MMM/yyyy hh:mm:ss");
71  m_ui->m_finalAnimationDateTimeEdit->setDisplayFormat("dd/MMM/yyyy hh:mm:ss");
72 
73  m_ui->m_widthSpinBox->setMinimum(1);
74  m_ui->m_widthSpinBox->setMaximum(1000);
75  m_ui->m_heightSpinBox->setMinimum(1);
76  m_ui->m_heightSpinBox->setMaximum(1000);
77 
78  connect(m_ui->m_drawTrailCheckBox, SIGNAL(clicked(bool) ), m_tsw, SLOT(onDrawTrailCheckBoxClicked(bool)));
79  //connect(m_ui->m_applyAnimationItemPushButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onApplyAnimationItemPushButtonClicked(bool)));
80  connect(m_ui->m_autoPanCheckBox, SIGNAL(clicked(bool) ), m_tsw, SLOT(onAutoPanCheckBoxClicked(bool)));
81  connect(m_ui->m_panFactorDoubleSpinBox, SIGNAL(valueChanged(double) ), m_tsw, SLOT(onPanFactorValueChanged(double)));
82  connect(m_ui->m_opacitySpinBox, SIGNAL(valueChanged(int)), m_tsw, SLOT(onOpacityValueChanged(int)));
83  connect(m_ui->m_widthSpinBox, SIGNAL(valueChanged(int)), m_tsw, SLOT(onTrajectoryPixmapSizeChanged(int)));
84  connect(m_ui->m_heightSpinBox, SIGNAL(valueChanged(int)), m_tsw, SLOT(onTrajectoryPixmapSizeChanged(int)));
85  connect(m_ui->m_forwardRadioButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onForwardRadioButtonClicked(bool)));
86  connect(m_ui->m_backwardRadioButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onBackwardRadioButtonClicked(bool)));
87  connect(m_ui->m_loopCheckBox, SIGNAL(clicked(bool) ), m_tsw, SLOT(onLoopCheckBoxClicked(bool)));
88  connect(m_ui->m_goAndBackCheckBox, SIGNAL(clicked(bool) ), m_tsw, SLOT(onGoAndBackCheckBoxClicked(bool)));
89  connect(m_ui->m_applyTimeIntervalPushButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onApplyTimeIntervalPushButtonClicked(bool)));
90  connect(m_ui->m_frontPushButton, SIGNAL(clicked(bool)), m_tsw, SLOT(onFrontPushButtonClicked(bool)));
91  connect(m_ui->m_backPushButton, SIGNAL(clicked(bool)), m_tsw, SLOT(onBackPushButtonClicked(bool)));
92  connect(m_ui->m_animationComboBox, SIGNAL(activated(int) ), m_tsw, SLOT(onAnimationComboBoxActivated(int)));
93  connect(m_ui->m_removePushButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onRemovePushButtonClicked(bool)));
94  connect(m_ui->m_removeAllPushButton, SIGNAL(clicked(bool) ), m_tsw, SLOT(onRemoveAllPushButtonClicked(bool)));
95  connect(m_ui->m_resetInitialTimePushButton, SIGNAL(clicked()), m_tsw, SLOT(onResetInitialTimePushButtonClicked()));
96  connect(m_ui->m_resetFinalTimePushButton, SIGNAL(clicked()), m_tsw, SLOT(onResetFinalTimePushButtonClicked()));
97  connect(m_ui->m_iconRotateCheckBox, SIGNAL(clicked(bool)), m_tsw, SLOT(onIconRotateCheckBoxClicked(bool)));
98 
99  connect(m_ui->m_helpPushButton, SIGNAL(clicked()), this, SLOT(onHelpPushButtonClicked()));
100 
101 }
102 
104 {
105 }
106 
108 {
109  TimeSliderWidget *tsw = (TimeSliderWidget*)parent();
111  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
112  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
113  QDateTime qdatetimei(qdatei, qtimei);
114  m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetimei);
115 
117  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
118  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
119  QDateTime qdatetimef(qdatef, qtimef);
120  m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetimef);
121 
122  // set mimimum datetime
124  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
125  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
126  m_ui->m_initialAnimationDateTimeEdit->setMinimumDateTime(minimum);
127 
128  // set maximum datetime
130  QDateTime maximum(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
131  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
132  m_ui->m_finalAnimationDateTimeEdit->setMaximumDateTime(maximum);
133 
134  if(tsw->m_direction == QAbstractAnimation::Forward)
135  {
136  if(m_ui->m_forwardRadioButton->isChecked() == false)
137  m_ui->m_forwardRadioButton->toggle();
138  }
139 
140  if(tsw->m_loop)
141  m_ui->m_loopCheckBox->setChecked(true);
142  if(tsw->m_goAndBack)
143  m_ui->m_goAndBackCheckBox->setChecked(true);
144 }
145 
147 {
148  return m_ui->m_forwardRadioButton->isChecked();
149 }
150 
152 {
153  return m_ui->m_loopCheckBox->isChecked();
154 }
155 
157 {
158  return m_ui->m_goAndBackCheckBox->isChecked();
159 }
160 
162 {
163  return m_ui->m_initialAnimationDateTimeEdit->dateTime();
164 }
165 
167 {
168  return m_ui->m_finalAnimationDateTimeEdit->dateTime();
169 }
170 
172 {
173  return qdate2TimeInstant(m_ui->m_initialAnimationDateTimeEdit->dateTime());
174 }
175 
177 {
178  return qdate2TimeInstant(m_ui->m_finalAnimationDateTimeEdit->dateTime());
179 }
180 
182 {
183 }
184 
186 {
187 }
te::dt::TimePeriod m_temporalAnimationExtent
Animation temporal extent. It is used for show animation.
std::auto_ptr< Ui::SliderPropertiesDialogForm > m_ui
It takes the necessary steps after changing the duration.
QDateTime timeInstant2QDate(te::dt::TimeInstant time)
bool isGoBackChecked()
It returns a boolean that indicates if the time slider animation is to reverse it's direction on ce a...
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
bool m_goAndBack
Forward and then backward direction.
boost::gregorian::greg_year getYear() const
It returns the gregorian year.
Definition: Date.h:111
boost::gregorian::greg_day getDay() const
It returns the gregorian day - from 1 to 31.
Definition: Date.h:97
TimeSliderWidget * m_tsw
The Timer Slider Widget pointer.
bool isLoopChecked()
It returns a boolean that indicates if the time slider animation is supposed to be displayed looping ...
A class to represent time instant.
Definition: TimeInstant.h:55
QDateTime getInitialQDate()
It gets the initial time as QDateTime.
te::dt::TimePeriod m_temporalExtent
Temporal extent.
void populateUi()
It initialize a property animation dialog.
QDateTime getFinalQDate()
It gets the final time as QDateTime.
Date getDate() const
It returns the date associated to time instant.
Definition: TimeInstant.h:106
A base class for date data types.
Definition: Date.h:53
TimeInstant getFinalTimeInstant() const
It gets the final time instant.
Definition: TimePeriod.cpp:50
TimeInstant getInitialTimeInstant() const
It gets the initial time instant.
Definition: TimePeriod.cpp:45
void onDrawTrackCheckBoxClicked(bool b)
AutoPan radio button clicked.
bool m_loop
This property holds whether the slider's animation is on loop.
A class to represent time duration with nano-second/micro-second resolution.
Definition: TimeDuration.h:51
SliderPropertiesDialog(QWidget *parent, Qt::WindowFlags f=0)
Constructor.
TimeDuration getTime() const
It returns the time duration associated to time instant.
Definition: TimeInstant.cpp:49
long getMinutes() const
It returns the minutes of a hour - from 0 to 59.
Definition: TimeDuration.h:98
te::dt::TimeInstant getFinalTime()
It gets the final time.
te::dt::TimeInstant getInitialTime()
It gets the initial time.
te::dt::TimeInstant qdate2TimeInstant(QDateTime qdate)
boost::gregorian::greg_month getMonth() const
It returns the gregorian month - from 1 to 12.
Definition: Date.h:104
long getHours() const
It returns the hours of a day - from 0 to 23.
Definition: TimeDuration.h:91
A wdiget used to control the visualization of temporal data.
bool isForwardChecked()
It returns a boolean that indicates if animation is going forward or backward.