TimeSeriesDataWidget.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/charts/TimeSeriesDataWidget.cpp
22 
23  \brief A widget used to adjust a timeSeries' input data.
24 */
25 
26 //Terralib
27 #include "../../../qt/widgets/charts/Utils.h"
28 #include "../../../dataaccess.h"
29 #include "../../../datatype/Property.h"
30 #include "../../../st/core/timeseries/TimeSeries.h"
31 #include "TimeSeriesDataWidget.h"
32 #include "ui_TimeSeriesDataWidgetForm.h"
33 
34 //QT
35 #include <QMessageBox>
36 
38  : QWidget(parent, f),
39  m_ui(new Ui::TimeSeriesDataWidgetForm),
40  m_dataSet (dataSet),
41  m_dataType(dataType)
42 {
43  m_ui->setupUi(this);
44  QString item;
45 
46  for (std::size_t i = 0; i < m_dataSet->getNumProperties(); i++)
47  {
48  switch(m_dataSet->getPropertyDataType(i))
49  {
51  item = QString::fromUtf8(m_dataSet->getPropertyName(i).c_str());
52  m_ui->m_timeComboBox->addItem(item, QVariant::fromValue(i));
53  break;
55  break;
56  default:
57  item = QString::fromUtf8(m_dataSet->getPropertyName(i).c_str());
58  m_ui->m_valueComboBox->addItem(item, QVariant::fromValue(i));
59  m_ui->m_idComboBox->addItem(item, QVariant::fromValue(i));
60  }
61  }
62 }
63 
65 
66 Ui::TimeSeriesDataWidgetForm* te::qt::widgets::TimeSeriesDataWidget::getForm()
67 {
68  return m_ui.get();
69 }
70 
72 {
73  te::st::TimeSeries* timeSeries = new te::st::TimeSeries(m_ui->m_idComboBox->currentText().toUtf8().data());
74 
75  m_dataSet->moveBeforeFirst();
76  while(m_dataSet->moveNext())
77  {
78  //Get time and value of time series
79  std::unique_ptr<te::dt::DateTime> time(m_dataSet->getDateTime(m_ui->m_timeComboBox->currentText().toUtf8().data()));
80  std::unique_ptr<te::dt::AbstractData> value(m_dataSet->getValue(m_ui->m_valueComboBox->currentText().toUtf8().data()));
81  timeSeries->add(time.release(), value.release());
82  }
83 
84  return timeSeries;
85 }
86 
87 
88 
89 
90 
A class that models the description of a dataset.
Definition: DataSetType.h:72
Ui::TimeSeriesDataWidgetForm * getForm()
Returns a pointer to the widget&#39;s form.
std::unique_ptr< Ui::TimeSeriesDataWidgetForm > m_ui
The widget&#39;s form.
void add(te::dt::DateTime *time, te::dt::AbstractData *value)
It adds an observation (time and attribute value) into the time series.
Definition: TimeSeries.cpp:160
te::st::TimeSeries * getTimeSeries()
Returns a pointer to the widget&#39;s form.
A dataset is the unit of information manipulated by the data access module of TerraLib.
TimeSeriesDataWidget(te::da::DataSet *dataSet, te::da::DataSetType *dataType, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
A class to represent time series.
Definition: TimeSeries.h:66
std::unique_ptr< te::da::DataSet > m_dataSet
The dataset that will be used to generate the histogram graph.
A widget used to adjust a timeSeries&#39; input data.