TiePointLocatorWidget.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/TiePointLocatorWidget.h
22 
23  \brief This file has the TiePointLocatorWidget class.
24 */
25 
26 #ifndef __TERRALIB_QT_WIDGETS_RP_INTERNAL_TIEPOINTLOCATORWIDGET_H
27 #define __TERRALIB_QT_WIDGETS_RP_INTERNAL_TIEPOINTLOCATORWIDGET_H
28 
29 // TerraLib
30 #include "../../../color/RGBAColor.h"
31 #include "../../../geometry/Coord2D.h"
32 #include "../../../geometry/GTParameters.h"
33 #ifndef Q_MOC_RUN
34 #include "../../../maptools/AbstractLayer.h"
35 #include "../../../rp/TiePointsLocator.h"
36 #endif
37 #include "../Config.h"
38 
39 // STL
40 #include <map>
41 #include <memory>
42 #include <set>
43 
44 // Qt
45 #include <QTableWidgetItem>
46 #include <QWidget>
47 
48 namespace Ui { class TiePointLocatorWidgetForm; }
49 
50 namespace te
51 {
52 
53  namespace se { class Mark; }
54 
55  namespace qt
56  {
57  namespace widgets
58  {
59  class MapDisplay;
60  class RasterNavigatorWidget;
61  class TiePointLocatorParametersWidget;
62 
63  /*! \class TiePointData Tie Point data. */
65  {
66  public :
67 
68  /*! \enum TiePointAcquisitionType Tie point acquisition type. */
70  {
71  InvalidAcquisitionT, //!< Invalid acquisition type.
72  ManualAcquisitionT, //!< Manual acquisition type.
73  AutomaticAcquisitionT //!< Automatic acquisition type.
74  };
75 
76  TiePointAcquisitionType m_acqType; //!< Acquisition type.
77  te::gm::GTParameters::TiePoint m_tiePoint; //!< Tie point coordinates - std::pair< Reference Raster Line/Col Coord,. Adjust Raster Line/Col Coord >.
78  bool m_selected; //!< Tie point selection status;
79 
80  TiePointData();
81 
82  TiePointData( const TiePointData& other );
83 
84  ~TiePointData();
85 
86  const TiePointData& operator=( const TiePointData& other );
87 
88  typedef std::map< unsigned int, TiePointData > TPContainerT; //!< Tie-pints container type definition.
89 
90  };
91 
92  /*!
93  \class TiePointLocatorWidget
94 
95  \brief This class is used to define a widget for tie point acquirement.
96  */
98  {
99  Q_OBJECT
100 
101  public:
102 
104  {
105  None, //!< None first coord picked
106  Reference, //!< Reference first coord was picked
107  Adjust //!< Adjust first coord was picked
108  };
109 
110  TiePointLocatorWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
111 
113 
114  Ui::TiePointLocatorWidgetForm* getForm() const;
115 
116  public:
117 
118  /*!
119  \brief Get the current acquired tie-points.
120 
121  \param tiePoints The current acquired tie-points.
122  */
123  void getTiePoints( std::vector< te::gm::GTParameters::TiePoint >& tiePoints ) const;
124 
125  /*!
126  \brief Get the current acquired tie-points.
127 
128  \param tiePoints The current acquired tie-points.
129  */
130  void getTiePointsIdxCoords( std::vector< te::gm::GTParameters::TiePoint >& tiePoints ) const;
131 
132  /*!
133  \brief Get tie point data container.
134 
135  \return The tie point data container.
136  */
137  const te::qt::widgets::TiePointData::TPContainerT& getTiePointContainer();
138 
139  /*!
140  \brief Get tie point reference coord that does not have an adjust coordenate or
141  \ tie point adjust coord that does not have an reference coordenate
142  \param firstCoord The tie point reference or adjsut coord.
143 
144  \return The m_tiePointHasFirstCoord type (None, Reference or Adjust).
145  */
146  FirstCoordType getFirstTiePointCoord(te::gm::Coord2D& firstCoord);
147 
148  /*!
149  \brief This method is used to set the selected layer used to be the reference layer
150 
151  \param layer The layer ptr
152 
153  \note This layer MUST HAVE a valid raster object.
154  */
155  void setReferenceLayer(te::map::AbstractLayerPtr layer);
156 
157  /*!
158  \brief This method is used to set the selected layer used to be the adjust layer
159 
160  \param layer The layer ptr
161 
162  \note This layer MUST HAVE a valid raster object.
163  */
164  void setAdjustLayer(te::map::AbstractLayerPtr layer);
165 
166  void getOutputSRID(int& srid);
167 
168  void getOutputResolution(double& resX, double& resY);
169 
170  std::string getTransformationName() const;
171 
172  te::rst::Interpolator::Method getInterpolatorMethod() const;
173 
174  protected:
175 
176  void refCoordPicked(double x, double y);
177 
178  void adjCoordPicked(double x, double y);
179 
180  void refCoordMoved(double xorig, double yorig, double xnew, double ynew);
181 
182  void adjCoordMoved(double xorig, double yorig, double xnew, double ynew);
183 
184  void setTiePointMarkLegend(QPixmap p);
185 
186  void setSelectedTiePointMarkLegend(QPixmap p);
187 
188  void setReferenceTiePointMarkLegend(QPixmap p);
189 
190  void createSelection(int initialIdx, int nPos);
191 
192  bool shotSecondtPoint();
193 
194  bool shotFirstPoint();
195 
196  protected slots:
197 
198  void onAutoAcquireTiePointsToolButtonClicked();
199 
200  void onSelectAllToolButtonClicked();
201 
202  void onUnselectAllToolButtonClicked();
203 
204  void onDeleteSelectedToolButtonClicked();
205 
206  void onAddToolButtonClicked();
207 
208  void onTiePointsTableWidgetItemSelectionChanged();
209 
210  void onRefreshToolButtonClicked();
211 
212  void onDoneToolButtonClicked();
213 
214  void onRefMapDisplayExtentChanged();
215 
216  void onAdjMapDisplayExtentChanged();
217 
218  void onRefPointPicked(double x, double y);
219 
220  void onAdjPointPicked(double x, double y);
221 
222  void onRefPointMoved(double xorig, double yorig, double xnew, double ynew);
223 
224  void onAdjPointMoved(double xorig, double yorig, double xnew, double ynew);
225 
226  void onTiePointsUpdated();
227 
228  void onSRIDPushButtonClicked();
229 
230  void onLoadTiePointsToolButtonClicked();
231 
232  void onSaveTiePointsToolButtonClicked();
233 
234  void onTiePointsTableWidgetItemChanged(QTableWidgetItem*);
235 
236  protected:
237 
238  /*! \brief Uptate the tie-points table widget. */
239  void tiePointsTableUpdate();
240 
241  /*! \brief Uptate the current transformation information widgets. */
242  void transformationInfoUpdate();
243 
244  void startUpNavigators();
245 
246  void drawTiePoints();
247 
248  QPixmap getPixmap(te::color::RGBAColor** rgba);
249 
250  void reset();
251 
252  signals:
253 
254  void tiePointsUpdated();
255 
256  void doneAcquiredTiePoints();
257 
258  private:
259 
260  std::unique_ptr<Ui::TiePointLocatorWidgetForm> m_ui;
261 
263 
264  te::map::AbstractLayerPtr m_refLayer; //!< Layer with reference imagem
265  te::map::AbstractLayerPtr m_adjLayer; //!< Layer with adjust imagem
266 
267  te::qt::widgets::TiePointData::TPContainerT m_tiePoints; //!< Internal tie-points container.
268 
270  FirstCoordType m_tiePointFirstCoord; //!< Type of coord if the tie-point has the first part set;
271  unsigned int m_tiePointIdCounter; //!< A ID counter for new tie pointes inserted into m_tiePoints;
272 
273  std::set<int> m_tiePointsSelected; //!< List of selected tie points.
274 
275  te::qt::widgets::RasterNavigatorWidget* m_refNavigator; //!< Reference raster navigator
277 
278  te::color::RGBAColor** m_rgbaMarkSelected; //!< Represents the pattern of a selected tie point
279  te::color::RGBAColor** m_rgbaMarkUnselected; //!< Represents the pattern of a unselected tie point
280  te::color::RGBAColor** m_rgbaMarkRef; //!< Represents the pattern of reference tie point
281  te::se::Mark* m_markSelected; //!< Represents the mark of a selected tie point
282  te::se::Mark* m_markUnselected; //!< Represents the mark of a unselected tie point
283  te::se::Mark* m_markRef; //!< Represents the mark of a reference tie point
284  std::map< unsigned int, QPointF > m_refPoints; //!< Display reference coordinates
285  std::map< unsigned int, QPointF > m_adjPoints; //!< Display adjust coordinates
286  };
287 
288  } // end namespace widgets
289  } // end namespace qt
290 } // end namespace te
291 
292 #endif // __TERRALIB_QT_WIDGETS_RP_INTERNAL_TIEPOINTLOCATORWIDGET_H
293 
te::color::RGBAColor ** m_rgbaMarkSelected
Represents the pattern of a selected tie point.
#define slots
std::map< unsigned int, TiePointData > TPContainerT
Tie-pints container type definition.
te::qt::widgets::RasterNavigatorWidget * m_refNavigator
Reference raster navigator.
This class is used to define a widget for tie point acquirement.
A Mark specifies a geometric shape and applies coloring to it.
Definition: Mark.h:84
te::se::Mark * m_markRef
Represents the mark of a reference tie point.
te::map::AbstractLayerPtr m_refLayer
Layer with reference imagem.
te::qt::widgets::RasterNavigatorWidget * m_adjNavigator
Adjust raster navigator.
te::gm::GTParameters::TiePoint m_tiePoint
Tie point coordinates - std::pair< Reference Raster Line/Col Coord,. Adjust Raster Line/Col Coord >...
std::map< unsigned int, QPointF > m_refPoints
Display reference coordinates.
std::map< unsigned int, QPointF > m_adjPoints
Display adjust coordinates.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
te::qt::widgets::TiePointLocatorParametersWidget * m_tiePointParameters
Tie Point parameters widget.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
FirstCoordType m_tiePointFirstCoord
Type of coord if the tie-point has the first part set;.
te::qt::widgets::TiePointData::TPContainerT m_tiePoints
Internal tie-points container.
te::se::Mark * m_markSelected
Represents the mark of a selected tie point.
te::map::AbstractLayerPtr m_adjLayer
Layer with adjust imagem.
std::unique_ptr< Ui::TiePointLocatorWidgetForm > m_ui
TerraLib.
te::se::Mark * m_markUnselected
Represents the mark of a unselected tie point.
te::color::RGBAColor ** m_rgbaMarkRef
Represents the pattern of reference tie point.
bool m_selected
Tie point selection status;.
te::gm::GTParameters::TiePoint m_currentTiePoint
The current tie-point.
std::set< int > m_tiePointsSelected
List of selected tie points.
This class is used to define a widget for tie point parameters acquirement.
This class is used to navigate over a DataSetLayer (having a raster representation) and given a set o...
te::color::RGBAColor ** m_rgbaMarkUnselected
Represents the pattern of a unselected tie point.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
Definition: RGBAColor.h:57
#define TEQTWIDGETSEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:63
TiePointAcquisitionType m_acqType
Acquisition type.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
unsigned int m_tiePointIdCounter
A ID counter for new tie pointes inserted into m_tiePoints;.
const TiePointData & operator=(const TiePointData &other)