27 #include "../../../common/progress/ProgressManager.h" 
   28 #include "../../../common/STLUtils.h" 
   29 #include "../../../dataaccess/dataset/DataSet.h" 
   30 #include "../../../dataaccess/utils/Utils.h" 
   31 #include "../../../raster/RasterFactory.h" 
   32 #include "../../../rp/Functions.h" 
   33 #include "../../widgets/help/HelpPushButton.h" 
   34 #include "../../widgets/progress/ProgressViewerDialog.h" 
   35 #include "../layer/search/LayerSearchWidget.h" 
   36 #include "../layer/search/LayerSearchWizardPage.h" 
   47 #include <QMessageBox> 
   48 #include <QApplication> 
   55   this->setWizardStyle(QWizard::ModernStyle);
 
   56   this->setWindowTitle(tr(
"Arithmetic Operation"));
 
   59   this->setOption(QWizard::HaveHelpButton, 
true);
 
   60   this->setOption(QWizard::HelpButtonOnRight, 
false);
 
   64   this->setButton(QWizard::HelpButton, helpButton);
 
   78   if(currentPage() ==  m_layerSearchPage.get())
 
   80     std::list<te::map::AbstractLayerPtr> list = m_layerSearchPage->getSearchWidget()->getSelecteds();
 
   82     m_arithmeticOpPage->setList(list);
 
   84     return m_layerSearchPage->isComplete();
 
   86   else if(currentPage() ==  m_arithmeticOpPage.get())
 
   88     return m_arithmeticOpPage->isComplete();
 
   90   else if(currentPage() ==  m_rasterInfoPage.get())
 
  100   m_layerSearchPage->getSearchWidget()->setList(layerList);
 
  101   m_layerSearchPage->getSearchWidget()->filterOnlyByRaster();
 
  102   m_layerSearchPage->getSearchWidget()->enableMultiSelection(
true);
 
  107   return m_outputLayer;
 
  116   addPage(m_layerSearchPage.get());
 
  117   addPage(m_arithmeticOpPage.get());
 
  118   addPage(m_rasterInfoPage.get());
 
  127   QApplication::setOverrideCursor(Qt::WaitCursor);
 
  129   int type = m_arithmeticOpPage->getOperationType();
 
  133   if(type == ARITH_OP_TYPE_1)
 
  134     algoInputParams = paramsFromOp1();
 
  135   else if(type == ARITH_OP_TYPE_2)
 
  136     algoInputParams = paramsFromOp2();
 
  137   else if(type == ARITH_OP_TYPE_3)
 
  138     algoInputParams = paramsFromOp3();
 
  139   else if(type == ARITH_OP_TYPE_4)
 
  140     algoInputParams = paramsFromOp4();
 
  141   else if(type == ARITH_OP_TYPE_5)
 
  142     algoInputParams = paramsFromOp5();
 
  143   else if(type == ARITH_OP_TYPE_6)
 
  144     algoInputParams = paramsFromOp6();
 
  145   else if(type == ARITH_OP_TYPE_USER_DEFINED)
 
  146     algoInputParams = paramsFromOpUserdDef();
 
  150   algoOutputParams.
m_rType = m_rasterInfoPage->getWidget()->getType();
 
  151   algoOutputParams.
m_rInfo = m_rasterInfoPage->getWidget()->getInfo();
 
  157     if(algorithmInstance.
initialize(algoInputParams))
 
  159       if(algorithmInstance.
execute(algoOutputParams))
 
  161         algoOutputParams.
