]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_ImportImageDlg.h
Salome HOME
Merge branch 'BR_H2018_2' of https://codev-tuleap.cea.fr/plugins/git/salome/hydro...
[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 #include <HYDROData_Image.h>
24
25 #include <QMap>
26
27 #define LAMBERT_X0 700000
28 #define LAMBERT_Y0 6600000
29 #define LAMBERT_LONG 3
30 #define LAMBERT_LATT 46.5
31 #define IMG_DELTA 500
32
33 class QButtonGroup;
34 class QComboBox;
35 class QGroupBox;
36 class QLabel;
37 class QLineEdit;
38 class QCheckBox;
39
40 class QtxDoubleSpinBox;
41 class QtxIntSpinBox;
42 class QAbstractSpinBox;
43 class QToolButton;
44
45 class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel
46 {
47   Q_OBJECT
48
49 public:
50   struct TransformationData
51   {
52     QPoint  ImagePoint;
53     QPointF GeodesicPoint;
54     QPointF CartesianPoint;
55
56     TransformationData() {}
57
58     TransformationData( const QPoint& theImagePoint ) :
59       ImagePoint( theImagePoint ) {}
60
61     TransformationData( const QPoint&  theImagePoint,
62                         const QPointF& theGeodesicPoint,
63                         const QPointF& theCartesianPoint ) :
64       ImagePoint( theImagePoint ),
65       GeodesicPoint( theGeodesicPoint ),
66       CartesianPoint( theCartesianPoint ) {}
67   };
68   typedef QMap< int, TransformationData > TransformationDataMap;
69
70   typedef QPair< QString, TransformationDataMap > PrsPointData;
71   typedef QList< PrsPointData >                   PrsPointDataList;
72   typedef QListIterator< PrsPointData >           PrsPointDataListIterator;
73
74 public:
75   HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle );
76   virtual ~HYDROGUI_ImportImageDlg();
77
78   void                       setIsEdit( const bool theIsEdit );
79   void                       reset();
80
81   void                       setImageName( const QString& theName );
82   QString                    getImageName() const;
83
84   void                       setRefImageName( const QString& theName );
85   QString                    getRefImageName() const;
86
87   QString                    getFileName() const;
88   void                       setFileName( const QString& theName );
89   QString                    getGeoreferencementFileName() const;
90
91   void                       setImageSize( const QSize& theSize,
92                                            const bool theIsRefImage = false );
93
94   void                       setTransformationMode( const int theMode );
95   int                        getTransformationMode() const;
96
97   void                       setByTwoPoints( const bool theIsByTwoPoints );
98   bool                       isByTwoPoints() const;
99
100   void                       setTransformationDataMap( const TransformationDataMap& theMap,
101                                                        const bool theIsOnlyInput = false,
102                                                        const bool theIsRefImage = false );
103   bool                       getTransformationDataMap( TransformationDataMap& theMap,
104                                                        const bool theIsRefImage = false ) const;
105
106   void                       setPrsPointDataList( const PrsPointDataList& theList );
107
108   void                       initializePointSelection();
109
110
111   void                       ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo);
112
113
114   void                       ActivateFile( const QString& theFileName, bool isEnableFilesChoice );
115
116 public:
117
118   static TransformationData  ComputeTrsfData( const int      theMode,
119                                               const QPoint&  theLocalPoint,
120                                               const QPointF& theGlobalPoint );
121
122 protected slots:
123   void                       onBrowse();
124   void                       onGeoBrowse();
125   void                       onModeActivated( int );
126   void                       onRefImageActivated( const QString& );
127   void                       onPointBtnToggled( bool );
128   void                       onPointCoordChanged( int );
129   void                       onSetCIsUsed( bool theCIsUsed );
130
131   void                       onGeodesicCoordChanged();
132   void                       onGeodesicCoordChanged( const int thePointType );
133
134   void                       onCartesianCoordChanged();
135   void                       onCartesianCoordChanged( const int thePointType );
136
137 private:
138   void                       clearSpins( QAbstractSpinBox* theSpin );
139   bool                       blockSignalsPoints( const bool theState );
140   bool                       blockSignalsGeodesic( const bool theState );
141   bool                       blockSignalsCartesian( const bool theState );
142
143 signals:
144   void                       createPreview( QImage, HYDROData_Image::ECW_FileInfo* );
145   void                       activatePointSelection( int );
146   void                       pointCoordChanged( bool theIsRef,
147                                                 int thePointType,
148                                                 bool theIsY,
149                                                 int theValue );
150   void                       modeActivated( int );
151   void                       refImageActivated( const QString& );
152   void                       setCIsUsed( bool theIsByTwoPoints );
153   void                       filesSelected( const QStringList& );
154
155 private:
156   QGroupBox*                   myFileNameGroup;    //!< The group for the source image file selection
157   QLineEdit*                   myFileName;         //!< Source image file name input field
158   QToolButton*                 myBrowseBtn;
159
160   QGroupBox*                   myImageNameGroup;   //!< The group for the image name input field
161   QLineEdit*                   myImageName;        //!< The image name input field
162
163   QGroupBox*                   myTransformGroup;   //!< The group of input contols for points definition
164
165   QButtonGroup*                myModeGroup;        //!< The group for the input mode selector
166   QComboBox*                   myRefImage;         //!< Reference image selector
167
168   QLineEdit*                   myGeoFileName;      //!< Image georeferencement file name input field
169
170   QList<QLabel*>               myGeodesicLabels;   //!< Labels for geodesic coords input fields
171
172   QMap<int, QPushButton*>      myPointBtnMap;      //!< A,B,C points selection modes activators
173   QMap<int, QtxIntSpinBox*>    myPointXMap;        //!< X coord on the image
174   QMap<int, QtxIntSpinBox*>    myPointYMap;        //!< Y coord on the image
175   QMap<int, QtxIntSpinBox*>    myPointXDegMap;     //!< Longitude degrees
176   QMap<int, QtxIntSpinBox*>    myPointYDegMap;     //!< Latitude degrees
177   QMap<int, QtxIntSpinBox*>    myPointXMinMap;     //!< Longitude minutes
178   QMap<int, QtxIntSpinBox*>    myPointYMinMap;     //!< Latitude minutes
179   QMap<int, QtxDoubleSpinBox*> myPointXSecMap;     //!< Longitude seconds
180   QMap<int, QtxDoubleSpinBox*> myPointYSecMap;     //!< Latitude seconds
181
182   QMap<int, QtxDoubleSpinBox*> myCartPointXMap;    //!< Lambert93 (cartesian) X coord (m)
183   QMap<int, QtxDoubleSpinBox*> myCartPointYMap;    //!< Lambert93 (cartesian) Y coord (m)
184
185   QMap<int, QtxIntSpinBox*>    myRefPointXMap;     //!< X coord on the reference image
186   QMap<int, QtxIntSpinBox*>    myRefPointYMap;     //!< Y coord on the reference image
187
188   QCheckBox*                   myPointCEnabler;    //!< Checkbox for enabling definition of the point C
189
190   PrsPointDataList             myPrsPointDataList; //!< Points presentations
191
192   bool                         myIsInitialized;    //!< True if a point selection is activated
193 };
194
195 #endif