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/KernelMapOperation.h" 37 #include "../Exception.h" 40 #include "ui_KernelMapDialogForm.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::KernelMapDialog::KernelMapDialog(
QWidget* parent, Qt::WindowFlags f)
61 m_ui(new
Ui::KernelMapDialogForm)
66 m_ui->m_nColsLineEdit->setValidator(
new QIntValidator(
this));
68 fillKernelParameters();
71 m_ui->m_imgLabel->setPixmap(QIcon::fromTheme(
"sa-kernelmap-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_kernelmap.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())
100 m_ui->m_inputLayerComboBox->addItem(it->get()->getTitle().c_str(), QVariant::fromValue(l));
107 if(
m_ui->m_inputLayerComboBox->count() > 0)
119 m_ui->m_functionComboBox->clear();
128 m_ui->m_estimationComboBox->clear();
137 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(index, Qt::UserRole);
141 std::unique_ptr<te::da::DataSetType> dsType = l->getSchema();
143 std::vector<te::dt::Property*> propVec = dsType->getProperties();
145 m_ui->m_attrLayerComboBox->clear();
147 for(std::size_t t = 0; t < propVec.size(); ++t)
149 int dataType = propVec[t]->getType();
156 m_ui->m_attrLayerComboBox->addItem(propVec[t]->getName().c_str(), dataType);
175 m_ui->m_gridRadioButton->setChecked(
true);
176 m_ui->m_attrRadioButton->setEnabled(
false);
177 m_ui->m_attrNameLineEdit->clear();
181 m_ui->m_gridRadioButton->setChecked(
true);
182 m_ui->m_attrRadioButton->setEnabled(
true);
183 m_ui->m_attrNameLineEdit->clear();
192 if(
m_ui->m_repositoryLineEdit->text().isEmpty())
194 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a repository for the result."));
198 if(
m_ui->m_newLayerNameLineEdit->text().isEmpty())
200 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define a name for the resulting layer."));
205 QVariant varLayer =
m_ui->m_inputLayerComboBox->itemData(
m_ui->m_inputLayerComboBox->currentIndex(), Qt::UserRole);
214 kInParams->m_useAdaptativeRadius =
m_ui->m_useAdaptRadiusCheckBox->isChecked();
216 if(!
m_ui->m_useAdaptRadiusCheckBox->isChecked())
218 kInParams->m_radiusPercentValue =
m_ui->m_radiusSpinBox->value();
221 if(
m_ui->m_useAttrLayerCheckBox->isChecked())
223 kInParams->m_intensityAttrName =
m_ui->m_attrLayerComboBox->currentText().toUtf8().data();
226 kInParams->m_ds = l->getData();
227 kInParams->m_dsType = l->getSchema();
232 kOutParams->
m_outputPath =
m_ui->m_repositoryLineEdit->text().toUtf8().data();
235 if(
m_ui->m_gridRadioButton->isChecked())
237 if(
m_ui->m_nColsLineEdit->text().isEmpty())
239 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the number of columns to the output grid."));
244 kOutParams->
m_nCols =
m_ui->m_nColsLineEdit->text().toInt();
246 else if(
m_ui->m_attrRadioButton->isChecked())
248 if(
m_ui->m_attrNameLineEdit->text().isEmpty())
250 QMessageBox::information(
this, tr(
"Warning"), tr(
"Define the attribute name to the output data."));
261 QApplication::setOverrideCursor(Qt::WaitCursor);
273 catch(
const std::exception& e)
275 QMessageBox::warning(
this, tr(
"Warning"), e.what());
277 QApplication::restoreOverrideCursor();
283 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Kernel Map internal error."));
285 QApplication::restoreOverrideCursor();
290 QApplication::restoreOverrideCursor();
295 std::string dataSetName;
297 if(
m_ui->m_gridRadioButton->isChecked())
301 dataSetName = std::string(
m_ui->m_newLayerNameLineEdit->text().toUtf8().data()) +
".tif";
303 else if(
m_ui->m_attrRadioButton->isChecked())
307 dataSetName =
m_ui->m_newLayerNameLineEdit->text().toUtf8().data();
314 if(
m_ui->m_gridRadioButton->isChecked())
318 else if(
m_ui->m_attrRadioButton->isChecked())
328 m_ui->m_newLayerNameLineEdit->clear();
329 m_ui->m_repositoryLineEdit->clear();
331 QString fileName = QFileDialog::getExistingDirectory(
this, tr(
"Set output location..."));
333 if (fileName.isEmpty())
336 m_ui->m_repositoryLineEdit->setText(fileName);
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.
Class used to calculate the kernel map of a dataset.
void setLayers(std::list< te::map::AbstractLayerPtr > layers)
Set the layer that can be used.
TESAEXPORT te::da::DataSourcePtr CreateGDALDataSource(std::string path, std::string dataSetName)
Class that represents the kernel output parameters.
void onOkPushButtonClicked()
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
void setOutputParameters(te::sa::KernelOutputParams *outParams)
std::unique_ptr< Ui::KernelMapDialogForm > m_ui
void onInputLayerComboBoxActivated(int index)
te::map::AbstractLayerPtr getOutputLayer()
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.
void fillKernelParameters()
std::string m_outputPath
Attribute with URI of the output file.
virtual void execute()
Function to execute the kernel operation.
TESAEXPORT te::map::AbstractLayerPtr CreateLayer(te::da::DataSourcePtr ds, std::string dataSetName)
std::string m_outputDataSetName
Attribute that defines the output dataset name.
void onTargetFileToolButtonPressed()
A layer with reference to a dataset.
TESAEXPORT void CreateKernelGrouping(te::map::AbstractLayerPtr layer, std::string kernelAttr)
A dialog to calculate the kernel map of a dataset.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::map::AbstractLayerPtr m_outputLayer
Generated Layer.
int m_nCols
Attribute with number of columns to create the grid (if KernelOutputType is Grid) ...
void setInputParameters(te::sa::KernelInputParams *inParams)