Salome HOME
Copy/paste functionality for images, polylines and calculation cases.
[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
28 #include <SUIT_FileDlg.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SUIT_Session.h>
31
32 #include <QtxDoubleSpinBox.h>
33 #include <QtxIntSpinBox.h>
34
35 #include <QButtonGroup>
36 #include <QComboBox>
37 #include <QGroupBox>
38 #include <QLabel>
39 #include <QLayout>
40 #include <QLineEdit>
41 #include <QPainter>
42 #include <QPicture>
43 #include <QPushButton>
44 #include <QRadioButton>
45 #include <QToolButton>
46
47 HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle )
48 : HYDROGUI_InputPanel( theModule, theTitle )
49 {
50   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
51
52   // Import image from file
53   myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) );
54
55   QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
56
57   myFileName = new QLineEdit( myFileNameGroup );
58   myFileName->setReadOnly( true );
59
60   QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup );
61   aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
62
63   QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
64   aFileNameLayout->setMargin( 5 );
65   aFileNameLayout->setSpacing( 5 );
66   aFileNameLayout->addWidget( aFileNameLabel );
67   aFileNameLayout->addWidget( myFileName );
68   aFileNameLayout->addWidget( aBrowseBtn );
69
70   // Image name
71   myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) );
72
73   QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
74   myImageName = new QLineEdit( myImageNameGroup );
75
76   QBoxLayout* anImageNameLayout = new QHBoxLayout( myImageNameGroup );
77   anImageNameLayout->setMargin( 5 );
78   anImageNameLayout->setSpacing( 5 );
79   anImageNameLayout->addWidget( anImageNameLabel );
80   anImageNameLayout->addWidget( myImageName );
81
82   // Transform image
83   myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ) );
84
85   // Make a pixmap for arrow
86   QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) );
87
88   QPicture anArrowPicture;
89   anArrowPicture.setBoundingRect( QRect( QPoint( 0, 0 ), anArrowPixmap.size() ) );
90
91   QPainter aPainter;
92   aPainter.begin( &anArrowPicture );
93   aPainter.drawPixmap( 0, 0, anArrowPixmap );
94   aPainter.end();
95
96   QRadioButton* aManualBtn = new QRadioButton( tr( "MANUALLY" ), myTransformGroup );
97   QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup );
98
99   myModeGroup = new QButtonGroup( myTransformGroup );
100   myModeGroup->addButton( aManualBtn, Manual );
101   myModeGroup->addButton( aRefImageBtn, RefImage );
102
103   QBoxLayout* aModeLayout = new QHBoxLayout();
104   aModeLayout->setMargin( 0 );
105   aModeLayout->setSpacing( 5 );
106   aModeLayout->addWidget( aManualBtn );
107   aModeLayout->addWidget( aRefImageBtn );
108
109   myRefImageWg = new QWidget( myTransformGroup );
110   QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE" ), myRefImageWg );
111   myRefImage = new QComboBox( myRefImageWg );
112
113   QBoxLayout* aRefImageLayout = new QHBoxLayout( myRefImageWg );
114   aRefImageLayout->setMargin( 0 );
115   aRefImageLayout->setSpacing( 5 );
116   aRefImageLayout->addWidget( aRefImageLabel );
117   aRefImageLayout->addWidget( myRefImage );
118   aRefImageLayout->setStretch( 1, 1 );
119
120   QGridLayout* aTransformLayout = new QGridLayout( myTransformGroup );
121   aTransformLayout->setMargin( 5 );
122   aTransformLayout->setSpacing( 5 );
123   aTransformLayout->addLayout( aModeLayout, 0, 0, 1, 9 );
124   aTransformLayout->addWidget( myRefImageWg, 1, 0, 1, 9 );
125
126   for( int aPointType = HYDROGUI_PrsImage::PointA;
127        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
128   {
129     QString aPointStr;
130     switch( aPointType )
131     {
132       case HYDROGUI_PrsImage::PointA: aPointStr = tr( "ACTIVATE_POINT_A_SELECTION" ); break;
133       case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break;
134       case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break;
135     }
136     QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup );
137     aPointBtn->setCheckable( true );
138
139     QLabel* aPointXLabel = new QLabel( "X", myTransformGroup );
140     QLabel* aPointYLabel = new QLabel( "Y", myTransformGroup );
141
142     QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
143     QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
144
145     QLabel* aPointArrowLabel = new QLabel( myTransformGroup );
146     aPointArrowLabel->setPicture( anArrowPicture );
147
148     QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), myTransformGroup );
149     QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), myTransformGroup );
150     QLabel* aPointXMinLabel = new QLabel( "'", myTransformGroup );
151     QLabel* aPointYMinLabel = new QLabel( "'", myTransformGroup );
152     QLabel* aPointXSecLabel = new QLabel( "\"", myTransformGroup );
153     QLabel* aPointYSecLabel = new QLabel( "\"", myTransformGroup );
154     myLambertLabels << aPointXDegLabel << aPointYDegLabel
155                     << aPointXMinLabel << aPointYMinLabel
156                     << aPointXSecLabel << aPointYSecLabel;
157
158     QtxIntSpinBox* aPointXDeg = new QtxIntSpinBox( -180, 180, 1, myTransformGroup );
159     QtxIntSpinBox* aPointYDeg = new QtxIntSpinBox( -90, 90, 1, myTransformGroup );
160     QtxIntSpinBox* aPointXMin = new QtxIntSpinBox( 0, 59, 1, myTransformGroup );
161     QtxIntSpinBox* aPointYMin = new QtxIntSpinBox( 0, 59, 1, myTransformGroup );
162     QtxDoubleSpinBox* aPointXSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, myTransformGroup );
163     QtxDoubleSpinBox* aPointYSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, myTransformGroup );
164
165     QtxIntSpinBox* aRefPointX = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
166     QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later
167
168     int aRow = 4 * aPointType + 2;
169     aTransformLayout->addWidget( aPointBtn,        aRow,     0, 1, 9 );
170
171     aTransformLayout->addWidget( aPointXLabel,     aRow + 1, 0 );
172     aTransformLayout->addWidget( aPointX,          aRow + 1, 1 );
173     aTransformLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 );
174     aTransformLayout->addWidget( aPointXDeg,       aRow + 1, 3 );
175     aTransformLayout->addWidget( aPointXDegLabel,  aRow + 1, 4 );
176     aTransformLayout->addWidget( aPointXMin,       aRow + 1, 5 );
177     aTransformLayout->addWidget( aPointXMinLabel,  aRow + 1, 6 );
178     aTransformLayout->addWidget( aPointXSec,       aRow + 1, 7 );
179     aTransformLayout->addWidget( aPointXSecLabel,  aRow + 1, 8 );
180
181     aTransformLayout->addWidget( aRefPointX,       aRow + 1, 3, 1, 6 );
182
183     aTransformLayout->addWidget( aPointYLabel,     aRow + 2, 0 );
184     aTransformLayout->addWidget( aPointY,          aRow + 2, 1 );
185     aTransformLayout->addWidget( aPointYDeg,       aRow + 2, 3 );
186     aTransformLayout->addWidget( aPointYDegLabel,  aRow + 2, 4 );
187     aTransformLayout->addWidget( aPointYMin,       aRow + 2, 5 );
188     aTransformLayout->addWidget( aPointYMinLabel,  aRow + 2, 6 );
189     aTransformLayout->addWidget( aPointYSec,       aRow + 2, 7 );
190     aTransformLayout->addWidget( aPointYSecLabel,  aRow + 2, 8 );
191
192     aTransformLayout->addWidget( aRefPointY,       aRow + 2, 3, 1, 6 );
193
194     if( aPointType != HYDROGUI_PrsImage::PointC )
195     {
196       QFrame* aLine = new QFrame( myTransformGroup );
197       aLine->setFrameShape( QFrame::HLine );
198       aLine->setFrameShadow( QFrame::Sunken );
199       aTransformLayout->addWidget( aLine, aRow + 3, 0, 1, 9 );
200     }
201
202     myPointBtnMap[ aPointType ] = aPointBtn;
203     myPointXMap[ aPointType ] = aPointX;
204     myPointYMap[ aPointType ] = aPointY;
205     myPointXDegMap[ aPointType ] = aPointXDeg;
206     myPointYDegMap[ aPointType ] = aPointYDeg;
207     myPointXMinMap[ aPointType ] = aPointXMin;
208     myPointYMinMap[ aPointType ] = aPointYMin;
209     myPointXSecMap[ aPointType ] = aPointXSec;
210     myPointYSecMap[ aPointType ] = aPointYSec;
211
212     myRefPointXMap[ aPointType ] = aRefPointX;
213     myRefPointYMap[ aPointType ] = aRefPointY;
214
215     connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
216
217     connect( aPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
218     connect( aPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
219     connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
220     connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
221   }
222   aTransformLayout->setColumnStretch( 1, 1 ); // double
223   aTransformLayout->setColumnStretch( 3, 1 ); // degrees
224   aTransformLayout->setColumnStretch( 5, 1 ); // minutes
225   aTransformLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
226
227   // Common
228   addWidget( myFileNameGroup );
229   addWidget( myImageNameGroup );
230   addWidget( myTransformGroup );
231   addStretch();
232
233   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
234
235   connect( myModeGroup, SIGNAL( buttonClicked( int ) ),
236            this, SLOT( onModeActivated( int ) ) );
237
238   connect( myRefImage, SIGNAL( activated( const QString& ) ),
239            this, SLOT( onRefImageActivated( const QString& ) ) );
240
241   onModeActivated( Manual );
242
243   setMinimumWidth( 350 );
244 }
245
246 HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
247 {
248 }
249
250 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
251 {
252   myFileNameGroup->setVisible( !theIsEdit );
253   myImageNameGroup->setEnabled( theIsEdit );
254   myTransformGroup->setEnabled( theIsEdit );
255 }
256
257 void HYDROGUI_ImportImageDlg::reset()
258 {
259   myFileName->clear();
260   myImageName->clear();
261   myImageNameGroup->setEnabled( false );
262   for( int aPointType = HYDROGUI_PrsImage::PointA;
263        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
264   {
265     QPushButton* aBtn = myPointBtnMap[ aPointType ];
266     bool anIsBlocked = aBtn->blockSignals( true );
267     aBtn->setChecked( false );
268     aBtn->blockSignals( anIsBlocked );
269
270     myPointXMap[ aPointType ]->clear();
271     myPointYMap[ aPointType ]->clear();
272     myPointXDegMap[ aPointType ]->clear();
273     myPointYDegMap[ aPointType ]->clear();
274     myPointXMinMap[ aPointType ]->clear();
275     myPointYMinMap[ aPointType ]->clear();
276     myPointXSecMap[ aPointType ]->clear();
277     myPointYSecMap[ aPointType ]->clear();
278
279     myRefPointXMap[ aPointType ]->clear();
280     myRefPointYMap[ aPointType ]->clear();
281   }
282   myTransformGroup->setEnabled( false );
283   myModeGroup->button( Manual )->setChecked( true );
284   myRefImage->clear();
285
286   onModeActivated( Manual );
287
288   myPrsPointDataList.clear();
289 }
290
291 void HYDROGUI_ImportImageDlg::setImageName( const QString& theName )
292 {
293   myImageName->setText( theName );
294 }
295
296 QString HYDROGUI_ImportImageDlg::getImageName() const
297 {
298   return myImageName->text();
299 }
300
301 QString HYDROGUI_ImportImageDlg::getFileName() const
302 {
303   return myFileName->text();
304 }
305
306 void HYDROGUI_ImportImageDlg::setImageSize( const QSize& theSize,
307                                             const bool theIsRefImage )
308 {
309   int aWidth = theSize.width();
310   int aHeight = theSize.height();
311   for( int aPointType = HYDROGUI_PrsImage::PointA;
312        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
313   {
314     if( theIsRefImage )
315     {
316       myRefPointXMap[ aPointType ]->setRange( 0, aWidth );
317       myRefPointYMap[ aPointType ]->setRange( 0, aHeight );
318     }
319     else
320     {
321       myPointXMap[ aPointType ]->setRange( 0, aWidth );
322       myPointYMap[ aPointType ]->setRange( 0, aHeight );
323     }
324   }
325 }
326
327 int HYDROGUI_ImportImageDlg::getTransformationMode() const
328 {
329   return myModeGroup->button( Manual )->isChecked() ? Manual : RefImage;
330 }
331
332 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
333                                                         const bool theIsOnlyInput,
334                                                         const bool theIsRefImage )
335 {
336   for( int aPointType = HYDROGUI_PrsImage::PointA;
337        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
338   {
339     if( theMap.contains( aPointType ) )
340     {
341       const TransformationData& aData = theMap[ aPointType ];
342
343       QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
344       QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
345       aPointX->setValue( aData.first.x() );
346       aPointY->setValue( aData.first.y() );
347
348       if( !theIsOnlyInput && !theIsRefImage )
349       {
350         QPointF aPoint = aData.second;
351         int aXDeg = 0, aYDeg = 0;
352         int aXMin = 0, aYMin = 0;
353         double aXSec = 0, aYSec = 0;
354         HYDROGUI_Tool::DoubleToLambert( aPoint.x(), aXDeg, aXMin, aXSec );
355         HYDROGUI_Tool::DoubleToLambert( aPoint.y(), aYDeg, aYMin, aYSec );
356
357         myPointXDegMap[ aPointType ]->setValue( aXDeg );
358         myPointYDegMap[ aPointType ]->setValue( aYDeg );
359         myPointXMinMap[ aPointType ]->setValue( aXMin );
360         myPointYMinMap[ aPointType ]->setValue( aYMin );
361         myPointXSecMap[ aPointType ]->setValue( aXSec );
362         myPointYSecMap[ aPointType ]->setValue( aYSec );
363       }
364     }
365   }
366 }
367
368 bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap,
369                                                         const bool theIsRefImage ) const
370 {
371   theMap.clear();
372   for( int aPointType = HYDROGUI_PrsImage::PointA;
373        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
374   {
375     bool anIsOk[8];
376     for( int i = 0; i < 8; i++ )
377       anIsOk[ i ] = true;
378
379     QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
380     QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
381     int aX1 = aPointX->text().toInt( &anIsOk[0] );
382     int aY1 = aPointY->text().toInt( &anIsOk[1] );
383
384     int aXDeg = 0, aYDeg = 0;
385     int aXMin = 0, aYMin = 0;
386     double aXSec = 0, aYSec = 0;
387     if( !theIsRefImage )
388     {
389       aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] );
390       aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] );
391       aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] );
392       aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] );
393       aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] );
394       aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] );
395     }
396
397     for( int i = 0; i < 8; i++ )
398       if( !anIsOk[ i ] )
399         return false;
400
401     double aX2 = 0, aY2 = 0;
402     HYDROGUI_Tool::LambertToDouble( aXDeg, aXMin, aXSec, aX2 );
403     HYDROGUI_Tool::LambertToDouble( aYDeg, aYMin, aYSec, aY2 );
404
405     TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ) );
406     theMap[ aPointType ] = aData;
407   }
408   return true;
409 }
410
411 void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
412 {
413   myPrsPointDataList = theList;
414
415   if( !myPrsPointDataList.isEmpty() )
416   {
417     myModeGroup->button( RefImage )->setEnabled( true );
418
419     myRefImage->clear();
420     myRefImage->addItem( "" ); // first empty item
421
422     PrsPointDataListIterator anIter( myPrsPointDataList );
423     while( anIter.hasNext() )
424       myRefImage->addItem( anIter.next().first );
425   }
426   else
427     myModeGroup->button( RefImage )->setEnabled( false );
428 }
429
430 void HYDROGUI_ImportImageDlg::initializePointSelection()
431 {
432   myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
433
434   // ouv: tmp
435   myPointXDegMap[ HYDROGUI_PrsImage::PointA ]->setValue( 50 );
436   myPointXMinMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 );
437   myPointXSecMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 );
438   myPointYDegMap[ HYDROGUI_PrsImage::PointA ]->setValue( 50 );
439   myPointYMinMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 );
440   myPointYSecMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 );
441
442   myPointXDegMap[ HYDROGUI_PrsImage::PointB ]->setValue( 50 );
443   myPointXMinMap[ HYDROGUI_PrsImage::PointB ]->setValue( 1 );
444   myPointXSecMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 );
445   myPointYDegMap[ HYDROGUI_PrsImage::PointB ]->setValue( 50 );
446   myPointYMinMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 );
447   myPointYSecMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 );
448
449   myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setValue( 50 );
450   myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 );
451   myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 );
452   myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setValue( 50 );
453   myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setValue( 1 );
454   myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 );
455 }
456
457 void HYDROGUI_ImportImageDlg::onBrowse()
458 {
459   QString aFilter( tr( "IMAGE_FILTER" ) );
460   QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
461   //QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp";
462   if( !aFileName.isEmpty() )
463   {
464     QImage anImage( aFileName );
465     if( !anImage.isNull() )
466     {
467       myFileName->setText( aFileName );
468       emit createPreview( anImage );
469       myImageNameGroup->setEnabled( true );
470       myTransformGroup->setEnabled( true );
471     }
472   }
473 }
474
475 void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
476 {
477   bool anIsManual = theMode == Manual;
478   for( int aPointType = HYDROGUI_PrsImage::PointA;
479        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
480   {
481     myRefImageWg->setVisible( !anIsManual );
482
483     myPointXDegMap[ aPointType ]->setVisible( anIsManual );
484     myPointYDegMap[ aPointType ]->setVisible( anIsManual );
485     myPointXMinMap[ aPointType ]->setVisible( anIsManual );
486     myPointYMinMap[ aPointType ]->setVisible( anIsManual );
487     myPointXSecMap[ aPointType ]->setVisible( anIsManual );
488     myPointYSecMap[ aPointType ]->setVisible( anIsManual );
489
490     myRefPointXMap[ aPointType ]->setVisible( !anIsManual );
491     myRefPointYMap[ aPointType ]->setVisible( !anIsManual );
492   }
493
494   QListIterator<QLabel*> anIter( myLambertLabels );
495   while( anIter.hasNext() )
496     anIter.next()->setVisible( anIsManual );
497 }
498
499 void HYDROGUI_ImportImageDlg::onRefImageActivated( const QString& theName )
500 {
501   emit refImageActivated( theName );
502 }
503
504 void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState )
505 {
506   int aPointType = HYDROGUI_PrsImage::None;
507   if( theState )
508   {
509     QMapIterator<int, QPushButton*> anIter( myPointBtnMap );
510     while( anIter.hasNext() )
511     {
512       int aBtnPointType = anIter.next().key();
513       QPushButton* aBtn = anIter.value();
514       if( aBtn == sender() )
515         aPointType = aBtnPointType;
516       else
517       {
518         bool anIsBlocked = aBtn->blockSignals( true );
519         aBtn->setChecked( false );
520         aBtn->blockSignals( anIsBlocked );
521       }
522     }
523   }
524   emit activatePointSelection( aPointType );
525 }
526
527 void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue )
528 {
529   QObject* aSender = sender();
530   if( !aSender )
531     return;
532
533   for( int aPointType = HYDROGUI_PrsImage::PointA;
534        aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
535   {
536     if( aSender == myPointXMap[ aPointType ] ||
537         aSender == myPointYMap[ aPointType ] )
538     {
539       bool anIsY = aSender == myPointYMap[ aPointType ];
540       emit pointCoordChanged( false, aPointType, anIsY, theValue );
541     }
542     else if( aSender == myRefPointXMap[ aPointType ] ||
543              aSender == myRefPointYMap[ aPointType ] )
544     {
545       bool anIsY = aSender == myRefPointYMap[ aPointType ];
546       emit pointCoordChanged( true, aPointType, anIsY, theValue );
547     }
548   }
549 }