All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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(onWidthValueChanged(int)));
84  connect(m_ui->m_heightSpinBox, SIGNAL(valueChanged(int)), m_tsw, SLOT(onHeightValueChanged(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 
98  connect(m_ui->m_helpPushButton, SIGNAL(clicked()), this, SLOT(onHelpPushButtonClicked()));
99 
100 }
101 
103 {
104 }
105 
107 {
108  TimeSliderWidget *tsw = (TimeSliderWidget*)parent();
110  QDate qdatei(ti.getDate().getYear(), ti.getDate().getMonth(), ti.getDate().getDay());
111  QTime qtimei(ti.getTime().getHours(), ti.getTime().getMinutes(), ti.getTime().getSeconds());
112  QDateTime qdatetimei(qdatei, qtimei);
113  m_ui->m_initialAnimationDateTimeEdit->setDateTime(qdatetimei);
114 
116  QDate qdatef(tf.getDate().getYear(), tf.getDate().getMonth(), tf.getDate().getDay());
117  QTime qtimef(tf.getTime().getHours(), tf.getTime().getMinutes(), tf.getTime().getSeconds());
118  QDateTime qdatetimef(qdatef, qtimef);
119  m_ui->m_finalAnimationDateTimeEdit->setDateTime(qdatetimef);
120 
121  // set mimimum datetime
123  QDateTime minimum(QDate(tmin.getDate().getYear(), tmin.getDate().getMonth(), tmin.getDate().getDay()),
124  QTime(tmin.getTime().getHours(), tmin.getTime().getMinutes(), tmin.getTime().getSeconds()));
125  m_ui->m_initialAnimationDateTimeEdit->setMinimumDateTime(minimum);
126 
127  // set maximum datetime
129  QDateTime maximum(QDate(tmax.getDate().getYear(), tmax.getDate().getMonth(), tmax.getDate().getDay()),
130  QTime(tmax.getTime().getHours(), tmax.getTime().getMinutes(), tmax.getTime().getSeconds()));
131  m_ui->m_finalAnimationDateTimeEdit->setMaximumDateTime(maximum);
132 
133  if(tsw->m_direction == QAbstractAnimation::Forward)
134  {
135  if(m_ui->m_forwardRadioButton->isChecked() == false)
136  m_ui->m_forwardRadioButton->toggle();
137  }
138 
139  if(tsw->m_loop)
140  m_ui->m_loopCheckBox->setChecked(true);
141  if(tsw->m_goAndBack)
142  m_ui->m_goAndBackCheckBox->setChecked(true);
143 }
144 
146 {
147  return m_ui->m_forwardRadioButton->isChecked();
148 }
149 
151 {
152  return m_ui->m_loopCheckBox->isChecked();
153 }
154 
156 {
157  return m_ui->m_goAndBackCheckBox->isChecked();
158 }
159 
161 {
162  return m_ui->m_initialAnimationDateTimeEdit->dateTime();
163 }
164 
166 {
167  return m_ui->m_finalAnimationDateTimeEdit->dateTime();
168 }
169 
171 {
172  return qdate2TimeInstant(m_ui->m_initialAnimationDateTimeEdit->dateTime());
173 }
174 
176 {
177  return qdate2TimeInstant(m_ui->m_finalAnimationDateTimeEdit->dateTime());
178 }
179 
181 {
182 }
183 
185 {
186 }
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.