Salome HOME
Lambert changed to Geodesic.
[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 class QButtonGroup;
31 class QComboBox;
32 class QGroupBox;
33 class QLabel;
34 class QLineEdit;
35 class QCheckBox;
36
37 class QtxDoubleSpinBox;
38 class QtxIntSpinBox;
39
40 class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel
41 {
42   Q_OBJECT
43
44 public:
45   struct TransformationData
46   {
47     QPoint  ImagePoint;
48     QPointF GeodesicPoint;
49     QPointF CartesianPoint;
50
51     TransformationData() {}
52
53     TransformationData( const QPoint& theImagePoint ) :
54       ImagePoint( theImagePoint ) {}
55
56     TransformationData( const QPoint&  theImagePoint,
57                         const QPointF& theGeodesicPoint,
58                         const QPointF& theCartesianPoint ) :
59       ImagePoint( theImagePoint ),
60       GeodesicPoint( theGeodesicPoint ),
61       CartesianPoint( theCartesianPoint ) {}
62   };
63   typedef QMap< int, TransformationData > TransformationDataMap;
64
65   typedef QPair< QString, TransformationDataMap > PrsPointData;
66   typedef QList< PrsPointData >                   PrsPointDataList;
67   typedef QListIterator< PrsPointData >           PrsPointDataListIterator;
68
69 public:
70   HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle );
71   virtual ~HYDROGUI_ImportImageDlg();
72
73   void                       setIsEdit( const bool theIsEdit );
74   void                       reset();
75
76   void                       setImageName( const QString& theName );
77   QString                    getImageName() const;
78
79   void                       setRefImageName( const QString& theName );
80   QString                    getRefImageName() const;
81
82   QString                    getFileName() const;
83
84   void                       setImageSize( const QSize& theSize,
85                                            const bool theIsRefImage = false );
86
87   void                       setTransformationMode( const int theMode );
88   int                        getTransformationMode() const;
89
90   void                       setByTwoPoints( const bool theIsByTwoPoints );
91   bool                       isByTwoPoints() const;
92
93   void                       setTransformationDataMap( const TransformationDataMap& theMap,
94                                                        const bool theIsOnlyInput = false,
95                                                        const bool theIsRefImage = false );
96   bool                       getTransformationDataMap( TransformationDataMap& theMap,
97                                                        const bool theIsRefImage = false ) const;
98
99   void                       setPrsPointDataList( const PrsPointDataList& theList );
100
101   void                       initializePointSelection();
102
103 public:
104
105   static TransformationData  ComputeTrsfData( const int      theMode,
106                                               const QPoint&  theLocalPoint,
107                                               const QPointF& theGlobalPoint );
108
109 protected slots:
110   void                       onBrowse();
111   void                       onModeActivated( int );
112   void                       onRefImageActivated( const QString& );
113   void                       onPointBtnToggled( bool );
114   void                       onPointCoordChanged( int );
115
116   void                       onGeodesicCoordChanged();
117   void                       onGeodesicCoordChanged( const int thePointType );
118
119   void                       onCartesianCoordChanged();
120   void                       onCartesianCoordChanged( const int thePointType );
121
122 private:
123   void                       blockSignalsGeodesic( const bool theState );
124   void                       blockSignalsCartesian( const bool theState );
125
126 signals:
127   void                       createPreview( QImage );
128   void                       activatePointSelection( int );
129   void                       pointCoordChanged( bool theIsRef,
130                                                 int thePointType,
131                                                 bool theIsY,
132                                                 int theValue );
133   void                       modeActivated( int );
134   void                       refImageActivated( const QString& );
135
136 private:
137   QGroupBox*                 myFileNameGroup;
138   QLineEdit*                 myFileName;
139
140   QGroupBox*                 myImageNameGroup;
141   QLineEdit*                 myImageName;
142
143   QGroupBox*                 myTransformGroup;
144
145   QButtonGroup*              myModeGroup;
146   QComboBox*                 myRefImage;
147
148   QList<QLabel*>             myGeodesicLabels;
149
150   QMap<int, QPushButton*>    myPointBtnMap;
151   QMap<int, QtxIntSpinBox*>  myPointXMap;
152   QMap<int, QtxIntSpinBox*>  myPointYMap;
153   QMap<int, QtxIntSpinBox*>  myPointXDegMap;
154   QMap<int, QtxIntSpinBox*>  myPointYDegMap;
155   QMap<int, QtxIntSpinBox*>  myPointXMinMap;
156   QMap<int, QtxIntSpinBox*>  myPointYMinMap;
157   QMap<int, QtxDoubleSpinBox*> myPointXSecMap;
158   QMap<int, QtxDoubleSpinBox*> myPointYSecMap;
159
160   QMap<int, QtxDoubleSpinBox*> myCartPointXMap;
161   QMap<int, QtxDoubleSpinBox*> myCartPointYMap;
162
163   QMap<int, QtxIntSpinBox*>  myRefPointXMap;
164   QMap<int, QtxIntSpinBox*>  myRefPointYMap;
165
166   QCheckBox*                 myPointCEnabler;
167
168   PrsPointDataList           myPrsPointDataList;
169
170   bool                       myIsInitialized;
171 };
172
173 #endif