Salome HOME
porting to sketcher in GEOM
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportImageDlg.cxx
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 #include "HYDROGUI_ImportImageDlg.h"
24
25 #include "HYDROGUI_PrsImage.h"
26 #include "HYDROGUI_Tool.h"
27 #include "HYDROGUI_Module.h"
28
29 #include <HYDROData_Lambert93.h>
30 #include <HYDROData_Image.h>
31
32 #include <LightApp_Application.h>
33 #include <SUIT_FileDlg.h>
34 #include <SUIT_ResourceMgr.h>
35 #include <SUIT_Desktop.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_Session.h>
38
39 #include <QtxDoubleSpinBox.h>
40 #include <QtxIntSpinBox.h>
41
42 #include <QButtonGroup>
43 #include <QComboBox>
44 #include <QGroupBox>
45 #include <QLabel>
46 #include <QLayout>
47 #include <QLineEdit>
48 #include <QPainter>
49 #include <QPicture>
50 #include <QPushButton>
51 #include <QRadioButton>
52 #include <QToolButton>
53 #include <QCheckBox>
54
55 HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle )
56 : HYDROGUI_InputPanel( theModule, theTitle ),
57   myIsInitialized( false )
58 {
59   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
60
61   // Import image from file
62   myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this );
63
64   QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
65
66   myFileName = new QLineEdit( myFileNameGroup );
67   myFileName->setReadOnly( true );
68
69   QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
70   aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
71
72   QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
73   aFileNameLayout->setMargin( 5 );
74   aFileNameLayout->setSpacing( 5 );
75   aFileNameLayout->addWidget( aFileNameLabel );
76   aFileNameLayout->addWidget( myFileName );
77   aFileNameLayout->addWidget( aBrowseBtn );
78
79   // Image name
80   myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this );
81
82   QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
83   myImageName = new QLineEdit( myImageNameGroup );
84
85   QBoxLayout* anImageNameLayout = new QHBoxLayout( myImageNameGroup );
86   anImageNameLayout->setMargin( 5 );
87   anImageNameLayout->setSpacing( 5 );
88   anImageNameLayout->addWidget( anImageNameLabel );
89   anImageNameLayout->addWidget( myImageName );
90
91   // Transform image
92   myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this );
93
94   // Make a pixmap for arrow
95   QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) );
96
97   QPicture anArrowPicture;
98   anArrowPicture.setBoundingRect( QRect( QPoint( 0, 0 ), anArrowPixmap.size() ) );
99
100   QPainter aPainter;
101   aPainter.begin( &anArrowPicture );
102   aPainter.drawPixmap( 0, 0, anArrowPixmap );
103   aPainter.end();
104
105   QRadioButton* aManualGeodesicBtn = new QRadioButton( tr( "MANUALLY_GEODESIC" ), myTransformGroup );
106   QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup );
107   QRadioButton* aCartesianFromFileBtn = new QRadioButton( tr( "LAMBERT93_FROM_FILE" ), myTransformGroup );
108   QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup );
109
110   myModeGroup = new QButtonGroup( myTransformGroup );
111   myModeGroup->addButton( aManualGeodesicBtn, HYDROData_Image::ManualGeodesic );
112   myModeGroup->addButton( aManualCartesianBtn, HYDROData_Image::ManualCartesian );
113   myModeGroup->addButton( aCartesianFromFileBtn, HYDROData_Image::CartesianFromFile );
114   myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage );
115
116   myRefImage = new QComboBox( myTransformGroup );
117
118   QVBoxLayout* aTransformLayout = new QVBoxLayout( myTransformGroup );
119   aTransformLayout->setMargin( 5 );
120   aTransformLayout->setSpacing( 5 );
121
122   QGridLayout* aModeLayout = new QGridLayout( myTransformGroup );
123   aModeLayout->setMargin( 0 );
124   aModeLayout->setSpacing( 5 );
125   aModeLayout->addWidget( aManualGeodesicBtn,   0, 0 );
126   aModeLayout->addWidget( aManualCartesianBtn, 1, 0 );
127   aModeLayout->addWidget( aCartesianFromFileBtn, 2, 0 );
128   aModeLayout->addWidget( aRefImageBtn,        3, 0 );
129   aModeLayout->addWidget( myRefImage,          3, 1 );
130   aModeLayout->setColumnStretch( 1, 1 );
131
132   aTransformLayout->addLayout( aModeLayout );
133
134   // Manual input widget
135   QWidget* aManualInputGroup = new QWidget( myTransformGroup );
136   QGridLayout* aManualInputLayout = new QGridLayout( aManualInputGroup );
137   aManualInputLayout->setMargin( 5 );
138   aManualInputLayout->setSpacing( 5 );
139
140   QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), aManualInputGroup );
141   QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), aManualInputGroup );
142   QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), aManualInputGroup );
143   QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), aManualInputGroup );
144
145   aManualInputLayout->addWidget( aImageCSLabel,  0, 1 );
146   aManualInputLayout->addWidget( aGeodesicLabel, 0, 2, 1, 6 );
147   aManualInputLayout->addWidget( aLambertLabel,  0, 2, 1, 6 );
148   aManualInputLayout->addWidget( aRefImageLabel, 0, 2, 1, 6 );
149
150   for( int aPointType = HYDROGUI_PrsImage::PointA;
151        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
152   {
153     QString aPointStr;
154     switch( aPointType )
155     {
156       case HYDROGUI_PrsImage::PointA: aPointStr = tr( "ACTIVATE_POINT_A_SELECTION" ); break;
157       case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break;
158       case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break;
159     }
160     QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup );
161     aPointBtn->setCheckable( true );
162
163     QLabel* aPointXLabel = new QLabel( "X", aManualInputGroup );
164     QLabel* aPointYLabel = new QLabel( "Y", aManualInputGroup );
165
166     QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
167     QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
168
169     QLabel* aPointArrowLabel = new QLabel( aManualInputGroup );
170     aPointArrowLabel->setPicture( anArrowPicture );
171
172     QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup );
173     QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup );
174     QLabel* aPointXMinLabel = new QLabel( "'", aManualInputGroup );
175     QLabel* aPointYMinLabel = new QLabel( "'", aManualInputGroup );
176     QLabel* aPointXSecLabel = new QLabel( "\"", aManualInputGroup );
177     QLabel* aPointYSecLabel = new QLabel( "\"", aManualInputGroup );
178     QLabel* aPointLatLabel = new QLabel( tr( "POINT_LATITUDE" ), aManualInputGroup );
179     QLabel* aPointLonLabel = new QLabel( tr( "POINT_LONGITUDE" ), aManualInputGroup );
180     myGeodesicLabels << aPointXDegLabel << aPointYDegLabel
181                     << aPointXMinLabel << aPointYMinLabel
182                     << aPointXSecLabel << aPointYSecLabel
183                     << aPointLonLabel << aPointLatLabel;
184
185     QtxIntSpinBox* aPointXDeg = new QtxIntSpinBox( -179, 179, 1, aManualInputGroup );
186     QtxIntSpinBox* aPointYDeg = new QtxIntSpinBox( 0, 89, 1, aManualInputGroup );
187     QtxIntSpinBox* aPointXMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup );
188     QtxIntSpinBox* aPointYMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup );
189     QtxDoubleSpinBox* aPointXSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup );
190     QtxDoubleSpinBox* aPointYSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup );
191
192     QtxDoubleSpinBox* aCartPointX = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
193     QtxDoubleSpinBox* aCartPointY = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
194
195     QtxIntSpinBox* aRefPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
196     QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
197
198     int aRow = 4 * aPointType;
199     if ( aPointType == HYDROGUI_PrsImage::PointC )
200     {
201       myPointCEnabler = new QCheckBox( aManualInputGroup );
202       aManualInputLayout->addWidget( myPointCEnabler, aRow,    0, 1, 2, Qt::AlignHCenter );
203       aManualInputLayout->addWidget( aPointBtn,       aRow,    2, 1, 8 );
204     }
205     else
206     {
207       aManualInputLayout->addWidget( aPointBtn,       aRow,    0, 1, 10 );
208     }
209
210     aManualInputLayout->addWidget( aPointXLabel,     aRow + 1, 0 );
211     aManualInputLayout->addWidget( aPointX,          aRow + 1, 1 );
212     aManualInputLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 );
213     aManualInputLayout->addWidget( aPointXDeg,       aRow + 1, 3 );
214     aManualInputLayout->addWidget( aPointXDegLabel,  aRow + 1, 4 );
215     aManualInputLayout->addWidget( aPointXMin,       aRow + 1, 5 );
216     aManualInputLayout->addWidget( aPointXMinLabel,  aRow + 1, 6 );
217     aManualInputLayout->addWidget( aPointXSec,       aRow + 1, 7 );
218     aManualInputLayout->addWidget( aPointXSecLabel,  aRow + 1, 8 );
219     aManualInputLayout->addWidget( aPointLonLabel,   aRow + 1, 9 );
220
221     aManualInputLayout->addWidget( aCartPointX,      aRow + 1, 3, 1, 6 );
222     aManualInputLayout->addWidget( aRefPointX,       aRow + 1, 3, 1, 6 );
223
224     aManualInputLayout->addWidget( aPointYLabel,     aRow + 2, 0 );
225     aManualInputLayout->addWidget( aPointY,          aRow + 2, 1 );
226     aManualInputLayout->addWidget( aPointYDeg,       aRow + 2, 3 );
227     aManualInputLayout->addWidget( aPointYDegLabel,  aRow + 2, 4 );
228     aManualInputLayout->addWidget( aPointYMin,       aRow + 2, 5 );
229     aManualInputLayout->addWidget( aPointYMinLabel,  aRow + 2, 6 );
230     aManualInputLayout->addWidget( aPointYSec,       aRow + 2, 7 );
231     aManualInputLayout->addWidget( aPointYSecLabel,  aRow + 2, 8 );
232     aManualInputLayout->addWidget( aPointLatLabel,   aRow + 2, 9 );
233
234     aManualInputLayout->addWidget( aCartPointY,      aRow + 2, 3, 1, 6 );
235     aManualInputLayout->addWidget( aRefPointY,       aRow + 2, 3, 1, 6 );
236
237     if( aPointType != HYDROGUI_PrsImage::PointC )
238     {
239       QFrame* aLine = new QFrame( aManualInputGroup );
240       aLine->setFrameShape( QFrame::HLine );
241       aLine->setFrameShadow( QFrame::Sunken );
242       aManualInputLayout->addWidget( aLine, aRow + 3, 0, 1, 10 );
243     }
244
245     myPointBtnMap[ aPointType ] = aPointBtn;
246     myPointXMap[ aPointType ] = aPointX;
247     myPointYMap[ aPointType ] = aPointY;
248     myPointXDegMap[ aPointType ] = aPointXDeg;
249     myPointYDegMap[ aPointType ] = aPointYDeg;
250     myPointXMinMap[ aPointType ] = aPointXMin;
251     myPointYMinMap[ aPointType ] = aPointYMin;
252     myPointXSecMap[ aPointType ] = aPointXSec;
253     myPointYSecMap[ aPointType ] = aPointYSec;
254
255     myCartPointXMap[ aPointType ] = aCartPointX;
256     myCartPointYMap[ aPointType ] = aCartPointY;
257
258     myRefPointXMap[ aPointType ] = aRefPointX;
259     myRefPointYMap[ aPointType ] = aRefPointY;
260
261     connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
262
263     connect( aPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
264     connect( aPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
265
266     connect( aPointXDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
267     connect( aPointYDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
268     connect( aPointXMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
269     connect( aPointYMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
270     connect( aPointXSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) );
271     connect( aPointYSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) );
272
273     connect( aCartPointX, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
274     connect( aCartPointY, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
275
276     connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
277     connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
278   }
279
280   // Connect checkbox enabling point C
281   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointBtnMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
282   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
283   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
284   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
285   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
286   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
287   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
288   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
289   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
290   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
291   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
292   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
293   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
294
295   connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SLOT( onSetCIsUsed( bool ) ) );
296
297   aManualInputLayout->setColumnStretch( 1, 1 ); // double
298   aManualInputLayout->setColumnStretch( 3, 1 ); // degrees
299   aManualInputLayout->setColumnStretch( 5, 1 ); // minutes
300   aManualInputLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
301
302   // Image georeferencement file widget
303   QWidget* aFromFileInputGroup = new QWidget( myTransformGroup );
304   QBoxLayout* aFromFileInputLayout = new QHBoxLayout( aFromFileInputGroup );
305   aFromFileInputLayout->setMargin( 5 );
306   aFromFileInputLayout->setSpacing( 5 );
307  
308   QLabel* aGeoFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFromFileInputGroup );
309
310   myGeoFileName = new QLineEdit( aFromFileInputGroup );
311   myGeoFileName->setReadOnly( true );
312
313   QToolButton* aGeoBrowseBtn = new QToolButton( aFromFileInputGroup );
314   aGeoBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
315
316   aFromFileInputLayout->addWidget( aGeoFileNameLabel );
317   aFromFileInputLayout->addWidget( myGeoFileName );
318   aFromFileInputLayout->addWidget( aGeoBrowseBtn );
319
320   // Widgets connections
321   connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setVisible ( bool ) ) );
322   connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
323   connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
324   connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
325   connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setVisible ( bool ) ) );
326   connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
327   connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
328   connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
329   connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setVisible ( bool ) ) );
330   connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
331   connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
332   connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
333   connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setVisible ( bool ) ) );
334   connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aManualInputGroup, SLOT( setHidden ( bool ) ) );
335
336   // Input widgets
337   aTransformLayout->addWidget( aManualInputGroup );
338   aTransformLayout->addWidget( aFromFileInputGroup );
339
340   // Common
341   addWidget( myFileNameGroup );
342   addWidget( myImageNameGroup );
343   addWidget( myTransformGroup );
344   addStretch();
345
346   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
347
348   connect( myModeGroup, SIGNAL( buttonClicked( int ) ),
349            this, SLOT( onModeActivated( int ) ) );
350
351   connect( aGeoBrowseBtn, SIGNAL( clicked() ), this, SLOT( onGeoBrowse() ) );
352
353   connect( myRefImage, SIGNAL( activated( const QString& ) ),
354            this, SLOT( onRefImageActivated( const QString& ) ) );
355
356   //setTransformationMode( HYDROData_Image::ManualCartesian );
357
358   setMinimumWidth( 350 );
359 }
360
361 HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
362 {
363 }
364
365 void HYDROGUI_ImportImageDlg::onSetCIsUsed( bool theCIsUsed )
366 {
367   if ( !theCIsUsed  && myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->isChecked() )
368   {
369     // Turn on point A selection if point C selection has been activated and we disable point C.
370     myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->toggle();
371   }
372   emit setCIsUsed( theCIsUsed );
373 }
374
375 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
376 {
377   myFileNameGroup->setVisible( !theIsEdit );
378   myImageNameGroup->setEnabled( theIsEdit );
379   myTransformGroup->setEnabled( theIsEdit );
380 }
381
382 void HYDROGUI_ImportImageDlg::reset()
383 {
384   myFileName->clear();
385   myImageName->clear();
386   myImageNameGroup->setEnabled( false );
387   myGeoFileName->clear();
388   bool isPBlocked = blockSignalsPoints( true );
389   bool isGBlocked = blockSignalsGeodesic( true );
390   bool isCBlocked = blockSignalsCartesian( true );
391   for( int aPointType = HYDROGUI_PrsImage::PointA;
392        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
393   {
394     QPushButton* aBtn = myPointBtnMap[ aPointType ];
395     bool anIsBlocked = aBtn->blockSignals( true );
396     aBtn->setChecked( false );
397     aBtn->blockSignals( anIsBlocked );
398
399     clearSpins( myPointXMap[ aPointType ] );
400     clearSpins( myPointYMap[ aPointType ] );
401     clearSpins( myPointXDegMap[ aPointType ] );
402     clearSpins( myPointYDegMap[ aPointType ] );
403     clearSpins( myPointXMinMap[ aPointType ] );
404     clearSpins( myPointYMinMap[ aPointType ] );
405     clearSpins( myPointXSecMap[ aPointType ] );
406     clearSpins( myPointYSecMap[ aPointType ] );
407
408     clearSpins( myRefPointXMap[ aPointType ] );
409     clearSpins( myRefPointYMap[ aPointType ] );
410
411     clearSpins( myCartPointXMap[ aPointType ] );
412     clearSpins( myCartPointYMap[ aPointType ] );
413   }
414   blockSignalsPoints( isPBlocked );
415   blockSignalsGeodesic( isGBlocked );
416   blockSignalsCartesian( isCBlocked );
417   
418   // Emulate turning off C point usage
419   myPointCEnabler->blockSignals( true );
420   
421   myPointCEnabler->setChecked( false );
422   myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
423   myPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
424   myPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
425   myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
426   myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
427   myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
428   myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
429   myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
430   myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
431   myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
432   myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
433   myRefPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
434   myRefPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
435   onSetCIsUsed( false );
436
437   myPointCEnabler->blockSignals( false );
438   
439   myTransformGroup->setEnabled( false );
440   myRefImage->clear();
441
442   setTransformationMode( HYDROData_Image::ManualCartesian );
443
444   myPrsPointDataList.clear();
445
446   myIsInitialized = false;
447 }
448
449 void HYDROGUI_ImportImageDlg::setImageName( const QString& theName )
450 {
451   myImageName->setText( theName );
452 }
453
454 QString HYDROGUI_ImportImageDlg::getImageName() const
455 {
456   return myImageName->text();
457 }
458
459 void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName )
460 {
461   myRefImage->setCurrentIndex( myRefImage->findText( theName ) );
462 }
463
464 QString HYDROGUI_ImportImageDlg::getRefImageName() const
465 {
466   return myRefImage->currentText();
467 }
468
469 QString HYDROGUI_ImportImageDlg::getFileName() const
470 {
471   return myFileName->text();
472 }
473
474 void HYDROGUI_ImportImageDlg::setFileName( const QString& theName )
475 {
476   myFileName->setText( theName );
477   myImageNameGroup->setEnabled( true );
478   myTransformGroup->setEnabled( true );
479 }
480
481 QString HYDROGUI_ImportImageDlg::getGeoreferencementFileName() const
482 {
483   return myGeoFileName->text();
484 }
485
486 void HYDROGUI_ImportImageDlg::setImageSize( const QSize& theSize,
487                                             const bool theIsRefImage )
488 {
489   int aWidth = theSize.width();
490   int aHeight = theSize.height();
491   for( int aPointType = HYDROGUI_PrsImage::PointA;
492        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
493   {
494     if( theIsRefImage )
495     {
496       myRefPointXMap[ aPointType ]->setRange( 0, aWidth );
497       myRefPointYMap[ aPointType ]->setRange( 0, aHeight );
498     }
499     else
500     {
501       myPointXMap[ aPointType ]->setRange( 0, aWidth );
502       myPointYMap[ aPointType ]->setRange( 0, aHeight );
503     }
504   }
505 }
506
507 void HYDROGUI_ImportImageDlg::setTransformationMode( const int theMode )
508 {
509   myModeGroup->button( theMode )->setChecked( true );
510   onModeActivated( theMode );
511 }
512
513 int HYDROGUI_ImportImageDlg::getTransformationMode() const
514 {
515   return myModeGroup->checkedId();
516 }
517
518 void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints )
519 {
520   myPointCEnabler->setChecked( !theIsByTwoPoints );
521 }
522
523 bool HYDROGUI_ImportImageDlg::isByTwoPoints() const
524 {
525   return !myPointCEnabler->isChecked();
526 }
527
528 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
529                                                         const bool theIsOnlyInput,
530                                                         const bool theIsRefImage )
531 {
532   blockSignalsGeodesic( true );
533   blockSignalsCartesian( true );
534   for( int aPointType = HYDROGUI_PrsImage::PointA;
535        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
536   {
537     if( theMap.contains( aPointType ) )
538     {
539       const TransformationData& aData = theMap[ aPointType ];
540
541       QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
542       QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
543       aPointX->setValue( aData.ImagePoint.x() );
544       aPointY->setValue( aData.ImagePoint.y() );
545
546       if( !theIsOnlyInput && !theIsRefImage )
547       {
548         QPointF aLPoint = aData.GeodesicPoint;
549         int aXDeg = 0, aYDeg = 0;
550         int aXMin = 0, aYMin = 0;
551         double aXSec = 0, aYSec = 0;
552         HYDROData_Lambert93::degToDMS( aLPoint.x(), aXDeg, aXMin, aXSec );
553         HYDROData_Lambert93::degToDMS( aLPoint.y(), aYDeg, aYMin, aYSec );
554
555         myPointXDegMap[ aPointType ]->setValue( aXDeg );
556         myPointYDegMap[ aPointType ]->setValue( aYDeg );
557         myPointXMinMap[ aPointType ]->setValue( aXMin );
558         myPointYMinMap[ aPointType ]->setValue( aYMin );
559         myPointXSecMap[ aPointType ]->setValue( aXSec );
560         myPointYSecMap[ aPointType ]->setValue( aYSec );
561
562         QPointF aCPoint = aData.CartesianPoint;
563         myCartPointXMap[ aPointType ]->setValue( aCPoint.x() );
564         myCartPointYMap[ aPointType ]->setValue( aCPoint.y() );
565       }
566     }
567   }
568   blockSignalsGeodesic( false );
569   blockSignalsCartesian( false );
570 }
571
572 bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap,
573                                                         const bool theIsRefImage ) const
574 {
575   theMap.clear();
576   for( int aPointType = HYDROGUI_PrsImage::PointA;
577        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
578   {
579     bool anIsOk[10];
580     for( int i = 0; i < 10; i++ )
581       anIsOk[ i ] = true;
582
583     QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
584     QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
585     int aX1 = aPointX->text().toInt( &anIsOk[0] );
586     int aY1 = aPointY->text().toInt( &anIsOk[1] );
587
588     int aXDeg = 0, aYDeg = 0;
589     int aXMin = 0, aYMin = 0;
590     double aXSec = 0, aYSec = 0;
591     double aXCart = 0, aYCart = 0;
592     if( !theIsRefImage )
593     {
594       aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] );
595       aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] );
596       aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] );
597       aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] );
598       aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] );
599       aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] );
600
601       aXCart = myCartPointXMap[ aPointType ]->text().toDouble( &anIsOk[8] );
602       aYCart = myCartPointYMap[ aPointType ]->text().toDouble( &anIsOk[9] );
603     }
604
605     for( int i = 0; i < 10; i++ )
606       if( !anIsOk[ i ] )
607         return false;
608
609     double aX2 = 0, aY2 = 0;
610     HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aX2 );
611     HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aY2 );
612
613     TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ), QPointF( aXCart, aYCart ) );
614     theMap[ aPointType ] = aData;
615   }
616   return true;
617 }
618
619 void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
620 {
621   myPrsPointDataList = theList;
622
623   if( !myPrsPointDataList.isEmpty() )
624   {
625     myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true );
626
627     myRefImage->clear();
628     myRefImage->addItem( "" ); // first empty item
629
630     PrsPointDataListIterator anIter( myPrsPointDataList );
631     while( anIter.hasNext() )
632       myRefImage->addItem( anIter.next().first );
633   }
634   else
635     myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false );
636 }
637
638 void HYDROGUI_ImportImageDlg::initializePointSelection()
639 {
640   if( myIsInitialized )
641     return;
642
643   myIsInitialized = true;
644
645   myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
646
647   double aCartX0 = LAMBERT_X0;
648   double aCartY0 = LAMBERT_Y0;
649
650   blockSignalsCartesian( true );
651
652   myCartPointXMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartX0 );
653   myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + IMG_DELTA );
654
655   myCartPointXMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartX0 + IMG_DELTA );
656   myCartPointYMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartY0 + IMG_DELTA );
657
658   myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartX0 );
659   myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartY0 );
660
661   for( int aPointType = HYDROGUI_PrsImage::PointA;
662        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
663     onCartesianCoordChanged( aPointType );
664
665   blockSignalsCartesian( false );
666 }
667
668 HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
669   const int      theMode,
670   const QPoint&  theLocalPoint,
671   const QPointF& theGlobalPoint )
672 {
673   TransformationData aResTrsfData;
674   aResTrsfData.ImagePoint = theLocalPoint;
675
676   double arx = theGlobalPoint.x();
677   double ary = theGlobalPoint.y();
678   if ( theMode == HYDROData_Image::ManualGeodesic )
679   {
680     // Geodesic to Cartesian
681     double aXCart = 0, aYCart = 0;
682     // Interpreting arY as attitude and arX as longitude
683     HYDROData_Lambert93::toXY( ary, arx, aXCart, aYCart );
684
685     aResTrsfData.GeodesicPoint = theGlobalPoint;
686     aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart );
687   }
688   else if ( theMode == HYDROData_Image::ManualCartesian )
689   {
690     // Cartesian to Geodesic
691     double aLonDeg = 0, aLatDeg = 0;
692     HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg );
693
694     aResTrsfData.CartesianPoint = theGlobalPoint;
695     aResTrsfData.GeodesicPoint = QPointF( aLonDeg, aLatDeg );
696   }
697
698   return aResTrsfData;
699 }
700
701 void HYDROGUI_ImportImageDlg::onBrowse()
702 {
703   QString aFilter( tr( "IMAGE_FILTER" ) );
704   QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
705   if( !aFileName.isEmpty() )
706   {
707     QImage anImage( aFileName );
708     if( anImage.isNull() )
709     {
710       QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
711       QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ).
712         arg( aFileName ).arg( QFileInfo( aFileName ).suffix() );
713       SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage );
714     }
715     else
716     {
717       setFileName( aFileName );
718       emit createPreview( anImage );
719     }
720   }
721 }
722
723 void HYDROGUI_ImportImageDlg::onGeoBrowse()
724 {
725   QString aFilter( tr( "IMAGE_GEOREFERENCEMENT_FILTER" ) );
726   QString aGeoFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_GEO_DATA_FROM_FILE" ), true );
727   if( !aGeoFileName.isEmpty() ) {
728     myGeoFileName->setText( aGeoFileName );
729   }
730 }
731
732 void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
733 {
734   bool anIsManualGeodesic = theMode == HYDROData_Image::ManualGeodesic;
735   bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian;
736   bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage;
737
738   myRefImage->setEnabled( anIsRefImage );
739
740   for( int aPointType = HYDROGUI_PrsImage::PointA;
741        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
742   {
743     myPointXDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
744     myPointYDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
745     myPointXMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
746     myPointYMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
747     myPointXSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
748     myPointYSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
749
750     myCartPointXMap[ aPointType ]->setVisible( anIsManualCartesian );
751     myCartPointYMap[ aPointType ]->setVisible( anIsManualCartesian );
752
753     myRefPointXMap[ aPointType ]->setVisible( anIsRefImage );
754     myRefPointYMap[ aPointType ]->setVisible( anIsRefImage );
755   }
756
757   QListIterator<QLabel*> anIter( myGeodesicLabels );
758   while( anIter.hasNext() )
759     anIter.next()->setVisible( anIsManualGeodesic );
760
761   emit modeActivated( theMode );
762 }
763
764 void HYDROGUI_ImportImageDlg::onRefImageActivated( const QString& theName )
765 {
766   emit refImageActivated( theName );
767 }
768
769 void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState )
770 {
771   int aPointType = HYDROGUI_PrsImage::None;
772   if( theState )
773   {
774     QMapIterator<int, QPushButton*> anIter( myPointBtnMap );
775     while( anIter.hasNext() )
776     {
777       int aBtnPointType = anIter.next().key();
778       QPushButton* aBtn = anIter.value();
779       if( aBtn == sender() )
780         aPointType = aBtnPointType;
781       else
782       {
783         bool anIsBlocked = aBtn->blockSignals( true );
784         aBtn->setChecked( false );
785         aBtn->blockSignals( anIsBlocked );
786       }
787     }
788   }
789   emit activatePointSelection( aPointType );
790 }
791
792 void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue )
793 {
794   QObject* aSender = sender();
795   if( !aSender )
796     return;
797
798   for( int aPointType = HYDROGUI_PrsImage::PointA;
799        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
800   {
801     if( aSender == myPointXMap[ aPointType ] ||
802         aSender == myPointYMap[ aPointType ] )
803     {
804       bool anIsY = aSender == myPointYMap[ aPointType ];
805       emit pointCoordChanged( false, aPointType, anIsY, theValue );
806     }
807     else if( aSender == myRefPointXMap[ aPointType ] ||
808              aSender == myRefPointYMap[ aPointType ] )
809     {
810       bool anIsY = aSender == myRefPointYMap[ aPointType ];
811       emit pointCoordChanged( true, aPointType, anIsY, theValue );
812     }
813   }
814 }
815
816 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged()
817 {
818   QObject* aSender = sender();
819   if( !aSender )
820     return;
821
822   for( int aPointType = HYDROGUI_PrsImage::PointA;
823        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
824   {
825     if( aSender == myPointXDegMap[ aPointType ] ||
826         aSender == myPointYDegMap[ aPointType ] ||
827         aSender == myPointXMinMap[ aPointType ] ||
828         aSender == myPointYMinMap[ aPointType ] ||
829         aSender == myPointXSecMap[ aPointType ] ||
830         aSender == myPointYSecMap[ aPointType ] )
831     {
832       onGeodesicCoordChanged( aPointType );
833       return;
834     }
835   }
836 }
837
838 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged( const int thePointType )
839 {
840   bool anIsOk[6];
841   for( int i = 0; i < 6; i++ )
842     anIsOk[ i ] = true;
843
844   int aXDeg = myPointXDegMap[ thePointType ]->text().toInt( &anIsOk[0] );
845   int aYDeg = myPointYDegMap[ thePointType ]->text().toInt( &anIsOk[1] );
846   int aXMin = myPointXMinMap[ thePointType ]->text().toInt( &anIsOk[2] );
847   int aYMin = myPointYMinMap[ thePointType ]->text().toInt( &anIsOk[3] );
848   double aXSec = myPointXSecMap[ thePointType ]->text().toDouble( &anIsOk[4] );
849   double aYSec = myPointYSecMap[ thePointType ]->text().toDouble( &anIsOk[5] );
850
851   for( int i = 0; i < 6; i++ )
852     if( !anIsOk[ i ] )
853       return;
854
855   double aLonDeg = 0, aLatDeg = 0;
856   HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aLonDeg );
857   HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aLatDeg );
858
859   double aXCart = 0, aYCart = 0;
860   HYDROData_Lambert93::toXY( aLatDeg, aLonDeg, aXCart, aYCart );
861
862   blockSignalsCartesian( true );
863
864   myCartPointXMap[ thePointType ]->setValue( aXCart );
865   myCartPointYMap[ thePointType ]->setValue( aYCart );
866
867   blockSignalsCartesian( false );
868 }
869
870 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged()
871 {
872   QObject* aSender = sender();
873   if( !aSender )
874     return;
875
876   for( int aPointType = HYDROGUI_PrsImage::PointA;
877        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
878   {
879     if( aSender == myCartPointXMap[ aPointType ] ||
880         aSender == myCartPointYMap[ aPointType ] )
881     {
882       onCartesianCoordChanged( aPointType );
883       return;
884     }
885   }
886 }
887
888 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType )
889 {
890   bool anIsOk[2];
891   for( int i = 0; i < 2; i++ )
892     anIsOk[ i ] = true;
893
894   double aXCart = myCartPointXMap[ thePointType ]->text().toDouble( &anIsOk[0] );
895   double aYCart = myCartPointYMap[ thePointType ]->text().toDouble( &anIsOk[1] );
896
897   for( int i = 0; i < 2; i++ )
898     if( !anIsOk[ i ] )
899       return;
900
901   double aLonDeg = 0, aLatDeg = 0;
902   HYDROData_Lambert93::toGeo( aXCart, aYCart, aLatDeg, aLonDeg );
903
904   int aXDeg = 0, aYDeg = 0;
905   int aXMin = 0, aYMin = 0;
906   double aXSec = 0, aYSec = 0;
907   HYDROData_Lambert93::degToDMS( aLonDeg, aXDeg, aXMin, aXSec );
908   HYDROData_Lambert93::degToDMS( aLatDeg, aYDeg, aYMin, aYSec );
909
910   blockSignalsGeodesic( true );
911
912   myPointXDegMap[ thePointType ]->setValue( aXDeg );
913   myPointYDegMap[ thePointType ]->setValue( aYDeg );
914   myPointXMinMap[ thePointType ]->setValue( aXMin );
915   myPointYMinMap[ thePointType ]->setValue( aYMin );
916   myPointXSecMap[ thePointType ]->setValue( aXSec );
917   myPointYSecMap[ thePointType ]->setValue( aYSec );
918
919   blockSignalsGeodesic( false );
920 }
921
922 void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
923 {
924   if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
925   {
926     QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
927     aSpin->setValue( aSpin->minimum() );
928   }
929   else if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
930   {
931     QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( theSpin );
932     aDblSpin->setValue( aDblSpin->minimum() );
933   }
934
935   theSpin->clear();
936 }
937
938 bool HYDROGUI_ImportImageDlg::blockSignalsPoints( const bool theState )
939 {
940   bool isBlocked = false;
941   for( int aPointType = HYDROGUI_PrsImage::PointA;
942        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
943   {
944     isBlocked = 
945     myPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
946     myPointYMap[ aPointType ]->blockSignals( theState );
947
948     myRefPointXMap[ aPointType ]->blockSignals( theState );
949     myRefPointYMap[ aPointType ]->blockSignals( theState );
950   }
951   return isBlocked;
952 }
953
954 bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
955 {
956   bool isBlocked = false;
957   for( int aPointType = HYDROGUI_PrsImage::PointA;
958        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
959   {
960     isBlocked = 
961     myPointXDegMap[ aPointType ]->blockSignals( theState ) || isBlocked;
962     myPointXMinMap[ aPointType ]->blockSignals( theState );
963     myPointXSecMap[ aPointType ]->blockSignals( theState );
964     myPointYDegMap[ aPointType ]->blockSignals( theState );
965     myPointYMinMap[ aPointType ]->blockSignals( theState );
966     myPointYSecMap[ aPointType ]->blockSignals( theState );
967   }
968   return isBlocked;
969 }
970
971 bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState )
972 {
973   bool isBlocked = false;
974   for( int aPointType = HYDROGUI_PrsImage::PointA;
975        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
976   {
977     isBlocked = 
978     myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
979     myCartPointYMap[ aPointType ]->blockSignals( theState );
980   }
981   return isBlocked;
982 }