All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScatterDataWidget.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2010-2013 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/scatterDataWidget.cpp
22 
23  \brief A widget used to adjust a scatter's input data.
24 */
25 
26 //Terralib
27 
28 #include "../../../dataaccess.h"
29 #include "../../../datatype/Property.h"
30 #include "../../../qt/widgets/charts/Utils.h"
31 #include "../../../raster.h"
32 #include "ScatterDataWidget.h"
33 #include "ui_ScatterDataWidgetForm.h"
34 
35 te::qt::widgets::ScatterDataWidget::ScatterDataWidget(te::da::DataSet* dataSet, te::da::DataSetType* dataType, QWidget* parent, Qt::WindowFlags f)
36  : QWidget(parent, f),
37  m_ui(new Ui::ScatterDataWidgetForm),
38  m_dataSet (dataSet),
39  m_dataType(dataType)
40 {
41  m_ui->setupUi(this);
42 
43  QString item;
44 
45  std::size_t rpos = te::da::GetFirstPropertyPos(dataSet, te::dt::RASTER_TYPE);
46 
47  if(rpos != std::string::npos)
48  {
49  size_t size = dataSet->getRaster(rpos)->getNumberOfBands();
50  for (size_t i = 0; i < size; i++)
51  {
52  item = QString::number(i);
53  m_ui->m_propertyXComboBox->addItem(QString::fromStdString("Band: ") + item);
54  m_ui->m_propertyYComboBox->addItem(QString::fromStdString("Band: ") + item);
55  }
56  }
57  else
58  {
59  for (std::size_t i = 0; i < dataSet->getNumProperties(); i++)
60  {
62  {
63  item = QString::fromStdString(dataSet->getPropertyName(i));
64  m_ui->m_propertyXComboBox->addItem(item);
65  m_ui->m_propertyYComboBox->addItem(item);
66  }
67  }
68  }
69 }
70 
71 Ui::ScatterDataWidgetForm* te::qt::widgets::ScatterDataWidget::getForm()
72 {
73  return m_ui.get();
74 }
75 
77 {
78  //Acquiring the dataset Properties types and creating a new scatter
79  std::size_t rpos = te::da::GetFirstPropertyPos(m_dataSet.get(), te::dt::RASTER_TYPE);
80 
81  if(rpos != std::string::npos)
82  return te::qt::widgets::createScatter(m_dataSet.get(), m_dataType.get(), m_ui->m_propertyXComboBox->currentIndex(), m_ui->m_propertyYComboBox->currentIndex());
83  else
84  return te::qt::widgets::createScatter(m_dataSet.get(), m_dataType.get(), te::da::GetPropertyPos(m_dataSet.get(), m_ui->m_propertyXComboBox->currentText().toStdString()), te::da::GetPropertyPos(m_dataSet.get(), m_ui->m_propertyYComboBox->currentText().toStdString()));
85 }
86 
88 {
89 }
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::auto_ptr< te::rst::Raster > getRaster(std::size_t i) const =0
Method for retrieving a raster attribute value.
te::qt::widgets::Scatter * getScatter()
Returns a pointer to the widget&#39;s form.
ScatterDataWidget(te::da::DataSet *dataSet, te::da::DataSetType *dataType, QWidget *parent=0, Qt::WindowFlags f=0)
Constructor.
A class to represent a scatter.
Definition: Scatter.h:51
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:428
std::auto_ptr< Ui::ScatterDataWidgetForm > m_ui
THe widget Form.
TEQTWIDGETSEXPORT Scatter * createScatter(te::da::DataSet *dataset, te::da::DataSetType *dataType, int propX, int propY)
Scatter Creator.
Definition: Utils.cpp:155
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
Definition: Utils.cpp:447
A class that models the description of a dataset.
Definition: DataSetType.h:72
Ui::ScatterDataWidgetForm * getForm()
Returns a pointer to the widget&#39;s form.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:111