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