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();
246 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
256 double gain = m_arithmeticOpPage->getGainValue();
257 double offSet = m_arithmeticOpPage->getOffSetValue();
258 bool normalize = m_arithmeticOpPage->normalize();
261 int bA = m_arithmeticOpPage->getLayerBandA();
264 std::auto_ptr<te::da::DataSet> dsA = lA->getData();
266 std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
269 int bB = m_arithmeticOpPage->getLayerBandB();
272 std::auto_ptr<te::da::DataSet> dsB = lB->getData();
274 std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
277 std::string arithmeticString = QString::number(gain).toLatin1().data();
278 arithmeticString +=
" * ( R0:";
279 arithmeticString += QString::number(bA).toLatin1().data();
280 arithmeticString +=
" + R1:";
281 arithmeticString += QString::number(bB).toLatin1().data();
282 arithmeticString +=
" ) + ";
283 arithmeticString += QString::number(offSet).toLatin1().data();
288 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
291 boost::shared_ptr<te::rst::Raster> rstBPtr(rstB.release());
301 double gain = m_arithmeticOpPage->getGainValue();
302 double offSet = m_arithmeticOpPage->getOffSetValue();
303 bool normalize = m_arithmeticOpPage->normalize();
306 int bA = m_arithmeticOpPage->getLayerBandA();
309 std::auto_ptr<te::da::DataSet> dsA = lA->getData();
311 std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
314 int bB = m_arithmeticOpPage->getLayerBandB();
317 std::auto_ptr<te::da::DataSet> dsB = lB->getData();
319 std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
322 std::string arithmeticString = QString::number(gain).toLatin1().data();
323 arithmeticString +=
" * ( R0:";
324 arithmeticString += QString::number(bA).toLatin1().data();
325 arithmeticString +=
" - R1:";
326 arithmeticString += QString::number(bB).toLatin1().data();
327 arithmeticString +=
" ) + ";
328 arithmeticString += QString::number(offSet).toLatin1().data();
333 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
336 boost::shared_ptr<te::rst::Raster> rstBPtr(rstB.release());
346 double gain = m_arithmeticOpPage->getGainValue();
347 double offSet = m_arithmeticOpPage->getOffSetValue();
348 bool normalize = m_arithmeticOpPage->normalize();
351 int bA = m_arithmeticOpPage->getLayerBandA();
354 std::auto_ptr<te::da::DataSet> dsA = lA->getData();
356 std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
359 int bB = m_arithmeticOpPage->getLayerBandB();
362 std::auto_ptr<te::da::DataSet> dsB = lB->getData();
364 std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
367 std::string arithmeticString = QString::number(gain).toLatin1().data();
368 arithmeticString +=
" * ( R0:";
369 arithmeticString += QString::number(bA).toLatin1().data();
370 arithmeticString +=
" * R1:";
371 arithmeticString += QString::number(bB).toLatin1().data();
372 arithmeticString +=
" ) + ";
373 arithmeticString += QString::number(offSet).toLatin1().data();
378 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
381 boost::shared_ptr<te::rst::Raster> rstBPtr(rstB.release());
391 double gain = m_arithmeticOpPage->getGainValue();
392 double offSet = m_arithmeticOpPage->getOffSetValue();
393 bool normalize = m_arithmeticOpPage->normalize();
396 int bA = m_arithmeticOpPage->getLayerBandA();
399 std::auto_ptr<te::da::DataSet> dsA = lA->getData();
401 std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
404 int bB = m_arithmeticOpPage->getLayerBandB();
407 std::auto_ptr<te::da::DataSet> dsB = lB->getData();
409 std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
412 std::string arithmeticString = QString::number(gain).toLatin1().data();
413 arithmeticString +=
" * ( R0:";
414 arithmeticString += QString::number(bA).toLatin1().data();
415 arithmeticString +=
" / R1:";
416 arithmeticString += QString::number(bB).toLatin1().data();
417 arithmeticString +=
" ) + ";
418 arithmeticString += QString::number(offSet).toLatin1().data();
423 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
426 boost::shared_ptr<te::rst::Raster> rstBPtr(rstB.release());
436 double gain = m_arithmeticOpPage->getGainValue();
437 double offSet = m_arithmeticOpPage->getOffSetValue();
438 bool normalize = m_arithmeticOpPage->normalize();
441 int bA = m_arithmeticOpPage->getLayerBandA();
444 std::auto_ptr<te::da::DataSet> dsA = lA->getData();
446 std::auto_ptr<te::rst::Raster> rstA = dsA->getRaster(rposA);
449 int bB = m_arithmeticOpPage->getLayerBandB();
452 std::auto_ptr<te::da::DataSet> dsB = lB->getData();
454 std::auto_ptr<te::rst::Raster> rstB = dsB->getRaster(rposB);
457 std::string arithmeticString =
"( ";
458 arithmeticString += QString::number(gain).toLatin1().data();
459 arithmeticString +=
" * ( R0:";
460 arithmeticString += QString::number(bA).toLatin1().data();
461 arithmeticString +=
" - R1:";
462 arithmeticString += QString::number(bB).toLatin1().data();
463 arithmeticString +=
" ) / ";
464 arithmeticString +=
"( R0:";
465 arithmeticString += QString::number(bA).toLatin1().data();
466 arithmeticString +=
" + R1:";
467 arithmeticString += QString::number(bB).toLatin1().data();
468 arithmeticString +=
" ) ) + ";
469 arithmeticString += QString::number(offSet).toLatin1().data();
474 boost::shared_ptr<te::rst::Raster> rstAPtr(rstA.release());
477 boost::shared_ptr<te::rst::Raster> rstBPtr(rstB.release());
487 double gain = m_arithmeticOpPage->getGainValue();
488 double offSet = m_arithmeticOpPage->getOffSetValue();
489 bool normalize = m_arithmeticOpPage->normalize();
490 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.