All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FusionWizardPage.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/FusionWizardPage.cpp
22 
23  \brief This file defines a class for a Fusion Wizard page.
24 */
25 
26 // TerraLib
27 #include "../../../dataaccess/dataset/DataSet.h"
28 #include "../../../dataaccess/utils/Utils.h"
29 #include "../../../raster/Interpolator.h"
30 #include "../../../raster/Raster.h"
31 #include "FusionWizardPage.h"
32 #include "ui_FusionWizardPageForm.h"
33 
34 // Qt
35 #include <QApplication>
36 #include <QGridLayout>
37 #include <QMessageBox>
38 
39 // stl
40 #include <memory>
41 
43 
45  : QWizardPage(parent),
46  m_ui(new Ui::FusionWizardPageForm),
47  m_layerLower(0),
48  m_layerHigher(0)
49 {
50 // setup controls
51  m_ui->setupUi(this);
52 
54 
55 //configure page
56  this->setTitle(tr("Fusion"));
57  this->setSubTitle(tr("Select the type of fusion and set their specific parameters."));
58 }
59 
61 {
62 
63 }
64 
66 {
67  return true;
68 }
69 
71 {
72  m_layerLower = layer;
73 
74  m_ui->m_ihsLowerLineEdit->setText(m_layerLower->getTitle().c_str());
75  m_ui->m_pcaLowerLineEdit->setText(m_layerLower->getTitle().c_str());
76 
77  listBandsLower();
78 }
79 
81 {
82  m_layerHigher = layer;
83 
84  m_ui->m_higherLineEdit->setText(m_layerHigher->getTitle().c_str());
85 
86  listBandsHigher();
87 }
88 
90 {
91  int idx = m_ui->m_fusionTypeComboBox->currentIndex();
92 
93  int type = m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
94 
95  if(type == FUSION_IHS)
96  return true;
97 
98  return false;
99 }
100 
102 {
103  int idx = m_ui->m_fusionTypeComboBox->currentIndex();
104 
105  int type = m_ui->m_fusionTypeComboBox->itemData(idx).toInt();
106 
107  if(type == FUSION_PCA)
108  return true;
109 
110  return false;
111 }
112 
114 {
115  return m_ui->m_cropCheckBox->isChecked();
116 }
117 
119 {
120  int interpolationIdx = m_ui->m_interpolatorComboBox->currentIndex();
121  te::rst::Interpolator::Method method = (te::rst::Interpolator::Method)m_ui->m_interpolatorComboBox->itemData(interpolationIdx).toInt();
122 
123  te::rp::IHSFusion::InputParameters algoInputParams;
124 
125  algoInputParams.m_enableProgress = true;
126  algoInputParams.m_interpMethod = method;
127 
128  algoInputParams.m_lowResRasterRedBandIndex = m_ui->m_ihsRComboBox->currentText().toInt();
129  algoInputParams.m_lowResRasterGreenBandIndex = m_ui->m_ihsGComboBox->currentText().toInt();
130  algoInputParams.m_lowResRasterBlueBandIndex = m_ui->m_ihsBComboBox->currentText().toInt();
131 
132  algoInputParams.m_highResRasterBand = m_ui->m_bandComboBox->currentText().toInt();
133 
134  return algoInputParams;
135 }
136 
138 {
139  te::rp::IHSFusion::OutputParameters algoOutputParams;
140 
141  return algoOutputParams;
142 }
143 
145 {
146  int interpolationIdx = m_ui->m_interpolatorComboBox->currentIndex();
147  te::rst::Interpolator::Method method = (te::rst::Interpolator::Method)m_ui->m_interpolatorComboBox->itemData(interpolationIdx).toInt();
148 
149  te::rp::PCAFusion::InputParameters algoInputParams;
150 
151  algoInputParams.m_enableProgress = true;
152  algoInputParams.m_interpMethod = method;
153 
154  int nBands = m_ui->m_listWidget->count();
155  for(int i = 0; i < nBands; ++i)
156  {
157  if(m_ui->m_listWidget->item(i)->isSelected())
158  algoInputParams.m_lowResRasterBands.push_back(i);
159  }
160 
161  algoInputParams.m_highResRasterBand = m_ui->m_bandComboBox->currentText().toInt();
162 
163  return algoInputParams;
164 }
165 
167 {
168  te::rp::PCAFusion::OutputParameters algoOutputParams;
169 
170  return algoOutputParams;
171 }
172 
174 {
175  m_ui->m_fusionTypeComboBox->clear();
176 
177  m_ui->m_fusionTypeComboBox->addItem(tr("IHS"), FUSION_IHS);
178  m_ui->m_fusionTypeComboBox->addItem(tr("PCA"), FUSION_PCA);
179 
180  m_ui->m_interpolatorComboBox->clear();
181 
182  m_ui->m_interpolatorComboBox->addItem(tr("Nearest Neighbor"), te::rst::Interpolator::NearestNeighbor);
183  m_ui->m_interpolatorComboBox->addItem(tr("Bilinear"), te::rst::Interpolator::Bilinear);
184  m_ui->m_interpolatorComboBox->addItem(tr("Bicubic"), te::rst::Interpolator::Bicubic);
185 }
186 
188 {
189  m_ui->m_ihsRComboBox->clear();
190  m_ui->m_ihsGComboBox->clear();
191  m_ui->m_ihsBComboBox->clear();
192  m_ui->m_listWidget->clear();
193 
194  assert(m_layerLower.get());
195 
196  //get input raster
197  std::auto_ptr<te::da::DataSet> ds = m_layerLower->getData();
198 
199  if(ds.get())
200  {
201  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
202 
203  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
204 
205  if(inputRst.get())
206  {
207  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
208  {
209  m_ui->m_ihsRComboBox->addItem(QString::number(i));
210  m_ui->m_ihsGComboBox->addItem(QString::number(i));
211  m_ui->m_ihsBComboBox->addItem(QString::number(i));
212  m_ui->m_listWidget->addItem(QString::number(i));
213  }
214  }
215  }
216 }
217 
219 {
220  m_ui->m_bandComboBox->clear();
221 
222  assert(m_layerHigher.get());
223 
224  //get input raster
225  std::auto_ptr<te::da::DataSet> ds = m_layerHigher->getData();
226 
227  if(ds.get())
228  {
229  std::size_t rpos = te::da::GetFirstPropertyPos(ds.get(), te::dt::RASTER_TYPE);
230 
231  std::auto_ptr<te::rst::Raster> inputRst = ds->getRaster(rpos);
232 
233  if(inputRst.get())
234  {
235  for(unsigned int i = 0; i < inputRst->getNumberOfBands(); ++i)
236  {
237  m_ui->m_bandComboBox->addItem(QString::number(i));
238  }
239  }
240  }
241 }
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: PCAFusion.h:70
te::rp::IHSFusion::InputParameters getInputIHSParams()
IHSFusion output parameters.
Definition: IHSFusion.h:108
IHSFusion input parameters.
Definition: IHSFusion.h:64
PCAFusion output parameters.
Definition: PCAFusion.h:96
unsigned int m_lowResRasterRedBandIndex
The low-resolution raster red band index (default:0).
Definition: IHSFusion.h:70
te::rp::PCAFusion::OutputParameters getOutputPCAParams()
void setLower(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation.
Q_DECLARE_METATYPE(te::map::AbstractLayerPtr)
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: PCAFusion.h:74
Bicubic interpolation method.
Definition: Interpolator.h:65
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: IHSFusion.h:78
This file defines a class for a Fusion Wizard page.
std::auto_ptr< Ui::FusionWizardPageForm > m_ui
unsigned int m_lowResRasterBlueBandIndex
The low-resolution raster blue band index (default:2).
Definition: IHSFusion.h:74
te::rp::IHSFusion::OutputParameters getOutputIHSParams()
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: IHSFusion.h:80
Method
Allowed interpolation methods.
Definition: Interpolator.h:61
std::vector< unsigned int > m_lowResRasterBands
The low-resolution raster band indexes.
Definition: PCAFusion.h:64
void setHigher(te::map::AbstractLayerPtr layer)
This method is used to set the selected layer for classifier operation.
PCAFusion input parameters.
Definition: PCAFusion.h:58
Bilinear interpolation method.
Definition: Interpolator.h:64
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
Definition: Utils.cpp:432
Near neighborhood interpolation method.
Definition: Interpolator.h:63
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: IHSFusion.h:82
unsigned int m_lowResRasterGreenBandIndex
The low-resolution raster green band index (default:1).
Definition: IHSFusion.h:72
unsigned int m_highResRasterBand
Band to process from the high-resolution raster.
Definition: PCAFusion.h:68
te::rp::PCAFusion::InputParameters getInputPCAParams()