Salome HOME
f1f2a6478f77ffd038e4435d9061f841d457427e
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.h
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef HYDROGUI_IMPORTIMAGEDLG_H
24 #define HYDROGUI_IMPORTIMAGEDLG_H
25
26 #include "HYDROGUI_InputPanel.h"
27
28 #include <QMap>
29
30 #define LAMBERT_X0 700000
31 #define LAMBERT_Y0 6600000
32 #define LAMBERT_LONG 3
33 #define LAMBERT_LATT 46.5
34 #define IMG_DELTA 500
35
36 class QButtonGroup;
37 class QComboBox;
38 class QGroupBox;
39 class QLabel;
40 class QLineEdit;
41 class QCheckBox;
42
43 class QtxDoubleSpinBox;
44 class QtxIntSpinBox;
45
46 class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel
47 {
48   Q_OBJECT
49
50 public:
51   struct TransformationData
52   {
53     QPoint  ImagePoint;
54     QPointF GeodesicPoint;
55     QPointF CartesianPoint;
56
57     TransformationData() {}
58
59     TransformationData( const QPoint& theImagePoint ) :
60       ImagePoint( theImagePoint ) {}
61
62     TransformationData( const QPoint&  theImagePoint,
63                         const QPointF& theGeodesicPoint,
64                         const QPointF& theCartesianPoint ) :
65       ImagePoint( theImagePoint ),
66       GeodesicPoint( theGeodesicPoint ),
67       CartesianPoint( theCartesianPoint ) {}
68   };
69   typedef QMap< int, TransformationData > TransformationDataMap;
70
71   typedef QPair< QString, TransformationDataMap > PrsPointData;
72   typedef QList< PrsPointData >                   PrsPointDataList;
73   typedef QListIterator< PrsPointData >           PrsPointDataListIterator;
74
75 public:
76   HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle );
77   virtual ~HYDROGUI_ImportImageDlg();
78
79   void                       setIsEdit( const bool theIsEdit );
80   void                       reset();
81
82   void                       setImageName( const QString& theName );
83   QString                    getImageName() const;
84
85   void                       setRefImageName( const QString& theName );
86   QString                    getRefImageName() const;
87
88   QString                    getFileName() const;
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 public:
111
112   static TransformationData  ComputeTrsfData( const int      theMode,
113                                               const QPoint&  theLocalPoint,
114                                               const QPointF& theGlobalPoint );
115
116 protected slots:
117   void                       onBrowse();
118   void                       onGeoBrowse();
119   void                       onModeActivated( int );
120   void                       onRefImageActivated( const QString& );
121   void                       onPointBtnToggled( bool );
122   void                       onPointCoordChanged( int );
123   void                       onSetCIsUsed( bool theCIsUsed );
124
125   void                       onGeodesicCoordChanged();
126   void                       onGeodesicCoordChanged( const int thePointType );
127
128   void                       onCartesianCoordChanged();
129   void                       onCartesianCoordChanged( const int thePointType );
130
131 private:
132   void                       blockSignalsGeodesic( const bool theState );
133   void                       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