RasterSlicingWizardPage.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 #ifndef TE_QT_WIDGETS_RASTERSLICINGWIZARDPAGE_H
22 #define TE_QT_WIDGETS_RASTERSLICINGWIZARDPAGE_H
23 
24 //Terralib
25 #ifndef Q_MOC_RUN
26 #include "../../../dataaccess/datasource/DataSourceInfo.h"
27 #include "../../../maptools/AbstractLayer.h"
28 #include "../../../qt/widgets/rp/RpToolsWidget.h"
29 #include "../canvas/Canvas.h"
30 #include "../canvas/MapDisplay.h"
31 #endif
32 #include "../Config.h"
33 
34 //Qt
35 #include <QWizardPage>
36 
37 //STL
38 #include <memory>
39 
40 //Forward declarations
41 namespace Ui
42 {
43  class RasterSlicingWizardPageForm;
44 }
45 
46 namespace te
47 {
48  namespace se
49  {
50  class ColorMap;
51  }
52 
53  namespace qt
54  {
55  namespace widgets
56  {
57  class ChartStyle;
58  class ChartDisplay;
59  class SlicingColorMapWidget;
60  class Histogram;
61  class HistogramChart;
62 
63  class TEQTWIDGETSEXPORT RasterSlicingWizardPage : public QWizardPage
64  {
65  Q_OBJECT
66 
67  public:
68 
69  /*! \brief Constructor. */
70  RasterSlicingWizardPage(QWidget* parent = 0);
71 
72  /*! \brief Destructor. */
74 
75  /*!
76  \brief This function returns the Color Map generated by the user.
77 
78  \return A color map representing the legend created by the user.
79 
80  /note The caller will take ownership of the returned pointer
81  */
82  te::se::ColorMap* getColorMap();
83 
84  /*!
85  \brief This function returns the band from the raster taht will be used.
86 
87  \return A string that represents the band that will be used to slice the raster.
88  */
89  std::string getCurrentBand();
90 
91  /*!
92  \brief This function returns the envelope that can be used to trim the raster if the user requests it.
93 
94  \return A reference to the Envelope that can be used to trim the raster if the user requests it.
95  */
96  const te::gm::Envelope& getExtent();
97 
98  /*!
99  \brief This function returns the srid of the display when the wizard was initiated.
100 
101  \return The srid of the display when the wizard was initiated.
102  */
103  int getSRID();
104 
105  /*!
106  \brief This function will check if the conditions required to trim the raster have been met.
107 
108  In order for this function to return true:
109 
110  The user must select the option to use the visible area;
111  The extent must be valid;
112  The extent must be within the raster;
113 
114  \return A boolean that indicates if the raster can be trimmed.
115  */
116  bool trimRaster();
117 
118  /*!
119  \brief This function sets the layer that contains the raster that will be sliced.
120 
121  \param layer The layer from which the raster will be obtained.
122  */
123  void setLayer(te::map::AbstractLayerPtr layer);
124 
125  /*!
126  \brief This function sets the envelope that will be used to trim tha raster if the user requests it.
127 
128  \param extent A reference to the envelope that can be used to trim tha raster.
129  */
130  void setExtent(const te::gm::Envelope& extent);
131 
132  /*!
133  \brief This function sets the srid of the display when the wizard was initiated.
134 
135  \param srid The current srid of the display.
136  */
137  void setSRID(int srid = 0);
138 
139  /*!
140  \brief This function sets the map display.
141 
142  \param Map display.
143  */
144  void setMapDisplay(te::qt::widgets::MapDisplay* mapDisplay);
145 
146  /*!
147  \brief This function sets the QActionGroup.
148 
149  \param QActionGroup.
150  */
151  void setActionGroup(QActionGroup* actionGroup);
152 
153  /*!
154  \brief This function returns the parameters as configured by the user.
155 
156  \param inputRasterBand The band from the raster selected by the user.
157  \param slicesNumber The number of slices that will be used to generate the histogram.
158  \param eqHistogram A boolean that holds weather the histogram will be equalized or not.
159  */
160  void getParameters(unsigned int& inputRasterBand, bool& eqHistogram);
161 
162  /*!
163  \brief This function evaluates the page to confirm if the user has completed the minimum configuration required to slice the raster.
164 
165  In order for this function to return true:
166 
167  The color map taht will be used on the output layer can not be empty.
168 
169  \param A boolean that indicates if the page is complete.
170  */
171  bool isComplete() const;
172 
173  /*!
174  \brief This function draws geometry after the envelope was acquired.
175  */
176  void drawGeom();
177 
178  /*!
179  \brief This function cleans the canvas.
180  */
181  void clearCanvas();
182 
183  /*!
184  \brief This function applies preview of raster slicing result.
185  */
186  void applyPreview();
187 
188  protected:
189 
190  void getRasterFromROI();
191 
192  void drawPreview(te::rst::Raster* raster);
193 
194  protected:
195 
196  std::unique_ptr<Ui::RasterSlicingWizardPageForm> m_ui; //!< The wizard page form
197  std::unique_ptr<te::qt::widgets::RpToolsWidget> m_tool; //!< Toolbar
198  te::qt::widgets::ChartDisplay* m_chartDisplay; //!< The display used to draw the preview histogram
199  te::qt::widgets::SlicingColorMapWidget* m_colorMapWidget; //!< The widget used to edit the legend of the output layer
200  te::qt::widgets::HistogramChart* m_histogramChart; //!< The preview histogram chart
201  std::unique_ptr<te::rst::Raster> m_raster; //!< The raster that will be sliced
202  te::map::AbstractLayerPtr m_rasterLayer; //!< Testing a better way to show the chart
204  std::unique_ptr<te::gm::Geometry> m_geom; //!< The geometry
205  std::unique_ptr<te::rst::Raster> m_rasterPreview; //!< The raster used for preview
206 
207  protected slots:
208 
209  void updateHistogram();
210  void onSliceBandComboBoxIndexCHanged(int index);
211  void onEnvelopeAcquired(te::gm::Envelope env);
212 
213  private:
214 
215  //No copy allowed
217  RasterSlicingWizardPage& operator=(const RasterSlicingWizardPage& rhs);
218 
219  te::gm::Envelope m_extent; //!< The envelope that can be used to trim the output raster
220  int m_srid; //!< The current srid from the display
221  };
222  } // namespace widgets
223  } // namespace qt
224 } // namespace te
225 
226 #endif // TE_QT_WIDGETS_RASTERSLICINGWIZARDPAGE_H
227 
#define slots
te::map::AbstractLayerPtr m_rasterLayer
Testing a better way to show the chart.
te::qt::widgets::HistogramChart * m_histogramChart
The preview histogram chart.
std::unique_ptr< Ui::RasterSlicingWizardPageForm > m_ui
The wizard page form.
te::qt::widgets::MapDisplay * m_mapDisplay
The map display.
A widget to control the display of a set of layers.
Definition: MapDisplay.h:71
std::unique_ptr< te::gm::Geometry > m_geom
The geometry.
te::gm::Envelope m_extent
The envelope that can be used to trim the output raster.
std::unique_ptr< te::rst::Raster > m_rasterPreview
The raster used for preview.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
std::unique_ptr< te::rst::Raster > m_raster
The raster that will be sliced.
A class to represent a chart display.
Definition: ChartDisplay.h:65
std::unique_ptr< te::qt::widgets::RpToolsWidget > m_tool
Toolbar.
#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::SlicingColorMapWidget * m_colorMapWidget
The widget used to edit the legend of the output layer.
te::qt::widgets::ChartDisplay * m_chartDisplay
The display used to draw the preview histogram.
int m_srid
The current srid from the display.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
A ColorMap defines either the colors of a pallette-type raster source or the mapping of numeric pixel...
Definition: ColorMap.h:61