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