27 #include "../../common/Exception.h" 28 #include "../../common/progress/ProgressManager.h" 29 #include "../../core/translator/Translator.h" 30 #include "../../dataaccess/datasource/DataSourceFactory.h" 31 #include "../../dataaccess/datasource/DataSourceInfoManager.h" 32 #include "../../dataaccess/datasource/DataSourceManager.h" 33 #include "../../dataaccess/utils/Utils.h" 34 #include "../../geometry/GeometryProperty.h" 35 #include "../../maptools/DataSetLayer.h" 36 #include "../../maptools/Utils.h" 37 #include "../../mnt/core/Utils.h" 38 #include "../../mnt/core/Volume.h" 39 #include "../../qt/af/ApplicationController.h" 40 #include "../../qt/widgets/datasource/selector/DataSourceSelectorDialog.h" 41 #include "../../qt/widgets/progress/ProgressViewerDialog.h" 42 #include "../../qt/widgets/rp/Utils.h" 43 #include "../../raster.h" 49 #include "ui_VolumeDialogForm.h" 52 #include <QFileDialog> 53 #include <QMessageBox> 57 m_ui(new
Ui::VolumeDialogForm),
67 connect(
m_ui->m_dummycheckBox, SIGNAL(toggled(
bool)),
m_ui->m_dummylineEdit, SLOT(setEnabled(
bool)));
76 m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins");
77 m_ui->m_helpPushButton->setPageReference(
"plugins/mnt/DTM_Volume.html");
89 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
95 if (it->get()->isValid())
97 std::unique_ptr<te::da::DataSetType> dsType(it->get()->getSchema());
101 m_ui->m_vectorlayersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
104 m_ui->m_rasterlayersComboBox->addItem(QString(it->get()->getTitle().c_str()), QVariant(it->get()->getId().c_str()));
122 QList<mntType> types;
126 if (search.exec() != QDialog::Accepted)
131 int index =
m_ui->m_rasterlayersComboBox->findText(search.
getLayer().get()->getTitle().c_str());
132 m_ui->m_rasterlayersComboBox->setCurrentIndex(index);
139 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
140 std::string layerID =
m_ui->m_rasterlayersComboBox->itemData(index, Qt::UserRole).toString().toUtf8().data();
143 if(layerID == it->get()->getId())
153 m_ui->m_dummylineEdit->setText(QString::number(in_raster->getBand(0)->getProperty()->m_noDataValue));
170 QList<mntType> types;
174 if (search.exec() != QDialog::Accepted)
179 int index =
m_ui->m_vectorlayersComboBox->findText(search.
getLayer().get()->getTitle().c_str());
180 m_ui->m_vectorlayersComboBox->setCurrentIndex(index);
186 m_ui->m_attributeComboBox->clear();
187 std::list<te::map::AbstractLayerPtr>::iterator it =
m_layers.begin();
188 std::string layerID =
m_ui->m_vectorlayersComboBox->itemData(index, Qt::UserRole).toString().toUtf8().data();
191 if(layerID == it->get()->getId())
196 std::vector<te::dt::Property*> props = dsType->getProperties();
197 for (std::size_t i = 0; i < props.size(); ++i)
199 m_ui->m_attributeComboBox->addItem(QString(props[i]->getName().c_str()), QVariant(props[i]->getName().c_str()));
214 QApplication::setOverrideCursor(Qt::WaitCursor);
223 if (!indsrasterLayer)
227 if (!inrasterDataSource.get())
231 std::unique_ptr<te::da::DataSetType> inrasterDsetType(inrasterDataSource->getDataSetType(inrasterDsetName));
234 if (
m_ui->m_selectCheckBox->isChecked())
242 if (!indsvectorLayer)
246 if (!invectorDataSource.get())
250 std::unique_ptr<te::da::DataSetType> invectorDsetType(invectorDataSource->getDataSetType(invectorDsetName));
254 std::string attr =
m_ui->m_attributeComboBox->currentText().toUtf8().data();
257 calvol->setSRID(srid);
258 calvol->setInput(inrasterDataSource, inrasterDsetName, std::move(inrasterDsetType), invectorDataSource, invectorDsetName, std::move(invectorDsetType), OidSet);
259 calvol->setParams(
m_ui->m_quotaLineEdit->text().toDouble(), attr,
m_ui->m_dummylineEdit->text().toDouble());
263 QApplication::restoreOverrideCursor();
264 std::vector<std::string> polyvec;
265 std::vector<std::string> cortevec;
266 std::vector<std::string> aterrovec;
267 std::vector<std::string> areavec;
268 std::vector<std::string> iquotavec;
269 calvol->getResults(polyvec, cortevec, aterrovec, areavec, iquotavec);
277 this->parentWidget());
279 if (result.exec() != QDialog::Accepted)
286 catch (
const std::exception& e)
288 QApplication::restoreOverrideCursor();
289 QMessageBox::information(
this, tr(
"Volume "), e.what());
293 QApplication::restoreOverrideCursor();
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
boost::shared_ptr< DataSource > DataSourcePtr
#define TE_TR(message)
It marks a string in order to get translated.
A dialog Show Calculate Volume Results.
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
This class represents a set of unique ids created in the same context. i.e. from the same data set...
te::map::AbstractLayerPtr getLayer()
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
const std::string & getDataSetName() const
void setActive(const QList< mntType > &types)
A layer with reference to a dataset.
TEMNTEXPORT te::mnt::mntType getMNTType(const te::da::DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
virtual const std::string & getDataSourceId() const