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>
52 #include "HYDRO_trace.hxx"
54 HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle )
55 : HYDROGUI_InputPanel( theModule, theTitle ),
56 myIsInitialized( false )
58 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
60 // Import image from file
61 myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this );
63 QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
65 myFileName = new QLineEdit( myFileNameGroup );
66 myFileName->setReadOnly( true );
68 myBrowseBtn = new QToolButton( myFileNameGroup );
69 myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
71 QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup );
72 aFileNameLayout->setMargin( 5 );
73 aFileNameLayout->setSpacing( 5 );
74 aFileNameLayout->addWidget( aFileNameLabel );
75 aFileNameLayout->addWidget( myFileName );
76 aFileNameLayout->addWidget( myBrowseBtn );
79 myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this );
81 QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup );
82 myImageName = new QLineEdit( myImageNameGroup );
84 QBoxLayout* anImageNameLayout = new QHBoxLayout( myImageNameGroup );
85 anImageNameLayout->setMargin( 5 );
86 anImageNameLayout->setSpacing( 5 );
87 anImageNameLayout->addWidget( anImageNameLabel );
88 anImageNameLayout->addWidget( myImageName );
91 myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this );
93 // Make a pixmap for arrow
94 QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) );
96 QPicture anArrowPicture;
97 anArrowPicture.setBoundingRect( QRect( QPoint( 0, 0 ), anArrowPixmap.size() ) );
100 aPainter.begin( &anArrowPicture );
101 aPainter.drawPixmap( 0, 0, anArrowPixmap );
104 QRadioButton* aManualGeodesicBtn = new QRadioButton( tr( "MANUALLY_GEODESIC" ), myTransformGroup );
105 QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup );
106 QRadioButton* aCartesianFromFileBtn = new QRadioButton( tr( "LAMBERT93_FROM_FILE" ), myTransformGroup );
107 QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup );
109 myModeGroup = new QButtonGroup( myTransformGroup );
110 myModeGroup->addButton( aManualGeodesicBtn, HYDROData_Image::ManualGeodesic );
111 myModeGroup->addButton( aManualCartesianBtn, HYDROData_Image::ManualCartesian );
112 myModeGroup->addButton( aCartesianFromFileBtn, HYDROData_Image::CartesianFromFile );
113 myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage );
115 myRefImage = new QComboBox( myTransformGroup );
117 QVBoxLayout* aTransformLayout = new QVBoxLayout( myTransformGroup );
118 aTransformLayout->setMargin( 5 );
119 aTransformLayout->setSpacing( 5 );
121 QGridLayout* aModeLayout = new QGridLayout( myTransformGroup );
122 aModeLayout->setMargin( 0 );
123 aModeLayout->setSpacing( 5 );
124 aModeLayout->addWidget( aManualGeodesicBtn, 0, 0 );
125 aModeLayout->addWidget( aManualCartesianBtn, 1, 0 );
126 aModeLayout->addWidget( aCartesianFromFileBtn, 2, 0 );
127 aModeLayout->addWidget( aRefImageBtn, 3, 0 );
128 aModeLayout->addWidget( myRefImage, 3, 1 );
129 aModeLayout->setColumnStretch( 1, 1 );
131 aTransformLayout->addLayout( aModeLayout );
133 // Manual input widget
134 QWidget* aManualInputGroup = new QWidget( myTransformGroup );
135 QGridLayout* aManualInputLayout = new QGridLayout( aManualInputGroup );
136 aManualInputLayout->setMargin( 5 );
137 aManualInputLayout->setSpacing( 5 );
139 QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), aManualInputGroup );
140 QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), aManualInputGroup );
141 QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), aManualInputGroup );
142 QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), aManualInputGroup );
144 aManualInputLayout->addWidget( aImageCSLabel, 0, 1 );
145 aManualInputLayout->addWidget( aGeodesicLabel, 0, 2, 1, 6 );
146 aManualInputLayout->addWidget( aLambertLabel, 0, 2, 1, 6 );
147 aManualInputLayout->addWidget( aRefImageLabel, 0, 2, 1, 6 );
149 for( int aPointType = HYDROGUI_PrsImage::PointA;
150 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
155 case HYDROGUI_PrsImage::PointA: aPointStr = tr( "ACTIVATE_POINT_A_SELECTION" ); break;
156 case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break;
157 case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break;
159 QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup );
160 aPointBtn->setCheckable( true );
162 QLabel* aPointXLabel = new QLabel( "X", aManualInputGroup );
163 QLabel* aPointYLabel = new QLabel( "Y", aManualInputGroup );
165 QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
166 QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
168 QLabel* aPointArrowLabel = new QLabel( aManualInputGroup );
169 aPointArrowLabel->setPicture( anArrowPicture );
171 QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup );
172 QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup );
173 QLabel* aPointXMinLabel = new QLabel( "'", aManualInputGroup );
174 QLabel* aPointYMinLabel = new QLabel( "'", aManualInputGroup );
175 QLabel* aPointXSecLabel = new QLabel( "\"", aManualInputGroup );
176 QLabel* aPointYSecLabel = new QLabel( "\"", aManualInputGroup );
177 QLabel* aPointLatLabel = new QLabel( tr( "POINT_LATITUDE" ), aManualInputGroup );
178 QLabel* aPointLonLabel = new QLabel( tr( "POINT_LONGITUDE" ), aManualInputGroup );
179 myGeodesicLabels << aPointXDegLabel << aPointYDegLabel
180 << aPointXMinLabel << aPointYMinLabel
181 << aPointXSecLabel << aPointYSecLabel
182 << aPointLonLabel << aPointLatLabel;
184 QtxIntSpinBox* aPointXDeg = new QtxIntSpinBox( -179, 179, 1, aManualInputGroup );
185 QtxIntSpinBox* aPointYDeg = new QtxIntSpinBox( 0, 89, 1, aManualInputGroup );
186 QtxIntSpinBox* aPointXMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup );
187 QtxIntSpinBox* aPointYMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup );
188 QtxDoubleSpinBox* aPointXSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup );
189 QtxDoubleSpinBox* aPointYSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup );
191 QtxDoubleSpinBox* aCartPointX = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
192 QtxDoubleSpinBox* aCartPointY = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup );
194 QtxIntSpinBox* aRefPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
195 QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later
197 int aRow = 4 * aPointType;
198 if ( aPointType == HYDROGUI_PrsImage::PointC )
200 myPointCEnabler = new QCheckBox( aManualInputGroup );
201 aManualInputLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter );
202 aManualInputLayout->addWidget( aPointBtn, aRow, 2, 1, 8 );
206 aManualInputLayout->addWidget( aPointBtn, aRow, 0, 1, 10 );
209 aManualInputLayout->addWidget( aPointXLabel, aRow + 1, 0 );
210 aManualInputLayout->addWidget( aPointX, aRow + 1, 1 );
211 aManualInputLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 );
212 aManualInputLayout->addWidget( aPointXDeg, aRow + 1, 3 );
213 aManualInputLayout->addWidget( aPointXDegLabel, aRow + 1, 4 );
214 aManualInputLayout->addWidget( aPointXMin, aRow + 1, 5 );
215 aManualInputLayout->addWidget( aPointXMinLabel, aRow + 1, 6 );
216 aManualInputLayout->addWidget( aPointXSec, aRow + 1, 7 );
217 aManualInputLayout->addWidget( aPointXSecLabel, aRow + 1, 8 );
218 aManualInputLayout->addWidget( aPointLonLabel, aRow + 1, 9 );
220 aManualInputLayout->addWidget( aCartPointX, aRow + 1, 3, 1, 6 );
221 aManualInputLayout->addWidget( aRefPointX, aRow + 1, 3, 1, 6 );
223 aManualInputLayout->addWidget( aPointYLabel, aRow + 2, 0 );
224 aManualInputLayout->addWidget( aPointY, aRow + 2, 1 );
225 aManualInputLayout->addWidget( aPointYDeg, aRow + 2, 3 );
226 aManualInputLayout->addWidget( aPointYDegLabel, aRow + 2, 4 );
227 aManualInputLayout->addWidget( aPointYMin, aRow + 2, 5 );
228 aManualInputLayout->addWidget( aPointYMinLabel, aRow + 2, 6 );
229 aManualInputLayout->addWidget( aPointYSec, aRow + 2, 7 );
230 aManualInputLayout->addWidget( aPointYSecLabel, aRow + 2, 8 );
231 aManualInputLayout->addWidget( aPointLatLabel, aRow + 2, 9 );
233 aManualInputLayout->addWidget( aCartPointY, aRow + 2, 3, 1, 6 );
234 aManualInputLayout->addWidget( aRefPointY, aRow + 2, 3, 1, 6 );
236 if( aPointType != HYDROGUI_PrsImage::PointC )
238 QFrame* aLine = new QFrame( aManualInputGroup );
239 aLine->setFrameShape( QFrame::HLine );
240 aLine->setFrameShadow( QFrame::Sunken );
241 aManualInputLayout->addWidget( aLine, aRow + 3, 0, 1, 10 );
244 myPointBtnMap[ aPointType ] = aPointBtn;
245 myPointXMap[ aPointType ] = aPointX;
246 myPointYMap[ aPointType ] = aPointY;
247 myPointXDegMap[ aPointType ] = aPointXDeg;
248 myPointYDegMap[ aPointType ] = aPointYDeg;
249 myPointXMinMap[ aPointType ] = aPointXMin;
250 myPointYMinMap[ aPointType ] = aPointYMin;
251 myPointXSecMap[ aPointType ] = aPointXSec;
252 myPointYSecMap[ aPointType ] = aPointYSec;
254 myCartPointXMap[ aPointType ] = aCartPointX;
255 myCartPointYMap[ aPointType ] = aCartPointY;
257 myRefPointXMap[ aPointType ] = aRefPointX;
258 myRefPointYMap[ aPointType ] = aRefPointY;
260 connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) );
262 connect( aPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
263 connect( aPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
265 connect( aPointXDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
266 connect( aPointYDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
267 connect( aPointXMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
268 connect( aPointYMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) );
269 connect( aPointXSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) );
270 connect( aPointYSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) );
272 connect( aCartPointX, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
273 connect( aCartPointY, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) );
275 connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
276 connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) );
279 // Connect checkbox enabling point C
280 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointBtnMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
281 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
282 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
283 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
284 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
285 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
286 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
287 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
288 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
289 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
290 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
291 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
292 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) );
294 connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SLOT( onSetCIsUsed( bool ) ) );
296 aManualInputLayout->setColumnStretch( 1, 1 ); // double
297 aManualInputLayout->setColumnStretch( 3, 1 ); // degrees
298 aManualInputLayout->setColumnStretch( 5, 1 ); // minutes
299 aManualInputLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits)
301 // Image georeferencement file widget
302 QWidget* aFromFileInputGroup = new QWidget( myTransformGroup );
303 QBoxLayout* aFromFileInputLayout = new QHBoxLayout( aFromFileInputGroup );
304 aFromFileInputLayout->setMargin( 5 );
305 aFromFileInputLayout->setSpacing( 5 );
307 QLabel* aGeoFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFromFileInputGroup );
309 myGeoFileName = new QLineEdit( aFromFileInputGroup );
310 myGeoFileName->setReadOnly( true );
312 QToolButton* aGeoBrowseBtn = new QToolButton( aFromFileInputGroup );
313 aGeoBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
315 aFromFileInputLayout->addWidget( aGeoFileNameLabel );
316 aFromFileInputLayout->addWidget( myGeoFileName );
317 aFromFileInputLayout->addWidget( aGeoBrowseBtn );
319 // Widgets connections
320 connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setVisible ( bool ) ) );
321 connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
322 connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
323 connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
324 connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setVisible ( bool ) ) );
325 connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
326 connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) );
327 connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
328 connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setVisible ( bool ) ) );
329 connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) );
330 connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) );
331 connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) );
332 connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setVisible ( bool ) ) );
333 connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aManualInputGroup, SLOT( setHidden ( bool ) ) );
336 aTransformLayout->addWidget( aManualInputGroup );
337 aTransformLayout->addWidget( aFromFileInputGroup );
340 addWidget( myFileNameGroup );
341 addWidget( myImageNameGroup );
342 addWidget( myTransformGroup );
345 connect( myBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
347 connect( myModeGroup, SIGNAL( buttonClicked( int ) ),
348 this, SLOT( onModeActivated( int ) ) );
350 connect( aGeoBrowseBtn, SIGNAL( clicked() ), this, SLOT( onGeoBrowse() ) );
352 connect( myRefImage, SIGNAL( activated( const QString& ) ),
353 this, SLOT( onRefImageActivated( const QString& ) ) );
355 //setTransformationMode( HYDROData_Image::ManualCartesian );
357 setMinimumWidth( 350 );
360 HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg()
364 void HYDROGUI_ImportImageDlg::onSetCIsUsed( bool theCIsUsed )
366 if ( !theCIsUsed && myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->isChecked() )
368 // Turn on point A selection if point C selection has been activated and we disable point C.
369 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->toggle();
371 emit setCIsUsed( theCIsUsed );
374 void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit )
376 myFileNameGroup->setVisible( !theIsEdit );
377 myImageNameGroup->setEnabled( theIsEdit );
378 myTransformGroup->setEnabled( theIsEdit );
381 void HYDROGUI_ImportImageDlg::reset()
384 myImageName->clear();
385 myImageNameGroup->setEnabled( false );
386 myGeoFileName->clear();
387 bool isPBlocked = blockSignalsPoints( true );
388 bool isGBlocked = blockSignalsGeodesic( true );
389 bool isCBlocked = blockSignalsCartesian( true );
390 for( int aPointType = HYDROGUI_PrsImage::PointA;
391 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
393 QPushButton* aBtn = myPointBtnMap[ aPointType ];
394 bool anIsBlocked = aBtn->blockSignals( true );
395 aBtn->setChecked( false );
396 aBtn->blockSignals( anIsBlocked );
398 clearSpins( myPointXMap[ aPointType ] );
399 clearSpins( myPointYMap[ aPointType ] );
400 clearSpins( myPointXDegMap[ aPointType ] );
401 clearSpins( myPointYDegMap[ aPointType ] );
402 clearSpins( myPointXMinMap[ aPointType ] );
403 clearSpins( myPointYMinMap[ aPointType ] );
404 clearSpins( myPointXSecMap[ aPointType ] );
405 clearSpins( myPointYSecMap[ aPointType ] );
407 clearSpins( myRefPointXMap[ aPointType ] );
408 clearSpins( myRefPointYMap[ aPointType ] );
410 clearSpins( myCartPointXMap[ aPointType ] );
411 clearSpins( myCartPointYMap[ aPointType ] );
413 blockSignalsPoints( isPBlocked );
414 blockSignalsGeodesic( isGBlocked );
415 blockSignalsCartesian( isCBlocked );
417 // Emulate turning off C point usage
418 myPointCEnabler->blockSignals( true );
420 myPointCEnabler->setChecked( false );
421 myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
422 myPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
423 myPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
424 myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
425 myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
426 myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
427 myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
428 myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
429 myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
430 myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
431 myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
432 myRefPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
433 myRefPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false );
434 onSetCIsUsed( false );
436 myPointCEnabler->blockSignals( false );
438 myTransformGroup->setEnabled( false );
441 setTransformationMode( HYDROData_Image::ManualCartesian );
443 myPrsPointDataList.clear();
445 myIsInitialized = false;
448 void HYDROGUI_ImportImageDlg::setImageName( const QString& theName )
450 myImageName->setText( theName );
453 QString HYDROGUI_ImportImageDlg::getImageName() const
455 return myImageName->text();
458 void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName )
460 myRefImage->setCurrentIndex( myRefImage->findText( theName ) );
463 QString HYDROGUI_ImportImageDlg::getRefImageName() const
465 return myRefImage->currentText();
468 QString HYDROGUI_ImportImageDlg::getFileName() const
470 return myFileName->text();
473 void HYDROGUI_ImportImageDlg::setFileName( const QString& theName )
475 myFileName->setText( theName );
476 myImageNameGroup->setEnabled( true );
477 myTransformGroup->setEnabled( true );
480 QString HYDROGUI_ImportImageDlg::getGeoreferencementFileName() const
482 return myGeoFileName->text();
485 void HYDROGUI_ImportImageDlg::setImageSize( const QSize& theSize,
486 const bool theIsRefImage )
488 int aWidth = theSize.width();
489 int aHeight = theSize.height();
490 for( int aPointType = HYDROGUI_PrsImage::PointA;
491 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
495 myRefPointXMap[ aPointType ]->setRange( 0, aWidth );
496 myRefPointYMap[ aPointType ]->setRange( 0, aHeight );
500 myPointXMap[ aPointType ]->setRange( 0, aWidth );
501 myPointYMap[ aPointType ]->setRange( 0, aHeight );
506 void HYDROGUI_ImportImageDlg::setTransformationMode( const int theMode )
508 myModeGroup->button( theMode )->setChecked( true );
509 onModeActivated( theMode );
512 int HYDROGUI_ImportImageDlg::getTransformationMode() const
514 return myModeGroup->checkedId();
517 void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints )
519 myPointCEnabler->setChecked( !theIsByTwoPoints );
522 bool HYDROGUI_ImportImageDlg::isByTwoPoints() const
524 return !myPointCEnabler->isChecked();
527 void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap,
528 const bool theIsOnlyInput,
529 const bool theIsRefImage )
531 DEBTRACE("setTransformationDataMap " << theIsOnlyInput << " " << theIsRefImage);
532 blockSignalsGeodesic( true );
533 blockSignalsCartesian( true );
534 for( int aPointType = HYDROGUI_PrsImage::PointA;
535 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
537 if( theMap.contains( aPointType ) )
539 const TransformationData& aData = theMap[ aPointType ];
541 QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
542 QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
543 aPointX->setValue( aData.ImagePoint.x() );
544 aPointY->setValue( aData.ImagePoint.y() );
545 DEBTRACE("aPointX " << aData.ImagePoint.x() << " aPointY " << aData.ImagePoint.y());
547 if( !theIsOnlyInput && !theIsRefImage )
549 QPointF aLPoint = aData.GeodesicPoint;
550 int aXDeg = 0, aYDeg = 0;
551 int aXMin = 0, aYMin = 0;
552 double aXSec = 0, aYSec = 0;
553 HYDROData_Lambert93::degToDMS( aLPoint.x(), aXDeg, aXMin, aXSec );
554 HYDROData_Lambert93::degToDMS( aLPoint.y(), aYDeg, aYMin, aYSec );
556 myPointXDegMap[ aPointType ]->setValue( aXDeg );
557 myPointYDegMap[ aPointType ]->setValue( aYDeg );
558 myPointXMinMap[ aPointType ]->setValue( aXMin );
559 myPointYMinMap[ aPointType ]->setValue( aYMin );
560 myPointXSecMap[ aPointType ]->setValue( aXSec );
561 myPointYSecMap[ aPointType ]->setValue( aYSec );
563 QPointF aCPoint = aData.CartesianPoint;
564 myCartPointXMap[ aPointType ]->setValue( aCPoint.x() );
565 myCartPointYMap[ aPointType ]->setValue( aCPoint.y() );
569 blockSignalsGeodesic( false );
570 blockSignalsCartesian( false );
573 bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap,
574 const bool theIsRefImage ) const
577 for( int aPointType = HYDROGUI_PrsImage::PointA;
578 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
581 for( int i = 0; i < 10; i++ )
584 QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ];
585 QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ];
586 int aX1 = aPointX->text().toInt( &anIsOk[0] );
587 int aY1 = aPointY->text().toInt( &anIsOk[1] );
589 int aXDeg = 0, aYDeg = 0;
590 int aXMin = 0, aYMin = 0;
591 double aXSec = 0, aYSec = 0;
592 double aXCart = 0, aYCart = 0;
595 aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] );
596 aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] );
597 aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] );
598 aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] );
599 aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] );
600 aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] );
602 aXCart = myCartPointXMap[ aPointType ]->text().toDouble( &anIsOk[8] );
603 aYCart = myCartPointYMap[ aPointType ]->text().toDouble( &anIsOk[9] );
606 for( int i = 0; i < 10; i++ )
610 double aX2 = 0, aY2 = 0;
611 HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aX2 );
612 HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aY2 );
614 TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ), QPointF( aXCart, aYCart ) );
615 theMap[ aPointType ] = aData;
620 void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList )
622 myPrsPointDataList = theList;
624 if( !myPrsPointDataList.isEmpty() )
626 myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true );
629 myRefImage->addItem( "" ); // first empty item
631 PrsPointDataListIterator anIter( myPrsPointDataList );
632 while( anIter.hasNext() )
633 myRefImage->addItem( anIter.next().first );
636 myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false );
639 void HYDROGUI_ImportImageDlg::initializePointSelection()
641 if( myIsInitialized )
644 myIsInitialized = true;
646 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
648 double aCartX0 = LAMBERT_X0;
649 double aCartY0 = LAMBERT_Y0;
651 blockSignalsCartesian( true );
653 myCartPointXMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartX0 );
654 myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + IMG_DELTA );
656 myCartPointXMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartX0 + IMG_DELTA );
657 myCartPointYMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartY0 + IMG_DELTA );
659 myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartX0 );
660 myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartY0 );
662 for( int aPointType = HYDROGUI_PrsImage::PointA;
663 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
664 onCartesianCoordChanged( aPointType );
666 blockSignalsCartesian( false );
669 void HYDROGUI_ImportImageDlg::ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo)
671 if( myIsInitialized )
674 myIsInitialized = true;
676 myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
677 myPointBtnMap[ HYDROGUI_PrsImage::PointB ]->setChecked( true );
678 myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setChecked( true );
680 setByTwoPoints(false);
682 HYDROData_Image::ECW_CellUnits Units = theECW_FileInfo->myCellSizeUnits;
684 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Deg)
686 blockSignalsGeodesic( true );
687 double Xa, Ya, Xb, Yb, Xc, Yc;
688 Xa = theECW_FileInfo->myOriginX;
689 Ya = theECW_FileInfo->myOriginY;
690 Xb = theECW_FileInfo->myOriginX;
691 Yb = theECW_FileInfo->myOriginY + theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myYSize;
692 Xc = theECW_FileInfo->myOriginX + theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myXSize;
693 Yc = theECW_FileInfo->myOriginY;
695 int Deg = 0, Min = 0;
698 HYDROData_Lambert93::degToDMS( Xa, Deg, Min, Sec );
699 myPointXDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
700 myPointXMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
701 myPointXSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
702 HYDROData_Lambert93::degToDMS( Ya, Deg, Min, Sec );
703 myPointYDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
704 myPointYMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
705 myPointYSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
707 HYDROData_Lambert93::degToDMS( Xb, Deg, Min, Sec );
708 myPointXDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
709 myPointXMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
710 myPointXSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
711 HYDROData_Lambert93::degToDMS( Yb, Deg, Min, Sec );
712 myPointYDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
713 myPointYMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
714 myPointYSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
716 HYDROData_Lambert93::degToDMS( Xc, Deg, Min, Sec );
717 myPointXDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
718 myPointXMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
719 myPointXSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
720 HYDROData_Lambert93::degToDMS( Yc, Deg, Min, Sec );
721 myPointYDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
722 myPointYMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
723 myPointYSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
725 for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
726 onGeodesicCoordChanged( aPointType );
727 blockSignalsGeodesic( false );
728 setTransformationMode( HYDROData_Image::ManualGeodesic );
730 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Meters ||
731 Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet )
734 if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet)
735 Coeff = 0.3048; //feets
736 blockSignalsCartesian( true );
737 double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, X3 = 0, Y3 = 0;
738 X1 = theECW_FileInfo->myOriginX;
739 Y1 = theECW_FileInfo->myOriginY;
740 X2 = theECW_FileInfo->myOriginX;
741 Y2 = theECW_FileInfo->myOriginY + Coeff * theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myXSize;
742 X3 = theECW_FileInfo->myOriginX + Coeff * theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myYSize;
743 Y3 = theECW_FileInfo->myOriginY;
745 //extract to A-point (top-left), B-point (bottom-left), C-Point (top-right)
746 double Xa = 0, Ya = 0, Xb = 0, Yb = 0, Xc = 0, Yc = 0;
747 Xa = Min(X1, Min(X2, X3));
748 Ya = Max(Y1, Max(Y2, Y3));
749 Xb = Max(X1, Max(X2, X3));
752 Yc = Min(Y1, Min(Y2, Y3));
754 myCartPointXMap[HYDROGUI_PrsImage::PointA]->setValue(Xa);
755 myCartPointYMap[HYDROGUI_PrsImage::PointA]->setValue(Ya);
757 myCartPointXMap[HYDROGUI_PrsImage::PointB]->setValue(Xb);
758 myCartPointYMap[HYDROGUI_PrsImage::PointB]->setValue(Yb);
760 myCartPointXMap[HYDROGUI_PrsImage::PointC]->setValue(Xc);
761 myCartPointYMap[HYDROGUI_PrsImage::PointC]->setValue(Yc);
763 for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
764 onCartesianCoordChanged( aPointType );
765 blockSignalsCartesian( false );
766 setTransformationMode( HYDROData_Image::ManualCartesian );
771 HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
773 const QPoint& theLocalPoint,
774 const QPointF& theGlobalPoint )
776 TransformationData aResTrsfData;
777 aResTrsfData.ImagePoint = theLocalPoint;
779 double arx = theGlobalPoint.x();
780 double ary = theGlobalPoint.y();
781 if ( theMode == HYDROData_Image::ManualGeodesic )
783 // Geodesic to Cartesian
784 double aXCart = 0, aYCart = 0;
785 // Interpreting arY as attitude and arX as longitude
786 HYDROData_Lambert93::toXY( ary, arx, aXCart, aYCart );
788 aResTrsfData.GeodesicPoint = theGlobalPoint;
789 aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart );
791 else if ( theMode == HYDROData_Image::ManualCartesian )
793 // Cartesian to Geodesic
794 double aLonDeg = 0, aLatDeg = 0;
795 HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg );
797 aResTrsfData.CartesianPoint = theGlobalPoint;
798 aResTrsfData.GeodesicPoint = QPointF( aLonDeg, aLatDeg );
804 void HYDROGUI_ImportImageDlg::onBrowse()
806 QString aFilter( tr( "IMAGE_FILTER_IMPORT" ) );
807 QStringList aFileNamesList = SUIT_FileDlg::getOpenFileNames( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true );
808 emit filesSelected( aFileNamesList );
811 void HYDROGUI_ImportImageDlg::ActivateFile( const QString& theFileName, bool isEnableFilesChoice )
813 myFileName->setEnabled( isEnableFilesChoice );
814 myBrowseBtn->setEnabled( isEnableFilesChoice );
816 if( !theFileName.isEmpty() )
818 QFileInfo aFI( theFileName );
820 HYDROData_Image::ECW_FileInfo* theECWInfo = NULL;
821 if (aFI.suffix().toLower() == "ecw")
823 theECWInfo = new HYDROData_Image::ECW_FileInfo;
824 HYDROData_Image::OpenECW(theFileName.toLatin1().data(), anImage, theECWInfo);
827 anImage = QImage(theFileName);
828 if( anImage.isNull() )
830 QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
831 QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ).
832 arg( theFileName ).arg( QFileInfo( theFileName ).suffix() );
833 SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage );
837 setFileName( theFileName );
839 emit createPreview( anImage, theECWInfo );
844 void HYDROGUI_ImportImageDlg::onGeoBrowse()
846 QString aFilter( tr( "IMAGE_GEOREFERENCEMENT_FILTER" ) );
847 QString aGeoFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_GEO_DATA_FROM_FILE" ), true );
848 if( !aGeoFileName.isEmpty() ) {
849 myGeoFileName->setText( aGeoFileName );
853 void HYDROGUI_ImportImageDlg::onModeActivated( int theMode )
855 bool anIsManualGeodesic = theMode == HYDROData_Image::ManualGeodesic;
856 bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian;
857 bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage;
859 myRefImage->setEnabled( anIsRefImage );
861 for( int aPointType = HYDROGUI_PrsImage::PointA;
862 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
864 myPointXDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
865 myPointYDegMap[ aPointType ]->setVisible( anIsManualGeodesic );
866 myPointXMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
867 myPointYMinMap[ aPointType ]->setVisible( anIsManualGeodesic );
868 myPointXSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
869 myPointYSecMap[ aPointType ]->setVisible( anIsManualGeodesic );
871 myCartPointXMap[ aPointType ]->setVisible( anIsManualCartesian );
872 myCartPointYMap[ aPointType ]->setVisible( anIsManualCartesian );
874 myRefPointXMap[ aPointType ]->setVisible( anIsRefImage );
875 myRefPointYMap[ aPointType ]->setVisible( anIsRefImage );
878 QListIterator<QLabel*> anIter( myGeodesicLabels );
879 while( anIter.hasNext() )
880 anIter.next()->setVisible( anIsManualGeodesic );
882 emit modeActivated( theMode );
885 void HYDROGUI_ImportImageDlg::onRefImageActivated( const QString& theName )
887 emit refImageActivated( theName );
890 void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState )
892 int aPointType = HYDROGUI_PrsImage::None;
895 QMapIterator<int, QPushButton*> anIter( myPointBtnMap );
896 while( anIter.hasNext() )
898 int aBtnPointType = anIter.next().key();
899 QPushButton* aBtn = anIter.value();
900 if( aBtn == sender() )
901 aPointType = aBtnPointType;
904 bool anIsBlocked = aBtn->blockSignals( true );
905 aBtn->setChecked( false );
906 aBtn->blockSignals( anIsBlocked );
910 emit activatePointSelection( aPointType );
913 void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue )
915 QObject* aSender = sender();
919 for( int aPointType = HYDROGUI_PrsImage::PointA;
920 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
922 if( aSender == myPointXMap[ aPointType ] ||
923 aSender == myPointYMap[ aPointType ] )
925 bool anIsY = aSender == myPointYMap[ aPointType ];
926 emit pointCoordChanged( false, aPointType, anIsY, theValue );
928 else if( aSender == myRefPointXMap[ aPointType ] ||
929 aSender == myRefPointYMap[ aPointType ] )
931 bool anIsY = aSender == myRefPointYMap[ aPointType ];
932 emit pointCoordChanged( true, aPointType, anIsY, theValue );
937 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged()
939 QObject* aSender = sender();
943 for( int aPointType = HYDROGUI_PrsImage::PointA;
944 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
946 if( aSender == myPointXDegMap[ aPointType ] ||
947 aSender == myPointYDegMap[ aPointType ] ||
948 aSender == myPointXMinMap[ aPointType ] ||
949 aSender == myPointYMinMap[ aPointType ] ||
950 aSender == myPointXSecMap[ aPointType ] ||
951 aSender == myPointYSecMap[ aPointType ] )
953 onGeodesicCoordChanged( aPointType );
959 void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged( const int thePointType )
962 for( int i = 0; i < 6; i++ )
965 int aXDeg = myPointXDegMap[ thePointType ]->text().toInt( &anIsOk[0] );
966 int aYDeg = myPointYDegMap[ thePointType ]->text().toInt( &anIsOk[1] );
967 int aXMin = myPointXMinMap[ thePointType ]->text().toInt( &anIsOk[2] );
968 int aYMin = myPointYMinMap[ thePointType ]->text().toInt( &anIsOk[3] );
969 double aXSec = myPointXSecMap[ thePointType ]->text().toDouble( &anIsOk[4] );
970 double aYSec = myPointYSecMap[ thePointType ]->text().toDouble( &anIsOk[5] );
972 for( int i = 0; i < 6; i++ )
976 double aLonDeg = 0, aLatDeg = 0;
977 HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aLonDeg );
978 HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aLatDeg );
980 double aXCart = 0, aYCart = 0;
981 HYDROData_Lambert93::toXY( aLatDeg, aLonDeg, aXCart, aYCart );
983 blockSignalsCartesian( true );
985 myCartPointXMap[ thePointType ]->setValue( aXCart );
986 myCartPointYMap[ thePointType ]->setValue( aYCart );
988 blockSignalsCartesian( false );
991 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged()
993 QObject* aSender = sender();
997 for( int aPointType = HYDROGUI_PrsImage::PointA;
998 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1000 if( aSender == myCartPointXMap[ aPointType ] ||
1001 aSender == myCartPointYMap[ aPointType ] )
1003 onCartesianCoordChanged( aPointType );
1009 void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType )
1012 for( int i = 0; i < 2; i++ )
1015 double aXCart = myCartPointXMap[ thePointType ]->text().toDouble( &anIsOk[0] );
1016 double aYCart = myCartPointYMap[ thePointType ]->text().toDouble( &anIsOk[1] );
1018 for( int i = 0; i < 2; i++ )
1022 double aLonDeg = 0, aLatDeg = 0;
1023 HYDROData_Lambert93::toGeo( aXCart, aYCart, aLatDeg, aLonDeg );
1025 int aXDeg = 0, aYDeg = 0;
1026 int aXMin = 0, aYMin = 0;
1027 double aXSec = 0, aYSec = 0;
1028 HYDROData_Lambert93::degToDMS( aLonDeg, aXDeg, aXMin, aXSec );
1029 HYDROData_Lambert93::degToDMS( aLatDeg, aYDeg, aYMin, aYSec );
1031 blockSignalsGeodesic( true );
1033 myPointXDegMap[ thePointType ]->setValue( aXDeg );
1034 myPointYDegMap[ thePointType ]->setValue( aYDeg );
1035 myPointXMinMap[ thePointType ]->setValue( aXMin );
1036 myPointYMinMap[ thePointType ]->setValue( aYMin );
1037 myPointXSecMap[ thePointType ]->setValue( aXSec );
1038 myPointYSecMap[ thePointType ]->setValue( aYSec );
1040 blockSignalsGeodesic( false );
1043 void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
1045 if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
1047 QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
1048 aSpin->setValue( aSpin->minimum() );
1050 else if ( dynamic_cast<QtxDoubleSpinBox*>( theSpin ) )
1052 QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( theSpin );
1053 aDblSpin->setValue( aDblSpin->minimum() );
1059 bool HYDROGUI_ImportImageDlg::blockSignalsPoints( const bool theState )
1061 bool isBlocked = false;
1062 for( int aPointType = HYDROGUI_PrsImage::PointA;
1063 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1066 myPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1067 myPointYMap[ aPointType ]->blockSignals( theState );
1069 myRefPointXMap[ aPointType ]->blockSignals( theState );
1070 myRefPointYMap[ aPointType ]->blockSignals( theState );
1075 bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
1077 bool isBlocked = false;
1078 for( int aPointType = HYDROGUI_PrsImage::PointA;
1079 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1082 myPointXDegMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1083 myPointXMinMap[ aPointType ]->blockSignals( theState );
1084 myPointXSecMap[ aPointType ]->blockSignals( theState );
1085 myPointYDegMap[ aPointType ]->blockSignals( theState );
1086 myPointYMinMap[ aPointType ]->blockSignals( theState );
1087 myPointYSecMap[ aPointType ]->blockSignals( theState );
1092 bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState )
1094 bool isBlocked = false;
1095 for( int aPointType = HYDROGUI_PrsImage::PointA;
1096 aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
1099 myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked;
1100 myCartPointYMap[ aPointType ]->blockSignals( theState );