All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeometricOpOutputWizardPage.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/vp/qt/GeometricOpWizardPage.cpp
22 
23  \brief This file defines a class for a Geometric Operation Wizard Page.
24 */
25 
26 // TerraLib
27 #include "../../common/StringUtils.h"
28 #include "../../dataaccess/dataset/DataSet.h"
29 #include "../../dataaccess/dataset/DataSetType.h"
30 #include "../../dataaccess/utils/Utils.h"
31 #include "../../maptools/AbstractLayer.h"
32 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h"
33 #include "../../qt/widgets/Utils.h"
34 #include "../../qt/widgets/utils/DoubleListWidget.h"
36 #include "ui_GeometricOpOutputWizardPageForm.h"
37 //#include "VectorProcessingConfig.h"
38 
39 // Qt
40 #include <QFileDialog>
41 #include <QIntValidator>
42 #include <QMessageBox>
43 
44 // BOOST
45 #include <boost/filesystem.hpp>
46 
47 // STL
48 #include <memory>
49 
51  : QWizardPage(parent),
52  m_ui(new Ui::GeometricOpOutputWizardPageForm),
53  m_toFile(false)
54 {
55 // setup controls
56  m_ui->setupUi(this);
57 
58 // configure page
59  this->setTitle(tr("Output Layer Attributes"));
60  this->setSubTitle(tr("Choose the output parameters that compose the output layer."));
61 
62 // icons
63  QSize iconSize(32, 32);
64 
65  m_ui->m_convexHullCheckBox->setIconSize(iconSize);
66  m_ui->m_convexHullCheckBox->setIcon(QIcon::fromTheme("vp-convex-hull-hint"));
67 
68  m_ui->m_centroidCheckBox->setIconSize(iconSize);
69  m_ui->m_centroidCheckBox->setIcon(QIcon::fromTheme("vp-centroid-hint"));
70 
71  m_ui->m_mbrCheckBox->setIconSize(iconSize);
72  m_ui->m_mbrCheckBox->setIcon(QIcon::fromTheme("vp-mbr-hint"));
73 
74  m_ui->m_areaCheckBox->setIconSize(iconSize);
75  m_ui->m_areaCheckBox->setIcon(QIcon::fromTheme("vp-area-hint"));
76 
77  m_ui->m_lineCheckBox->setIconSize(iconSize);
78  m_ui->m_lineCheckBox->setIcon(QIcon::fromTheme("vp-line-length-hint"));
79 
80  m_ui->m_perimeterCheckBox->setIconSize(iconSize);
81  m_ui->m_perimeterCheckBox->setIcon(QIcon::fromTheme("vp-perimeter-hint"));
82 
83  m_ui->m_targetDatasourceToolButton->setIcon(QIcon::fromTheme("datasource"));
84 
85  connect(m_ui->m_attributesComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onAttributeComboBoxChanged(int)));
86  connect(m_ui->m_allObjectsRadioButton, SIGNAL(toggled(bool)), this, SLOT(onAllObjectsToggled()));
87  connect(m_ui->m_simpleRadioButton, SIGNAL(toggled(bool)), this, SLOT(onSimpleOperationToggled()));
88  connect(m_ui->m_byAttributesRadioButton, SIGNAL(toggled(bool)), this, SLOT(onAttributeOperationToggled()));
89  connect(m_ui->m_targetDatasourceToolButton, SIGNAL(pressed()), this, SLOT(onTargetDatasourceToolButtonPressed()));
90  connect(m_ui->m_targetFileToolButton, SIGNAL(pressed()), this, SLOT(onTargetFileToolButtonPressed()));
91 
92 }
93 
95 {
96 }
97 
99 {
100  return m_ui->m_convexHullCheckBox->isChecked();
101 }
102 
104 {
105  return m_ui->m_centroidCheckBox->isChecked();
106 }
107 
109 {
110  return m_ui->m_mbrCheckBox->isChecked();
111 }
112 
114 {
115  return m_ui->m_areaCheckBox->isChecked();
116 }
117 
119 {
120  return m_ui->m_lineCheckBox->isChecked();
121 }
122 
124 {
125  return m_ui->m_perimeterCheckBox->isChecked();
126 }
127 
129 {
130  return m_attribute;
131 }
132 
133 void te::vp::GeometricOpOutputWizardPage::setAttributes(std::vector<std::string> attributes)
134 {
135  m_ui->m_attributesComboBox->clear();
136 
137  for(std::size_t i = 0; i < attributes.size(); ++i)
138  {
139  m_ui->m_attributesComboBox->addItem(QString::fromStdString(attributes[i]));
140  }
141 }
142 
144 {
145  if(m_ui->m_allObjectsRadioButton->isChecked())
146  return te::vp::ALL_OBJ;
147  if(m_ui->m_simpleRadioButton->isChecked())
148  return te::vp::AGGREG_OBJ;
149  if(m_ui->m_byAttributesRadioButton->isChecked())
151 
152  return te::vp::ALL_OBJ;
153 }
154 
156 {
157  return m_ui->m_outputGroupBox->isChecked();
158 }
159 
161 {
162  return m_ui->m_newLayerNameLineEdit->text().toStdString();
163 }
164 
166 {
167  return m_toFile;
168 }
169 
171 {
172  return m_outputDatasource;
173 }
174 
176 {
177  return m_ui->m_repositoryLineEdit->text().toStdString();
178 }
179 
181 {
182  if(m_ui->m_byAttributesRadioButton->isChecked())
183  m_attribute = m_ui->m_attributesComboBox->itemText(index).toStdString();
184  else
185  m_attribute = "";
186 }
187 
189 {
190  m_ui->m_outputGroupBox->setCheckable(true);
191  m_ui->m_attributesComboBox->setEnabled(false);
192  onAttributeComboBoxChanged(0);
193 }
194 
196 {
197  m_ui->m_outputGroupBox->setCheckable(false);
198  m_ui->m_attributesComboBox->setEnabled(false);
199  onAttributeComboBoxChanged(0);
200 }
201 
203 {
204  m_ui->m_outputGroupBox->setCheckable(false);
205  m_ui->m_attributesComboBox->setEnabled(true);
206 }
207 
209 {
210  m_ui->m_newLayerNameLineEdit->clear();
211  m_ui->m_newLayerNameLineEdit->setEnabled(true);
213  dlg.exec();
214 
215  std::list<te::da::DataSourceInfoPtr> dsPtrList = dlg.getSelecteds();
216 
217  if(dsPtrList.size() <= 0)
218  return;
219 
220  std::list<te::da::DataSourceInfoPtr>::iterator it = dsPtrList.begin();
221 
222  m_ui->m_repositoryLineEdit->setText(QString(it->get()->getTitle().c_str()));
223 
224  m_outputDatasource = *it;
225 
226  m_toFile = false;
227 }
228 
230 {
231  m_ui->m_newLayerNameLineEdit->clear();
232  m_ui->m_repositoryLineEdit->clear();
233 
234  QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), te::qt::widgets::GetFilePathFromSettings("vp_geomOp"), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
235 
236  if(dir.isEmpty() == false)
237  {
238  m_path = dir.replace(QRegExp("\\\\"), "/").toStdString();
239 
240  m_ui->m_repositoryLineEdit->setText(m_path.c_str());
241 
242  te::qt::widgets::AddFilePathToSettings(m_path.c_str(), "vp_geomOp");
243 
244  m_toFile = true;
245  }
246 }
TEQTWIDGETSEXPORT void AddFilePathToSettings(const QString &path, const QString &typeFile)
Save last used path in QSettings.
Definition: Utils.cpp:367
void setAttributes(std::vector< std::string > attributes)
GeometricOpObjStrategy
Defines the strategy used for the processing of the input geometries.
Definition: Enums.h:115
Aggregate all objects.
Definition: Enums.h:118
Aggregate objects by attribute.
Definition: Enums.h:119
const std::list< te::da::DataSourceInfoPtr > & getSelecteds() const
te::vp::GeometricOpObjStrategy getObjectStrategy()
A dialog for selecting a data source.
std::auto_ptr< Ui::GeometricOpOutputWizardPageForm > m_ui
TEQTWIDGETSEXPORT QString GetFilePathFromSettings(const QString &typeFile)
Returns the value of the last saved file path for the typeFile required.
Definition: Utils.cpp:376
All objects individually.
Definition: Enums.h:117
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr