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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ImportImageDlg.h"
21 #include "HYDROGUI_PrsImage.h"
22 #include "HYDROGUI_Tool.h"
23 #include "HYDROGUI_Module.h"
25 #include <HYDROData_Lambert93.h>
26 #include <HYDROData_Image.h>
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>
35 #include <QtxDoubleSpinBox.h>
36 #include <QtxIntSpinBox.h>
38 #include <QButtonGroup>
46 #include <QPushButton>
47 #include <QRadioButton>
48 #include <QToolButton>
51 HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle )
52 : HYDROGUI_InputPanel( theModule, theTitle ),
53 myIsInitialized( false )
55 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
57 // Import image from file
58 myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this );
60 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
62 myFileName = new QLineEdit( myFileNameGroup );
63 myFileName->setReadOnly( true );
65 myBrowseBtn = new QToolButton( myFileNameGroup );
66 myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
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 );
76 myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this );
78 QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
79 myImageName = new QLineEdit( myImageNameGroup );
81 QBoxLayout* anImageNameLayout = new QHBoxLayout( myImageNameGroup );
82 anImageNameLayout->setMargin( 5 );
83 anImageNameLayout->setSpacing( 5 );
84 anImageNameLayout->addWidget( anImageNameLabel );
85 anImageNameLayout->addWidget( myImageName );
88 myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this );
90 // Make a pixmap for arrow
91 QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) );
93 QPicture anArrowPicture;
94 anArrowPicture.setBoundingRect( QRect( QPoint( 0, 0 ), anArrowPixmap.size() ) );
97 aPainter.begin( &anArrowPicture );
98 aPainter.drawPixmap( 0, 0, anArrowPixmap );
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 );
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 );
112 myRefImage = new QComboBox( myTransformGroup );
114 QVBoxLayout* aTransformLayout = new QVBoxLayout( myTransformGroup );
115 aTransformLayout->setMargin( 5 );
116 aTransformLayout->setSpacing( 5 );
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 );
128 aTransformLayout->addLayout( aModeLayout );
130 // Manual input widget
131 QWidget* aManualInputGroup = new QWidget( myTransformGroup );
132 QGridLayout* aManualInputLayout = new QGridLayout( aManualInputGroup );
133 aManualInputLayout->setMargin( 5 );
134 aManualInputLayout->setSpacing( 5 );
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 );
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 );
146 for( int aPointType = HYDROGUI_PrsImage::PointA;
147 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
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;
156 QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup );
157 aPointBtn->setCheckable( true );
159 QLabel* aPointXLabel = new QLabel( "X", aManualInputGroup );
160 QLabel* aPointYLabel = new QLabel( "Y", aManualInputGroup );
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
165 QLabel* aPointArrowLabel = new QLabel( aManualInputGroup );
166 aPointArrowLabel->setPicture( anArrowPicture );
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;
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 );
188 QtxDoubleSpinBox* aCartPointX = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
189 QtxDoubleSpinBox* aCartPointY = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
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
194 int aRow = 4 * aPointType;
195 if ( aPointType == HYDROGUI_PrsImage::PointC )
197 myPointCEnabler = new QCheckBox( aManualInputGroup );
198 aManualInputLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter );
199 aManualInputLayout->addWidget( aPointBtn, aRow, 2, 1, 8 );
203 aManualInputLayout->addWidget( aPointBtn, aRow, 0, 1, 10 );
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 );
217 aManualInputLayout->addWidget( aCartPointX, aRow + 1, 3, 1, 6 );
218 aManualInputLayout->addWidget( aRefPointX, aRow + 1, 3, 1, 6 );
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 );
230 aManualInputLayout->addWidget( aCartPointY, aRow + 2, 3, 1, 6 );
231 aManualInputLayout->addWidget( aRefPointY, aRow + 2, 3, 1, 6 );
233 if( aPointType != HYDROGUI_PrsImage::PointC )
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 );
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;
251 myCartPointXMap[ aPointType ] = aCartPointX;
252 myCartPointYMap[ aPointType ] = aCartPointY;
254 myRefPointXMap[ aPointType ] = aRefPointX;
255 myRefPointYMap[ aPointType ] = aRefPointY;
257 connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
259 connect( aPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
260 connect( aPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
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() ) );
269 connect( aCartPointX, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
270 connect( aCartPointY, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
272 connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
273 connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
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 ) ) );
291 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SLOT( onSetCIsUsed( bool ) ) );
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)
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 );
304 QLabel* aGeoFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFromFileInputGroup );
306 myGeoFileName = new QLineEdit( aFromFileInputGroup );
307 myGeoFileName->setReadOnly( true );
309 QToolButton* aGeoBrowseBtn = new QToolButton( aFromFileInputGroup );
310 aGeoBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
312 aFromFileInputLayout->addWidget( aGeoFileNameLabel );
313 aFromFileInputLayout->addWidget( myGeoFileName );
314 aFromFileInputLayout->addWidget( aGeoBrowseBtn );
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 ) ) );
333 aTransformLayout->addWidget( aManualInputGroup );
334 aTransformLayout->addWidget( aFromFileInputGroup );
337 addWidget( myFileNameGroup );
338 addWidget( myImageNameGroup );
339 addWidget( myTransformGroup );
342 connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
344 connect( myModeGroup, SIGNAL( buttonClicked( int ) ),
345 this, SLOT( onModeActivated( int ) ) );
347 connect( aGeoBrowseBtn, SIGNAL( clicked() ), this, SLOT( onGeoBrowse() ) );
349 connect( myRefImage, SIGNAL( activated( const QString& ) ),
350 this, SLOT( onRefImageActivated( const QString& ) ) );
352 //setTransformationMode( HYDROData_Image::ManualCartesian );
354 setMinimumWidth( 350 );
357 HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
361 void HYDROGUI_ImportImageDlg::onSetCIsUsed( bool theCIsUsed )
363 if ( !theCIsUsed && myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->isChecked() )
365 // Turn on point A selection if point C selection has been activated and we disable point C.
366 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->toggle();
368 emit setCIsUsed( theCIsUsed );
371 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
373 myFileNameGroup->setVisible( !theIsEdit );
374 myImageNameGroup->setEnabled( theIsEdit );
375 myTransformGroup->setEnabled( theIsEdit );
378 void HYDROGUI_ImportImageDlg::reset()
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++ )
390 QPushButton* aBtn = myPointBtnMap[ aPointType ];
391 bool anIsBlocked = aBtn->blockSignals( true );
392 aBtn->setChecked( false );
393 aBtn->blockSignals( anIsBlocked );
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 ] );
404 clearSpins( myRefPointXMap[ aPointType ] );
405 clearSpins( myRefPointYMap[ aPointType ] );
407 clearSpins( myCartPointXMap[ aPointType ] );
408 clearSpins( myCartPointYMap[ aPointType ] );
410 blockSignalsPoints( isPBlocked );
411 blockSignalsGeodesic( isGBlocked );
412 blockSignalsCartesian( isCBlocked );
414 // Emulate turning off C point usage
415 myPointCEnabler->blockSignals( true );
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 );
433 myPointCEnabler->blockSignals( false );
435 myTransformGroup->setEnabled( false );
438 setTransformationMode( HYDROData_Image::ManualCartesian );
440 myPrsPointDataList.clear();
442 myIsInitialized = false;
445 void HYDROGUI_ImportImageDlg::setImageName( const QString& theName )
447 myImageName->setText( theName );
450 QString HYDROGUI_ImportImageDlg::getImageName() const
452 return myImageName->text();
455 void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName )
457 myRefImage->setCurrentIndex( myRefImage->findText( theName ) );
460 QString HYDROGUI_ImportImageDlg::getRefImageName() const
462 return myRefImage->currentText();
465 QString HYDROGUI_ImportImageDlg::getFileName() const
467 return myFileName->text();
470 void HYDROGUI_ImportImageDlg::setFileName( const QString& theName )
472 myFileName->setText( theName );
473 myImageNameGroup->setEnabled( true );
474 myTransformGroup->setEnabled( true );
477 QString HYDROGUI_ImportImageDlg::getGeoreferencementFileName() const
479 return myGeoFileName->text();
482 void HYDROGUI_ImportImageDlg::setImageSize( const QSize& theSize,
483 const bool theIsRefImage )
485 int aWidth = theSize.width();
486 int aHeight = theSize.height();
487 for( int aPointType = HYDROGUI_PrsImage::PointA;
488 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
492 myRefPointXMap[ aPointType ]->setRange( 0, aWidth );
493 myRefPointYMap[ aPointType ]->setRange( 0, aHeight );
497 myPointXMap[ aPointType ]->setRange( 0, aWidth );
498 myPointYMap[ aPointType ]->setRange( 0, aHeight );
503 void HYDROGUI_ImportImageDlg::setTransformationMode( const int theMode )
505 myModeGroup->button( theMode )->setChecked( true );
506 onModeActivated( theMode );
509 int HYDROGUI_ImportImageDlg::getTransformationMode() const
511 return myModeGroup->checkedId();
514 void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints )
516 myPointCEnabler->setChecked( !theIsByTwoPoints );
519 bool HYDROGUI_ImportImageDlg::isByTwoPoints() const
521 return !myPointCEnabler->isChecked();
524 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
525 const bool theIsOnlyInput,
526 const bool theIsRefImage )
528 blockSignalsGeodesic( true );
529 blockSignalsCartesian( true );
530 for( int aPointType = HYDROGUI_PrsImage::PointA;
531 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
533 if( theMap.contains( aPointType ) )
535 const TransformationData& aData = theMap[ aPointType ];
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() );
542 if( !theIsOnlyInput && !theIsRefImage )
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 );
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 );
558 QPointF aCPoint = aData.CartesianPoint;
559 myCartPointXMap[ aPointType ]->setValue( aCPoint.x() );
560 myCartPointYMap[ aPointType ]->setValue( aCPoint.y() );
564 blockSignalsGeodesic( false );
565 blockSignalsCartesian( false );
568 bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap,
569 const bool theIsRefImage ) const
572 for( int aPointType = HYDROGUI_PrsImage::PointA;
573 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
576 for( int i = 0; i < 10; i++ )
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] );
584 int aXDeg = 0, aYDeg = 0;
585 int aXMin = 0, aYMin = 0;
586 double aXSec = 0, aYSec = 0;
587 double aXCart = 0, aYCart = 0;
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] );
597 aXCart = myCartPointXMap[ aPointType ]->text().toDouble( &anIsOk[8] );
598 aYCart = myCartPointYMap[ aPointType ]->text().toDouble( &anIsOk[9] );
601 for( int i = 0; i < 10; i++ )
605 double aX2 = 0, aY2 = 0;
606 HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aX2 );
607 HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aY2 );
609 TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ), QPointF( aXCart, aYCart ) );
610 theMap[ aPointType ] = aData;
615 void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
617 myPrsPointDataList = theList;
619 if( !myPrsPointDataList.isEmpty() )
621 myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true );
624 myRefImage->addItem( "" ); // first empty item
626 PrsPointDataListIterator anIter( myPrsPointDataList );
627 while( anIter.hasNext() )
628 myRefImage->addItem( anIter.next().first );
631 myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false );
634 void HYDROGUI_ImportImageDlg::initializePointSelection()
636 if( myIsInitialized )
639 myIsInitialized = true;
641 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
643 double aCartX0 = LAMBERT_X0;
644 double aCartY0 = LAMBERT_Y0;
646 blockSignalsCartesian( true );
648 myCartPointXMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartX0 );
649 myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + IMG_DELTA );
651 myCartPointXMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartX0 + IMG_DELTA );
652 myCartPointYMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartY0 + IMG_DELTA );
654 myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartX0 );
655 myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartY0 );
657 for( int aPointType = HYDROGUI_PrsImage::PointA;
658 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
659 onCartesianCoordChanged( aPointType );
661 blockSignalsCartesian( false );
664 void HYDROGUI_ImportImageDlg::ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo)
666 if( myIsInitialized )
669 myIsInitialized = true;
671 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
672 myPointBtnMap[ HYDROGUI_PrsImage::PointB ]->setChecked( true );
673 myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setChecked( true );
675 setByTwoPoints(false);
677 HYDROData_Image::ECW_CellUnits Units = theECW_FileInfo->myCellSizeUnits;
679 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Deg)
681 blockSignalsGeodesic( true );
682 double Xa, Ya, Xb, Yb, Xc, Yc;
683 Xa = theECW_FileInfo->myOriginX;
684 Ya = theECW_FileInfo->myOriginY;
685 Xb = theECW_FileInfo->myOriginX;
686 Yb = theECW_FileInfo->myOriginY + theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myYSize;
687 Xc = theECW_FileInfo->myOriginX + theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myXSize;
688 Yc = theECW_FileInfo->myOriginY;
690 int Deg = 0, Min = 0;
693 HYDROData_Lambert93::degToDMS( Xa, Deg, Min, Sec );
694 myPointXDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
695 myPointXMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
696 myPointXSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
697 HYDROData_Lambert93::degToDMS( Ya, Deg, Min, Sec );
698 myPointYDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
699 myPointYMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
700 myPointYSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
702 HYDROData_Lambert93::degToDMS( Xb, Deg, Min, Sec );
703 myPointXDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
704 myPointXMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
705 myPointXSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
706 HYDROData_Lambert93::degToDMS( Yb, Deg, Min, Sec );
707 myPointYDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
708 myPointYMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
709 myPointYSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
711 HYDROData_Lambert93::degToDMS( Xc, Deg, Min, Sec );
712 myPointXDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
713 myPointXMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
714 myPointXSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
715 HYDROData_Lambert93::degToDMS( Yc, Deg, Min, Sec );
716 myPointYDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
717 myPointYMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
718 myPointYSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
720 for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
721 onGeodesicCoordChanged( aPointType );
722 blockSignalsGeodesic( false );
723 setTransformationMode( HYDROData_Image::ManualGeodesic );
725 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Meters ||
726 Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet )
729 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet)
730 Coeff = 0.3048; //feets
731 blockSignalsCartesian( true );
732 double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, X3 = 0, Y3 = 0;
733 X1 = theECW_FileInfo->myOriginX;
734 Y1 = theECW_FileInfo->myOriginY;
735 X2 = theECW_FileInfo->myOriginX;
736 Y2 = theECW_FileInfo->myOriginY + Coeff * theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myXSize;
737 X3 = theECW_FileInfo->myOriginX + Coeff * theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myYSize;
738 Y3 = theECW_FileInfo->myOriginY;
740 //extract to A-point (top-left), B-point (bottom-left), C-Point (top-right)
741 double Xa = 0, Ya = 0, Xb = 0, Yb = 0, Xc = 0, Yc = 0;
742 Xa = Min(X1, Min(X2, X3));
743 Ya = Max(Y1, Max(Y2, Y3));
744 Xb = Max(X1, Max(X2, X3));
747 Yc = Min(Y1, Min(Y2, Y3));
749 myCartPointXMap[HYDROGUI_PrsImage::PointA]->setValue(Xa);
750 myCartPointYMap[HYDROGUI_PrsImage::PointA]->setValue(Ya);
752 myCartPointXMap[HYDROGUI_PrsImage::PointB]->setValue(Xb);
753 myCartPointYMap[HYDROGUI_PrsImage::PointB]->setValue(Yb);
755 myCartPointXMap[HYDROGUI_PrsImage::PointC]->setValue(Xc);
756 myCartPointYMap[HYDROGUI_PrsImage::PointC]->setValue(Yc);
758 for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
759 onCartesianCoordChanged( aPointType );
760 blockSignalsCartesian( false );
761 setTransformationMode( HYDROData_Image::ManualCartesian );
766 HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
768 const QPoint& theLocalPoint,
769 const QPointF& theGlobalPoint )
771 TransformationData aResTrsfData;
772 aResTrsfData.ImagePoint = theLocalPoint;
774 double arx = theGlobalPoint.x();
775 double ary = theGlobalPoint.y();
776 if ( theMode == HYDROData_Image::ManualGeodesic )
778 // Geodesic to Cartesian
779 double aXCart = 0, aYCart = 0;
780 // Interpreting arY as attitude and arX as longitude
781 HYDROData_Lambert93::toXY( ary, arx, aXCart, aYCart );
783 aResTrsfData.GeodesicPoint = theGlobalPoint;
784 aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart );
786 else if ( theMode == HYDROData_Image::ManualCartesian )
788 // Cartesian to Geodesic
789 double aLonDeg = 0, aLatDeg = 0;
790 HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg );
792 aResTrsfData.CartesianPoint = theGlobalPoint;
793 aResTrsfData.GeodesicPoint = QPointF( aLonDeg, aLatDeg );
799 void HYDROGUI_ImportImageDlg::onBrowse()
801 QString aFilter( tr( "IMAGE_FILTER" ) );
802 QStringList aFileNamesList = SUIT_FileDlg::getOpenFileNames( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
803 emit filesSelected( aFileNamesList );
806 void HYDROGUI_ImportImageDlg::ActivateFile( const QString& theFileName, bool isEnableFilesChoice )
808 myFileName->setEnabled( isEnableFilesChoice );
809 myBrowseBtn->setEnabled( isEnableFilesChoice );
811 if( !theFileName.isEmpty() )
813 QFileInfo aFI( theFileName );
815 HYDROData_Image::ECW_FileInfo* theECWInfo = NULL;
816 if (aFI.completeSuffix().toLower() == "ecw")
818 theECWInfo = new HYDROData_Image::ECW_FileInfo;
819 HYDROData_Image::OpenECW(theFileName.toLatin1().data(), anImage, theECWInfo);
822 anImage = QImage(theFileName);
823 if( anImage.isNull() )
825 QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
826 QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ).
827 arg( theFileName ).arg( QFileInfo( theFileName ).suffix() );
828 SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage );
832 setFileName( theFileName );
834 emit createPreview( anImage, theECWInfo );
839 void HYDROGUI_ImportImageDlg::onGeoBrowse()
841 QString aFilter( tr( "IMAGE_GEOREFERENCEMENT_FILTER" ) );
842 QString aGeoFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_GEO_DATA_FROM_FILE" ), true );
843 if( !aGeoFileName.isEmpty() ) {
844 myGeoFileName->setText( aGeoFileName );
848 void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
850 bool anIsManualGeodesic = theMode == HYDROData_Image::ManualGeodesic;
851 bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian;
852 bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage;
854 myRefImage->setEnabled( anIsRefImage );
856 for( int aPointType = HYDROGUI_PrsImage::PointA;
857 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
859 myPointXDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
860 myPointYDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
861 myPointXMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
862 myPointYMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
863 myPointXSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
864 myPointYSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
866 myCartPointXMap[ aPointType ]->setVisible( anIsManualCartesian );
867 myCartPointYMap[ aPointType ]->setVisible( anIsManualCartesian );
869 myRefPointXMap[ aPointType ]->setVisible( anIsRefImage );
870 myRefPointYMap[ aPointType ]->setVisible( anIsRefImage );
873 QListIterator<QLabel*> anIter( myGeodesicLabels );
874 while( anIter.hasNext() )
875 anIter.next()->setVisible( anIsManualGeodesic );
877 emit modeActivated( theMode );
880 void HYDROGUI_ImportImageDlg::onRefImageActivated( const QString& theName )
882 emit refImageActivated( theName );
885 void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState )
887 int aPointType = HYDROGUI_PrsImage::None;
890 QMapIterator<int, QPushButton*> anIter( myPointBtnMap );
891 while( anIter.hasNext() )
893 int aBtnPointType = anIter.next().key();
894 QPushButton* aBtn = anIter.value();
895 if( aBtn == sender() )
896 aPointType = aBtnPointType;
899 bool anIsBlocked = aBtn->blockSignals( true );
900 aBtn->setChecked( false );
901 aBtn->blockSignals( anIsBlocked );
905 emit activatePointSelection( aPointType );
908 void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue )
910 QObject* aSender = sender();
914 for( int aPointType = HYDROGUI_PrsImage::PointA;
915 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
917 if( aSender == myPointXMap[ aPointType ] ||
918 aSender == myPointYMap[ aPointType ] )
920 bool anIsY = aSender == myPointYMap[ aPointType ];
921 emit pointCoordChanged( false, aPointType, anIsY, theValue );
923 else if( aSender == myRefPointXMap[ aPointType ] ||
924 aSender == myRefPointYMap[ aPointType ] )
926 bool anIsY = aSender == myRefPointYMap[ aPointType ];
927 emit pointCoordChanged( true, aPointType, anIsY, theValue );
932 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged()
934 QObject* aSender = sender();
938 for( int aPointType = HYDROGUI_PrsImage::PointA;
939 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
941 if( aSender == myPointXDegMap[ aPointType ] ||
942 aSender == myPointYDegMap[ aPointType ] ||
943 aSender == myPointXMinMap[ aPointType ] ||
944 aSender == myPointYMinMap[ aPointType ] ||
945 aSender == myPointXSecMap[ aPointType ] ||
946 aSender == myPointYSecMap[ aPointType ] )
948 onGeodesicCoordChanged( aPointType );
954 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged( const int thePointType )
957 for( int i = 0; i < 6; i++ )
960 int aXDeg = myPointXDegMap[ thePointType ]->text().toInt( &anIsOk[0] );
961 int aYDeg = myPointYDegMap[ thePointType ]->text().toInt( &anIsOk[1] );
962 int aXMin = myPointXMinMap[ thePointType ]->text().toInt( &anIsOk[2] );
963 int aYMin = myPointYMinMap[ thePointType ]->text().toInt( &anIsOk[3] );
964 double aXSec = myPointXSecMap[ thePointType ]->text().toDouble( &anIsOk[4] );
965 double aYSec = myPointYSecMap[ thePointType ]->text().toDouble( &anIsOk[5] );
967 for( int i = 0; i < 6; i++ )
971 double aLonDeg = 0, aLatDeg = 0;
972 HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aLonDeg );
973 HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aLatDeg );
975 double aXCart = 0, aYCart = 0;
976 HYDROData_Lambert93::toXY( aLatDeg, aLonDeg, aXCart, aYCart );
978 blockSignalsCartesian( true );
980 myCartPointXMap[ thePointType ]->setValue( aXCart );
981 myCartPointYMap[ thePointType ]->setValue( aYCart );
983 blockSignalsCartesian( false );
986 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged()
988 QObject* aSender = sender();
992 for( int aPointType = HYDROGUI_PrsImage::PointA;
993 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
995 if( aSender == myCartPointXMap[ aPointType ] ||
996 aSender == myCartPointYMap[ aPointType ] )
998 onCartesianCoordChanged( aPointType );
1004 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType )
1007 for( int i = 0; i < 2; i++ )
1010 double aXCart = myCartPointXMap[ thePointType ]->text().toDouble( &anIsOk[0] );
1011 double aYCart = myCartPointYMap[ thePointType ]->text().toDouble( &anIsOk[1] );
1013 for( int i = 0; i < 2; i++ )
1017 double aLonDeg = 0, aLatDeg = 0;
1018 HYDROData_Lambert93::toGeo( aXCart, aYCart, aLatDeg, aLonDeg );
1020 int aXDeg = 0, aYDeg = 0;
1021 int aXMin = 0, aYMin = 0;
1022 double aXSec = 0, aYSec = 0;
1023 HYDROData_Lambert93::degToDMS( aLonDeg, aXDeg, aXMin, aXSec );
1024 HYDROData_Lambert93::degToDMS( aLatDeg, aYDeg, aYMin, aYSec );
1026 blockSignalsGeodesic( true );
1028 myPointXDegMap[ thePointType ]->setValue( aXDeg );
1029 myPointYDegMap[ thePointType ]->setValue( aYDeg );
1030 myPointXMinMap[ thePointType ]->setValue( aXMin );
1031 myPointYMinMap[ thePointType ]->setValue( aYMin );
1032 myPointXSecMap[ thePointType ]->setValue( aXSec );
1033 myPointYSecMap[ thePointType ]->setValue( aYSec );
1035 blockSignalsGeodesic( false );
1038 void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
1040 if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
1042 QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
1043 aSpin->setValue( aSpin->minimum() );
1045 else if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
1047 QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( theSpin );
1048 aDblSpin->setValue( aDblSpin->minimum() );
1054 bool HYDROGUI_ImportImageDlg::blockSignalsPoints( const bool theState )
1056 bool isBlocked = false;
1057 for( int aPointType = HYDROGUI_PrsImage::PointA;
1058 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1061 myPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1062 myPointYMap[ aPointType ]->blockSignals( theState );
1064 myRefPointXMap[ aPointType ]->blockSignals( theState );
1065 myRefPointYMap[ aPointType ]->blockSignals( theState );
1070 bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
1072 bool isBlocked = false;
1073 for( int aPointType = HYDROGUI_PrsImage::PointA;
1074 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1077 myPointXDegMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1078 myPointXMinMap[ aPointType ]->blockSignals( theState );
1079 myPointXSecMap[ aPointType ]->blockSignals( theState );
1080 myPointYDegMap[ aPointType ]->blockSignals( theState );
1081 myPointYMinMap[ aPointType ]->blockSignals( theState );
1082 myPointYSecMap[ aPointType ]->blockSignals( theState );
1087 bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState )
1089 bool isBlocked = false;
1090 for( int aPointType = HYDROGUI_PrsImage::PointA;
1091 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1094 myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1095 myCartPointYMap[ aPointType ]->blockSignals( theState );