ObservationPropertiesWidget.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/st/ObservationPropertiesWidget.cpp
22 
23  \brief A widget used to adjust a Observation layer's properties
24 */
25 
26 //Terralib
27 #include "../../../dataaccess.h"
28 #include "../../../datatype/Property.h"
29 #include "../utils/DoubleListWidget.h"
31 #include "ui_ObservationPropertiesWidgetForm.h"
32 
33 //QT
34 #include <QWidget>
35 
37  : QWidget(parent, f),
38  m_ui(new Ui::ObservationPropertiesWidgetForm)
39 {
40  m_ui->setupUi(this);
41 
42  //Adjusting the doubleListWidget that will be used to configure the query's fields.
43  m_obsWidget.reset(new DoubleListWidget(m_ui->m_obsPropFrame));
44  m_obsWidget->setLeftLabel(tr("Properties"));
45  m_obsWidget->setRightLabel(tr("Observed Properties"));
46  QGridLayout* obsLayout = new QGridLayout(m_ui->m_obsPropFrame);
47  obsLayout->addWidget(m_obsWidget.get());
48  obsLayout->setContentsMargins(0, 0, 0, 0);
49 
50 // connect signal and slots
51  //connect(m_ui->m_phenomenomComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(onPropertyComboBoxIndexChanged(QString)));
52 }
53 
55  default;
56 
57 Ui::ObservationPropertiesWidgetForm* te::qt::widgets::ObservationPropertiesWidget::getForm()
58 {
59  return m_ui.get();
60 }
61 
63 {
64  std::vector<int> indexes;
65  std::vector<std::string> values = m_obsWidget->getOutputValues();
66 
67  for(size_t i = 0; i < values.size(); ++i)
68  indexes.push_back(static_cast<int>(te::da::GetPropertyPos(m_dataType.get(), values[i])));
69 
70  return indexes;
71 }
72 
74 {
75  return m_obsWidget->getOutputValues();
76 }
77 
79 {
80  return m_ui->m_geometryComboBox->currentText().toUtf8().data();
81 }
82 
84 {
85  if(m_dataType)
86  return static_cast<int>(m_dataType->getPropertyPosition(m_ui->m_geometryComboBox->currentText().toUtf8().data()));
87  else
88  return -1;
89 }
90 
92 {
93  return m_ui->m_idComboBox->currentText().toUtf8().data();
94 }
95 
97 {
98  if(m_dataType)
99  return static_cast<int>(m_dataType->getPropertyPosition(m_ui->m_idComboBox->currentText().toUtf8().data()));
100  else
101  return -1;
102 }
103 
105 {
106  QString item;
107  std::vector<std::string> propertyNames;
108  m_dataType = dataType;
109 
110  const std::vector<te::dt::Property*>& properties = dataType->getProperties();
111 
112  for (std::size_t i = 0; i < properties.size(); i++)
113  {
114  item = QString::fromUtf8(properties.at(i)->getName().c_str());
115  propertyNames.push_back(item.toUtf8().data());
116 
117  if(properties.at(i)->getType() == te::dt::GEOMETRY_TYPE)
118  m_ui->m_geometryComboBox->addItem(item);
119  else
120  m_ui->m_idComboBox->addItem(item);
121  }
122 
123  m_obsWidget->setInputValues(propertyNames);
124 }
125 
boost::shared_ptr< DataSetType > DataSetTypePtr
Definition: DataSetType.h:653
int getIdIndex()
Returns the index of the observation ID.
A widget used to adjust a Observation layer&#39;s properties.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
ObservationPropertiesWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
te::da::DataSetTypePtr m_dataType
The datasetType that will be used to generate the spatio-temporal layer.
std::unique_ptr< DoubleListWidget > m_obsWidget
The widget used to select the observed properties.
std::unique_ptr< Ui::ObservationPropertiesWidgetForm > m_ui
The widget&#39;s form.
std::string getGeometryPropName()
Returns the name of the property that holds the geometry.
std::vector< int > getOutputValues()
Returns a vector containing the indexes of the observed properties.
Ui::ObservationPropertiesWidgetForm * getForm()
Returns a pointer to the widget&#39;s form.
int getGeometryId()
Returns the index of the temporal property geometry.
void setUp(const te::da::DataSetTypePtr dataType)
Adjusts the widget&#39;s components based on the given datasettype.
std::string getIdPropName()
Returns the name of the property that holds the observation ID.
std::vector< std::string > getOutputPropNames()
Returns a vector containing the names of the observed properties.