27 #include "../../core/logger/Logger.h" 28 #include "../../common/progress/ProgressManager.h" 29 #include "../../core/translator/Translator.h" 30 #include "../../common/STLUtils.h" 31 #include "../../dataaccess/datasource/DataSource.h" 32 #include "../../dataaccess/utils/Utils.h" 33 #include "../../geometry/GeometryProperty.h" 34 #include "../../maptools/DataSetLayer.h" 35 #include "../../qt/widgets/progress/ProgressViewerDialog.h" 36 #include "../core/KernelRatioOperation.h" 37 #include "../Exception.h" 40 #include "ui_KernelRatioDialogForm.h" 43 #include <QFileDialog> 45 #include <QMessageBox> 52 #include <boost/algorithm/string.hpp> 53 #include <boost/filesystem.hpp> 54 #include <boost/uuid/random_generator.hpp> 55 #include <boost/uuid/uuid_io.hpp> 59 te::sa::KernelRatioDialog::KernelRatioDialog(
QWidget* parent, Qt::WindowFlags f)
61 m_ui(new
Ui::KernelRatioDialogForm)
66 m_ui->m_nColsLineEdit->setValidator(
new QIntValidator(
this));
68 fillKernelParameters();
71 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"sa-kernelratio-hint").pixmap(112,48));
74 connect(m_ui->m_inputLayerComboBox, SIGNAL(activated(
int)),
this, SLOT(onInputLayerComboBoxActivated(
int)));
75 connect(m_ui->m_okPushButton, SIGNAL(clicked()),
this, SLOT(onOkPushButtonClicked()));
76 connect(m_ui->m_targetFileToolButton, SIGNAL(pressed()),
this, SLOT(onTargetFileToolButtonPressed()));
79 m_ui->m_helpPushButton->setNameSpace(
"dpi.inpe.br.plugins");
80 m_ui->m_helpPushButton->setPageReference(
"plugins/sa/sa_kernelratio.html");
87 std::list<te::map::AbstractLayerPtr>::iterator it = layers.begin();
89 while(it != layers.end())
95 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
99 if(dsLayer && dsType->hasGeom())
101 m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
109 if(
m_ui->m_inputLayerComboBox->count() > 0)
121 m_ui->m_functionComboBoxA->clear();
129 m_ui->m_functionComboBoxB->clear();
138 m_ui->m_estimationComboBoxA->clear();
144 m_ui->m_estimationComboBoxB->clear();
151 m_ui->m_combinationComboBox->clear();
163 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
167 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
169 std::vector<te::dt::Property*> propVec = dsType->getProperties();
171 m_ui->m_attrLayerComboBoxA->clear();
172 m_ui->m_attrLayerComboBoxB->clear();
174 for(std::size_t t = 0; t < propVec.size(); ++t)
176 int dataType = propVec[t]->getType();
183 m_ui->m_attrLayerComboBoxA->addItem(propVec[t]->getName().c_str(), dataType);
184 m_ui->m_attrLayerComboBoxB->addItem(propVec[t]->getName().c_str(), dataType);
203 m_ui->m_gridRadioButton->setChecked(
true);
204 m_ui->m_attrRadioButton->setEnabled(
false);
205 m_ui->m_attrNameLineEdit->clear();
209 m_ui->m_gridRadioButton->setChecked(
true);
210 m_ui->m_attrRadioButton->setEnabled(
true);
211 m_ui->m_attrNameLineEdit->clear();
219 if(
m_ui->m_repositoryLineEdit->text().isEmpty())
221 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a repository for the result."));
225 if(
m_ui->m_newLayerNameLineEdit->text().isEmpty())
227 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a name for the resulting layer."));
232 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(
m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
240 kInParamsA->m_useAdaptativeRadius =
m_ui->m_useAdaptRadiusCheckBoxA->isChecked();
242 if(!
m_ui->m_useAdaptRadiusCheckBoxA->isChecked())
244 kInParamsA->m_radiusPercentValue =
m_ui->m_radiusSpinBoxA->value();
247 if(
m_ui->m_useAttrLayerCheckBoxA->isChecked())
249 kInParamsA->m_intensityAttrName =
m_ui->m_attrLayerComboBoxA->currentText().toUtf8().data();
252 kInParamsA->m_ds = l->getData();
253 kInParamsA->m_dsType = l->getSchema();
262 if(!
m_ui->m_useAdaptRadiusCheckBoxB->isChecked())
267 if(
m_ui->m_useAttrLayerCheckBoxB->isChecked())
272 kInParamsB->
m_ds = l->getData();
273 kInParamsB->
m_dsType = l->getSchema();
278 kOutParams->
m_outputPath =
m_ui->m_repositoryLineEdit->text().toUtf8().data();
282 if(
m_ui->m_gridRadioButton->isChecked())
284 if(
m_ui->m_nColsLineEdit->text().isEmpty())
286 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the number of columns to the output grid."));
291 kOutParams->
m_nCols =
m_ui->m_nColsLineEdit->text().toInt();
293 else if(
m_ui->m_attrRadioButton->isChecked())
295 if(
m_ui->m_attrNameLineEdit->text().isEmpty())
297 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the attribute name to the output data."));
308 QApplication::setOverrideCursor(Qt::WaitCursor);
320 catch(
const std::exception& e)
322 QMessageBox::warning(
this, tr(
"Warning"), e.what());
324 QApplication::restoreOverrideCursor();
330 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Kernel Map internal error."));
332 QApplication::restoreOverrideCursor();
337 QApplication::restoreOverrideCursor();
342 std::string dataSetName;
344 if(
m_ui->m_gridRadioButton->isChecked())
348 dataSetName = std::string(
m_ui->m_newLayerNameLineEdit->text().toUtf8().data()) +
".tif";
350 else if(
m_ui->m_attrRadioButton->isChecked())
354 dataSetName =
m_ui->m_newLayerNameLineEdit->text().toUtf8().data();
361 if(
m_ui->m_gridRadioButton->isChecked())
365 else if(
m_ui->m_attrRadioButton->isChecked())
375 m_ui->m_newLayerNameLineEdit->clear();
376 m_ui->m_repositoryLineEdit->clear();
378 QString fileName = QFileDialog::getExistingDirectory(
this, tr(
"Set output location..."));
380 if (fileName.isEmpty())
383 m_ui->m_repositoryLineEdit->setText(fileName);
virtual void execute()
Function to execute the kernel operation.
TESAEXPORT void CreateKernelColorMaping(te::map::AbstractLayerPtr layer)
boost::shared_ptr< DataSource > DataSourcePtr
TESAEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
te::sa::KernelOutputType m_storageType
Kernel storage type.
void onOkPushButtonClicked()
void setInputParameters(te::sa::KernelInputParams *inParamsA, te::sa::KernelInputParams *inParamsB)
KernelCombinationType
Types of kernel combination.
TESAEXPORT te::da::DataSourcePtr CreateGDALDataSource(std::string path, std::string dataSetName)
Class that represents the kernel output parameters.
void setOutputParameters(te::sa::KernelOutputParams *outParams)
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
void onInputLayerComboBoxActivated(int index)
te::map::AbstractLayerPtr m_outputLayer
Generated Layer.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
std::string m_outputAttrName
Attribute with the new attr name (if KernelOutputType is Attribute)
Utility functions for the data access module.
te::sa::KernelCombinationType m_combinationType
Kernel combination type (used by ratio kernel)
std::string m_outputPath
Attribute with URI of the output file.
void fillKernelParameters()
TESAEXPORT te::map::AbstractLayerPtr CreateLayer(te::da::DataSourcePtr ds, std::string dataSetName)
std::string m_outputDataSetName
Attribute that defines the output dataset name.
A layer with reference to a dataset.
TESAEXPORT void CreateKernelGrouping(te::map::AbstractLayerPtr layer, std::string kernelAttr)
Class used to calculate the kernel ratio of a datasets.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void onTargetFileToolButtonPressed()
A dialog to calculate the kernel ratio of a datasets.
std::unique_ptr< Ui::KernelRatioDialogForm > m_ui
int m_nCols
Attribute with number of columns to create the grid (if KernelOutputType is Grid) ...
te::map::AbstractLayerPtr getOutputLayer()