reset();
 
  165                                                       m_rasterInfoPage->getWidget()->getInfo());
 
  167         QMessageBox::information(
this, tr(
"Arithmetic Operation"), tr(
"Arithmetic Operation ended sucessfully"));
 
  171         QMessageBox::critical(
this, tr(
"Arithmetic Operation"), tr(
"Arithmetic Operation execution error.") +  ( 
" " + 
te::rp::Module::getLastLogStr() ).c_str());
 
  175         QApplication::restoreOverrideCursor();
 
  182       QMessageBox::critical(
this, tr(
"Arithmetic Operation"), tr(
"Arithmetic Operation initialization error") +
 
  187       QApplication::restoreOverrideCursor();
 
  192   catch(
const std::exception& e)
 
  194     QMessageBox::warning(
this, tr(
"Arithmetic Operation"), e.what());
 
  198     QApplication::restoreOverrideCursor();
 
  204     QMessageBox::warning(
this, tr(
"Arithmetic Operation"), tr(
"An exception has occurred!"));
 
  208     QApplication::restoreOverrideCursor();
 
  215   QApplication::restoreOverrideCursor();
 
  224   double gain = m_arithmeticOpPage->getGainValue();
 
  225   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  226   bool normalize = m_arithmeticOpPage->normalize();
 
  229   int bA = m_arithmeticOpPage->getLayerBandA();
 
  232   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  234   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  237   std::string arithmeticString  = QString::number(gain).toLatin1().data();
 
  238               arithmeticString += 
" * R0:";
 
  239               arithmeticString += QString::number(bA).toLatin1().data();
 
  240               arithmeticString += 
" + ";
 
  241               arithmeticString += QString::number(offSet).toLatin1().data();
 
  255   double gain = m_arithmeticOpPage->getGainValue();
 
  256   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  257   bool normalize = m_arithmeticOpPage->normalize();
 
  260   int bA = m_arithmeticOpPage->getLayerBandA();
 
  263   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  265   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  268   int bB = m_arithmeticOpPage->getLayerBandB();
 
  271   std::auto_ptr<te::da::DataSet> dsB = lB->getData();
 
  273   std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
 
  276   std::string arithmeticString  = QString::number(gain).toLatin1().data();
 
  277               arithmeticString += 
" * ( R0:";
 
  278               arithmeticString += QString::number(bA).toLatin1().data();
 
  279               arithmeticString += 
" + R1:";
 
  280               arithmeticString += QString::number(bB).toLatin1().data();
 
  281               arithmeticString += 
" ) + ";
 
  282               arithmeticString += QString::number(offSet).toLatin1().data();
 
  298   double gain = m_arithmeticOpPage->getGainValue();
 
  299   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  300   bool normalize = m_arithmeticOpPage->normalize();
 
  303   int bA = m_arithmeticOpPage->getLayerBandA();
 
  306   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  308   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  311   int bB = m_arithmeticOpPage->getLayerBandB();
 
  314   std::auto_ptr<te::da::DataSet> dsB = lB->getData();
 
  316   std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
 
  319   std::string arithmeticString  = QString::number(gain).toLatin1().data();
 
  320               arithmeticString += 
" * ( R0:";
 
  321               arithmeticString += QString::number(bA).toLatin1().data();
 
  322               arithmeticString += 
" - R1:";
 
  323               arithmeticString += QString::number(bB).toLatin1().data();
 
  324               arithmeticString += 
" ) + ";
 
  325               arithmeticString += QString::number(offSet).toLatin1().data();
 
  341   double gain = m_arithmeticOpPage->getGainValue();
 
  342   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  343   bool normalize = m_arithmeticOpPage->normalize();
 
  346   int bA = m_arithmeticOpPage->getLayerBandA();
 
  349   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  351   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  354   int bB = m_arithmeticOpPage->getLayerBandB();
 
  357   std::auto_ptr<te::da::DataSet> dsB = lB->getData();
 
  359   std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
 
  362   std::string arithmeticString  = QString::number(gain).toLatin1().data();
 
  363               arithmeticString += 
" * ( R0:";
 
  364               arithmeticString += QString::number(bA).toLatin1().data();
 
  365               arithmeticString += 
" * R1:";
 
  366               arithmeticString += QString::number(bB).toLatin1().data();
 
  367               arithmeticString += 
" ) + ";
 
  368               arithmeticString += QString::number(offSet).toLatin1().data();
 
  384   double gain = m_arithmeticOpPage->getGainValue();
 
  385   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  386   bool normalize = m_arithmeticOpPage->normalize();
 
  389   int bA = m_arithmeticOpPage->getLayerBandA();
 
  392   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  394   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  397   int bB = m_arithmeticOpPage->getLayerBandB();
 
  400   std::auto_ptr<te::da::DataSet> dsB = lB->getData();
 
  402   std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
 
  405   std::string arithmeticString  = QString::number(gain).toLatin1().data();
 
  406               arithmeticString += 
" * ( R0:";
 
  407               arithmeticString += QString::number(bA).toLatin1().data();
 
  408               arithmeticString += 
" / R1:";
 
  409               arithmeticString += QString::number(bB).toLatin1().data();
 
  410               arithmeticString += 
" ) + ";
 
  411               arithmeticString += QString::number(offSet).toLatin1().data();
 
  427   double gain = m_arithmeticOpPage->getGainValue();
 
  428   double offSet = m_arithmeticOpPage->getOffSetValue();
 
  429   bool normalize = m_arithmeticOpPage->normalize();
 
  432   int bA = m_arithmeticOpPage->getLayerBandA();
 
  435   std::auto_ptr<te::da::DataSet> dsA = lA->getData();
 
  437   std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
 
  440   int bB = m_arithmeticOpPage->getLayerBandB();
 
  443   std::auto_ptr<te::da::DataSet> dsB = lB->getData();
 
  445   std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
 
  448   std::string arithmeticString  = 
"( ";
 
  449               arithmeticString += QString::number(gain).toLatin1().data();
 
  450               arithmeticString += 
" * ( R0:";
 
  451               arithmeticString += QString::number(bA).toLatin1().data();
 
  452               arithmeticString += 
" - R1:";
 
  453               arithmeticString += QString::number(bB).toLatin1().data();
 
  454               arithmeticString += 
" ) / ";
 
  455               arithmeticString += 
"( R0:";
 
  456               arithmeticString += QString::number(bA).toLatin1().data();
 
  457               arithmeticString += 
" + R1:";
 
  458               arithmeticString += QString::number(bB).toLatin1().data();
 
  459               arithmeticString += 
" ) ) + ";
 
  460               arithmeticString += QString::number(offSet).toLatin1().data();
 
  476   bool normalize = m_arithmeticOpPage->normalize();
 
  477   std::string arithExpStr = m_arithmeticOpPage->getUserDefinedExpression();
 
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ). 
 
Utility functions for the data access module. 
 
This class is GUI used to define the arithmeticOp parameters for the RP arithmeticOp operation...
 
This file defines a class for a ArithmeticOp Wizard page. 
 
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory). 
 
This file defines a class for a Raster Info Wizard page. 
 
A Qt dialog that allows users to run a arithmeticOp operation defined by RP module. 
 
static const std::string & getLastLogStr()
Returns the last log string generated by this module. 
 
void removeViewer(int viewerId)
Dettach a progress viewer. 
 
static ProgressManager & getInstance()
It returns a reference to the singleton instance. 
 
This class is GUI used to define the raster info parameters for raster factory. 
 
ArithmeticOperations output parameters. 
 
int addViewer(AbstractProgressViewer *apv)
Attach a progress viewer. 
 
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution. 
 
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
 
Performs arithmetic operation over raster data. 
 
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
 
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
 
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.