27 #include "../../../common/StringUtils.h"
28 #include "../../../dataaccess/dataset/DataSet.h"
29 #include "../../../dataaccess/utils/Utils.h"
30 #include "../../../raster/Raster.h"
34 #include "ui_ContrastWizardPageForm.h"
37 #include <QGridLayout>
38 #include <QMessageBox>
42 #include <boost/lexical_cast.hpp>
48 : QWizardPage(parent),
49 m_ui(new Ui::ContrastWizardPageForm),
58 QGridLayout* displayLayout =
new QGridLayout(
m_ui->m_frame);
63 displayLayout->setContentsMargins(0,0,0,0);
68 connect(
m_ui->m_histogramPushButton, SIGNAL(clicked()),
this, SLOT(
showHistogram()));
73 this->setTitle(tr(
"Contrast"));
74 this->setSubTitle(tr(
"Select the type of contrast and set their specific parameters."));
78 m_ui->m_histogramPushButton->setEnabled(
false);
79 m_ui->m_histogramPushButton->setVisible(
false);
88 int nBands = m_ui->m_bandTableWidget->rowCount();
90 for(
int i = 0; i < nBands; ++i)
92 QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
94 if(checkBox->isChecked())
107 std::list<te::map::AbstractLayerPtr> list;
109 list.push_back(m_layer);
111 m_navigator->set(m_layer);
113 m_histogramDlg->set(m_layer);
126 int index = m_ui->m_contrastTypeComboBox->currentIndex();
127 int contrastType = m_ui->m_contrastTypeComboBox->itemData(index).toInt();
128 int nBands = m_ui->m_bandTableWidget->rowCount();
136 for(
int i = 0; i < nBands; ++i)
138 QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
140 if(checkBox->isChecked())
142 QString valueMin = m_ui->m_bandTableWidget->item(i, 1)->text();
143 algoInputParams.
m_lCMinInput.push_back(valueMin.toDouble());
145 QString valueMax = m_ui->m_bandTableWidget->item(i, 2)->text();
146 algoInputParams.
m_lCMaxInput.push_back(valueMax.toDouble());
154 for(
int i = 0; i < nBands; ++i)
156 QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
158 if(checkBox->isChecked())
160 QString valueMax = m_ui->m_bandTableWidget->item(i, 1)->text();
161 algoInputParams.
m_hECMaxInput.push_back(valueMax.toDouble());
169 for(
int i = 0; i < nBands; ++i)
171 QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
173 if(checkBox->isChecked())
175 QString valueMean = m_ui->m_bandTableWidget->item(i, 1)->text();
178 QString valueStdDev = m_ui->m_bandTableWidget->item(i, 2)->text();
184 for(
int i = 0; i < nBands; ++i)
186 QCheckBox* checkBox = (QCheckBox*)m_ui->m_bandTableWidget->cellWidget(i, 0);
188 if(checkBox->isChecked())
194 return algoInputParams;
199 QApplication::setOverrideCursor(Qt::WaitCursor);
211 std::map<std::string, std::string> rinfo;
212 rinfo[
"MEM_RASTER_NROWS"] = boost::lexical_cast<std::string>(inputRst->
getNumberOfRows());
213 rinfo[
"MEM_RASTER_NCOLS"] = boost::lexical_cast<std::string>(inputRst->
getNumberOfColumns());
214 rinfo[
"MEM_RASTER_DATATYPE"] = boost::lexical_cast<std::string>(inputRst->
getBandDataType(0));
215 rinfo[
"MEM_RASTER_NBANDS"] = boost::lexical_cast<std::string>(inputRst->
getNumberOfBands());
225 if(algorithmInstance.
initialize(algoInputParams))
227 if(algorithmInstance.
execute(algoOutputParams))
235 QMessageBox::warning(
this, tr(
"Warning"), tr(
"Constrast error."));
238 QApplication::restoreOverrideCursor();
246 m_ui->m_contrastTypeComboBox->clear();
255 assert(m_layer.get());
258 std::auto_ptr<te::da::DataSet> ds = m_layer->getData();
264 std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
268 for(
unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
270 m_ui->m_bandTableWidget->setRowCount(0);
273 for(
unsigned b = 0 ; b < inputRst->getNumberOfBands(); b++)
275 int newrow = m_ui->m_bandTableWidget->rowCount();
276 m_ui->m_bandTableWidget->insertRow(newrow);
278 QString bName(tr(
"Band "));
279 bName.append(QString::number(b));
281 QCheckBox* bandCheckBox =
new QCheckBox(bName,
this);
284 bandCheckBox->setChecked(
true);
286 m_ui->m_bandTableWidget->setCellWidget(newrow, 0, bandCheckBox);
292 m_ui->m_bandTableWidget->resizeColumnsToContents();
293 #if (QT_VERSION >= 0x050000)
294 m_ui->m_bandTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
296 m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
299 onContrastTypeComboBoxActivated(m_ui->m_contrastTypeComboBox->currentIndex());
304 assert(m_layer.get());
306 m_histogramDlg->show();
311 int contrastType = m_ui->m_contrastTypeComboBox->itemData(index).toInt();
316 list.append(tr(
"Band"));
317 list.append(tr(
"Minimum"));
318 list.append(tr(
"Maximum"));
320 m_ui->m_bandTableWidget->setColumnCount(3);
321 m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
323 int nBands = m_ui->m_bandTableWidget->rowCount();
325 for(
int i = 0; i < nBands; ++i)
327 QTableWidgetItem* itemMin =
new QTableWidgetItem(
"0");
328 itemMin->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
329 m_ui->m_bandTableWidget->setItem(i, 1, itemMin);
331 QTableWidgetItem* itemMax =
new QTableWidgetItem(
"255");
332 itemMax->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
333 m_ui->m_bandTableWidget->setItem(i, 2, itemMax);
339 list.append(tr(
"Band"));
340 list.append(tr(
"Maximum"));
342 m_ui->m_bandTableWidget->setColumnCount(2);
343 m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
345 int nBands = m_ui->m_bandTableWidget->rowCount();
347 for(
int i = 0; i < nBands; ++i)
349 QTableWidgetItem* itemMax =
new QTableWidgetItem(
"255");
350 itemMax->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
351 m_ui->m_bandTableWidget->setItem(i, 1, itemMax);
357 list.append(tr(
"Band"));
358 list.append(tr(
"Mean"));
359 list.append(tr(
"Std Dev"));
361 m_ui->m_bandTableWidget->setColumnCount(3);
362 m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
364 int nBands = m_ui->m_bandTableWidget->rowCount();
366 for(
int i = 0; i < nBands; ++i)
368 QTableWidgetItem* itemMean =
new QTableWidgetItem(
"127");
369 itemMean->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
370 m_ui->m_bandTableWidget->setItem(i, 1, itemMean);
372 QTableWidgetItem* itemStdDev =
new QTableWidgetItem(
"50");
373 itemStdDev->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
374 m_ui->m_bandTableWidget->setItem(i, 2, itemStdDev);
378 m_ui->m_bandTableWidget->resizeColumnsToContents();
379 #if (QT_VERSION >= 0x050000)
380 m_ui->m_bandTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
382 m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
te::map::AbstractLayerPtr get()
ContrastWizardPage(QWidget *parent=0)
te::rst::Raster * m_outRasterPtr
A pointer to a valid initiated raster instance where the result must be written, leave NULL to create...
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
This file defines a class for a RasterHistogram Dialog.
std::auto_ptr< te::qt::widgets::RasterHistogramDialog > m_histogramDlg
void set(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for contrast operation.
te::rp::Contrast::InputParameters getInputParams()
std::auto_ptr< Ui::ContrastWizardPageForm > m_ui
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::auto_ptr< te::qt::widgets::RasterNavigatorWidget > m_navigator
This file defines a class for a Contrast Wizard page.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
std::string m_createdOutRasterDSType
Output raster data source type (as described in te::raster::RasterFactory ), leave empty if the resul...
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Contrast output parameters.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
std::map< std::string, std::string > m_createdOutRasterInfo
The necessary information to create the raster (as described in te::raster::RasterFactory), leave empty if the result must be written to the raster pointed m_outRasterPtr.
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
void onContrastTypeComboBoxActivated(int index)