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  /*!
117  \brief Get the current acquired tie-points.
118 
119  \param tiePoints The current acquired tie-points (TiePoint.first=adjust raster lines/cols, TiePoint.second=the related correct X/Y coords under the output SRID).
120  */
121  void getTiePoints( std::vector< te::gm::GTParameters::TiePoint >& tiePoints ) const;
122 
123  /*!
124  \brief Get the current acquired tie-points.
125 
126  \param tiePoints The current acquired tie-points.
127  */
128  void getTiePointsIdxCoords( std::vector< te::gm::GTParameters::TiePoint >& tiePoints ) const;
129 
130  /*!
131  \brief Get tie point data container.
132 
133  \return The tie point data container.
134  */
135  const te::qt::widgets::TiePointData::TPContainerT& getTiePointContainer();
136 
137  /*!
138  \brief Get tie point reference coord that does not have an adjust coordenate or
139  \ tie point adjust coord that does not have an reference coordenate
140  \param firstCoord The tie point reference or adjsut coord.
141 
142  \return The m_tiePointHasFirstCoord type (None, Reference or Adjust).
143  */
144  FirstCoordType getFirstTiePointCoord(te::gm::Coord2D& firstCoord);
145 
146  /*!
147  \brief This method is used to set the selected layer used to be the reference layer
148 
149  \param layer The layer ptr
150 
151  \note This layer MUST HAVE a valid raster object.
152  */
153  void setReferenceLayer(te::map::AbstractLayerPtr layer);
154 
155  /*!
156  \brief This method is used to set the selected layer used to be the adjust layer
157 
158  \param layer The layer ptr
159 
160  \note This layer MUST HAVE a valid raster object.
161  */
162  void setAdjustLayer(te::map::AbstractLayerPtr layer);
163 
164  void getOutputSRID(int& srid);
165 
166  void getOutputResolution(double& resX, double& resY);
167 
168  std::string getTransformationName() const;
169 
170  te::rst::Interpolator::Method getInterpolatorMethod() const;
171 
172  protected:
173 
174  /*!
175  \brief A proxy to allow table itens sorting
176  */
177  class TableItem: public QTableWidgetItem
178  {
179  public:
180  TableItem(const double& value, int type = Type)
181  : QTableWidgetItem( QString::number( value ), type )
182  {
183  setData( 0, QVariant( value ) );
184  };
185 
186  TableItem(const QString &text, int type = Type)
187  : QTableWidgetItem( text, type )
188  {
189  setData( 0, QVariant( text.toDouble() ) );
190  };
191 
192  bool operator< (const QTableWidgetItem &other) const
193  {
194  return ( data(0).toDouble() < other.data(0).toDouble() );
195  };
196  };
197 
198  void refCoordPicked(double x, double y);
199 
200  void adjCoordPicked(double x, double y);
201 
202  void refCoordMoved(double xorig, double yorig, double xnew, double ynew);
203 
204  void adjCoordMoved(double xorig, double yorig, double xnew, double ynew);
205 
206  void setTiePointMarkLegend(QPixmap p);
207 
208  void setSelectedTiePointMarkLegend(QPixmap p);
209 
210  void setReferenceTiePointMarkLegend(QPixmap p);
211 
212  void createSelection(int initialIdx, int nPos);
213 
214  bool shotSecondtPoint();
215 
216  bool shotFirstPoint();
217 
218  protected slots:
219 
220  void onAutoAcquireTiePointsToolButtonClicked();
221 
222  void onSelectAllToolButtonClicked();
223 
224  void onUnselectAllToolButtonClicked();
225 
226  void onDeleteSelectedToolButtonClicked();
227 
228  void onAddToolButtonClicked();
229 
230  void onTiePointsTableWidgetItemSelectionChanged();
231 
232  void onRefreshToolButtonClicked();
233 
234  void onDoneToolButtonClicked();
235 
236  void onRefMapDisplayExtentChanged();
237 
238  void onAdjMapDisplayExtentChanged();
239 
240  void onRefPointPicked(double x, double y);
241 
242  void onAdjPointPicked(double x, double y);
243 
244  void onRefPointMoved(double xorig, double yorig, double xnew, double ynew);
245 
246  void onAdjPointMoved(double xorig, double yorig, double xnew, double ynew);
247 
248  void onTiePointsUpdated();
249 
250  void onSRIDPushButtonClicked();
251 
252  void onLoadTiePointsToolButtonClicked();
253 
254  void onSaveTiePointsToolButtonClicked();
255 
256  void onTiePointsTableWidgetItemChanged(QTableWidgetItem*);
257 
258  protected:
259 
260  /*! \brief Uptate the tie-points table widget. */
261  void tiePointsTableUpdate();
262 
263  /*! \brief Uptate the current transformation information widgets. */
264  void transformationInfoUpdate();
265 
266  void startUpNavigators();
267 
268  void drawTiePoints();
269 
270  QPixmap getPixmap(te::color::RGBAColor** rgba);
271 
272  void reset();
273 
274  /*!
275  \brief Returns the rasters pixel sizes relation (under the reference SRS)
276  \param pixelSizeXRelation X Relation.
277  \param pixelSizeYRelation Y Relation.
278  \note PixelSizeRelation = Reference_Raster_Pixel_Size / Adjust_Raster_Pixel_Size
279  */
280  void getRastersPixelSizesRelation( double& pixelSizeXRelation,
281  double& pixelSizeYRelation ) const;
282 
283  /*!
284  \brief Returns the rasters pixel size relation ((under the reference SRS)).
285  \note PixelSizeRelation = Reference_Raster_Mean_Pixel_Size / Adjust_Raster_Mean_Pixel_Size
286  */
287  double getRastersMeanPixelSizeRelation() const;
288 
289  signals:
290 
291  void tiePointsUpdated();
292 
293  void doneAcquiredTiePoints();
294 
295  private:
296 
297  std::unique_ptr<Ui::TiePointLocatorWidgetForm> m_ui;
298 
300 
301  te::map::AbstractLayerPtr m_refLayer; //!< Layer with reference imagem
302  te::map::AbstractLayerPtr m_adjLayer; //!< Layer with adjust imagem
303 
304  te::qt::widgets::TiePointData::TPContainerT m_tiePoints; //!< Internal tie-points container..
305 
307  FirstCoordType m_tiePointFirstCoord; //!< Type of coord if the tie-point has the first part set;
308  unsigned int m_tiePointIdCounter; //!< A ID counter for new tie pointes inserted into m_tiePoints;
309 
310  std::set<int> m_tiePointsSelected; //!< List of selected tie points.
311 
312  te::qt::widgets::RasterNavigatorWidget* m_refNavigator; //!< Reference raster navigator
314 
315  te::color::RGBAColor** m_rgbaMarkSelected; //!< Represents the pattern of a selected tie point
316  te::color::RGBAColor** m_rgbaMarkUnselected; //!< Represents the pattern of a unselected tie point
317  te::color::RGBAColor** m_rgbaMarkRef; //!< Represents the pattern of reference tie point
318  te::se::Mark* m_markSelected; //!< Represents the mark of a selected tie point
319  te::se::Mark* m_markUnselected; //!< Represents the mark of a unselected tie point
320  te::se::Mark* m_markRef; //!< Represents the mark of a reference tie point
321  std::map< unsigned int, QPointF > m_refPoints; //!< Display reference coordinates
322  std::map< unsigned int, QPointF > m_adjPoints; //!< Display adjust coordinates
323  };
324 
325  } // end namespace widgets
326  } // end namespace qt
327 } // end namespace te
328 
329 #endif // __TERRALIB_QT_WIDGETS_RP_INTERNAL_TIEPOINTLOCATORWIDGET_H
330 
te::color::RGBAColor ** m_rgbaMarkSelected
Represents the pattern of a selected tie point.
#define slots
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
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)