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 Mixture Model
178  MIXMODEL_PCA //!< Principal Components Mixture Model
179  };
180 
181  //!\struct MixModelComponent
182  //!\brief Defines component attributes
184  {
185  std::string m_name; //!< name
186  te::gm::Geometry *m_geomGrid; //!< component coordinades in raster lineXcolumn
187  te::gm::Geometry *m_geomGeo; //!< component coordinates in geografic coordinates
188  std::vector<double> m_values; //!< raster values
190  };
191 
192  public:
193 
194  MixtureModelWizardPage(QWidget* parent = 0);
195 
197 
198  bool isComplete() const;
199 
200  public:
201 
202  /*!
203  \brief This method is used to set the selected layer for mixture model operation
204  \param layer The layer ptr
205  \note This layer MUST HAVE a valid raster object.
206  */
207  void set(std::list<te::map::AbstractLayerPtr> layers);
208 
209  void setMapDisplay(te::qt::widgets::MapDisplay* mapDisplay);
210 
211  void setActionGroup(QActionGroup* actionGroup);
212 
213  std::list<te::map::AbstractLayerPtr> get();
214 
215  te::rp::MixtureModel::InputParameters getInputParams();
216 
217  bool isDecompose();
218 
219  te::rp::MixtureModel::OutputParameters getOutputParams();
220 
221  void saveMixtureModelComponents();
222 
223  void loadMixtureModelComponents(const std::string &fileName);
224 
225  void updateComponents();
226 
227  void clearCanvas();
228 
229  void onMapDisplayExtentChanged();
230 
231  boost::numeric::ublas::matrix<double> getTransfMatrix() {
232  return m_transfMatrix;
233  }
234 
235  te::cl::ROISet* getROISet();
236 
237  public slots:
238 
239  void onMixturetypeChanged();
240 
241  void onMixturetabChanged(int);
242 
243  void onSaveToolButtonClicked();
244 
245  void onLoadToolButtonClicked();
246 
247  void onPointPicked(double x, double y);
248 
249  void onEnvelopeAcquired(te::gm::Envelope env);
250 
251  void onGeomAquired(te::gm::Polygon* poly);
252 
253  void onRemoveToolButtonClicked();
254 
255  void onComponentItemClicked(QTreeWidgetItem * item, int column);
256  void oncomponentChanged();
257  void oncolorToolButtonClicked();
258  void onselectedEnabled(bool);
259  void onallEnabled(bool);
260 
261  void drawGeom();
262 
263  void onSensorToolButtonClicked(int);
264  void onBandItemClicked();
265 
266  void showROIManager(bool show);
267 
268  void onROIManagerClosed(te::cl::ROISet* rs);
269 
270  protected:
271 
272  void fillMixtureModelTypes();
273 
274  void listBands();
275 
276  void drawMarks();
277 
278  void PlotSpectralSignature();
279 
280  double GetMediumWavelength(std::string sensor);
281 
282  void addGeometryComponent();
283  void addPointComponent();
284  void clearComponents();
285 
286  private:
287  std::unique_ptr<Ui::MixtureModelWizardPageForm> m_ui;
288 
289  QSignalMapper m_ButtonSignalMapper;
290 
291  te::qt::widgets::SensorManagerDialog *m_sensorManagerDialog; //!< Dialog to select/edit spectral sensors
292  std::map<std::string, te::rp::SpectralSensorParams > m_SensorParams; //!< map with sensor parameters
293 
294  std::unique_ptr<te::qt::widgets::RpToolsWidget> m_navigator;
295  std::unique_ptr<te::qt::widgets::ROIManagerDialog> m_roiMngDlg;
296 
298 
299  std::map<std::string, MixModelComponent > m_components; //!< The map of selected components
300  unsigned int m_countComponents; //!< The maximum number of components inserted.
301 
302  std::list<te::map::AbstractLayerPtr> m_layers; //!< list of input layers
303  std::vector<double> m_maxValue; //!< vector to store maximum value of each band
304  te::color::RGBAColor** m_rgbaMark; //!< component color
305  te::se::Mark* m_mark; //!< component point mark type
306 
308 
310  QGridLayout* m_layoutg;
311  QColor m_color; //!< Current component color
312  te::gm::Geometry* m_geom; //!< Current geometry/envelope component
313  std::string m_comp; //!< Current component
314 
315  std::string m_json_out; //!< Json filename to save components
316  boost::numeric::ublas::matrix<double> m_transfMatrix; //!< Transformation matrix;
317  int m_type; //!< algorithm mixture model type (MIXMODEL_LINEAR or MIXMODEL_PCA)
318 
320  };
321 
322  } // end namespace widgets
323  } // end namespace qt
324 } // end namespace te
325 
326 #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
std::unique_ptr< te::qt::widgets::ROIManagerDialog > m_roiMngDlg
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
A ROISet is a set of ROI&#39;s.
Definition: ROISet.h:53
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.
TerraLib.
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