27 #include "../../../common/StringUtils.h" 28 #include "../../../dataaccess/dataset/DataSet.h" 29 #include "../../../dataaccess/utils/Utils.h" 30 #include "../../../raster/Interpolator.h" 31 #include "../../../raster/Raster.h" 32 #include "../../../rp/Functions.h" 33 #include "../../../rp/SpectralResponseFunctions.h" 34 #include "../../../se/Utils.h" 36 #include "ui_FusionWizardPageForm.h" 39 #include <QApplication> 40 #include <QFileDialog> 41 #include <QGridLayout> 42 #include <QMessageBox> 51 #include <qwt_legend.h> 56 te::qt::widgets::FusionWizardPage::FusionWizardPage(
QWidget* parent)
58 m_ui(new
Ui::FusionWizardPageForm),
59 m_scatterHighRes(
nullptr),
60 m_layerLower(
nullptr),
61 m_layerHigher(
nullptr)
68 fillSensorTypes(m_ui->m_sensorTypeComboBox);
73 m_chartDialog =
new QDialog(
this, Qt::Tool | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
74 QGridLayout* dlgLayout =
new QGridLayout(m_chartDialog);
76 dlgLayout->addWidget(m_chartDisplay);
78 m_chartDisplay->setAxisTitle(QwtPlot::xBottom, tr(
"Wavelength in Microns"));
79 m_chartDisplay->setAxisTitle(QwtPlot::yLeft, tr(
"Reflectance"));
80 m_chartDisplay->insertLegend(
new QwtLegend(), QwtPlot::RightLegend);
83 connect(m_ui->m_scatterBoolButton, SIGNAL(toggled(
bool)), m_chartDialog, SLOT(setVisible(
bool)));
84 connect(m_ui->m_sensorTypeComboBox, SIGNAL(activated(
int)),
this, SLOT(onHighResSensorTypeActivated(
int)));
85 connect(m_ui->m_csvToolButton, SIGNAL(clicked()),
this, SLOT(onHighCsvToolButtonClicked()));
89 this->setTitle(tr(
"Fusion"));
90 this->setSubTitle(tr(
"Select the type of fusion and set their specific parameters."));
92 m_ui->m_scatterBoolButton->setIcon(QIcon::fromTheme(
"chart-lines"));
126 int idx =
m_ui->m_fusionTypeComboBox->currentIndex();
128 int type =
m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
138 int idx =
m_ui->m_fusionTypeComboBox->currentIndex();
140 int type =
m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
150 int idx =
m_ui->m_fusionTypeComboBox->currentIndex();
152 int type =
m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
162 return m_ui->m_cropCheckBox->isChecked();
167 int interpolationIdx =
m_ui->m_interpolatorComboBox->currentIndex();
181 return algoInputParams;
188 return algoOutputParams;
193 int interpolationIdx =
m_ui->m_interpolatorComboBox->currentIndex();
201 int nBands =
m_ui->m_listWidget->count();
202 for(
int i = 0; i < nBands; ++i)
204 if(
m_ui->m_listWidget->item(i)->isSelected())
210 return algoInputParams;
217 return algoOutputParams;
222 int idx =
m_ui->m_interpolatorComboBox->currentIndex();
230 int nBands =
m_ui->m_wisperTableWidget->rowCount();
231 for(
int i = 0; i < nBands; ++i)
233 QTableWidgetItem* item =
m_ui->m_wisperTableWidget->item(i, 0);
235 if(item->checkState() == Qt::Checked)
239 QComboBox* cmbBox = (QComboBox*)
m_ui->m_wisperTableWidget->cellWidget(i, 2);
241 idx = cmbBox->currentIndex();
243 std::string stName = cmbBox->itemText(idx).toUtf8().data();
252 idx =
m_ui->m_sensorTypeComboBox->currentIndex();
254 std::string stName =
m_ui->m_sensorTypeComboBox->itemText(idx).toUtf8().data();
260 idx =
m_ui->m_waveletComboBox->currentIndex();
264 return algoInputParams;
271 return algoOutputParams;
289 std::string stName =
m_ui->m_sensorTypeComboBox->itemText(idx).toUtf8().data();
291 std::map<double, double> srf =
getSRFMap(st, stName);
292 std::map<double, double>::iterator it;
295 std::vector<double> wavelengthX;
296 std::vector<double> reflectanceY;
298 for(it = srf.begin(); it != srf.end(); ++it)
300 wavelengthX.push_back(it->first);
301 reflectanceY.push_back(it->second);
316 QComboBox* cmbBox =
dynamic_cast<QComboBox*
>(sender());
333 scatterChart->setPen(c);
335 scatterChart->setSymbol(
nullptr);
336 scatterChart->setStyle(QwtPlotCurve::Lines);
340 QString title(tr(
"Low Resolution - Band "));
341 title.append(QString::number(row));
342 scatterChart->setTitle(title);
349 std::string stName = cmbBox->itemText(idx).toUtf8().data();
351 std::map<double, double> srf =
getSRFMap(st, stName);
352 std::map<double, double>::iterator it;
355 std::vector<double> wavelengthX;
356 std::vector<double> reflectanceY;
358 for(it = srf.begin(); it != srf.end(); ++it)
360 wavelengthX.push_back(it->first);
361 reflectanceY.push_back(it->second);
376 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Spectral Response Function File"),
"", tr(
"CSV Files (*.csv *.CSV)"));
378 if(fileName.isEmpty())
381 int idx =
m_ui->m_sensorTypeComboBox->count();
382 m_ui->m_sensorTypeComboBox->addItem(fileName, QVariant(-1));
383 m_ui->m_sensorTypeComboBox->setCurrentIndex(idx);
395 QComboBox* combo = (QComboBox*)
m_ui->m_wisperTableWidget->cellWidget(row, 2);
400 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open Spectral Response Function File"),
"", tr(
"CSV Files (*.csv *.CSV)"));
402 if(fileName.isEmpty())
405 int idx = combo->count();
406 combo->addItem(fileName, QVariant(-1));
407 combo->setCurrentIndex(idx);
412 m_ui->m_fusionTypeComboBox->clear();
418 m_ui->m_interpolatorComboBox->clear();
464 m_ui->m_waveletComboBox->clear();
473 m_ui->m_ihsRComboBox->clear();
474 m_ui->m_ihsGComboBox->clear();
475 m_ui->m_ihsBComboBox->clear();
476 m_ui->m_listWidget->clear();
477 m_ui->m_wisperTableWidget->setRowCount(0);
490 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
494 for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
496 m_ui->m_ihsRComboBox->addItem(QString::number(i));
497 m_ui->m_ihsGComboBox->addItem(QString::number(i));
498 m_ui->m_ihsBComboBox->addItem(QString::number(i));
499 m_ui->m_listWidget->addItem(QString::number(i));
502 int newrow =
m_ui->m_wisperTableWidget->rowCount();
503 m_ui->m_wisperTableWidget->insertRow(newrow);
505 QString bName(tr(
"Band "));
506 bName.append(QString::number(i));
508 QTableWidgetItem* itemBand =
new QTableWidgetItem(bName);
509 itemBand->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
510 itemBand->setCheckState(Qt::Checked);
511 m_ui->m_wisperTableWidget->setItem(newrow, 0, itemBand);
515 button->setText(
"...");
516 button->setToolTip(tr(
"Open Spectral Response Function File..."));
517 button->resize(16,16);
519 m_ui->m_wisperTableWidget->setCellWidget(newrow, 1, button);
523 m_buttonMap.insert(std::map<QToolButton*, int>::value_type(button, (
int)i));
526 QComboBox* cmbBox =
new QComboBox(
this);
528 m_ui->m_wisperTableWidget->setCellWidget(newrow, 2, cmbBox);
532 m_comboMap.insert(std::map<QComboBox*, int>::value_type(cmbBox, (
int)i));
540 m_ui->m_wisperTableWidget->resizeColumnsToContents();
545 m_ui->m_bandComboBox_IHS->clear();
546 m_ui->m_bandComboBox_PCA->clear();
547 m_ui->m_bandComboBox_Wisper->clear();
558 std::unique_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
562 for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
564 m_ui->m_bandComboBox_IHS->addItem(QString::number(i));
565 m_ui->m_bandComboBox_PCA->addItem(QString::number(i));
566 m_ui->m_bandComboBox_Wisper->addItem(QString::number(i));
574 std::map<double, double> srfMap;
578 std::ifstream
file(stName.c_str());
586 std::getline(
file, buffer);
588 while(std::getline(
file, buffer))
590 std::vector<std::string>
line;
596 double wavelength = atof(line[0].c_str());
597 double response = atof(line[1].c_str());
599 srfMap.insert(std::map<double, double>::value_type(wavelength, response));
te::rp::IHSFusion::InputParameters getInputIHSParams()
te::rp::WisperFusion::OutputParameters getOutputWisperParams()
Near neighborhood interpolation method.
void onLowCsvToolButtonClicked()
void getSRF(const SensorType &sensor, ContainerT &container)
Returns a Spectral Response Function from the given sensor.
te::map::AbstractLayerPtr m_layerLower
te::qt::widgets::ChartDisplay * m_chartDisplay
std::unique_ptr< Ui::FusionWizardPageForm > m_ui
IHSFusion output parameters.
PCAFusion output parameters.
te::qt::widgets::ScatterChart * m_scatterChartHighRes
static te::dt::Date ds(2010, 01, 01)
std::map< QToolButton *, int > m_buttonMap
InterpolationMethod
Allowed interpolation methods.
InterpolationMethod Method
Allowed interpolation methods.
WisperFusion output parameters.
te::rp::PCAFusion::OutputParameters getOutputPCAParams()
void setLower(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation.
std::vector< te::qt::widgets::ScatterChart * > m_scatterChartLowResVec
void onHighResSensorTypeActivated(int idx)
SensorType
Satellite sensors.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr) te
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
This file defines a class for a Fusion Wizard page.
te::rp::WisperFusion::InputParameters getInputWisperParams()
std::vector< te::qt::widgets::Scatter * > m_scatterLowResVec
WaveletAtrousFilterType
Wavelet Atrous Filter types.
te::rp::IHSFusion::OutputParameters getOutputIHSParams()
te::qt::widgets::Scatter * m_scatterHighRes
Bicubic interpolation method.
void fillSensorTypes(QComboBox *combo)
void setHigher(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation.
void onLowResSensorTypeActivated(int idx)
Bilinear interpolation method.
TESEEXPORT std::string GenerateRandomColor()
Creates a random RGB color encoded using two hexadecimal digits per primary-color component prefixed ...
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
void onHighCsvToolButtonClicked()
std::map< QComboBox *, int > m_comboMap
LANDSAT 7 ETM+ Band 8 PAN.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::map::AbstractLayerPtr m_layerHigher
file(WRITE ${CMAKE_BINARY_DIR}/config_qhelp.cmake"configure_file (${TERRALIB_ABSOLUTE_ROOT_DIR}/doc/qhelp/help.qhcp.in ${CMAKE_BINARY_DIR}/share/terraview/help/help.qhcp @ONLY)") add_custom_command(OUTPUT del_dir COMMAND $
te::rp::PCAFusion::InputParameters getInputPCAParams()
std::map< double, double > getSRFMap(const int &st, std::string stName)