All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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("Properties");
45  m_obsWidget->setRightLabel("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 {
56 }
57 
58 Ui::ObservationPropertiesWidgetForm* te::qt::widgets::ObservationPropertiesWidget::getForm()
59 {
60  return m_ui.get();
61 }
62 
64 {
65  std::vector<int> indexes;
66  std::vector<std::string> values = m_obsWidget->getOutputValues();
67 
68  for(size_t i = 0; i < values.size(); ++i)
69  indexes.push_back(te::da::GetPropertyPos(m_dataType.get(), values[i]));
70 
71  return indexes;
72 }
73 
75 {
76  return m_obsWidget->getOutputValues();
77 }
78 
80 {
81  return m_ui->m_geometryComboBox->currentText().toStdString();
82 }
83 
85 {
86  if(m_dataType)
87  return m_dataType->getPropertyPosition(m_ui->m_geometryComboBox->currentText().toStdString());
88  else
89  return -1;
90 }
91 
93 {
94  return m_ui->m_idComboBox->currentText().toStdString();
95 }
96 
98 {
99  if(m_dataType)
100  return m_dataType->getPropertyPosition(m_ui->m_idComboBox->currentText().toStdString());
101  else
102  return -1;
103 }
104 
106 {
107  QString item;
108  std::vector<std::string> propertyNames;
109  m_dataType = dataType;
110 
111  const std::vector<te::dt::Property*>& properties = dataType->getProperties();
112 
113  for (std::size_t i = 0; i < properties.size(); i++)
114  {
115  item = QString::fromStdString(properties.at(i)->getName());
116  propertyNames.push_back(item.toStdString());
117 
118  if(properties.at(i)->getType() == te::dt::GEOMETRY_TYPE)
119  m_ui->m_geometryComboBox->addItem(item);
120  else
121  m_ui->m_idComboBox->addItem(item);
122  }
123 
124  m_obsWidget->setInputValues(propertyNames);
125 }
126 
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's properties.
std::auto_ptr< Ui::ObservationPropertiesWidgetForm > m_ui
The widget's form.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
Definition: Utils.cpp:500
ObservationPropertiesWidget(QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
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's form.
int getGeometryId()
Returns the index of the temporal property geometry.
void setUp(const te::da::DataSetTypePtr dataType)
Adjusts the widget'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.
std::auto_ptr< DoubleListWidget > m_obsWidget
The widget used to select the observed properties.