FilterDialogForm.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/qt/widgets/rp/FilterDialogForm.h
22 
23  \brief This file has the FilterDialogForm class.
24 */
25 
26 // TerraLib
27 #include "../../../common/progress/ProgressManager.h"
28 #include "../../../common/StringUtils.h"
29 #include "../../../dataaccess/dataset/DataSet.h"
30 #include "../../../dataaccess/dataset/DataSetType.h"
31 #include "../../../dataaccess/utils/Utils.h"
32 #include "../../../geometry/Utils.h"
33 #include "../../../maptools/Utils.h"
34 #include "../../../raster/RasterProperty.h"
35 #include "../../../rp/Filter.h"
36 #include "../../../rp/Module.h"
37 #include "../../../se/CoverageStyle.h"
38 #include "../../../se/RasterSymbolizer.h"
39 #include "../../../se/Rule.h"
40 #include "../../../se/SelectedChannel.h"
41 #include "../../../se/Utils.h"
42 #include "../../af/events/LayerEvents.h"
43 #include "../../widgets/tools/ExtentAcquire.h"
44 #include "../../widgets/utils/DoubleListWidget.h"
45 #include "../canvas/Canvas.h"
46 #include "../canvas/MapDisplay.h"
47 #include "../progress/ProgressViewerDialog.h"
48 #include "FilterDialogForm.h"
49 #include "MaskDialog.h"
50 #include "Utils.h"
51 #include "ui_FilterDialogForm.h"
52 
53 //QT
54 #include <QApplication>
55 #include <QGridLayout>
56 #include <QMessageBox>
57 #include <QCheckBox>
58 
59 //Boost
60 #include <boost/lexical_cast.hpp>
61 
63  : QDialog(parent),
64  m_ui(new Ui::FilterDialogForm),
65  m_previewRaster(nullptr),
66  m_geom(nullptr),
67  m_mapDisplay(nullptr)
68 {
69 //build form
70  m_ui->setupUi(this);
71 
72  m_ui->m_maskToolButton->setIcon(QIcon::fromTheme("mask"));
73  m_ui->m_loadMaskToolButton->setIcon(QIcon::fromTheme("mask-fill"));
74  m_ui->m_maskDefaultValueLineEdit->setValidator(new QDoubleValidator(this));
75 
76  QGridLayout* displayLayout = new QGridLayout(m_ui->m_navigatorWidget);
77  m_navigator.reset(new te::qt::widgets::RpToolsWidget(m_ui->m_navigatorWidget));
78  displayLayout->addWidget(m_navigator.get());
79  displayLayout->setContentsMargins(0,0,0,0);
80 
81  //build input layer
82  QGridLayout* inputLayout = new QGridLayout(m_ui->m_inputWidget);
83  inputLayout->setContentsMargins(0, 0, 0, 0);
85  inputLayout->addWidget(m_inputWidget);
86 
87  //build output parameters
88  QGridLayout* outputLayout = new QGridLayout(m_ui->m_outputWidget);
89  outputLayout->setContentsMargins(0, 0, 0, 0);
91  outputLayout->addWidget(m_outputWidget);
92 
93  //add double list widget to this form
94  m_doubleListWidget.reset(new te::qt::widgets::DoubleListWidget(m_ui->m_bandsGroupBox));
95  m_doubleListWidget->setLeftLabel("Input Bands");
96  m_doubleListWidget->setRightLabel("Output Bands");
97 
98  QGridLayout* layout = new QGridLayout(m_ui->m_bandsGroupBox);
99  layout->addWidget(m_doubleListWidget.get());
100  layout->setContentsMargins(0, 0, 0, 0);
101 
102  m_ui->m_helpPushButton->setNameSpace("dpi.inpe.br.plugins");
103  m_ui->m_helpPushButton->setPageReference("plugins/rp/rp_filter.html");
104 
105  m_ui->m_navigatorWidget->setEnabled(false);
106 
107  //connects
108  connect(m_ui->m_typeComboBox, SIGNAL(activated(int)), SLOT(onFilterTypeComboBoxActivated(int)));
109  connect(m_ui->m_iterationsSpinBox, SIGNAL(valueChanged(int)), SLOT(onIterationsChanged(int)));
110  connect(m_ui->m_maskToolButton, SIGNAL(clicked()), SLOT(onMaskToolButtonClicked()));
111  connect(m_ui->m_loadMaskToolButton, SIGNAL(clicked()), SLOT(onLoadMaskToolButtonClicked()));
112  connect(m_ui->m_previewCheckBox, SIGNAL(toggled(bool)), SLOT(onPreviewCheckBoxToggled(bool)));
113  connect(m_inputWidget, SIGNAL(layerChanged()), this, SLOT(layerChanged()));
114  connect(m_ui->m_okPushButton, SIGNAL(clicked()), SLOT(onOkPushButtonClicked()));
115  connect(m_navigator.get(), SIGNAL(envelopeAcquired(te::gm::Envelope)), this, SLOT(onEnvelopeAcquired(te::gm::Envelope)));
116 
117  listFilterTypes();
118 }
119 
121 
123 {
124  if (m_doubleListWidget->getOutputValues().empty())
125  return false;
126 
127  return true;
128 }
129 
131 {
132  m_doubleListWidget->clearInputValues();
133  m_doubleListWidget->clearOutputValues();
134 
135  std::unique_ptr<te::rst::Raster> raster(te::map::GetRaster(m_layer.get()));
136 
137  std::vector<std::string> bands;
138  for (unsigned int b = 0; b < raster->getNumberOfBands(); b++)
139  bands.push_back(te::common::Convert2String(b));
140 
141  m_doubleListWidget->setInputValues(bands);
142 }
143 
144 void te::qt::widgets::FilterDialogForm::setList(std::list<te::map::AbstractLayerPtr>& layerList, te::map::AbstractLayerPtr selectedlayer)
145 {
146  std::list<te::map::AbstractLayerPtr> layersRasterList;
147 
148  std::list<te::map::AbstractLayerPtr>::iterator it = layerList.begin();
149  //Filter only raster layers
150  while (it != layerList.end())
151  {
152  std::unique_ptr<te::da::DataSetType> dsType = it->get()->getSchema();
153  if (dsType->hasRaster())
154  layersRasterList.push_back(it->get());
155  ++it;
156  }
157 
158  m_inputWidget->setLayerList(layersRasterList);
159 
160  if (!layersRasterList.empty())
161  {
162  m_layer = layersRasterList.begin()->get();
163  setParams();
164  }
165 
166  if (selectedlayer && selectedlayer->isValid())
167  {
168  std::unique_ptr<te::rst::Raster> raster(te::map::GetRaster(m_layer.get()));
169 
170  // for while, consider one rule
172 
173  //get visible bands
174  std::vector<std::string> bands;
175  if (channelSelect->getColorCompositionType() == te::se::RGB_COMPOSITION)
176  {
177  std::string channelName = channelSelect->getRedChannel()->getSourceChannelName();
178  bands.push_back(channelName);
179 
180  channelName = channelSelect->getGreenChannel()->getSourceChannelName();
181  bands.push_back(channelName);
182 
183  channelName = channelSelect->getBlueChannel()->getSourceChannelName();
184  bands.push_back(channelName);
185  }
186  else
187  {
188  std::string channelName = channelSelect->getGrayChannel()->getSourceChannelName();
189  bands.push_back(channelName);
190  }
191 
192  std::vector<std::string> inputBands;
193  for (unsigned int i = 0; i < raster->getNumberOfBands(); i++)
194  {
195  bool isOutputBand = false;
196  for (unsigned int b = 0; b < bands.size(); b++)
197  {
198  if (bands[b] == te::common::Convert2String(i))
199  {
200  isOutputBand = true;
201  break;
202  }
203  }
204 
205  if (!isOutputBand)
206  inputBands.push_back(te::common::Convert2String(i));
207  }
208 
209  m_doubleListWidget->clearInputValues();
210  m_doubleListWidget->setInputValues(inputBands);
211  m_doubleListWidget->setOutputValues(bands);
212  }
213 }
214 
216 {
217  m_navigator->setMapDisplay(mapDisplay);
218  m_mapDisplay = mapDisplay;
219 }
220 
222 {
223  //configure tools
224  m_navigator->setActionGroup(actionGroup);
225  m_navigator->enableBoxAction();
226 }
227 
229 {
230  int idx = m_ui->m_typeComboBox->currentIndex();
231 
232  te::rp::Filter::InputParameters algoInputParams;
233  algoInputParams.m_iterationsNumber = m_ui->m_iterationsSpinBox->value();
234  algoInputParams.m_enableProgress = true;
235  algoInputParams.m_filterType = (te::rp::Filter::InputParameters::FilterType)m_ui->m_typeComboBox->itemData(idx).toInt();
236 
237  if(
238  (
240  ||
242  ||
244  )
245  &&
246  (
247  m_window.size1() > 0
248  )
249  )
250  {
251  algoInputParams.m_windowH = static_cast<unsigned int>(m_window.size1());
252  algoInputParams.m_windowW = static_cast<unsigned int>(m_window.size2());
253  algoInputParams.m_window = m_window;
254  }
255  else
256  {
257  algoInputParams.m_windowH = m_ui->m_maskSizeSpinBox->value();
258  algoInputParams.m_windowW = m_ui->m_maskSizeSpinBox->value();
259  }
260 
261  int nBands = static_cast<int>(m_doubleListWidget->getOutputValues().size());
262  for(int i = 0; i < nBands; ++i)
263  {
264  algoInputParams.m_inRasterBands.push_back(std::atoi(m_doubleListWidget->getOutputValues()[i].c_str()));
265  }
266 
267  return algoInputParams;
268 }
269 
271 {
272  int filterType = m_ui->m_typeComboBox->itemData(index).toInt();
273 
274  bool flag =
275  (
277  ||
279  ||
281  );
282 
283  m_ui->m_maskSizeSpinBox->setEnabled(flag);
284  m_ui->m_maskToolButton->setEnabled(flag);
285  m_ui->m_maskDefaultValueLineEdit->setEnabled(flag);
286 
287  if(m_ui->m_previewCheckBox->isChecked())
288  applyPreview();
289 }
290 
292 {
293  getInputParams();
294 
295  if(m_ui->m_previewCheckBox->isChecked())
296  applyPreview();
297 }
298 
300 {
301  te::qt::widgets::MaskDialog dlg(this);
302 
303  dlg.setMaskSize(m_ui->m_maskSizeSpinBox->value(), m_ui->m_maskSizeSpinBox->value(),
304  m_ui->m_maskDefaultValueLineEdit->text().isEmpty() ? 0 : m_ui->m_maskDefaultValueLineEdit->text().toDouble());
305 
306  if(dlg.exec() == QDialog::Accepted)
307  {
308  m_window = dlg.getMatrix();
309 
310  m_ui->m_loadMaskToolButton->setEnabled(true);
311  }
312 }
313 
315 {
316  te::qt::widgets::MaskDialog dlg(this);
317 
318  dlg.setMaskSize(m_window);
319 
320  m_ui->m_maskSizeSpinBox->setValue(static_cast<int>(m_window.size1()));
321 
322  if(dlg.exec() == QDialog::Accepted)
323  {
324  m_window = dlg.getMatrix();
325  }
326 }
327 
329 {
330  if (isChecked)
331  {
332  m_ui->m_navigatorWidget->setEnabled(true);
333  m_navigator->setEnvelopeTool(true);
334  }
335  else
336  {
337  m_ui->m_navigatorWidget->setEnabled(false);
338  m_navigator->setEnvelopeTool(false);
339  }
340 }
341 
343 {
344  if(!m_inputWidget->getInputLayer().get())
345  {
346  QMessageBox::information(this, tr("Filter"), tr("Input image is not defined."));
347  return;
348  }
349 
350  //check output parameters
351  if (m_outputWidget->getOutputRaster().empty())
352  {
353  QMessageBox::information(this, tr("Filter"), tr("Output image is not defined."));
354  return;
355  }
356 
357  if (!execute())
358  {
359  QMessageBox::information(this, tr("Filter"), tr("Error to execute the filter."));
360  return;
361  }
362 
363  clearCanvas();
364 
365  emit closeTool();
366 }
367 
369 {
371 }
372 
374 {
375  if (!m_ui->m_previewCheckBox->isChecked() || !env.isValid())
376  return;
377 
378  if (env.getLowerLeftX() == 0 && env.getLowerLeftY() == 0 && env.getUpperRightX() == 0 && env.getUpperRightY() == 0)
379  return;
380 
381  // verify if is necessary convert the raster to the given srid
382  bool needRemap = false;
383  if ((m_mapDisplay->getSRID() != TE_UNKNOWN_SRS) && (m_layer->getSRID() != TE_UNKNOWN_SRS) && (m_mapDisplay->getSRID() != m_layer->getSRID()))
384  needRemap = true;
385 
386  te::gm::Envelope envOut = env;
387 
388  // create a SRS converter
389  std::unique_ptr<te::srs::Converter> converter(new te::srs::Converter());
390 
391  if (needRemap)
392  {
393  converter->setSourceSRID(m_mapDisplay->getSRID());
394  converter->setTargetSRID(m_layer->getSRID());
395 
396  converter->convert(envOut.getLowerLeftX(), envOut.getLowerLeftY(), envOut.m_llx, envOut.m_lly);
397  converter->convert(envOut.getUpperRightX(), envOut.getUpperRightY(), envOut.m_urx, envOut.m_ury);
398  }
399 
400  if (!envOut.intersects(m_layer->getExtent()))
401  {
402  QMessageBox::warning(this, tr("Warning"), tr("ROI is invalid."));
403  return;
404  }
405 
406  m_geom = nullptr;
407 
409 
410  if(!m_geom->isValid())
411  return;
412 
414 
415  drawGeom();
416 }
417 
419 {
420  drawGeom();
421 
422  if (m_ui->m_previewCheckBox->isChecked() && m_previewRaster)
423  {
425  }
426 }
427 
429 {
431  {
432  QMessageBox::warning(this, tr("Filter"), tr("File already exists."));
433  return false;
434  }
435 
436  //get layer
437  std::unique_ptr<te::rst::Raster> inputRst(te::map::GetRaster(m_layer.get()));
438 
439  //run filter
440  te::rp::Filter algorithmInstance;
441 
443  algoInputParams.m_inRasterPtr = inputRst.get();
444 
445  te::rp::Filter::OutputParameters algoOutputParams;
446  algoOutputParams.m_rInfo = m_outputWidget->getInfo();
447  algoOutputParams.m_rType = m_outputWidget->getType();
448 
449  //progress
451 
452  QApplication::setOverrideCursor(Qt::WaitCursor);
453 
454  if (algorithmInstance.initialize(algoInputParams))
455  {
456  if (algorithmInstance.execute(algoOutputParams))
457  {
458  algoOutputParams.reset();
459 
460  //set output layer
463 
464  QMessageBox::information(this, tr("Filter"), tr("Filter ended sucessfully"));
465  }
466  else
467  {
468  QMessageBox::critical(this, tr("Filter"), tr("Filter execution error.") +
469  (" " + algorithmInstance.getErrorMessage()).c_str());
470 
471  QApplication::restoreOverrideCursor();
472 
473  return false;
474  }
475  }
476  else
477  {
478  QMessageBox::critical(this, tr("Filter"), tr("Filter initialization error.") +
479  (" " + algorithmInstance.getErrorMessage() ).c_str());
480 
481  QApplication::restoreOverrideCursor();
482 
483  return false;
484  }
485 
486  QApplication::restoreOverrideCursor();
487 
489 
490  emit addLayer(m_outputLayer);
491 
492  return true;
493 }
494 
496 {
497  m_doubleListWidget->clearInputValues();
498  m_doubleListWidget->clearOutputValues();
499 
500  //get input raster
501  std::unique_ptr<te::rst::Raster> inputRst(te::map::GetRaster(m_layer.get()));
502 
503  if(inputRst.get())
504  {
505  std::vector<std::string> bands;
506 
507  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
508  bands.push_back(te::common::Convert2String(i));
509 
510  m_doubleListWidget->setOutputValues(bands);
511  }
512 }
513 
515 {
516  m_ui->m_typeComboBox->clear();
517 
518  m_ui->m_typeComboBox->addItem(tr("Sobel"), te::rp::Filter::InputParameters::SobelFilterT);
519  m_ui->m_typeComboBox->addItem(tr("Roberts"), te::rp::Filter::InputParameters::RobertsFilterT);
520  m_ui->m_typeComboBox->addItem(tr("Mean"), te::rp::Filter::InputParameters::MeanFilterT);
521  m_ui->m_typeComboBox->addItem(tr("Mode"), te::rp::Filter::InputParameters::ModeFilterT);
522  m_ui->m_typeComboBox->addItem(tr("Median"), te::rp::Filter::InputParameters::MedianFilterT);
523  m_ui->m_typeComboBox->addItem(tr("Dilation"), te::rp::Filter::InputParameters::DilationFilterT);
524  m_ui->m_typeComboBox->addItem(tr("Erosion"), te::rp::Filter::InputParameters::ErosionFilterT);
525  m_ui->m_typeComboBox->addItem(tr("User Defined"), te::rp::Filter::InputParameters::UserDefinedWindowT);
526 
528 }
529 
531 {
532  if (!m_rasterPreview)
533  return;
534 
535  //run filter
536  te::rp::Filter algorithmInstance;
537 
539  algoInputParams.m_inRasterPtr = m_rasterPreview;
540 
541  te::rp::Filter::OutputParameters algoOutputParams;
542 
543  std::map<std::string, std::string> rinfo;
544  rinfo["MEM_RASTER_NROWS"] = boost::lexical_cast<std::string>(m_rasterPreview->getNumberOfRows());
545  rinfo["MEM_RASTER_NCOLS"] = boost::lexical_cast<std::string>(m_rasterPreview->getNumberOfColumns());
546  rinfo["MEM_RASTER_DATATYPE"] = boost::lexical_cast<std::string>(m_rasterPreview->getBandDataType(0));
547  rinfo["MEM_RASTER_NBANDS"] = boost::lexical_cast<std::string>(m_rasterPreview->getNumberOfBands());
548 
549  algoOutputParams.m_rType = "MEM";
550  algoOutputParams.m_rInfo = rinfo;
551 
552  //progress
554 
555  QApplication::setOverrideCursor(Qt::WaitCursor);
556 
557  if (algorithmInstance.initialize(algoInputParams))
558  {
559  if (algorithmInstance.execute(algoOutputParams))
560  {
561  //set output layer
562  te::dt::AbstractData* abs = algoOutputParams.m_outputRasterPtr->clone();
563 
564  te::rst::Raster* rst = static_cast<te::rst::Raster*>(abs);
566 
567  if (m_ui->m_previewCheckBox->isChecked())
569 
570  QApplication::restoreOverrideCursor();
571  }
572  else
573  {
574  QApplication::restoreOverrideCursor();
575 
576  QMessageBox::critical(this, tr("Filter"), tr("Filter execution error.") +
577  (" " + algorithmInstance.getErrorMessage()).c_str());
578 
579  return;
580  }
581  }
582  else
583  {
584  QApplication::restoreOverrideCursor();
585 
586  QMessageBox::critical(this, tr("Filter"), tr("Filter initialization error.") +
587  (" " + algorithmInstance.getErrorMessage()).c_str());
588 
589  return;
590  }
591 }
592 
594 {
595  QApplication::setOverrideCursor(Qt::WaitCursor);
596 
597  const te::gm::Envelope& envRaster = *raster->getExtent();
598  const te::gm::Envelope& env = m_mapDisplay->getExtent();
599 
601 
602  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
603  assert(cs);
604 
605  te::qt::widgets::Canvas* canvasInstance = new Canvas(m_mapDisplay->width(), m_mapDisplay->height());
606  canvasInstance->setDevice(m_mapDisplay->getDraftPixmap(), false);
607  canvasInstance->setWindow(env.m_llx, env.m_lly, env.m_urx, env.m_ury);
608 
609  canvasInstance->setPolygonContourWidth(2);
610  canvasInstance->setPolygonContourColor(te::color::RGBAColor(100, 177, 216, TE_OPAQUE));
611 
612  // Draw raster
613  bool cancel = false;
614  te::map::DrawRaster(raster, canvasInstance, envRaster, raster->getSRID(), env, m_mapDisplay->getSRID(), cs, nullptr, m_mapDisplay->getScale(), &cancel);
615 
616  if (!m_geom->isValid())
617  return;
618 
619  canvasInstance->draw(m_geom);
620 
621  m_mapDisplay->repaint();
622 
623  delete canvasInstance;
624 
625  QApplication::restoreOverrideCursor();
626 }
627 
629 {
630  if(!m_geom || !m_geom->isValid())
631  return;
632 
633  const te::gm::Envelope& env = m_mapDisplay->getExtent();
634 
635  te::qt::widgets::Canvas* canvasInstance = new Canvas(m_mapDisplay->width(), m_mapDisplay->height());
636  canvasInstance->setDevice(m_mapDisplay->getDraftPixmap(), false);
637  canvasInstance->setWindow(env.m_llx, env.m_lly, env.m_urx, env.m_ury);
638 
639  canvasInstance->setPolygonContourWidth(2);
640  canvasInstance->setPolygonContourColor(te::color::RGBAColor(100, 177, 216, TE_OPAQUE));
641 
642  canvasInstance->draw(m_geom);
643 
644  m_mapDisplay->repaint();
645 
646  delete canvasInstance;
647 }
648 
650 {
651  te::se::Style* style = m_layer->getStyle();
652  assert(style);
653 
654  te::se::CoverageStyle* cs = dynamic_cast<te::se::CoverageStyle*>(style);
655  assert(cs);
656 
657  // for while, consider one rule
658  const te::se::Rule* rule = cs->getRule(0);
659 
660  const std::vector<te::se::Symbolizer*>& symbolizers = rule->getSymbolizers();
661  assert(!symbolizers.empty());
662 
663  // for while, consider one raster symbolizer
664  te::se::RasterSymbolizer* symbolizer = dynamic_cast<te::se::RasterSymbolizer*>(symbolizers[0]);
665  assert(symbolizer);
666 
667  return symbolizer->getChannelSelection();
668 }
669 
671 {
673  {
674  QApplication::setOverrideCursor(Qt::WaitCursor);
675 
677 
678  // verify if is necessary convert the raster to the given srid
679  bool needRemap = false;
680  if ((m_mapDisplay->getSRID() != TE_UNKNOWN_SRS) && (m_layer->getSRID() != TE_UNKNOWN_SRS) && (m_mapDisplay->getSRID() != m_layer->getSRID()))
681  needRemap = true;
682 
683  // create a SRS converter
684  std::unique_ptr<te::srs::Converter> converter(new te::srs::Converter());
685 
686  if (needRemap)
687  {
688  converter->setSourceSRID(m_mapDisplay->getSRID());
689  converter->setTargetSRID(m_layer->getSRID());
690 
691  converter->convert(env->getLowerLeftX(), env->getLowerLeftY(), env->m_llx, env->m_lly);
692  converter->convert(env->getUpperRightX(), env->getUpperRightY(), env->m_urx, env->m_ury);
693  }
694 
695  std::unique_ptr<te::rst::Raster> raster(te::map::GetRaster(m_layer.get()));
696 
697  std::map<std::string, std::string> info;
698  info["FORCE_MEM_DRIVER"] = "TRUE";
699  //execute clipping
700  m_rasterPreview = raster->trim(env, info);
701 
702  if (m_ui->m_previewCheckBox->isChecked())
703  {
704  applyPreview();
705  }
706 
707  QApplication::restoreOverrideCursor();
708  }
709 }
710 
712 {
714 
715  canvasInstance.clear();
716 
717  m_mapDisplay->repaint();
718 }
719 
721 {
722  clearCanvas();
723 
724  emit closeTool();
725 }
const std::string & getErrorMessage() const
Return the current error message if there is any.
The resultant pixel will be the mode of pixels in the convolution window. When the window is multimod...
Definition: rp/Filter.h:66
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
void clear()
It clears the canvas content and fills with the background color.
te::map::AbstractLayerPtr m_layer
This class is a dialog to create a user defined mask.
Definition: MaskDialog.h:57
The resultant pixel will be the mean of pixels in the convolution window.
Definition: rp/Filter.h:65
te::qt::widgets::OutputRasterWidget * m_outputWidget
void setActionGroup(QActionGroup *actionGroup)
void setDevice(QPaintDevice *device, bool takeOwnerShip)
It sets new device as QPrinter.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
Definition: Style.h:65
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: rp/Filter.h:85
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
void onEnvelopeAcquired(te::gm::Envelope env)
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_navigator
The resultant pixel will be the lowest pixel value in the convolution window.
Definition: rp/Filter.h:69
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
std::unique_ptr< te::qt::widgets::DoubleListWidget > m_doubleListWidget
The CoverageStyle defines the styling that is to be applied to a subset of Coverage data...
Definition: CoverageStyle.h:45
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const
Subsetting operation for trimming (cropping) the raster.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
TESEEXPORT Style * CreateCoverageStyle(const std::vector< te::rst::BandProperty * > &properties)
Try creates an appropriate coverage style based on given band properties.
double m_urx
Upper right corner x-coordinate.
virtual double getScale() const
Calculates and return the current scale.
bool execute(AlgorithmOutputParameters &outputParams) _NOEXCEPT_OP(false)
Executes the algorithm using the supplied parameters.
#define TE_OPAQUE
For an RGBA color this is the value of the alpha-channel for totally opaque.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
SelectedChannel * getRedChannel() const
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: rp/Filter.h:113
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
A widget to control the display of a set of layers.
boost::numeric::ublas::matrix< double > m_window
User defined convolution window.
SelectedChannel * getBlueChannel() const
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
void draw(const te::gm::Geometry *geom)
It draws the geometry on canvas.
void drawPreview(te::rst::Raster *raster)
unsigned int m_windowH
The height of the convolution window. (commonly 3, with W=3 to make a 3x3 window, and so on) ...
Definition: rp/Filter.h:81
std::string getSourceChannelName() const
std::vector< unsigned int > m_inRasterBands
Bands to be used from the input raster 1.
Definition: rp/Filter.h:77
void setParams()
This method is used to set the selected layer for filter operation.
void onPreviewCheckBoxToggled(bool isChecked)
Rule * getRule(std::size_t i) const
Definition: Style.cpp:105
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
Definition: rp/Filter.h:115
int b
Definition: TsRtree.cpp:32
The resultant pixel will be the median of pixels in the convolution window.
Definition: rp/Filter.h:67
TEMAPEXPORT void DrawRaster(te::da::DataSetType *type, te::da::DataSourcePtr ds, Canvas *canvas, const te::gm::Envelope &bbox, int bboxSRID, const te::gm::Envelope &visibleArea, int srid, te::se::CoverageStyle *style, te::map::RasterContrast *rc, const double &scale, bool *cancel)
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state...
double m_llx
Lower left corner x-coordinate.
unsigned int m_iterationsNumber
The number of iterations to perform (default:1).
Definition: rp/Filter.h:79
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
An Envelope defines a 2D rectangular region.
The resultant pixel will be the highest pixel value in the convolution window.
Definition: rp/Filter.h:68
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.
virtual int getSRID() const
It return the Spatial Reference System used by the Map Display.
te::qt::widgets::InputLayerWidget * m_inputWidget
std::unique_ptr< Ui::FilterDialogForm > m_ui
virtual int getBandDataType(std::size_t i) const =0
Returns the data type in a particular band (or dimension).
void setPolygonContourWidth(int w)
It sets the polygon contour width.
list bands
Definition: compose.py:2
This class is used to set output layer.
ColorCompositionType getColorCompositionType() const
This class is used to set input layer.
virtual const te::gm::Envelope & getExtent() const
It returns the world extent showned by the MapDisplay.
This file defines a class for a MaskDialog.
The RasterSymbolizer describes how to render raster/matrix-coverage data (e.g., satellite photos...
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
This file has the FilterDialogForm class.
void setMapDisplay(te::qt::widgets::MapDisplay *mapDisplay)
Utility functions for the data access module.
A series of well-known filtering algorithms for images, linear and non-linear..
Definition: rp/Filter.h:47
te::map::AbstractLayerPtr getInputLayer()
void setMaskSize(int height, int width, double defaultValue)
Definition: MaskDialog.cpp:52
const std::vector< Symbolizer * > & getSymbolizers() const
Definition: Rule.cpp:158
double m_lly
Lower left corner y-coordinate.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
te::se::ChannelSelection * getChannelSelection()
Filter input parameters.
Definition: rp/Filter.h:55
void setList(std::list< te::map::AbstractLayerPtr > &layerList, te::map::AbstractLayerPtr selectedlayer)
TEMAPEXPORT te::rst::Raster * GetRaster(AbstractLayer *layer)
It gets the raster referenced by the given data set layer.
std::map< std::string, std::string > getInfo() const
te::map::AbstractLayerPtr m_outputLayer
int getSRID() const
Returns the raster spatial reference system identifier.
SelectedChannel * getGreenChannel() const
boost::numeric::ublas::matrix< double > getMatrix()
Definition: MaskDialog.cpp:110
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
Definition: Rule.h:76
TEQTWIDGETSEXPORT te::map::AbstractLayerPtr createLayer(const std::string &driverName, const te::core::URI &connInfo)
virtual QPixmap * getDraftPixmap() const
It returns the map display draft pixmap.
double m_ury
Upper right corner y-coordinate.
unsigned int m_windowW
The width of the convolution window.
Definition: rp/Filter.h:83
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
FilterType m_filterType
The edge filter type.
Definition: rp/Filter.h:73
This class is used to navigate over a DataSetLayer (having a raster representation) and given a set o...
Definition: RpToolsWidget.h:70
te::qt::widgets::MapDisplay * m_mapDisplay
void setLayerList(std::list< te::map::AbstractLayerPtr > list)
te::rp::Filter::InputParameters getInputParams()
te::rst::Raster const * m_inRasterPtr
Input raster.
Definition: rp/Filter.h:75
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
Definition: StringUtils.h:56
bool initialize(const AlgorithmInputParameters &inputParams) _NOEXCEPT_OP(false)
Initialize the algorithm instance making it ready for execution.
Filter output parameters.
Definition: rp/Filter.h:109
void addLayer(te::map::AbstractLayerPtr layer)
SelectedChannel * getGrayChannel() const
boost::numeric::ublas::matrix< double > m_window
User defined convolution window. (The size must be equal to m_windowH x m_windowW. Default: an empty matrix)
Definition: rp/Filter.h:87
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
bool isValid() const
It tells if the rectangle is valid or not.
TEQTWIDGETSEXPORT void applyRasterMultiResolution(const QString &toolName, te::rst::Raster *raster)
The user will define the weights of a convolution window.
Definition: rp/Filter.h:70
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the ge generated output raster (label image).
Definition: rp/Filter.h:117
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
ChannelSelection specifies the false-color channel selection for a multi-spectral raster source (such...