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