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 <QtGui/QMessageBox> 
   39 #include <QtGui/QCheckBox> 
   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;
 
  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   m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
 
  295   onContrastTypeComboBoxActivated(m_ui->m_contrastTypeComboBox->currentIndex());
 
  300   assert(m_layer.get());
 
  302   m_histogramDlg->show();
 
  307   int contrastType = m_ui->m_contrastTypeComboBox->itemData(index).toInt();
 
  312     list.append(tr(
"Band"));
 
  313     list.append(tr(
"Minimum"));
 
  314     list.append(tr(
"Maximum"));
 
  316     m_ui->m_bandTableWidget->setColumnCount(3);
 
  317     m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
 
  319     int nBands = m_ui->m_bandTableWidget->rowCount();
 
  321     for(
int i = 0; i < nBands; ++i)
 
  323       QTableWidgetItem* itemMin = 
new QTableWidgetItem(
"0");
 
  324       itemMin->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
 
  325       m_ui->m_bandTableWidget->setItem(i, 1, itemMin);
 
  327       QTableWidgetItem* itemMax = 
new QTableWidgetItem(
"255");
 
  328       itemMax->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
 
  329       m_ui->m_bandTableWidget->setItem(i, 2, itemMax);
 
  335     list.append(tr(
"Band"));
 
  336     list.append(tr(
"Maximum"));
 
  338     m_ui->m_bandTableWidget->setColumnCount(2);
 
  339     m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
 
  341     int nBands = m_ui->m_bandTableWidget->rowCount();
 
  343     for(
int i = 0; i < nBands; ++i)
 
  345       QTableWidgetItem* itemMax = 
new QTableWidgetItem(
"255");
 
  346       itemMax->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
 
  347       m_ui->m_bandTableWidget->setItem(i, 1, itemMax);
 
  353     list.append(tr(
"Band"));
 
  354     list.append(tr(
"Mean"));
 
  355     list.append(tr(
"Std Dev"));
 
  357     m_ui->m_bandTableWidget->setColumnCount(3);
 
  358     m_ui->m_bandTableWidget->setHorizontalHeaderLabels(list);
 
  360     int nBands = m_ui->m_bandTableWidget->rowCount();
 
  362     for(
int i = 0; i < nBands; ++i)
 
  364       QTableWidgetItem* itemMean = 
new QTableWidgetItem(
"127");
 
  365       itemMean->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
 
  366       m_ui->m_bandTableWidget->setItem(i, 1, itemMean);
 
  368       QTableWidgetItem* itemStdDev = 
new QTableWidgetItem(
"50");
 
  369       itemStdDev->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
 
  370       m_ui->m_bandTableWidget->setItem(i, 2, itemStdDev);
 
  374   m_ui->m_bandTableWidget->resizeColumnsToContents();
 
  375   m_ui->m_bandTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
 
This file defines a class for a RasterHistogram Dialog. 
 
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters. 
 
This file has the RasterNavigatorWidget class. 
 
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 getNumberOfRows() const 
Returns the raster number of rows. 
 
Contrast output parameters. 
 
std::auto_ptr< te::qt::widgets::RasterNavigatorWidget > m_navigator
 
std::vector< unsigned int > m_inRasterBands
Bands to be processed from the input raster. 
 
This class is used to navigate over a DataSetLayer (having a raster representation) and given a set o...
 
std::vector< double > m_lCMaxInput
The contrast maximum input greyscale value of each band. 
 
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster. 
 
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. 
 
void onContrastTypeComboBoxActivated(int index)
 
This class is a dialog for the RasterHistogram widget. 
 
std::string m_createdOutRasterDSType
Output raster data source type (as described in te::raster::RasterFactory ), leave empty if the resul...
 
te::rst::Raster const * m_inRasterPtr
Input raster. 
 
std::auto_ptr< Ui::ContrastWizardPageForm > m_ui
 
void set(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for contrast operation. 
 
std::vector< double > m_lCMinInput
The contrast minimum input greyscale value of each band. 
 
ContrastType m_type
The contrast type to be applied. 
 
Contrast input parameters. 
 
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension). 
 
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
 
ContrastWizardPage(QWidget *parent=0)
 
std::vector< double > m_hECMaxInput
The contrast maximum input greyscale value of each band. 
 
unsigned int getNumberOfColumns() const 
Returns the raster number of columns. 
 
te::rp::Contrast::InputParameters getInputParams()
 
std::auto_ptr< te::qt::widgets::RasterHistogramDialog > m_histogramDlg
 
te::map::AbstractLayerPtr get()
 
An abstract class for raster data strucutures. 
 
std::vector< double > m_sMASCMeanInput
The mean greyscale to be applied in each band. 
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
std::vector< double > m_sMASCStdInput
The standard deviation to be applied in each band. 
 
This file defines a class for a Contrast Wizard page. 
 
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.