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 "../../../color/RGBAColor.h"
119 #include "../../../geometry/Geometry.h"
120 #ifndef Q_MOC_RUN
121 #include "../../../maptools/AbstractLayer.h"
122 #include "../../../qt/widgets/canvas/MapDisplay.h"
123 #include "../../../qt/widgets/charts/ChartDisplay.h"
124 #include "../../../qt/widgets/charts/ChartDisplayWidget.h"
125 #include "../../../qt/widgets/charts/ChartStyle.h"
126 #include "../../../raster/Raster.h"
127 #include "../../../rp/Functions.h"
128 #include "../../../rp/MixtureModel.h"
129 #endif
130 #include "../Config.h"
131 
132 
133 // STL
134 #include <memory>
135 
136 // Qt
137 #include <QWizardPage>
138 #include <QTableWidget>
139 #include <QActionGroup>
140 #include <qgridlayout.h>
141 #include <QSignalMapper>
142 #include <QTreeWidget>
143 #include <QTreeWidgetItem>
144 
145 //QWT
146 #include <qwt_plot_curve.h>
147 
148 // Forward declaration
149 namespace Ui { class MixtureModelWizardPageForm; }
150 
151 namespace te
152 {
153  namespace se { class Mark; }
154 
155  namespace qt
156  {
157  namespace widgets
158  {
159  class RpToolsWidget;
160  class SensorManagerDialog;
161 
162  /*!
163  \class MixtureModelWizardPage
164 
165  \brief This class is GUI used to define the mixture model parameters for the RP constast operation.
166  */
167  class TEQTWIDGETSEXPORT MixtureModelWizardPage : public QWizardPage
168  {
169  Q_OBJECT
170 
171  //!\enum MixModelTypes
172  //!\brief Available Algorithms for Mixture Model
174  {
175  MIXMODEL_LINEAR, //!< Linear Mixture Model
176  MIXMODEL_PCA //!< Principal Components Mixture Model
177  };
178 
179  //!\struct MixModelComponent
180  //!\brief Defines component attributes
182  {
183  std::string m_name; //!< name
184  te::gm::Geometry *m_geomGrid; //!< component coordinades in raster lineXcolumn
185  te::gm::Geometry *m_geomGeo; //!< component coordinates in geografic coordinates
186  std::vector<double> m_values; //!< raster values
188  };
189 
190  public:
191 
192  MixtureModelWizardPage(QWidget* parent = 0);
193 
195 
196  bool isComplete() const;
197 
198  public:
199 
200  /*!
201  \brief This method is used to set the selected layer for mixture model operation
202  \param layer The layer ptr
203  \note This layer MUST HAVE a valid raster object.
204  */
205  void set(std::list<te::map::AbstractLayerPtr> layers);
206 
207  void setMapDisplay(te::qt::widgets::MapDisplay* mapDisplay);
208 
209  void setActionGroup(QActionGroup* actionGroup);
210 
211  std::list<te::map::AbstractLayerPtr> get();
212 
213  te::rp::MixtureModel::InputParameters getInputParams();
214 
215  bool isDecompose();
216 
217  te::rp::MixtureModel::OutputParameters getOutputParams();
218 
219  void saveMixtureModelComponents();
220 
221  void loadMixtureModelComponents(const std::string &fileName);
222 
223  void updateComponents();
224 
225  void clearCanvas();
226 
227  void onMapDisplayExtentChanged();
228 
229  boost::numeric::ublas::matrix<double> getTransfMatrix() {
230  return m_transfMatrix;
231  }
232 
233  public slots:
234 
235  void onMixturetypeChanged();
236 
237  void onMixturetabChanged(int);
238 
239  void onSaveToolButtonClicked();
240 
241  void onLoadToolButtonClicked();
242 
243  void onPointPicked(double x, double y);
244 
245  void onEnvelopeAcquired(te::gm::Envelope env);
246 
247  void onGeomAquired(te::gm::Polygon* poly);
248 
249  void onRemoveToolButtonClicked();
250 
251  void onComponentItemClicked(QTreeWidgetItem * item, int column);
252  void oncomponentChanged();
253  void oncolorToolButtonClicked();
254  void onselectedEnabled(bool);
255  void onallEnabled(bool);
256 
257  void drawGeom();
258 
259  void onSensorToolButtonClicked(int);
260  void onBandItemClicked();
261 
262  protected:
263 
264  void fillMixtureModelTypes();
265 
266  void listBands();
267 
268  void drawMarks();
269 
270  void PlotSpectralSignature();
271 
272  double GetMediumWavelength(std::string sensor);
273 
274  void addGeometryComponent();
275  void addPointComponent();
276  void clearComponents();
277 
278  private:
279  QSignalMapper m_ButtonSignalMapper;
280 
281  te::qt::widgets::SensorManagerDialog *m_sensorManagerDialog; //!< Dialog to select/edit spectral sensors
282  std::map<std::string, te::rp::SpectralSensorParams > m_SensorParams; //!< map with sensor parameters
283 
284  std::unique_ptr<Ui::MixtureModelWizardPageForm> m_ui;
285  std::unique_ptr<te::qt::widgets::RpToolsWidget> m_navigator;
286 
288 
289  std::map<std::string, MixModelComponent > m_components; //!< The map of selected components
290  unsigned int m_countComponents; //!< The maximum number of components inserted.
291 
292  std::list<te::map::AbstractLayerPtr> m_layers; //!< list of input layers
293  std::vector<double> m_maxValue; //!< vector to store maximum value of each band
294  te::color::RGBAColor** m_rgbaMark; //!< component color
295  te::se::Mark* m_mark; //!< component point mark type
296 
298 
300  QGridLayout* m_layoutg;
301  QColor m_color; //!< Current component color
302  te::gm::Geometry* m_geom; //!< Current geometry/envelope component
303  std::string m_comp; //!< Current component
304 
305  std::string m_json_out; //!< Json filename to save components
306  boost::numeric::ublas::matrix<double> m_transfMatrix; //!< Transformation matrix;
307  int m_type; //!< algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
308  };
309 
310  } // end namespace widgets
311  } // end namespace qt
312 } // end namespace te
313 
314 #endif // __TERRALIB_QT_WIDGETS_RP_INTERNAL_MIXTUREMODELWIZARDPAGE_H
te::color::RGBAColor ** m_rgbaMark
component color
std::list< te::map::AbstractLayerPtr > m_layers
list of input layers
#define slots
std::map< std::string, te::rp::SpectralSensorParams > m_SensorParams
map with sensor parameters
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
te::gm::Geometry * m_geomGeo
component coordinates in geografic coordinates
unsigned int m_countComponents
The maximum number of components inserted.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:71
boost::numeric::ublas::matrix< double > m_transfMatrix
Transformation matrix;.
te::gm::Geometry * m_geomGrid
component coordinades in raster lineXcolumn
This class is GUI used to define the mixture model parameters for the RP constast operation...
te::qt::widgets::ChartDisplayWidget * m_displayWidget
int m_type
algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
MixtureModel input parameters.
Definition: MixtureModel.h:72
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
std::map< std::string, MixModelComponent > m_components
The map of selected components.
URI C++ Library.
te::gm::Geometry * m_geom
Current geometry/envelope component.
std::vector< double > m_maxValue
vector to store maximum value of each band
te::se::Mark * m_mark
component point mark type
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:75
std::string m_json_out
Json filename to save components.
std::unique_ptr< Ui::MixtureModelWizardPageForm > m_ui
A wdiget used to display a chart.
MixtureModel output parameters.
Definition: MixtureModel.h:127
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
MixModelTypes
Available Algorithms for Mixture Model.
#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::SensorManagerDialog * m_sensorManagerDialog
Dialog to select/edit spectral sensors.
QColor m_color
Current component color.
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_navigator
A dialog used to build a SensorManagerDialog element.
boost::numeric::ublas::matrix< double > getTransfMatrix()
te::qt::widgets::MapDisplay * m_mapDisplay