All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MosaicWizardPage.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/MosaicWizardPage.cpp
22 
23  \brief This file defines a class for a Mosaic Wizard page.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../dataaccess/utils/Utils.h"
29 #include "../../../geometry/GTFactory.h"
30 #include "../../../raster/Interpolator.h"
31 #include "../../../rp/Blender.h"
32 #include "TiePointLocatorDialog.h"
33 #include "TiePointLocatorWidget.h"
34 #include "MosaicWizardPage.h"
36 #include "ui_MosaicWizardPageForm.h"
37 
38 // Qt
39 #include <QApplication>
40 #include <QGridLayout>
41 #include <QMessageBox>
42 
43 // stl
44 #include <memory>
45 
47 
49  : QWizardPage(parent),
50  m_ui(new Ui::MosaicWizardPageForm)
51 {
52 // setup controls
53  m_ui->setupUi(this);
54 
56 
57 //configure page
58  this->setTitle(tr("Mosaic"));
59  this->setSubTitle(tr("Select the type of mosaic and set their specific parameters."));
60 
61  m_ui->m_noDataValueLineEdit->setValidator(new QDoubleValidator(this));
62 
63  m_ui->m_tpmAcquireToolButton->setIcon(QIcon::fromTheme("wand"));
64 
65  //add tie point locator parameters widget
66  QGridLayout* layout = new QGridLayout(m_ui->m_tplpWidget);
69  layout->setContentsMargins(0, 0, 0, 0);
70  layout->addWidget(m_tiePointParameters);
71 
72  //connects
73  connect(m_ui->m_tpmAcquireToolButton, SIGNAL(clicked()), this, SLOT(onTiePointsAcquiredToolButtonClicked()));
74 }
75 
77 {
78  m_tiePoints.clear();
79 }
80 
82 {
83  return true;
84 }
85 
87 {
88  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
89 
90  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
91 
92  return (type == MOSAIC_GEO);
93 }
94 
96 {
97  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
98 
99  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
100 
101  return (type == MOSAIC_TIEPOINT);
102 }
103 
105 {
106  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
107 
108  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
109 
110  return (type == MOSAIC_SEQUENCE);
111 }
112 
113 void te::qt::widgets::MosaicWizardPage::setList(std::list<te::map::AbstractLayerPtr>& layerList)
114 {
115  m_layerList = layerList;
116 
117  //fill layer combos
118  m_ui->m_tpmLayerAComboBox->clear();
119  m_ui->m_tpmLayerBComboBox->clear();
120 
121  std::list<te::map::AbstractLayerPtr>::iterator it = m_layerList.begin();
122  std::vector<std::size_t> bands;
123 
124  while(it != m_layerList.end())
125  {
127 
128  std::auto_ptr<te::da::DataSet> ds = l->getData();
129  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
130  std::auto_ptr<te::rst::Raster> rst = ds->getRaster(rpos);
131 
132  if(rst.get())
133  bands.push_back(rst->getNumberOfBands());
134 
135  m_ui->m_tpmLayerAComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
136  m_ui->m_tpmLayerBComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
137 
138  ++it;
139  }
140 
141  //fill band info
142  std::vector<std::size_t>::iterator itBand = std::min_element(bands.begin(), bands.end());
143 
144  for(std::size_t t = 0; t < *itBand; ++t)
145  {
146  m_ui->m_smRefBandComboBox->addItem(QString::number(t));
147  }
148 }
149 
151 {
152  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
153  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
154 
155  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
156  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
157 
158  te::rp::GeoMosaic::InputParameters algoInputParams;
159 
160  algoInputParams.m_interpMethod = interpolator;
161  algoInputParams.m_blendMethod = blender;
162  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
163  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
164  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
165  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
166 
167  return algoInputParams;
168 }
169 
171 {
172  te::rp::GeoMosaic::OutputParameters algoOutputParams;
173 
174  return algoOutputParams;
175 }
176 
178 {
180 
181  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
182  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
183 
184  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
185  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
186 
187  int linkerIdx = m_ui->m_tpmLinkTypeComboBox->currentIndex();
188  te::rp::TiePointsMosaic::InputParameters::TiePointsLinkType tpLinkType = (te::rp::TiePointsMosaic::InputParameters::TiePointsLinkType)m_ui->m_tpmLinkTypeComboBox->itemData(linkerIdx).toInt();
189 
190  algoInputParams.m_interpMethod = interpolator;
191  algoInputParams.m_blendMethod = blender;
192  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
193  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
194  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
195  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
196 
197  algoInputParams.m_geomTransfName = m_ui->m_smGeomTransformComboBox->currentText().toStdString();
198  algoInputParams.m_tiePointsLinkType = tpLinkType;
199  algoInputParams.m_tiePoints = m_tiePoints;
200 
201 
202  return algoInputParams;
203 }
204 
206 {
208 
209  return algoOutputParams;
210 }
211 
213 {
215 
216  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
217  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
218 
219  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
220  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
221 
222  algoInputParams.m_interpMethod = interpolator;
223  algoInputParams.m_blendMethod = blender;
224  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
225  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
226  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
227  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
228 
229  algoInputParams.m_geomTransfName = m_ui->m_smGeomTransformComboBox->currentText().toStdString();
230  algoInputParams.m_tiePointsLocationBandIndex = m_ui->m_smRefBandComboBox->currentText().toInt();
231  algoInputParams.m_minRequiredTiePointsCoveredAreaPercent = m_ui->m_smMinTiePointsSpinBox->value();
232 
233  algoInputParams.m_enableMultiThread = true;
234  algoInputParams.m_enableProgress = true;
235 
236  algoInputParams.m_locatorParams = m_tiePointParameters->getTiePointInputParameters();
237 
238  return algoInputParams;
239 }
240 
242 {
244 
245  return algoOutputParams;
246 }
247 
249 {
250  int aIdx = m_ui->m_tpmLayerAComboBox->currentIndex();
251  QVariant aVarLayer = m_ui->m_tpmLayerAComboBox->itemData(aIdx, Qt::UserRole);
252  te::map::AbstractLayerPtr aLayer = aVarLayer.value<te::map::AbstractLayerPtr>();
253 
254  return aLayer;
255 }
256 
258 {
259  int bIdx = m_ui->m_tpmLayerBComboBox->currentIndex();
260  QVariant bVarLayer = m_ui->m_tpmLayerBComboBox->itemData(bIdx, Qt::UserRole);
261  te::map::AbstractLayerPtr bLayer = bVarLayer.value<te::map::AbstractLayerPtr>();
262 
263  return bLayer;
264 }
265 
267 {
268  int aIdx = m_ui->m_tpmLayerAComboBox->currentIndex();
269  QVariant aVarLayer = m_ui->m_tpmLayerAComboBox->itemData(aIdx, Qt::UserRole);
270  te::map::AbstractLayerPtr aLayer = aVarLayer.value<te::map::AbstractLayerPtr>();
271 
272  int bIdx = m_ui->m_tpmLayerBComboBox->currentIndex();
273  QVariant bVarLayer = m_ui->m_tpmLayerBComboBox->itemData(bIdx, Qt::UserRole);
274  te::map::AbstractLayerPtr bLayer = bVarLayer.value<te::map::AbstractLayerPtr>();
275 
277 
278  dlg.setReferenceLayer(aLayer);
279  dlg.setAdjustLayer(bLayer);
280 
281  dlg.exec();
282 
283  std::vector<te::gm::GTParameters::TiePoint> tiePoints;
284 
285  dlg.getWidget()->getTiePointsIdxCoords(tiePoints);
286 
287  m_tiePoints.clear();
288  m_tiePoints.push_back(tiePoints);
289 }
290 
291 
293 {
294  //mosaic types
295  m_ui->m_mosaicTypeComboBox->clear();
296 
297  m_ui->m_mosaicTypeComboBox->addItem(tr("Geo Mosaic"), MOSAIC_GEO);
298  m_ui->m_mosaicTypeComboBox->addItem(tr("Tie Points Mosaic"), MOSAIC_TIEPOINT);
299  m_ui->m_mosaicTypeComboBox->addItem(tr("Sequence Mosaic"), MOSAIC_SEQUENCE);
300 
301  //interpolator types
302  m_ui->m_interpolatorTypeComboBox->clear();
303 
304  m_ui->m_interpolatorTypeComboBox->addItem(tr("Nearest Neighbor"), te::rst::NearestNeighbor);
305  m_ui->m_interpolatorTypeComboBox->addItem(tr("Bilinear"), te::rst::Bilinear);
306  m_ui->m_interpolatorTypeComboBox->addItem(tr("Bicubic"), te::rst::Bicubic);
307 
308  //blender types
309  m_ui->m_blenderTypeComboBox->clear();
310 
311  m_ui->m_blenderTypeComboBox->addItem(tr("No blending performed"), te::rp::Blender::NoBlendMethod);
312  m_ui->m_blenderTypeComboBox->addItem(tr("Euclidean distance method"), te::rp::Blender::EuclideanDistanceMethod);
313  m_ui->m_blenderTypeComboBox->addItem(tr("Sum method"), te::rp::Blender::SumMethod);
314  //m_ui->m_blenderTypeComboBox->addItem(tr("Invalid blending method"), te::rp::Blender::InvalidBlendMethod);
315 
316  //tie points link types
317  m_ui->m_tpmLinkTypeComboBox->clear();
318 
319  m_ui->m_tpmLinkTypeComboBox->addItem(tr("Linking adjacent raster pairs"), te::rp::TiePointsMosaic::InputParameters::AdjacentRastersLinkingTiePointsT);
320  m_ui->m_tpmLinkTypeComboBox->addItem(tr("Linking any raster to the first raster"), te::rp::TiePointsMosaic::InputParameters::FirstRasterLinkingTiePointsT);
321  //m_ui->m_tpmLinkTypeComboBox->addItem(tr("Invalid linking type"), te::rp::TiePointsMosaic::InputParameters::InvalidTiePointsT);
322 
323  m_ui->m_tpmLinkTypeComboBox->setEnabled(false);
324 
325  //geometric transformations
326  m_ui->m_tpmGeomTransformComboBox->clear();
327  m_ui->m_smGeomTransformComboBox->clear();
328 
331 
332  while( gtItB != gtItE )
333  {
334  m_ui->m_tpmGeomTransformComboBox->addItem(QString(gtItB->first.c_str()));
335  m_ui->m_smGeomTransformComboBox->addItem(QString(gtItB->first.c_str()));
336  ++gtItB;
337  }
338 }
339 
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
Near neighborhood interpolation method.
Definition: Enums.h:95
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
std::auto_ptr< Ui::MosaicWizardPageForm > m_ui
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: GeoMosaic.h:64
This file has the TiePointLocatorWidget class.
GeoMosaic input parameters.
Definition: GeoMosaic.h:56
Tie-points linking any raster to the first sequence raster (te::gm::GTParameters::TiePoint::first are...
te::rp::TiePointsLocator::InputParameters m_locatorParams
The parameters used by the tie-points locator when processing each rasters pair (leave untouched to u...
bool m_enableProgress
Enable/Disable the progress interface (default:false).
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
te::rp::TiePointsMosaic::InputParameters getInputTPParams()
te::map::AbstractLayerPtr getTiePointMosaicLayerA()
static dictionary_type & getDictionary()
It returns a reference to the internal dictionary of concrete factories.
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
This file has the TiePointLocatorParametersWidget class.
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
InterpolationMethod Method
Allowed interpolation methods.
Definition: Interpolator.h:62
No blending performed.
Definition: Blender.h:66
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
te::qt::widgets::TiePointLocatorParametersWidget * m_tiePointParameters
Tie Point parameters widget.
std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints
Tie-points between each adjacent raster pair (te::gm::GTParameters::TiePoint::first are raster (with ...
TiePointsLinkType m_tiePointsLinkType
The given tie points linking type, see TiePointsLinkType.
Tie-points linking adjacent raster pairs (te::gm::GTParameters::TiePoint::first are raster (with inde...
Pixels will be summed inside the raster overlapped area.
Definition: Blender.h:68
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
te::rp::GeoMosaic::OutputParameters getOutputGeoParams()
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
Definition: GeoMosaic.h:70
double m_minRequiredTiePointsCoveredAreaPercent
The mininumum required tie-points covered area percent of each raster area - valid range [0...
te::rp::SequenceMosaic::OutputParameters getOutputSeqParams()
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator end() const
It returns an iterator to the end of the container.
This file defines a class for a Mosaic Wizard page.
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Bicubic interpolation method.
Definition: Enums.h:97
void setList(std::list< te::map::AbstractLayerPtr > &layerList)
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
te::map::AbstractLayerPtr getTiePointMosaicLayerB()
This class is used to define a widget for tie point parameters acquirement.
te::rp::GeoMosaic::InputParameters getInputGeoParams()
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator begin() const
It returns an iterator to the first stored factory.
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
GeoMosaic output parameters.
Definition: GeoMosaic.h:100
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
Definition: GeoMosaic.h:72
Euclidean distance method.
Definition: Blender.h:67
Bilinear interpolation method.
Definition: Enums.h:96
te::rp::TiePointsMosaic::OutputParameters getOutputTPParams()
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Definition: GeoMosaic.h:68
te::rp::SequenceMosaic::InputParameters getInputSeqParams()
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:481
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition: GeoMosaic.h:66
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Definition: GeoMosaic.h:74
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
unsigned int m_tiePointsLocationBandIndex
The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defa...