X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ImportImageDlg.cxx;h=4286978d8d517ba799d5f2e9e5985419a104a463;hb=fc42f9cabfa130d72aea8c10f003d6bec315b6c6;hp=9e3e173bfa54c83799ebb6629346d50f6e76beef;hpb=b475ac9f5ce7ab52045e70fec0c8e6f8ffb51432;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 9e3e173b..4286978d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -24,29 +24,42 @@ #include "HYDROGUI_PrsImage.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Module.h" +#include +#include + +#include +#include #include +#include +#include #include -#include -#include +#include +#include + +#include +#include #include -#include #include #include #include #include #include #include +#include #include +#include HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ), + myIsInitialized( false ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); // Import image from file - myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ) ); + myFileNameGroup = new QGroupBox( tr( "IMPORT_IMAGE_FROM_FILE" ), this ); QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); @@ -64,7 +77,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aFileNameLayout->addWidget( aBrowseBtn ); // Image name - myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) ); + myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this ); QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), myImageNameGroup ); myImageName = new QLineEdit( myImageNameGroup ); @@ -75,12 +88,8 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co anImageNameLayout->addWidget( anImageNameLabel ); anImageNameLayout->addWidget( myImageName ); - // Mapping - myMappingGroup = new QGroupBox( tr( "MAPPING" ) ); - - QGridLayout* aMappingLayout = new QGridLayout( myMappingGroup ); - aMappingLayout->setMargin( 5 ); - aMappingLayout->setSpacing( 5 ); + // Transform image + myTransformGroup = new QGroupBox( tr( "TRANSFORM_IMAGE" ), this ); // Make a pixmap for arrow QPixmap anArrowPixmap = aResMgr->loadPixmap( "HYDRO", tr( "ARROW_RIGHT_ICO" ) ); @@ -93,6 +102,51 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aPainter.drawPixmap( 0, 0, anArrowPixmap ); aPainter.end(); + QRadioButton* aManualGeodesicBtn = new QRadioButton( tr( "MANUALLY_GEODESIC" ), myTransformGroup ); + QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup ); + QRadioButton* aCartesianFromFileBtn = new QRadioButton( tr( "LAMBERT93_FROM_FILE" ), myTransformGroup ); + QRadioButton* aRefImageBtn = new QRadioButton( tr( "BY_REFERENCE_IMAGE" ), myTransformGroup ); + + myModeGroup = new QButtonGroup( myTransformGroup ); + myModeGroup->addButton( aManualGeodesicBtn, HYDROData_Image::ManualGeodesic ); + myModeGroup->addButton( aManualCartesianBtn, HYDROData_Image::ManualCartesian ); + myModeGroup->addButton( aCartesianFromFileBtn, HYDROData_Image::CartesianFromFile ); + myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage ); + + myRefImage = new QComboBox( myTransformGroup ); + + QVBoxLayout* aTransformLayout = new QVBoxLayout( myTransformGroup ); + aTransformLayout->setMargin( 5 ); + aTransformLayout->setSpacing( 5 ); + + QGridLayout* aModeLayout = new QGridLayout( myTransformGroup ); + aModeLayout->setMargin( 0 ); + aModeLayout->setSpacing( 5 ); + aModeLayout->addWidget( aManualGeodesicBtn, 0, 0 ); + aModeLayout->addWidget( aManualCartesianBtn, 1, 0 ); + aModeLayout->addWidget( aCartesianFromFileBtn, 2, 0 ); + aModeLayout->addWidget( aRefImageBtn, 3, 0 ); + aModeLayout->addWidget( myRefImage, 3, 1 ); + aModeLayout->setColumnStretch( 1, 1 ); + + aTransformLayout->addLayout( aModeLayout ); + + // Manual input widget + QWidget* aManualInputGroup = new QWidget( myTransformGroup ); + QGridLayout* aManualInputLayout = new QGridLayout( aManualInputGroup ); + aManualInputLayout->setMargin( 5 ); + aManualInputLayout->setSpacing( 5 ); + + QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), aManualInputGroup ); + QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), aManualInputGroup ); + QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), aManualInputGroup ); + QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), aManualInputGroup ); + + aManualInputLayout->addWidget( aImageCSLabel, 0, 1 ); + aManualInputLayout->addWidget( aGeodesicLabel, 0, 2, 1, 6 ); + aManualInputLayout->addWidget( aLambertLabel, 0, 2, 1, 6 ); + aManualInputLayout->addWidget( aRefImageLabel, 0, 2, 1, 6 ); + for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { @@ -103,76 +157,89 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co case HYDROGUI_PrsImage::PointB: aPointStr = tr( "ACTIVATE_POINT_B_SELECTION" ); break; case HYDROGUI_PrsImage::PointC: aPointStr = tr( "ACTIVATE_POINT_C_SELECTION" ); break; } - QPushButton* aPointBtn = new QPushButton( aPointStr, myMappingGroup ); + QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup ); aPointBtn->setCheckable( true ); - QLabel* aPointXLabel = new QLabel( "X", myMappingGroup ); - QLabel* aPointYLabel = new QLabel( "Y", myMappingGroup ); + QLabel* aPointXLabel = new QLabel( "X", aManualInputGroup ); + QLabel* aPointYLabel = new QLabel( "Y", aManualInputGroup ); - QLineEdit* aPointX = new QLineEdit( myMappingGroup ); - QLineEdit* aPointY = new QLineEdit( myMappingGroup ); + QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later + QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later - aPointX->setReadOnly( true ); - aPointY->setReadOnly( true ); - - //QLabel* aPointArrowLabel = new QLabel( ">", myMappingGroup ); - QLabel* aPointArrowLabel = new QLabel( myMappingGroup ); + QLabel* aPointArrowLabel = new QLabel( aManualInputGroup ); aPointArrowLabel->setPicture( anArrowPicture ); - QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup ); - QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), myMappingGroup ); - QLabel* aPointXMinLabel = new QLabel( "'", myMappingGroup ); - QLabel* aPointYMinLabel = new QLabel( "'", myMappingGroup ); - QLabel* aPointXSecLabel = new QLabel( "\"", myMappingGroup ); - QLabel* aPointYSecLabel = new QLabel( "\"", myMappingGroup ); - - QLineEdit* aPointXDeg = new QLineEdit( myMappingGroup ); - QLineEdit* aPointYDeg = new QLineEdit( myMappingGroup ); - QLineEdit* aPointXMin = new QLineEdit( myMappingGroup ); - QLineEdit* aPointYMin = new QLineEdit( myMappingGroup ); - QLineEdit* aPointXSec = new QLineEdit( myMappingGroup ); - QLineEdit* aPointYSec = new QLineEdit( myMappingGroup ); - - QIntValidator* aXDegValidator = new QIntValidator( -180, 180, this ); - QIntValidator* aYDegValidator = new QIntValidator( -90, 90, this ); - QIntValidator* aMinValidator = new QIntValidator( 0, 59, this ); - QDoubleValidator* aSecValidator = new QDoubleValidator( 0, 59.9999, 4, this ); - - aPointXDeg->setValidator( aXDegValidator ); - aPointYDeg->setValidator( aYDegValidator ); - aPointXMin->setValidator( aMinValidator ); - aPointYMin->setValidator( aMinValidator ); - aPointXSec->setValidator( aSecValidator ); - aPointYSec->setValidator( aSecValidator ); + QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup ); + QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), aManualInputGroup ); + QLabel* aPointXMinLabel = new QLabel( "'", aManualInputGroup ); + QLabel* aPointYMinLabel = new QLabel( "'", aManualInputGroup ); + QLabel* aPointXSecLabel = new QLabel( "\"", aManualInputGroup ); + QLabel* aPointYSecLabel = new QLabel( "\"", aManualInputGroup ); + QLabel* aPointLatLabel = new QLabel( tr( "POINT_LATITUDE" ), aManualInputGroup ); + QLabel* aPointLonLabel = new QLabel( tr( "POINT_LONGITUDE" ), aManualInputGroup ); + myGeodesicLabels << aPointXDegLabel << aPointYDegLabel + << aPointXMinLabel << aPointYMinLabel + << aPointXSecLabel << aPointYSecLabel + << aPointLonLabel << aPointLatLabel; + + QtxIntSpinBox* aPointXDeg = new QtxIntSpinBox( -179, 179, 1, aManualInputGroup ); + QtxIntSpinBox* aPointYDeg = new QtxIntSpinBox( 0, 89, 1, aManualInputGroup ); + QtxIntSpinBox* aPointXMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup ); + QtxIntSpinBox* aPointYMin = new QtxIntSpinBox( 0, 59, 1, aManualInputGroup ); + QtxDoubleSpinBox* aPointXSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup ); + QtxDoubleSpinBox* aPointYSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, aManualInputGroup ); + + QtxDoubleSpinBox* aCartPointX = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup ); + QtxDoubleSpinBox* aCartPointY = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, aManualInputGroup ); + + QtxIntSpinBox* aRefPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later + QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later int aRow = 4 * aPointType; - aMappingLayout->addWidget( aPointBtn, aRow, 0, 1, 9 ); - - aMappingLayout->addWidget( aPointXLabel, aRow + 1, 0 ); - aMappingLayout->addWidget( aPointX, aRow + 1, 1 ); - aMappingLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 ); - aMappingLayout->addWidget( aPointXDeg, aRow + 1, 3 ); - aMappingLayout->addWidget( aPointXDegLabel, aRow + 1, 4 ); - aMappingLayout->addWidget( aPointXMin, aRow + 1, 5 ); - aMappingLayout->addWidget( aPointXMinLabel, aRow + 1, 6 ); - aMappingLayout->addWidget( aPointXSec, aRow + 1, 7 ); - aMappingLayout->addWidget( aPointXSecLabel, aRow + 1, 8 ); - - aMappingLayout->addWidget( aPointYLabel, aRow + 2, 0 ); - aMappingLayout->addWidget( aPointY, aRow + 2, 1 ); - aMappingLayout->addWidget( aPointYDeg, aRow + 2, 3 ); - aMappingLayout->addWidget( aPointYDegLabel, aRow + 2, 4 ); - aMappingLayout->addWidget( aPointYMin, aRow + 2, 5 ); - aMappingLayout->addWidget( aPointYMinLabel, aRow + 2, 6 ); - aMappingLayout->addWidget( aPointYSec, aRow + 2, 7 ); - aMappingLayout->addWidget( aPointYSecLabel, aRow + 2, 8 ); + if ( aPointType == HYDROGUI_PrsImage::PointC ) + { + myPointCEnabler = new QCheckBox( aManualInputGroup ); + aManualInputLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter ); + aManualInputLayout->addWidget( aPointBtn, aRow, 2, 1, 8 ); + } + else + { + aManualInputLayout->addWidget( aPointBtn, aRow, 0, 1, 10 ); + } + + aManualInputLayout->addWidget( aPointXLabel, aRow + 1, 0 ); + aManualInputLayout->addWidget( aPointX, aRow + 1, 1 ); + aManualInputLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 ); + aManualInputLayout->addWidget( aPointXDeg, aRow + 1, 3 ); + aManualInputLayout->addWidget( aPointXDegLabel, aRow + 1, 4 ); + aManualInputLayout->addWidget( aPointXMin, aRow + 1, 5 ); + aManualInputLayout->addWidget( aPointXMinLabel, aRow + 1, 6 ); + aManualInputLayout->addWidget( aPointXSec, aRow + 1, 7 ); + aManualInputLayout->addWidget( aPointXSecLabel, aRow + 1, 8 ); + aManualInputLayout->addWidget( aPointLonLabel, aRow + 1, 9 ); + + aManualInputLayout->addWidget( aCartPointX, aRow + 1, 3, 1, 6 ); + aManualInputLayout->addWidget( aRefPointX, aRow + 1, 3, 1, 6 ); + + aManualInputLayout->addWidget( aPointYLabel, aRow + 2, 0 ); + aManualInputLayout->addWidget( aPointY, aRow + 2, 1 ); + aManualInputLayout->addWidget( aPointYDeg, aRow + 2, 3 ); + aManualInputLayout->addWidget( aPointYDegLabel, aRow + 2, 4 ); + aManualInputLayout->addWidget( aPointYMin, aRow + 2, 5 ); + aManualInputLayout->addWidget( aPointYMinLabel, aRow + 2, 6 ); + aManualInputLayout->addWidget( aPointYSec, aRow + 2, 7 ); + aManualInputLayout->addWidget( aPointYSecLabel, aRow + 2, 8 ); + aManualInputLayout->addWidget( aPointLatLabel, aRow + 2, 9 ); + + aManualInputLayout->addWidget( aCartPointY, aRow + 2, 3, 1, 6 ); + aManualInputLayout->addWidget( aRefPointY, aRow + 2, 3, 1, 6 ); if( aPointType != HYDROGUI_PrsImage::PointC ) { - QFrame* aLine = new QFrame( myMappingGroup ); + QFrame* aLine = new QFrame( aManualInputGroup ); aLine->setFrameShape( QFrame::HLine ); aLine->setFrameShadow( QFrame::Sunken ); - aMappingLayout->addWidget( aLine, aRow + 3, 0, 1, 9 ); + aManualInputLayout->addWidget( aLine, aRow + 3, 0, 1, 10 ); } myPointBtnMap[ aPointType ] = aPointBtn; @@ -185,32 +252,131 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co myPointXSecMap[ aPointType ] = aPointXSec; myPointYSecMap[ aPointType ] = aPointYSec; + myCartPointXMap[ aPointType ] = aCartPointX; + myCartPointYMap[ aPointType ] = aCartPointY; + + myRefPointXMap[ aPointType ] = aRefPointX; + myRefPointYMap[ aPointType ] = aRefPointY; + connect( aPointBtn, SIGNAL( toggled( bool ) ), this, SLOT( onPointBtnToggled( bool ) ) ); + + connect( aPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) ); + connect( aPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) ); + + connect( aPointXDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) ); + connect( aPointYDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) ); + connect( aPointXMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) ); + connect( aPointYMin, SIGNAL( valueChanged( int ) ), this, SLOT( onGeodesicCoordChanged() ) ); + connect( aPointXSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) ); + connect( aPointYSec, SIGNAL( valueChanged( double ) ), this, SLOT( onGeodesicCoordChanged() ) ); + + connect( aCartPointX, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) ); + connect( aCartPointY, SIGNAL( valueChanged( double ) ), this, SLOT( onCartesianCoordChanged() ) ); + + connect( aRefPointX, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) ); + connect( aRefPointY, SIGNAL( valueChanged( int ) ), this, SLOT( onPointCoordChanged( int ) ) ); } - aMappingLayout->setColumnStretch( 1, 1 ); // x - aMappingLayout->setColumnStretch( 3, 1 ); // degrees - aMappingLayout->setColumnStretch( 5, 1 ); // minutes - aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits) - // Common - addWidget( myFileNameGroup, 0, 0 ); - addWidget( myImageNameGroup, 1, 0 ); - addWidget( myMappingGroup, 2, 0 ); + // Connect checkbox enabling point C + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointBtnMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYDegMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYMinMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointXSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myPointYSecMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myCartPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); + + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SLOT( onSetCIsUsed( bool ) ) ); + + aManualInputLayout->setColumnStretch( 1, 1 ); // double + aManualInputLayout->setColumnStretch( 3, 1 ); // degrees + aManualInputLayout->setColumnStretch( 5, 1 ); // minutes + aManualInputLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits) + + // Image georeferencement file widget + QWidget* aFromFileInputGroup = new QWidget( myTransformGroup ); + QBoxLayout* aFromFileInputLayout = new QHBoxLayout( aFromFileInputGroup ); + aFromFileInputLayout->setMargin( 5 ); + aFromFileInputLayout->setSpacing( 5 ); + + QLabel* aGeoFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFromFileInputGroup ); + + myGeoFileName = new QLineEdit( aFromFileInputGroup ); + myGeoFileName->setReadOnly( true ); + + QToolButton* aGeoBrowseBtn = new QToolButton( aFromFileInputGroup ); + aGeoBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); + + aFromFileInputLayout->addWidget( aGeoFileNameLabel ); + aFromFileInputLayout->addWidget( myGeoFileName ); + aFromFileInputLayout->addWidget( aGeoBrowseBtn ); + + // Widgets connections + connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setVisible ( bool ) ) ); + connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) ); + connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) ); + connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) ); + connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setVisible ( bool ) ) ); + connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) ); + connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) ); + connect( aManualGeodesicBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) ); + connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setVisible ( bool ) ) ); + connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) ); + connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) ); + connect( aRefImageBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setHidden ( bool ) ) ); + connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aFromFileInputGroup, SLOT( setVisible ( bool ) ) ); + connect( aCartesianFromFileBtn, SIGNAL( toggled( bool ) ), aManualInputGroup, SLOT( setHidden ( bool ) ) ); + + // Input widgets + aTransformLayout->addWidget( aManualInputGroup ); + aTransformLayout->addWidget( aFromFileInputGroup ); - setRowStretch(); + // Common + addWidget( myFileNameGroup ); + addWidget( myImageNameGroup ); + addWidget( myTransformGroup ); + addStretch(); connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + + connect( myModeGroup, SIGNAL( buttonClicked( int ) ), + this, SLOT( onModeActivated( int ) ) ); + + connect( aGeoBrowseBtn, SIGNAL( clicked() ), this, SLOT( onGeoBrowse() ) ); + + connect( myRefImage, SIGNAL( activated( const QString& ) ), + this, SLOT( onRefImageActivated( const QString& ) ) ); + + //setTransformationMode( HYDROData_Image::ManualCartesian ); + + setMinimumWidth( 350 ); } HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg() { } +void HYDROGUI_ImportImageDlg::onSetCIsUsed( bool theCIsUsed ) +{ + if ( !theCIsUsed && myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->isChecked() ) + { + // Turn on point A selection if point C selection has been activated and we disable point C. + myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->toggle(); + } + emit setCIsUsed( theCIsUsed ); +} + void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit ) { myFileNameGroup->setVisible( !theIsEdit ); myImageNameGroup->setEnabled( theIsEdit ); - myMappingGroup->setEnabled( theIsEdit ); + myTransformGroup->setEnabled( theIsEdit ); } void HYDROGUI_ImportImageDlg::reset() @@ -218,6 +384,10 @@ void HYDROGUI_ImportImageDlg::reset() myFileName->clear(); myImageName->clear(); myImageNameGroup->setEnabled( false ); + myGeoFileName->clear(); + bool isPBlocked = blockSignalsPoints( true ); + bool isGBlocked = blockSignalsGeodesic( true ); + bool isCBlocked = blockSignalsCartesian( true ); for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { @@ -226,16 +396,54 @@ void HYDROGUI_ImportImageDlg::reset() aBtn->setChecked( false ); aBtn->blockSignals( anIsBlocked ); - myPointXMap[ aPointType ]->clear(); - myPointYMap[ aPointType ]->clear(); - myPointXDegMap[ aPointType ]->clear(); - myPointYDegMap[ aPointType ]->clear(); - myPointXMinMap[ aPointType ]->clear(); - myPointYMinMap[ aPointType ]->clear(); - myPointXSecMap[ aPointType ]->clear(); - myPointYSecMap[ aPointType ]->clear(); + clearSpins( myPointXMap[ aPointType ] ); + clearSpins( myPointYMap[ aPointType ] ); + clearSpins( myPointXDegMap[ aPointType ] ); + clearSpins( myPointYDegMap[ aPointType ] ); + clearSpins( myPointXMinMap[ aPointType ] ); + clearSpins( myPointYMinMap[ aPointType ] ); + clearSpins( myPointXSecMap[ aPointType ] ); + clearSpins( myPointYSecMap[ aPointType ] ); + + clearSpins( myRefPointXMap[ aPointType ] ); + clearSpins( myRefPointYMap[ aPointType ] ); + + clearSpins( myCartPointXMap[ aPointType ] ); + clearSpins( myCartPointYMap[ aPointType ] ); } - myMappingGroup->setEnabled( false ); + blockSignalsPoints( isPBlocked ); + blockSignalsGeodesic( isGBlocked ); + blockSignalsCartesian( isCBlocked ); + + // Emulate turning off C point usage + myPointCEnabler->blockSignals( true ); + + myPointCEnabler->setChecked( false ); + myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myRefPointXMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + myRefPointYMap[ HYDROGUI_PrsImage::PointC ]->setEnabled( false ); + onSetCIsUsed( false ); + + myPointCEnabler->blockSignals( false ); + + myTransformGroup->setEnabled( false ); + myRefImage->clear(); + + setTransformationMode( HYDROData_Image::ManualCartesian ); + + myPrsPointDataList.clear(); + + myIsInitialized = false; } void HYDROGUI_ImportImageDlg::setImageName( const QString& theName ) @@ -248,116 +456,316 @@ QString HYDROGUI_ImportImageDlg::getImageName() const return myImageName->text(); } +void HYDROGUI_ImportImageDlg::setRefImageName( const QString& theName ) +{ + myRefImage->setCurrentIndex( myRefImage->findText( theName ) ); +} + +QString HYDROGUI_ImportImageDlg::getRefImageName() const +{ + return myRefImage->currentText(); +} + +QString HYDROGUI_ImportImageDlg::getFileName() const +{ + return myFileName->text(); +} + +void HYDROGUI_ImportImageDlg::setFileName( const QString& theName ) +{ + myFileName->setText( theName ); + myImageNameGroup->setEnabled( true ); + myTransformGroup->setEnabled( true ); +} + +QString HYDROGUI_ImportImageDlg::getGeoreferencementFileName() const +{ + return myGeoFileName->text(); +} + +void HYDROGUI_ImportImageDlg::setImageSize( const QSize& theSize, + const bool theIsRefImage ) +{ + int aWidth = theSize.width(); + int aHeight = theSize.height(); + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + if( theIsRefImage ) + { + myRefPointXMap[ aPointType ]->setRange( 0, aWidth ); + myRefPointYMap[ aPointType ]->setRange( 0, aHeight ); + } + else + { + myPointXMap[ aPointType ]->setRange( 0, aWidth ); + myPointYMap[ aPointType ]->setRange( 0, aHeight ); + } + } +} + +void HYDROGUI_ImportImageDlg::setTransformationMode( const int theMode ) +{ + myModeGroup->button( theMode )->setChecked( true ); + onModeActivated( theMode ); +} + +int HYDROGUI_ImportImageDlg::getTransformationMode() const +{ + return myModeGroup->checkedId(); +} + +void HYDROGUI_ImportImageDlg::setByTwoPoints( const bool theIsByTwoPoints ) +{ + myPointCEnabler->setChecked( !theIsByTwoPoints ); +} + +bool HYDROGUI_ImportImageDlg::isByTwoPoints() const +{ + return !myPointCEnabler->isChecked(); +} + void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationDataMap& theMap, - const bool theIsOnlyInput ) + const bool theIsOnlyInput, + const bool theIsRefImage ) { + blockSignalsGeodesic( true ); + blockSignalsCartesian( true ); for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { if( theMap.contains( aPointType ) ) { const TransformationData& aData = theMap[ aPointType ]; - myPointXMap[ aPointType ]->setText( QString::number( aData.first.x() ) ); - myPointYMap[ aPointType ]->setText( QString::number( aData.first.y() ) ); - if( !theIsOnlyInput ) + QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ]; + QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ]; + aPointX->setValue( aData.ImagePoint.x() ); + aPointY->setValue( aData.ImagePoint.y() ); + + if( !theIsOnlyInput && !theIsRefImage ) { - QPointF aPoint = aData.second; + QPointF aLPoint = aData.GeodesicPoint; int aXDeg = 0, aYDeg = 0; int aXMin = 0, aYMin = 0; double aXSec = 0, aYSec = 0; - HYDROGUI_Tool::DoubleToLambert( aPoint.x(), aXDeg, aXMin, aXSec ); - HYDROGUI_Tool::DoubleToLambert( aPoint.y(), aYDeg, aYMin, aYSec ); - - myPointXDegMap[ aPointType ]->setText( QString::number( aXDeg ) ); - myPointYDegMap[ aPointType ]->setText( QString::number( aYDeg ) ); - myPointXMinMap[ aPointType ]->setText( QString::number( aXMin ) ); - myPointYMinMap[ aPointType ]->setText( QString::number( aYMin ) ); - myPointXSecMap[ aPointType ]->setText( QString::number( aXSec ) ); - myPointYSecMap[ aPointType ]->setText( QString::number( aYSec ) ); + HYDROData_Lambert93::degToDMS( aLPoint.x(), aXDeg, aXMin, aXSec ); + HYDROData_Lambert93::degToDMS( aLPoint.y(), aYDeg, aYMin, aYSec ); + + myPointXDegMap[ aPointType ]->setValue( aXDeg ); + myPointYDegMap[ aPointType ]->setValue( aYDeg ); + myPointXMinMap[ aPointType ]->setValue( aXMin ); + myPointYMinMap[ aPointType ]->setValue( aYMin ); + myPointXSecMap[ aPointType ]->setValue( aXSec ); + myPointYSecMap[ aPointType ]->setValue( aYSec ); + + QPointF aCPoint = aData.CartesianPoint; + myCartPointXMap[ aPointType ]->setValue( aCPoint.x() ); + myCartPointYMap[ aPointType ]->setValue( aCPoint.y() ); } } } + blockSignalsGeodesic( false ); + blockSignalsCartesian( false ); } -bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap ) const +bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& theMap, + const bool theIsRefImage ) const { theMap.clear(); for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { - bool anIsOk[8]; - for( int i = 0; i < 8; i++ ) - anIsOk[ i ] = false; - - int aX1 = myPointXMap[ aPointType ]->text().toInt( &anIsOk[0] ); - int aY1 = myPointYMap[ aPointType ]->text().toInt( &anIsOk[1] ); - int aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] ); - int aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] ); - int aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] ); - int aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] ); - double aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] ); - double aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] ); - - for( int i = 0; i < 8; i++ ) + bool anIsOk[10]; + for( int i = 0; i < 10; i++ ) + anIsOk[ i ] = true; + + QtxIntSpinBox* aPointX = theIsRefImage ? myRefPointXMap[ aPointType ] : myPointXMap[ aPointType ]; + QtxIntSpinBox* aPointY = theIsRefImage ? myRefPointYMap[ aPointType ] : myPointYMap[ aPointType ]; + int aX1 = aPointX->text().toInt( &anIsOk[0] ); + int aY1 = aPointY->text().toInt( &anIsOk[1] ); + + int aXDeg = 0, aYDeg = 0; + int aXMin = 0, aYMin = 0; + double aXSec = 0, aYSec = 0; + double aXCart = 0, aYCart = 0; + if( !theIsRefImage ) + { + aXDeg = myPointXDegMap[ aPointType ]->text().toInt( &anIsOk[2] ); + aYDeg = myPointYDegMap[ aPointType ]->text().toInt( &anIsOk[3] ); + aXMin = myPointXMinMap[ aPointType ]->text().toInt( &anIsOk[4] ); + aYMin = myPointYMinMap[ aPointType ]->text().toInt( &anIsOk[5] ); + aXSec = myPointXSecMap[ aPointType ]->text().toDouble( &anIsOk[6] ); + aYSec = myPointYSecMap[ aPointType ]->text().toDouble( &anIsOk[7] ); + + aXCart = myCartPointXMap[ aPointType ]->text().toDouble( &anIsOk[8] ); + aYCart = myCartPointYMap[ aPointType ]->text().toDouble( &anIsOk[9] ); + } + + for( int i = 0; i < 10; i++ ) if( !anIsOk[ i ] ) return false; double aX2 = 0, aY2 = 0; - HYDROGUI_Tool::LambertToDouble( aXDeg, aXMin, aXSec, aX2 ); - HYDROGUI_Tool::LambertToDouble( aYDeg, aYMin, aYSec, aY2 ); + HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aX2 ); + HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aY2 ); - TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ) ); + TransformationData aData( QPoint( aX1, aY1 ), QPointF( aX2, aY2 ), QPointF( aXCart, aYCart ) ); theMap[ aPointType ] = aData; } return true; } +void HYDROGUI_ImportImageDlg::setPrsPointDataList( const PrsPointDataList& theList ) +{ + myPrsPointDataList = theList; + + if( !myPrsPointDataList.isEmpty() ) + { + myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( true ); + + myRefImage->clear(); + myRefImage->addItem( "" ); // first empty item + + PrsPointDataListIterator anIter( myPrsPointDataList ); + while( anIter.hasNext() ) + myRefImage->addItem( anIter.next().first ); + } + else + myModeGroup->button( HYDROData_Image::ReferenceImage )->setEnabled( false ); +} + void HYDROGUI_ImportImageDlg::initializePointSelection() { + if( myIsInitialized ) + return; + + myIsInitialized = true; + myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true ); - // ouv: tmp - myPointXDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" ); - myPointXMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" ); - myPointXSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" ); - myPointYDegMap[ HYDROGUI_PrsImage::PointA ]->setText( "50" ); - myPointYMinMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" ); - myPointYSecMap[ HYDROGUI_PrsImage::PointA ]->setText( "0" ); - - myPointXDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" ); - myPointXMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "1" ); - myPointXSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" ); - myPointYDegMap[ HYDROGUI_PrsImage::PointB ]->setText( "50" ); - myPointYMinMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" ); - myPointYSecMap[ HYDROGUI_PrsImage::PointB ]->setText( "0" ); - - myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" ); - myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" ); - myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" ); - myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setText( "50" ); - myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setText( "1" ); - myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setText( "0" ); + double aCartX0 = LAMBERT_X0; + double aCartY0 = LAMBERT_Y0; + + blockSignalsCartesian( true ); + + myCartPointXMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartX0 ); + myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + IMG_DELTA ); + + myCartPointXMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartX0 + IMG_DELTA ); + myCartPointYMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartY0 + IMG_DELTA ); + + myCartPointXMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartX0 ); + myCartPointYMap[ HYDROGUI_PrsImage::PointC ]->setValue( aCartY0 ); + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + onCartesianCoordChanged( aPointType ); + + blockSignalsCartesian( false ); +} + +HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData( + const int theMode, + const QPoint& theLocalPoint, + const QPointF& theGlobalPoint ) +{ + TransformationData aResTrsfData; + aResTrsfData.ImagePoint = theLocalPoint; + + double arx = theGlobalPoint.x(); + double ary = theGlobalPoint.y(); + if ( theMode == HYDROData_Image::ManualGeodesic ) + { + // Geodesic to Cartesian + double aXCart = 0, aYCart = 0; + // Interpreting arY as attitude and arX as longitude + HYDROData_Lambert93::toXY( ary, arx, aXCart, aYCart ); + + aResTrsfData.GeodesicPoint = theGlobalPoint; + aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart ); + } + else if ( theMode == HYDROData_Image::ManualCartesian ) + { + // Cartesian to Geodesic + double aLonDeg = 0, aLatDeg = 0; + HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg ); + + aResTrsfData.CartesianPoint = theGlobalPoint; + aResTrsfData.GeodesicPoint = QPointF( aLonDeg, aLatDeg ); + } + + return aResTrsfData; } void HYDROGUI_ImportImageDlg::onBrowse() { QString aFilter( tr( "IMAGE_FILTER" ) ); - QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter ); - //QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp"; + QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true ); if( !aFileName.isEmpty() ) { QImage anImage( aFileName ); - if( !anImage.isNull() ) + if( anImage.isNull() ) { - myFileName->setText( aFileName ); + QString aTitle = QObject::tr( "INPUT_VALID_DATA" ); + QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ). + arg( aFileName ).arg( QFileInfo( aFileName ).suffix() ); + SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage ); + } + else + { + setFileName( aFileName ); emit createPreview( anImage ); - myImageNameGroup->setEnabled( true ); - myMappingGroup->setEnabled( true ); } } } +void HYDROGUI_ImportImageDlg::onGeoBrowse() +{ + QString aFilter( tr( "IMAGE_GEOREFERENCEMENT_FILTER" ) ); + QString aGeoFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_GEO_DATA_FROM_FILE" ), true ); + if( !aGeoFileName.isEmpty() ) { + myGeoFileName->setText( aGeoFileName ); + } +} + +void HYDROGUI_ImportImageDlg::onModeActivated( int theMode ) +{ + bool anIsManualGeodesic = theMode == HYDROData_Image::ManualGeodesic; + bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian; + bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage; + + myRefImage->setEnabled( anIsRefImage ); + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + myPointXDegMap[ aPointType ]->setVisible( anIsManualGeodesic ); + myPointYDegMap[ aPointType ]->setVisible( anIsManualGeodesic ); + myPointXMinMap[ aPointType ]->setVisible( anIsManualGeodesic ); + myPointYMinMap[ aPointType ]->setVisible( anIsManualGeodesic ); + myPointXSecMap[ aPointType ]->setVisible( anIsManualGeodesic ); + myPointYSecMap[ aPointType ]->setVisible( anIsManualGeodesic ); + + myCartPointXMap[ aPointType ]->setVisible( anIsManualCartesian ); + myCartPointYMap[ aPointType ]->setVisible( anIsManualCartesian ); + + myRefPointXMap[ aPointType ]->setVisible( anIsRefImage ); + myRefPointYMap[ aPointType ]->setVisible( anIsRefImage ); + } + + QListIterator anIter( myGeodesicLabels ); + while( anIter.hasNext() ) + anIter.next()->setVisible( anIsManualGeodesic ); + + emit modeActivated( theMode ); +} + +void HYDROGUI_ImportImageDlg::onRefImageActivated( const QString& theName ) +{ + emit refImageActivated( theName ); +} + void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState ) { int aPointType = HYDROGUI_PrsImage::None; @@ -380,3 +788,195 @@ void HYDROGUI_ImportImageDlg::onPointBtnToggled( bool theState ) } emit activatePointSelection( aPointType ); } + +void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue ) +{ + QObject* aSender = sender(); + if( !aSender ) + return; + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + if( aSender == myPointXMap[ aPointType ] || + aSender == myPointYMap[ aPointType ] ) + { + bool anIsY = aSender == myPointYMap[ aPointType ]; + emit pointCoordChanged( false, aPointType, anIsY, theValue ); + } + else if( aSender == myRefPointXMap[ aPointType ] || + aSender == myRefPointYMap[ aPointType ] ) + { + bool anIsY = aSender == myRefPointYMap[ aPointType ]; + emit pointCoordChanged( true, aPointType, anIsY, theValue ); + } + } +} + +void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged() +{ + QObject* aSender = sender(); + if( !aSender ) + return; + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + if( aSender == myPointXDegMap[ aPointType ] || + aSender == myPointYDegMap[ aPointType ] || + aSender == myPointXMinMap[ aPointType ] || + aSender == myPointYMinMap[ aPointType ] || + aSender == myPointXSecMap[ aPointType ] || + aSender == myPointYSecMap[ aPointType ] ) + { + onGeodesicCoordChanged( aPointType ); + return; + } + } +} + +void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged( const int thePointType ) +{ + bool anIsOk[6]; + for( int i = 0; i < 6; i++ ) + anIsOk[ i ] = true; + + int aXDeg = myPointXDegMap[ thePointType ]->text().toInt( &anIsOk[0] ); + int aYDeg = myPointYDegMap[ thePointType ]->text().toInt( &anIsOk[1] ); + int aXMin = myPointXMinMap[ thePointType ]->text().toInt( &anIsOk[2] ); + int aYMin = myPointYMinMap[ thePointType ]->text().toInt( &anIsOk[3] ); + double aXSec = myPointXSecMap[ thePointType ]->text().toDouble( &anIsOk[4] ); + double aYSec = myPointYSecMap[ thePointType ]->text().toDouble( &anIsOk[5] ); + + for( int i = 0; i < 6; i++ ) + if( !anIsOk[ i ] ) + return; + + double aLonDeg = 0, aLatDeg = 0; + HYDROData_Lambert93::DMSToDeg( aXDeg, aXMin, aXSec, aLonDeg ); + HYDROData_Lambert93::DMSToDeg( aYDeg, aYMin, aYSec, aLatDeg ); + + double aXCart = 0, aYCart = 0; + HYDROData_Lambert93::toXY( aLatDeg, aLonDeg, aXCart, aYCart ); + + blockSignalsCartesian( true ); + + myCartPointXMap[ thePointType ]->setValue( aXCart ); + myCartPointYMap[ thePointType ]->setValue( aYCart ); + + blockSignalsCartesian( false ); +} + +void HYDROGUI_ImportImageDlg::onCartesianCoordChanged() +{ + QObject* aSender = sender(); + if( !aSender ) + return; + + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + if( aSender == myCartPointXMap[ aPointType ] || + aSender == myCartPointYMap[ aPointType ] ) + { + onCartesianCoordChanged( aPointType ); + return; + } + } +} + +void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType ) +{ + bool anIsOk[2]; + for( int i = 0; i < 2; i++ ) + anIsOk[ i ] = true; + + double aXCart = myCartPointXMap[ thePointType ]->text().toDouble( &anIsOk[0] ); + double aYCart = myCartPointYMap[ thePointType ]->text().toDouble( &anIsOk[1] ); + + for( int i = 0; i < 2; i++ ) + if( !anIsOk[ i ] ) + return; + + double aLonDeg = 0, aLatDeg = 0; + HYDROData_Lambert93::toGeo( aXCart, aYCart, aLatDeg, aLonDeg ); + + int aXDeg = 0, aYDeg = 0; + int aXMin = 0, aYMin = 0; + double aXSec = 0, aYSec = 0; + HYDROData_Lambert93::degToDMS( aLonDeg, aXDeg, aXMin, aXSec ); + HYDROData_Lambert93::degToDMS( aLatDeg, aYDeg, aYMin, aYSec ); + + blockSignalsGeodesic( true ); + + myPointXDegMap[ thePointType ]->setValue( aXDeg ); + myPointYDegMap[ thePointType ]->setValue( aYDeg ); + myPointXMinMap[ thePointType ]->setValue( aXMin ); + myPointYMinMap[ thePointType ]->setValue( aYMin ); + myPointXSecMap[ thePointType ]->setValue( aXSec ); + myPointYSecMap[ thePointType ]->setValue( aYSec ); + + blockSignalsGeodesic( false ); +} + +void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin ) +{ + if ( dynamic_cast( theSpin ) ) + { + QtxIntSpinBox* aSpin = dynamic_cast( theSpin ); + aSpin->setValue( aSpin->minimum() ); + } + else if ( dynamic_cast( theSpin ) ) + { + QtxDoubleSpinBox* aDblSpin = dynamic_cast( theSpin ); + aDblSpin->setValue( aDblSpin->minimum() ); + } + + theSpin->clear(); +} + +bool HYDROGUI_ImportImageDlg::blockSignalsPoints( const bool theState ) +{ + bool isBlocked = false; + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + isBlocked = + myPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked; + myPointYMap[ aPointType ]->blockSignals( theState ); + + myRefPointXMap[ aPointType ]->blockSignals( theState ); + myRefPointYMap[ aPointType ]->blockSignals( theState ); + } + return isBlocked; +} + +bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState ) +{ + bool isBlocked = false; + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + isBlocked = + myPointXDegMap[ aPointType ]->blockSignals( theState ) || isBlocked; + myPointXMinMap[ aPointType ]->blockSignals( theState ); + myPointXSecMap[ aPointType ]->blockSignals( theState ); + myPointYDegMap[ aPointType ]->blockSignals( theState ); + myPointYMinMap[ aPointType ]->blockSignals( theState ); + myPointYSecMap[ aPointType ]->blockSignals( theState ); + } + return isBlocked; +} + +bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState ) +{ + bool isBlocked = false; + for( int aPointType = HYDROGUI_PrsImage::PointA; + aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) + { + isBlocked = + myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked; + myCartPointYMap[ aPointType ]->blockSignals( theState ); + } + return isBlocked; +}