Salome HOME
9072a3e2f5e58ee970b1136c55bcccfeeb07fea7
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROGUI_IMPORTIMAGEDLG_H
20 #define HYDROGUI_IMPORTIMAGEDLG_H
21
22 #include "HYDROGUI_InputPanel.h"
23
24 #include <QMap>
25
26 #define LAMBERT_X0 700000
27 #define LAMBERT_Y0 6600000
28 #define LAMBERT_LONG 3
29 #define LAMBERT_LATT 46.5
30 #define IMG_DELTA 500
31
32 class QButtonGroup;
33 class QComboBox;
34 class QGroupBox;
35 class QLabel;
36 class QLineEdit;
37 class QCheckBox;
38
39 class QtxDoubleSpinBox;
40 class QtxIntSpinBox;
41 class QAbstractSpinBox;
42
43 class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel
44 {
45   Q_OBJECT
46
47 public:
48   struct TransformationData
49   {
50     QPoint  ImagePoint;
51     QPointF GeodesicPoint;
52     QPointF CartesianPoint;
53
54     TransformationData() {}
55
56     TransformationData( const QPoint& theImagePoint ) :
57       ImagePoint( theImagePoint ) {}
58
59     TransformationData( const QPoint&  theImagePoint,
60                         const QPointF& theGeodesicPoint,
61                         const QPointF& theCartesianPoint ) :
62       ImagePoint( theImagePoint ),
63       GeodesicPoint( theGeodesicPoint ),
64       CartesianPoint( theCartesianPoint ) {}
65   };
66   typedef QMap< int, TransformationData > TransformationDataMap;
67
68   typedef QPair< QString, TransformationDataMap > PrsPointData;
69   typedef QList< PrsPointData >                   PrsPointDataList;
70   typedef QListIterator< PrsPointData >           PrsPointDataListIterator;
71
72 public:
73   HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle );
74   virtual ~HYDROGUI_ImportImageDlg();
75
76   void                       setIsEdit( const bool theIsEdit );
77   void                       reset();
78
79   void                       setImageName( const QString& theName );
80   QString                    getImageName() const;
81
82   void                       setRefImageName( const QString& theName );
83   QString                    getRefImageName() const;
84
85   QString                    getFileName() const;
86   void                       setFileName( const QString& theName );
87   QString                    getGeoreferencementFileName() const;
88
89   void                       setImageSize( const QSize& theSize,
90                                            const bool theIsRefImage = false );
91
92   void                       setTransformationMode( const int theMode );
93   int                        getTransformationMode() const;
94
95   void                       setByTwoPoints( const bool theIsByTwoPoints );
96   bool                       isByTwoPoints() const;
97
98   void                       setTransformationDataMap( const TransformationDataMap& theMap,
99                                                        const bool theIsOnlyInput = false,
100                                                        const bool theIsRefImage = false );
101   bool                       getTransformationDataMap( TransformationDataMap& theMap,
102                                                        const bool theIsRefImage = false ) const;
103
104   void                       setPrsPointDataList( const PrsPointDataList& theList );
105
106   void                       initializePointSelection();
107
108 public:
109
110   static TransformationData  ComputeTrsfData( const int      theMode,
111                                               const QPoint&  theLocalPoint,
112                                               const QPointF& theGlobalPoint );
113
114 protected slots:
115   void                       onBrowse();
116   void                       onGeoBrowse();
117   void                       onModeActivated( int );
118   void                       onRefImageActivated( const QString& );
119   void                       onPointBtnToggled( bool );
120   void                       onPointCoordChanged( int );
121   void                       onSetCIsUsed( bool theCIsUsed );
122
123   void                       onGeodesicCoordChanged();
124   void                       onGeodesicCoordChanged( const int thePointType );
125
126   void                       onCartesianCoordChanged();
127   void                       onCartesianCoordChanged( const int thePointType );
128
129 private:
130   void                       clearSpins( QAbstractSpinBox* theSpin );
131   bool                       blockSignalsPoints( const bool theState );
132   bool                       blockSignalsGeodesic( const bool theState );
133   bool                       blockSignalsCartesian( const bool theState );
134
135 signals:
136   void                       createPreview( QImage );
137   void                       activatePointSelection( int );
138   void                       pointCoordChanged( bool theIsRef,
139                                                 int thePointType,
140                                                 bool theIsY,
141                                                 int theValue );
142   void                       modeActivated( int );
143   void                       refImageActivated( const QString& );
144   void                       setCIsUsed( bool theIsByTwoPoints );
145
146 private:
147   QGroupBox*                   myFileNameGroup;    //!< The group for the source image file selection
148   QLineEdit*                   myFileName;         //!< Source image file name input field
149
150   QGroupBox*                   myImageNameGroup;   //!< The group for the image name input field
151   QLineEdit*                   myImageName;        //!< The image name input field
152
153   QGroupBox*                   myTransformGroup;   //!< The group of input contols for points definition
154
155   QButtonGroup*                myModeGroup;        //!< The group for the input mode selector
156   QComboBox*                   myRefImage;         //!< Reference image selector
157
158   QLineEdit*                   myGeoFileName;      //!< Image georeferencement file name input field
159
160   QList<QLabel*>               myGeodesicLabels;   //!< Labels for geodesic coords input fields
161
162   QMap<int, QPushButton*>      myPointBtnMap;      //!< A,B,C points selection modes activators
163   QMap<int, QtxIntSpinBox*>    myPointXMap;        //!< X coord on the image
164   QMap<int, QtxIntSpinBox*>    myPointYMap;        //!< Y coord on the image
165   QMap<int, QtxIntSpinBox*>    myPointXDegMap;     //!< Longitude degrees
166   QMap<int, QtxIntSpinBox*>    myPointYDegMap;     //!< Latitude degrees
167   QMap<int, QtxIntSpinBox*>    myPointXMinMap;     //!< Longitude minutes
168   QMap<int, QtxIntSpinBox*>    myPointYMinMap;     //!< Latitude minutes
169   QMap<int, QtxDoubleSpinBox*> myPointXSecMap;     //!< Longitude seconds
170   QMap<int, QtxDoubleSpinBox*> myPointYSecMap;     //!< Latitude seconds
171
172   QMap<int, QtxDoubleSpinBox*> myCartPointXMap;    //!< Lambert93 (cartesian) X coord (m)
173   QMap<int, QtxDoubleSpinBox*> myCartPointYMap;    //!< Lambert93 (cartesian) Y coord (m)
174
175   QMap<int, QtxIntSpinBox*>    myRefPointXMap;     //!< X coord on the reference image
176   QMap<int, QtxIntSpinBox*>    myRefPointYMap;     //!< Y coord on the reference image
177
178   QCheckBox*                   myPointCEnabler;    //!< Checkbox for enabling definition of the point C
179
180   PrsPointDataList             myPrsPointDataList; //!< Points presentations
181
182   bool                         myIsInitialized;    //!< True if a point selection is activated
183 };
184
185 #endif