Salome HOME
8823389061318ba782c955bbc0b022c5d158648c
[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   enum TransformationMode { ManualLambert = 0, ManualCartesian, RefImage };
46
47 public:
48   struct TransformationData
49   {
50     QPoint  ImagePoint;
51     QPointF LambertPoint;
52     QPointF CartesianPoint;
53
54     TransformationData() {}
55
56     TransformationData( const QPoint& theImagePoint,
57                         const QPointF& theLambertPoint,
58                         const QPointF& theCartesianPoint ) :
59       ImagePoint( theImagePoint ),
60       LambertPoint( theLambertPoint ),
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   QString                    getFileName() const;
80
81   void                       setImageSize( const QSize& theSize,
82                                            const bool theIsRefImage = false );
83
84   void                       setTransformationMode( const int theMode );
85   int                        getTransformationMode() const;
86
87   void                       setTransformationDataMap( const TransformationDataMap& theMap,
88                                                        const bool theIsOnlyInput = false,
89                                                        const bool theIsRefImage = false );
90   bool                       getTransformationDataMap( TransformationDataMap& theMap,
91                                                        const bool theIsRefImage = false ) const;
92
93   QString                    getRefImageName() const;
94
95   void                       setPrsPointDataList( const PrsPointDataList& theList );
96
97   void                       initializePointSelection();
98
99 protected slots:
100   void                       onBrowse();
101   void                       onModeActivated( int );
102   void                       onRefImageActivated( const QString& );
103   void                       onPointBtnToggled( bool );
104   void                       onPointCoordChanged( int );
105
106   void                       onLambertCoordChanged();
107   void                       onLambertCoordChanged( const int thePointType );
108
109   void                       onCartesianCoordChanged();
110   void                       onCartesianCoordChanged( const int thePointType );
111
112 private:
113   void                       blockSignalsLambert( const bool theState );
114   void                       blockSignalsCartesian( const bool theState );
115
116 signals:
117   void                       createPreview( QImage );
118   void                       activatePointSelection( int );
119   void                       pointCoordChanged( bool theIsRef,
120                                                 int thePointType,
121                                                 bool theIsY,
122                                                 int theValue );
123   void                       modeActivated( int );
124   void                       refImageActivated( const QString& );
125
126 private:
127   QGroupBox*                 myFileNameGroup;
128   QLineEdit*                 myFileName;
129
130   QGroupBox*                 myImageNameGroup;
131   QLineEdit*                 myImageName;
132
133   QGroupBox*                 myTransformGroup;
134
135   QButtonGroup*              myModeGroup;
136   QComboBox*                 myRefImage;
137
138   QList<QLabel*>             myLambertLabels;
139
140   QMap<int, QPushButton*>    myPointBtnMap;
141   QMap<int, QtxIntSpinBox*>  myPointXMap;
142   QMap<int, QtxIntSpinBox*>  myPointYMap;
143   QMap<int, QtxIntSpinBox*>  myPointXDegMap;
144   QMap<int, QtxIntSpinBox*>  myPointYDegMap;
145   QMap<int, QtxIntSpinBox*>  myPointXMinMap;
146   QMap<int, QtxIntSpinBox*>  myPointYMinMap;
147   QMap<int, QtxDoubleSpinBox*> myPointXSecMap;
148   QMap<int, QtxDoubleSpinBox*> myPointYSecMap;
149
150   QMap<int, QtxDoubleSpinBox*> myCartPointXMap;
151   QMap<int, QtxDoubleSpinBox*> myCartPointYMap;
152
153   QMap<int, QtxIntSpinBox*>  myRefPointXMap;
154   QMap<int, QtxIntSpinBox*>  myRefPointYMap;
155
156   QCheckBox*                 myPointCEnabler;
157
158   PrsPointDataList           myPrsPointDataList;
159
160   bool                       myIsInitialized;
161 };
162
163 #endif