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) 2011-2012 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"
35 #include "ui_MosaicWizardPageForm.h"
36 
37 // Qt
38 #include <QApplication>
39 #include <QGridLayout>
40 #include <QMessageBox>
41 
42 // stl
43 #include <memory>
44 
46 
48  : QWizardPage(parent),
49  m_ui(new Ui::MosaicWizardPageForm)
50 {
51 // setup controls
52  m_ui->setupUi(this);
53 
55 
56 //configure page
57  this->setTitle(tr("Mosaic"));
58  this->setSubTitle(tr("Select the type of mosaic and set their specific parameters."));
59 
60  m_ui->m_noDataValueLineEdit->setValidator(new QDoubleValidator(this));
61 
62  m_ui->m_tpmAcquireToolButton->setIcon(QIcon::fromTheme("wand"));
63 
64  //connects
65  connect(m_ui->m_tpmAcquireToolButton, SIGNAL(clicked()), this, SLOT(onTiePointsAcquiredToolButtonClicked()));
66 }
67 
69 {
70  m_tiePoints.clear();
71 }
72 
74 {
75  return true;
76 }
77 
79 {
80  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
81 
82  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
83 
84  return (type == MOSAIC_GEO);
85 }
86 
88 {
89  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
90 
91  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
92 
93  return (type == MOSAIC_TIEPOINT);
94 }
95 
97 {
98  int idx = m_ui->m_mosaicTypeComboBox->currentIndex();
99 
100  int type = m_ui->m_mosaicTypeComboBox->itemData(idx).toInt();
101 
102  return (type == MOSAIC_SEQUENCE);
103 }
104 
105 void te::qt::widgets::MosaicWizardPage::setList(std::list<te::map::AbstractLayerPtr>& layerList)
106 {
107  m_layerList = layerList;
108 
109  //fill layer combos
110  m_ui->m_tpmLayerAComboBox->clear();
111  m_ui->m_tpmLayerBComboBox->clear();
112 
113  std::list<te::map::AbstractLayerPtr>::iterator it = m_layerList.begin();
114  std::vector<std::size_t> bands;
115 
116  while(it != m_layerList.end())
117  {
119 
120  std::auto_ptr<te::da::DataSet> ds = l->getData();
121  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
122  std::auto_ptr<te::rst::Raster> rst = ds->getRaster(rpos);
123 
124  if(rst.get())
125  bands.push_back(rst->getNumberOfBands());
126 
127  m_ui->m_tpmLayerAComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
128  m_ui->m_tpmLayerBComboBox->addItem(l->getTitle().c_str(), QVariant::fromValue(l));
129 
130  ++it;
131  }
132 
133  //fill band info
134  std::vector<std::size_t>::iterator itBand = std::min_element(bands.begin(), bands.end());
135 
136  for(std::size_t t = 0; t < *itBand; ++t)
137  {
138  m_ui->m_smRefBandComboBox->addItem(QString::number(t));
139  }
140 }
141 
143 {
144  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
145  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
146 
147  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
148  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
149 
150  te::rp::GeoMosaic::InputParameters algoInputParams;
151 
152  algoInputParams.m_interpMethod = interpolator;
153  algoInputParams.m_blendMethod = blender;
154  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
155  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
156  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
157  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
158 
159  return algoInputParams;
160 }
161 
163 {
164  te::rp::GeoMosaic::OutputParameters algoOutputParams;
165 
166  return algoOutputParams;
167 }
168 
170 {
172 
173  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
174  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
175 
176  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
177  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
178 
179  int linkerIdx = m_ui->m_tpmLinkTypeComboBox->currentIndex();
180  te::rp::TiePointsMosaic::InputParameters::TiePointsLinkType tpLinkType = (te::rp::TiePointsMosaic::InputParameters::TiePointsLinkType)m_ui->m_tpmLinkTypeComboBox->itemData(linkerIdx).toInt();
181 
182  algoInputParams.m_interpMethod = interpolator;
183  algoInputParams.m_blendMethod = blender;
184  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
185  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
186  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
187  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
188 
189  algoInputParams.m_geomTransfName = m_ui->m_smGeomTransformComboBox->currentText().toStdString();
190  algoInputParams.m_tiePointsLinkType = tpLinkType;
191  algoInputParams.m_tiePoints = m_tiePoints;
192 
193 
194  return algoInputParams;
195 }
196 
198 {
200 
201  return algoOutputParams;
202 }
203 
205 {
207 
208  int interpolationIdx = m_ui->m_interpolatorTypeComboBox->currentIndex();
209  te::rst::Interpolator::Method interpolator = (te::rst::Interpolator::Method)m_ui->m_interpolatorTypeComboBox->itemData(interpolationIdx).toInt();
210 
211  int blenderIdx = m_ui->m_blenderTypeComboBox->currentIndex();
212  te::rp::Blender::BlendMethod blender = (te::rp::Blender::BlendMethod)m_ui->m_blenderTypeComboBox->itemData(blenderIdx).toInt();
213 
214  algoInputParams.m_interpMethod = interpolator;
215  algoInputParams.m_blendMethod = blender;
216  algoInputParams.m_noDataValue = m_ui->m_noDataValueLineEdit->text().isEmpty() ? 0 : m_ui->m_noDataValueLineEdit->text().toDouble();
217  algoInputParams.m_forceInputNoDataValue = m_ui->m_noDataValueCheckBox->isChecked();
218  algoInputParams.m_autoEqualize = m_ui->m_autoEqualizeCheckBox->isChecked();
219  algoInputParams.m_useRasterCache = m_ui->m_rasterCacheCheckBox->isChecked();
220 
221  algoInputParams.m_geomTransfName = m_ui->m_smGeomTransformComboBox->currentText().toStdString();
222  algoInputParams.m_tiePointsLocationBandIndex = m_ui->m_smRefBandComboBox->currentText().toInt();
223  algoInputParams.m_minRequiredTiePointsCoveredAreaPercent = m_ui->m_smMinTiePointsSpinBox->value();
224 
225  algoInputParams.m_enableMultiThread = true;
226  algoInputParams.m_enableProgress = true;
227 
228  // The parameters used by the tie-points locator when processing each rasters pair was leaved untouched to use the default.
229 
230  return algoInputParams;
231 }
232 
234 {
236 
237  return algoOutputParams;
238 }
239 
241 {
242  int aIdx = m_ui->m_tpmLayerAComboBox->currentIndex();
243  QVariant aVarLayer = m_ui->m_tpmLayerAComboBox->itemData(aIdx, Qt::UserRole);
244  te::map::AbstractLayerPtr aLayer = aVarLayer.value<te::map::AbstractLayerPtr>();
245 
246  return aLayer;
247 }
248 
250 {
251  int bIdx = m_ui->m_tpmLayerBComboBox->currentIndex();
252  QVariant bVarLayer = m_ui->m_tpmLayerBComboBox->itemData(bIdx, Qt::UserRole);
253  te::map::AbstractLayerPtr bLayer = bVarLayer.value<te::map::AbstractLayerPtr>();
254 
255  return bLayer;
256 }
257 
259 {
260  int aIdx = m_ui->m_tpmLayerAComboBox->currentIndex();
261  QVariant aVarLayer = m_ui->m_tpmLayerAComboBox->itemData(aIdx, Qt::UserRole);
262  te::map::AbstractLayerPtr aLayer = aVarLayer.value<te::map::AbstractLayerPtr>();
263 
264  int bIdx = m_ui->m_tpmLayerBComboBox->currentIndex();
265  QVariant bVarLayer = m_ui->m_tpmLayerBComboBox->itemData(bIdx, Qt::UserRole);
266  te::map::AbstractLayerPtr bLayer = bVarLayer.value<te::map::AbstractLayerPtr>();
267 
269 
270  dlg.setReferenceLayer(aLayer);
271  dlg.setAdjustLayer(bLayer);
272 
273  dlg.exec();
274 
275  std::vector<te::gm::GTParameters::TiePoint> tiePoints;
276 
277  dlg.getWidget()->getTiePointsIdxCoords(tiePoints);
278 
279  m_tiePoints.clear();
280  m_tiePoints.push_back(tiePoints);
281 }
282 
283 
285 {
286  //mosaic types
287  m_ui->m_mosaicTypeComboBox->clear();
288 
289  m_ui->m_mosaicTypeComboBox->addItem(tr("Geo Mosaic"), MOSAIC_GEO);
290  m_ui->m_mosaicTypeComboBox->addItem(tr("Tie Points Mosaic"), MOSAIC_TIEPOINT);
291  m_ui->m_mosaicTypeComboBox->addItem(tr("Sequence Mosaic"), MOSAIC_SEQUENCE);
292 
293  //interpolator types
294  m_ui->m_interpolatorTypeComboBox->clear();
295 
296  m_ui->m_interpolatorTypeComboBox->addItem(tr("Nearest Neighbor"), te::rst::Interpolator::NearestNeighbor);
297  m_ui->m_interpolatorTypeComboBox->addItem(tr("Bilinear"), te::rst::Interpolator::Bilinear);
298  m_ui->m_interpolatorTypeComboBox->addItem(tr("Bicubic"), te::rst::Interpolator::Bicubic);
299 
300  //blender types
301  m_ui->m_blenderTypeComboBox->clear();
302 
303  m_ui->m_blenderTypeComboBox->addItem(tr("No blending performed"), te::rp::Blender::NoBlendMethod);
304  m_ui->m_blenderTypeComboBox->addItem(tr("Euclidean distance method"), te::rp::Blender::EuclideanDistanceMethod);
305  m_ui->m_blenderTypeComboBox->addItem(tr("Invalid blending method"), te::rp::Blender::InvalidBlendMethod);
306 
307  //tie points link types
308  m_ui->m_tpmLinkTypeComboBox->clear();
309 
310  m_ui->m_tpmLinkTypeComboBox->addItem(tr("Linking adjacent raster pairs"), te::rp::TiePointsMosaic::InputParameters::AdjacentRastersLinkingTiePointsT);
311  m_ui->m_tpmLinkTypeComboBox->addItem(tr("Linking any raster to the first raster"), te::rp::TiePointsMosaic::InputParameters::FirstRasterLinkingTiePointsT);
312  m_ui->m_tpmLinkTypeComboBox->addItem(tr("Invalid linking type"), te::rp::TiePointsMosaic::InputParameters::InvalidTiePointsT);
313 
314  m_ui->m_tpmLinkTypeComboBox->setEnabled(false);
315 
316  //geometric transformations
317  m_ui->m_tpmGeomTransformComboBox->clear();
318  m_ui->m_smGeomTransformComboBox->clear();
319 
322 
323  while( gtItB != gtItE )
324  {
325  m_ui->m_tpmGeomTransformComboBox->addItem(QString(gtItB->first.c_str()));
326  m_ui->m_smGeomTransformComboBox->addItem(QString(gtItB->first.c_str()));
327  ++gtItB;
328  }
329 }
330 
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).
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...
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).
No blending performed.
Definition: Blender.h:64
Bicubic interpolation method.
Definition: Interpolator.h:65
std::map< TFACTORYKEY, TFACTORY *, TKEYCOMPARE >::const_iterator const_iterator
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...
Invalid blending method.
Definition: Blender.h:63
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).
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()
Method
Allowed interpolation methods.
Definition: Interpolator.h:61
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
Bilinear interpolation method.
Definition: Interpolator.h:64
Euclidean distance method.
Definition: Blender.h:65
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:432
Near neighborhood interpolation method.
Definition: Interpolator.h:63
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...