MixtureModelWizardPage.h
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/MixtureModelWizardPage.h
22 
23  \brief This file defines a class for a MixtureModel Wizard page.
24 
25  /brief JSON File Structure used to save the mix model components information
26 
27  {
28  "Band_Sensors":{
29  [
30  "Band": {
31  "band": "****",
32  "use": "****",
33  "sensor": "****"
34  },
35  .
36  .
37  .
38  "Band": {
39  "band": "****",
40  "use": "****",
41  "sensor": "****"
42  },
43  ]
44  },
45 
46  "MixModel_Components":{
47  [
48  "Component": {
49  "name": "****",
50  "coordGrid": {
51  "xGrid": "****",
52  "yGrid": "****"
53  },
54  "coordGeo": {
55  "xGeo": "****",
56  "yGeo": "****"
57  },
58  "Color": "****"
59  },
60  .
61  .
62  .
63  "Component": {
64  "name": "****",
65  "coordGrid": {
66  "xGrid": "****",
67  "yGrid": "****"
68  },
69  "coordGeo": {
70  "xGeo": "****",
71  "yGeo": "****"
72  },
73  "Color":"****"
74  },
75  ]
76  },
77 
78  "Mixture Model": {
79  "Method": "****"
80  },
81 
82  "Transform Matrix": [
83  [
84  "****",
85  .
86  .
87  .
88  "****"
89  ],
90  .
91  .
92  .
93  [
94  "****",
95  .
96  .
97  .
98  "****"
99  ]
100  ]
101  }
102 
103 
104  struct MixModelComponent
105  {
106  std::string m_name;
107  te::gm::Geometry* m_geomGrid;
108  te::gm::Geometry* m_geomGeo;
109  std::vector<double> m_values;
110  te::color::RGBAColor m_color;
111  };
112 */
113 
114 #ifndef __TERRALIB_QT_WIDGETS_RP_INTERNAL_MIXTUREMODELWIZARDPAGE_H
115 #define __TERRALIB_QT_WIDGETS_RP_INTERNAL_MIXTUREMODELWIZARDPAGE_H
116 
117 // TerraLib
118 #include "../../../classification/ROISet.h"
119 #include "../../../color/RGBAColor.h"
120 #include "../../../geometry/Geometry.h"
121 #ifndef Q_MOC_RUN
122 #include "../../../maptools/AbstractLayer.h"
123 #include "../../../qt/widgets/canvas/MapDisplay.h"
124 #include "../../../qt/widgets/charts/ChartDisplay.h"
125 #include "../../../qt/widgets/charts/ChartDisplayWidget.h"
126 #include "../../../qt/widgets/charts/ChartStyle.h"
127 #include "../../../raster/Raster.h"
128 #include "../../../rp/Functions.h"
129 #include "../../../rp/MixtureModel.h"
130 #endif
131 #include "../Config.h"
132 
133 
134 // STL
135 #include <memory>
136 
137 // Qt
138 #include <QWizardPage>
139 #include <QTableWidget>
140 #include <QActionGroup>
141 #include <qgridlayout.h>
142 #include <QSignalMapper>
143 #include <QTreeWidget>
144 #include <QTreeWidgetItem>
145 
146 //QWT
147 #include <qwt_plot_curve.h>
148 
149 // Forward declaration
150 namespace Ui { class MixtureModelWizardPageForm; }
151 
152 namespace te
153 {
154  namespace se { class Mark; }
155 
156  namespace qt
157  {
158  namespace widgets
159  {
160  class RpToolsWidget;
161  class SensorManagerDialog;
162  class ROIManagerDialog;
163 
164  /*!
165  \class MixtureModelWizardPage
166 
167  \brief This class is GUI used to define the mixture model parameters for the RP constast operation.
168  */
169  class TEQTWIDGETSEXPORT MixtureModelWizardPage : public QWizardPage
170  {
171  Q_OBJECT
172 
173  //!\enum MixModelTypes
174  //!\brief Available Algorithms for Mixture Model
176  {
177  MIXMODEL_LINEAR, //!< Linear (Least Square Method).
178  MIXMODEL_PCA, //!< Principal Components Mixture Model.
179  MIXMODEL_LINEAR_RLS3T //!< Linear (Resticted Least Square Method (only 3 components, 4 bands).
180  };
181 
182  //!\struct MixModelComponent
183  //!\brief Defines component attributes
185  {
186  std::string m_name; //!< name
187  te::gm::Geometry *m_geomGrid; //!< component coordinades in raster lineXcolumn
188  te::gm::Geometry *m_geomGeo; //!< component coordinates in geografic coordinates
189  std::vector<double> m_values; //!< raster values
191  };
192 
193  public:
194 
195  MixtureModelWizardPage(QWidget* parent = 0);
196 
198 
199  bool isComplete() const;
200 
201  public:
202 
203  /*!
204  \brief This method is used to set the selected layer for mixture model operation
205  \param layer The layer ptr
206  \note This layer MUST HAVE a valid raster object.
207  */
208  void set(std::list<te::map::AbstractLayerPtr> layers);
209 
211 
212  void setActionGroup(QActionGroup* actionGroup);
213 
214  std::list<te::map::AbstractLayerPtr> get();
215 
217 
218  bool isDecompose();
219 
221 
223 
224  void loadMixtureModelComponents(const std::string &fileName);
225 
227 
228  void clearCanvas();
229 
231 
232  boost::numeric::ublas::matrix<double> getTransfMatrix() {
233  return m_transfMatrix;
234  }
235 
237 
238  public slots:
239 
241 
243 
245 
247 
248  void onPointPicked(double x, double y);
249 
251 
253 
255 
256  void onComponentItemClicked(QTreeWidgetItem * item, int column);
259  void onselectedEnabled(bool);
260  void onallEnabled(bool);
261 
262  void drawGeom();
263 
266 
267  void showROIManager(bool show);
268 
270 
271  protected:
272 
274 
275  void listBands();
276 
277  void drawMarks();
278 
280 
281  double GetMediumWavelength(std::string sensor);
282 
286 
287  void printTransMatrix() const;
288 
289  private:
290  std::unique_ptr<Ui::MixtureModelWizardPageForm> m_ui;
291 
292  QSignalMapper m_ButtonSignalMapper;
293 
294  te::qt::widgets::SensorManagerDialog *m_sensorManagerDialog; //!< Dialog to select/edit spectral sensors
295  std::map<std::string, te::rp::SpectralSensorParams > m_SensorParams; //!< map with sensor parameters
296 
297  std::unique_ptr<te::qt::widgets::RpToolsWidget> m_navigator;
298  std::unique_ptr<te::qt::widgets::ROIManagerDialog> m_roiMngDlg;
299 
301 
302  std::map<std::string, MixModelComponent > m_components; //!< The map of selected components
303  unsigned int m_countComponents; //!< The maximum number of components inserted.
304 
305  std::list<te::map::AbstractLayerPtr> m_layers; //!< list of input layers
306  std::vector<double> m_maxValue; //!< vector to store maximum value of each band
307  te::color::RGBAColor** m_rgbaMark; //!< component color
308  te::se::Mark* m_mark; //!< component point mark type
309 
311 
313  QGridLayout* m_layoutg;
314  QColor m_color; //!< Current component color
315  te::gm::Geometry* m_geom; //!< Current geometry/envelope component
316  std::string m_comp; //!< Current component
317 
318  std::string m_json_out; //!< Json filename to save components
319  boost::numeric::ublas::matrix<double> m_transfMatrix; //!< Transformation matrix;
320  int m_type; //!< algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
321 
323  };
324 
325  } // end namespace widgets
326  } // end namespace qt
327 } // end namespace te
328 
329 #endif // __TERRALIB_QT_WIDGETS_RP_INTERNAL_MIXTUREMODELWIZARDPAGE_H
te::qt::widgets::MixtureModelWizardPage::MIXMODEL_PCA
@ MIXMODEL_PCA
Principal Components Mixture Model.
Definition: MixtureModelWizardPage.h:178
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::qt::widgets::MixtureModelWizardPage::printTransMatrix
void printTransMatrix() const
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::qt::widgets::MixtureModelWizardPage::m_layers
std::list< te::map::AbstractLayerPtr > m_layers
list of input layers
Definition: MixtureModelWizardPage.h:305
te::qt::widgets::MixtureModelWizardPage::m_components
std::map< std::string, MixModelComponent > m_components
The map of selected components.
Definition: MixtureModelWizardPage.h:302
te::qt::widgets::MixtureModelWizardPage::isDecompose
bool isDecompose()
te::qt::widgets::MixtureModelWizardPage::isComplete
bool isComplete() const
te::qt::widgets::MixtureModelWizardPage::GetMediumWavelength
double GetMediumWavelength(std::string sensor)
te::qt::widgets::MixtureModelWizardPage::onSaveToolButtonClicked
void onSaveToolButtonClicked()
te::qt::widgets::MixtureModelWizardPage::m_layoutg
QGridLayout * m_layoutg
Definition: MixtureModelWizardPage.h:313
te::qt::widgets::MapDisplay
A widget to control the display of a set of layers.
Definition: MapDisplay.h:72
te::qt::widgets::MixtureModelWizardPage::MixModelComponent::m_name
std::string m_name
name
Definition: MixtureModelWizardPage.h:186
te::qt::widgets::MixtureModelWizardPage::oncolorToolButtonClicked
void oncolorToolButtonClicked()
te::qt::widgets::MixtureModelWizardPage::onEnvelopeAcquired
void onEnvelopeAcquired(te::gm::Envelope env)
te::qt::widgets::MixtureModelWizardPage::onBandItemClicked
void onBandItemClicked()
te::qt::widgets::SensorManagerDialog
A dialog used to build a SensorManagerDialog element.
Definition: SensorManagerDialog.h:62
te::qt::widgets::MixtureModelWizardPage::m_json_out
std::string m_json_out
Json filename to save components.
Definition: MixtureModelWizardPage.h:318
te::qt::widgets::MixtureModelWizardPage::m_displayWidget
te::qt::widgets::ChartDisplayWidget * m_displayWidget
Definition: MixtureModelWizardPage.h:312
te::qt::widgets::MixtureModelWizardPage::MixtureModelWizardPage
MixtureModelWizardPage(QWidget *parent=0)
te::cl::ROISet
A ROISet is a set of ROI's.
Definition: ROISet.h:54
te::qt::widgets::MixtureModelWizardPage::loadMixtureModelComponents
void loadMixtureModelComponents(const std::string &fileName)
te::qt::widgets::MixtureModelWizardPage::onPointPicked
void onPointPicked(double x, double y)
te::qt::widgets::MixtureModelWizardPage::m_ui
std::unique_ptr< Ui::MixtureModelWizardPageForm > m_ui
Definition: MixtureModelWizardPage.h:290
te::qt::widgets::MixtureModelWizardPage::onROIManagerClosed
void onROIManagerClosed(te::cl::ROISet *rs)
TEQTWIDGETSEXPORT
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
te::qt::widgets::MixtureModelWizardPage::m_roiMngDlg
std::unique_ptr< te::qt::widgets::ROIManagerDialog > m_roiMngDlg
Definition: MixtureModelWizardPage.h:298
te::rp::MixtureModel::OutputParameters
MixtureModel output parameters.
Definition: MixtureModel.h:128
te::qt::widgets::MixtureModelWizardPage::m_navigator
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_navigator
Definition: MixtureModelWizardPage.h:297
te::gm::Polygon
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
te::qt::widgets::MixtureModelWizardPage::onRemoveToolButtonClicked
void onRemoveToolButtonClicked()
te::qt::widgets::MixtureModelWizardPage::onMapDisplayExtentChanged
void onMapDisplayExtentChanged()
te::qt::widgets::MixtureModelWizardPage::MixModelTypes
MixModelTypes
Available Algorithms for Mixture Model.
Definition: MixtureModelWizardPage.h:176
te::qt::widgets::MixtureModelWizardPage::onselectedEnabled
void onselectedEnabled(bool)
te::qt::widgets::MixtureModelWizardPage
This class is GUI used to define the mixture model parameters for the RP constast operation.
Definition: MixtureModelWizardPage.h:170
te::qt::widgets::MixtureModelWizardPage::m_mark
te::se::Mark * m_mark
component point mark type
Definition: MixtureModelWizardPage.h:308
te::qt::widgets::MixtureModelWizardPage::m_rgbaMark
te::color::RGBAColor ** m_rgbaMark
component color
Definition: MixtureModelWizardPage.h:307
te::qt::widgets::MixtureModelWizardPage::fillMixtureModelTypes
void fillMixtureModelTypes()
te::qt::widgets::MixtureModelWizardPage::showROIManager
void showROIManager(bool show)
te::qt::widgets::MixtureModelWizardPage::oncomponentChanged
void oncomponentChanged()
Ui
Definition: ConfigInputAddressDialog.h:44
te::qt::widgets::MixtureModelWizardPage::setActionGroup
void setActionGroup(QActionGroup *actionGroup)
te::qt::widgets::MixtureModelWizardPage::setMapDisplay
void setMapDisplay(te::qt::widgets::MapDisplay *mapDisplay)
te::qt::widgets::MixtureModelWizardPage::onSensorToolButtonClicked
void onSensorToolButtonClicked(int)
te::qt::widgets::MixtureModelWizardPage::onMixturetabChanged
void onMixturetabChanged(int)
te::qt::widgets::MixtureModelWizardPage::m_SensorParams
std::map< std::string, te::rp::SpectralSensorParams > m_SensorParams
map with sensor parameters
Definition: MixtureModelWizardPage.h:295
te::qt::widgets::MixtureModelWizardPage::MixModelComponent::m_geomGrid
te::gm::Geometry * m_geomGrid
component coordinades in raster lineXcolumn
Definition: MixtureModelWizardPage.h:187
te::qt::widgets::MixtureModelWizardPage::getTransfMatrix
boost::numeric::ublas::matrix< double > getTransfMatrix()
Definition: MixtureModelWizardPage.h:232
te::qt::widgets::MixtureModelWizardPage::m_mapDisplay
te::qt::widgets::MapDisplay * m_mapDisplay
Definition: MixtureModelWizardPage.h:310
te::qt::widgets::MixtureModelWizardPage::getInputParams
te::rp::MixtureModel::InputParameters getInputParams()
te::qt::widgets::MixtureModelWizardPage::m_type
int m_type
algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
Definition: MixtureModelWizardPage.h:320
te::qt::widgets::MixtureModelWizardPage::onComponentItemClicked
void onComponentItemClicked(QTreeWidgetItem *item, int column)
te::qt::widgets::MixtureModelWizardPage::updateComponents
void updateComponents()
slots
#define slots
Definition: VirtualMachine.h:48
te::qt::widgets::ChartDisplayWidget
A wdiget used to display a chart.
Definition: ChartDisplayWidget.h:63
te::se::Mark
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:85
te::qt::widgets::MixtureModelWizardPage::m_rs
te::cl::ROISet * m_rs
Definition: MixtureModelWizardPage.h:322
te::qt::widgets::MixtureModelWizardPage::onallEnabled
void onallEnabled(bool)
te::qt::widgets::MixtureModelWizardPage::PlotSpectralSignature
void PlotSpectralSignature()
te::qt::widgets::MixtureModelWizardPage::MIXMODEL_LINEAR
@ MIXMODEL_LINEAR
Linear (Least Square Method).
Definition: MixtureModelWizardPage.h:177
te::qt::widgets::MixtureModelWizardPage::MixModelComponent
Defines component attributes.
Definition: MixtureModelWizardPage.h:185
te::qt::widgets::MixtureModelWizardPage::addGeometryComponent
void addGeometryComponent()
te::qt::widgets::MixtureModelWizardPage::MixModelComponent::m_color
te::color::RGBAColor m_color
color
Definition: MixtureModelWizardPage.h:190
te::qt::widgets::MixtureModelWizardPage::m_geom
te::gm::Geometry * m_geom
Current geometry/envelope component.
Definition: MixtureModelWizardPage.h:315
te::qt::widgets::MixtureModelWizardPage::m_sensorManagerDialog
te::qt::widgets::SensorManagerDialog * m_sensorManagerDialog
Dialog to select/edit spectral sensors.
Definition: MixtureModelWizardPage.h:294
te::qt::widgets::MixtureModelWizardPage::m_transfMatrix
boost::numeric::ublas::matrix< double > m_transfMatrix
Transformation matrix;.
Definition: MixtureModelWizardPage.h:319
te::qt::widgets::MixtureModelWizardPage::onGeomAquired
void onGeomAquired(te::gm::Polygon *poly)
te::color::RGBAColor
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:58
te::qt::widgets::MixtureModelWizardPage::getOutputParams
te::rp::MixtureModel::OutputParameters getOutputParams()
te::qt::widgets::MixtureModelWizardPage::set
void set(std::list< te::map::AbstractLayerPtr > layers)
This method is used to set the selected layer for mixture model operation.
te::qt::widgets::MixtureModelWizardPage::drawMarks
void drawMarks()
te::qt::widgets::MixtureModelWizardPage::m_ButtonSignalMapper
QSignalMapper m_ButtonSignalMapper
Definition: MixtureModelWizardPage.h:292
te::qt::widgets::MixtureModelWizardPage::get
std::list< te::map::AbstractLayerPtr > get()
te::qt::widgets::MixtureModelWizardPage::m_bandindex
int m_bandindex
Definition: MixtureModelWizardPage.h:300
te::qt::widgets::MixtureModelWizardPage::onMixturetypeChanged
void onMixturetypeChanged()
te::qt::widgets::MixtureModelWizardPage::listBands
void listBands()
te::qt::widgets::MixtureModelWizardPage::m_countComponents
unsigned int m_countComponents
The maximum number of components inserted.
Definition: MixtureModelWizardPage.h:303
te::rp::MixtureModel::InputParameters
MixtureModel input parameters.
Definition: MixtureModel.h:73
te::qt::widgets::MixtureModelWizardPage::MixModelComponent::m_values
std::vector< double > m_values
raster values
Definition: MixtureModelWizardPage.h:189
te::qt::widgets::MixtureModelWizardPage::onLoadToolButtonClicked
void onLoadToolButtonClicked()
te::gm::Geometry
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
te::qt::widgets::MixtureModelWizardPage::MixModelComponent::m_geomGeo
te::gm::Geometry * m_geomGeo
component coordinates in geografic coordinates
Definition: MixtureModelWizardPage.h:188
te::qt::widgets::MixtureModelWizardPage::clearCanvas
void clearCanvas()
te::qt::widgets::MixtureModelWizardPage::m_comp
std::string m_comp
Current component.
Definition: MixtureModelWizardPage.h:316
te::qt::widgets::MixtureModelWizardPage::getROISet
te::cl::ROISet * getROISet()
te::qt::widgets::MixtureModelWizardPage::clearComponents
void clearComponents()
te::qt::widgets::MixtureModelWizardPage::drawGeom
void drawGeom()
te::qt::widgets::MixtureModelWizardPage::addPointComponent
void addPointComponent()
te::qt::widgets::MixtureModelWizardPage::m_maxValue
std::vector< double > m_maxValue
vector to store maximum value of each band
Definition: MixtureModelWizardPage.h:306
te::qt::widgets::MixtureModelWizardPage::~MixtureModelWizardPage
~MixtureModelWizardPage()
te::qt::widgets::MixtureModelWizardPage::m_color
QColor m_color
Current component color.
Definition: MixtureModelWizardPage.h:314
te::qt::widgets::MixtureModelWizardPage::saveMixtureModelComponents
void saveMixtureModelComponents()