X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ImportImageDlg.cxx;h=2a65913e0af635fdbfcb97f1b48283a3c3d2421e;hb=a53349567d67f4df0ef737798a25c24d9dc8f08e;hp=775a43bac416a6d3a002d8cf2e36110be405ebae;hpb=e462de6222a46d226e7353f8bb91b60deadf81c2;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 775a43ba..2a65913e 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,12 +20,16 @@ #include "HYDROGUI_PrsImage.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Module.h" #include #include +#include #include #include +#include +#include #include #include @@ -62,15 +62,15 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co myFileName = new QLineEdit( myFileNameGroup ); myFileName->setReadOnly( true ); - QToolButton* aBrowseBtn = new QToolButton( myFileNameGroup ); - aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); + myBrowseBtn = new QToolButton( myFileNameGroup ); + myBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); QBoxLayout* aFileNameLayout = new QHBoxLayout( myFileNameGroup ); aFileNameLayout->setMargin( 5 ); aFileNameLayout->setSpacing( 5 ); aFileNameLayout->addWidget( aFileNameLabel ); aFileNameLayout->addWidget( myFileName ); - aFileNameLayout->addWidget( aBrowseBtn ); + aFileNameLayout->addWidget( myBrowseBtn ); // Image name myImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ), this ); @@ -98,51 +98,50 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aPainter.drawPixmap( 0, 0, anArrowPixmap ); aPainter.end(); - QRadioButton* aManualCartesianBtn = new QRadioButton( tr( "MANUALLY_CARTESIAN" ), myTransformGroup ); - QRadioButton* aManualLambertBtn = new QRadioButton( tr( "MANUALLY_LAMBERT93" ), myTransformGroup ); + 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( aManualLambertBtn, HYDROData_Image::ManualLambert ); + myModeGroup->addButton( aCartesianFromFileBtn, HYDROData_Image::CartesianFromFile ); myModeGroup->addButton( aRefImageBtn, HYDROData_Image::ReferenceImage ); myRefImage = new QComboBox( myTransformGroup ); - QGridLayout* aTransformLayout = new QGridLayout( 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( aManualCartesianBtn, 0, 0 ); - aModeLayout->addWidget( aManualLambertBtn, 1, 0 ); - aModeLayout->addWidget( aRefImageBtn, 2, 0 ); - aModeLayout->addWidget( myRefImage, 2, 1 ); + 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, 0, 0, 1, 9 ); + aTransformLayout->addLayout( aModeLayout ); - QLabel* aImageCSLabel = new QLabel( tr( "IMAGE_CS" ), myTransformGroup ); - QLabel* aGeodesicLabel = new QLabel( tr( "GEODESIC" ), myTransformGroup ); - QLabel* aLambertLabel = new QLabel( tr( "LAMBERT93" ), myTransformGroup ); - QLabel* aRefImageLabel = new QLabel( tr( "REFERENCE_IMAGE_CS" ), myTransformGroup ); + // Manual input widget + QWidget* aManualInputGroup = new QWidget( myTransformGroup ); + QGridLayout* aManualInputLayout = new QGridLayout( aManualInputGroup ); + aManualInputLayout->setMargin( 5 ); + aManualInputLayout->setSpacing( 5 ); - aTransformLayout->addWidget( aImageCSLabel, 2, 1 ); - aTransformLayout->addWidget( aGeodesicLabel, 2, 3, 1, 6 ); - aTransformLayout->addWidget( aLambertLabel, 2, 3, 1, 6 ); - aTransformLayout->addWidget( aRefImageLabel, 2, 3, 1, 6 ); + 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 ); - connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setVisible ( bool ) ) ); - connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setHidden ( bool ) ) ); - connect( aManualCartesianBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, SLOT( setHidden ( bool ) ) ); - connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aLambertLabel, SLOT( setVisible ( bool ) ) ); - connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aGeodesicLabel, SLOT( setHidden ( bool ) ) ); - connect( aManualLambertBtn, SIGNAL( toggled( bool ) ), aRefImageLabel, 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 ) ) ); + 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++ ) @@ -157,81 +156,86 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co QPushButton* aPointBtn = new QPushButton( aPointStr, myTransformGroup ); aPointBtn->setCheckable( true ); - QLabel* aPointXLabel = new QLabel( "X", myTransformGroup ); - QLabel* aPointYLabel = new QLabel( "Y", myTransformGroup ); + QLabel* aPointXLabel = new QLabel( "X", aManualInputGroup ); + QLabel* aPointYLabel = new QLabel( "Y", aManualInputGroup ); - QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later - QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later + QtxIntSpinBox* aPointX = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later + QtxIntSpinBox* aPointY = new QtxIntSpinBox( 0, 0, 1, aManualInputGroup ); // max is updated later - QLabel* aPointArrowLabel = new QLabel( myTransformGroup ); + QLabel* aPointArrowLabel = new QLabel( aManualInputGroup ); aPointArrowLabel->setPicture( anArrowPicture ); - QLabel* aPointXDegLabel = new QLabel( QChar( 0x00B0 ), myTransformGroup ); - QLabel* aPointYDegLabel = new QLabel( QChar( 0x00B0 ), myTransformGroup ); - QLabel* aPointXMinLabel = new QLabel( "'", myTransformGroup ); - QLabel* aPointYMinLabel = new QLabel( "'", myTransformGroup ); - QLabel* aPointXSecLabel = new QLabel( "\"", myTransformGroup ); - QLabel* aPointYSecLabel = new QLabel( "\"", myTransformGroup ); - myLambertLabels << aPointXDegLabel << aPointYDegLabel + 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; + << aPointXSecLabel << aPointYSecLabel + << aPointLonLabel << aPointLatLabel; - QtxIntSpinBox* aPointXDeg = new QtxIntSpinBox( -180, 180, 1, myTransformGroup ); - QtxIntSpinBox* aPointYDeg = new QtxIntSpinBox( -90, 90, 1, myTransformGroup ); - QtxIntSpinBox* aPointXMin = new QtxIntSpinBox( 0, 59, 1, myTransformGroup ); - QtxIntSpinBox* aPointYMin = new QtxIntSpinBox( 0, 59, 1, myTransformGroup ); - QtxDoubleSpinBox* aPointXSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, myTransformGroup ); - QtxDoubleSpinBox* aPointYSec = new QtxDoubleSpinBox( 0, 59.9999, 1, 4, 4, myTransformGroup ); + 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, myTransformGroup ); - QtxDoubleSpinBox* aCartPointY = new QtxDoubleSpinBox( 0, 1e8, 1, 2, 2, myTransformGroup ); + 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, myTransformGroup ); // max is updated later - QtxIntSpinBox* aRefPointY = new QtxIntSpinBox( 0, 0, 1, myTransformGroup ); // max is updated later + 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 + 3; + int aRow = 4 * aPointType; if ( aPointType == HYDROGUI_PrsImage::PointC ) { - myPointCEnabler = new QCheckBox( myTransformGroup ); - aTransformLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter ); - aTransformLayout->addWidget( aPointBtn, aRow, 2, 1, 7 ); + myPointCEnabler = new QCheckBox( aManualInputGroup ); + aManualInputLayout->addWidget( myPointCEnabler, aRow, 0, 1, 2, Qt::AlignHCenter ); + aManualInputLayout->addWidget( aPointBtn, aRow, 2, 1, 8 ); } else { - aTransformLayout->addWidget( aPointBtn, aRow, 0, 1, 9 ); + aManualInputLayout->addWidget( aPointBtn, aRow, 0, 1, 10 ); } - aTransformLayout->addWidget( aPointXLabel, aRow + 1, 0 ); - aTransformLayout->addWidget( aPointX, aRow + 1, 1 ); - aTransformLayout->addWidget( aPointArrowLabel, aRow + 1, 2, 2, 1 ); - aTransformLayout->addWidget( aPointXDeg, aRow + 1, 3 ); - aTransformLayout->addWidget( aPointXDegLabel, aRow + 1, 4 ); - aTransformLayout->addWidget( aPointXMin, aRow + 1, 5 ); - aTransformLayout->addWidget( aPointXMinLabel, aRow + 1, 6 ); - aTransformLayout->addWidget( aPointXSec, aRow + 1, 7 ); - aTransformLayout->addWidget( aPointXSecLabel, aRow + 1, 8 ); - - aTransformLayout->addWidget( aCartPointX, aRow + 1, 3, 1, 6 ); - aTransformLayout->addWidget( aRefPointX, aRow + 1, 3, 1, 6 ); - - aTransformLayout->addWidget( aPointYLabel, aRow + 2, 0 ); - aTransformLayout->addWidget( aPointY, aRow + 2, 1 ); - aTransformLayout->addWidget( aPointYDeg, aRow + 2, 3 ); - aTransformLayout->addWidget( aPointYDegLabel, aRow + 2, 4 ); - aTransformLayout->addWidget( aPointYMin, aRow + 2, 5 ); - aTransformLayout->addWidget( aPointYMinLabel, aRow + 2, 6 ); - aTransformLayout->addWidget( aPointYSec, aRow + 2, 7 ); - aTransformLayout->addWidget( aPointYSecLabel, aRow + 2, 8 ); - - aTransformLayout->addWidget( aCartPointY, aRow + 2, 3, 1, 6 ); - aTransformLayout->addWidget( aRefPointY, aRow + 2, 3, 1, 6 ); + 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( myTransformGroup ); + QFrame* aLine = new QFrame( aManualInputGroup ); aLine->setFrameShape( QFrame::HLine ); aLine->setFrameShadow( QFrame::Sunken ); - aTransformLayout->addWidget( aLine, aRow + 3, 0, 1, 9 ); + aManualInputLayout->addWidget( aLine, aRow + 3, 0, 1, 10 ); } myPointBtnMap[ aPointType ] = aPointBtn; @@ -255,12 +259,12 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co 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( onLambertCoordChanged() ) ); - connect( aPointYDeg, SIGNAL( valueChanged( int ) ), this, SLOT( onLambertCoordChanged() ) ); - connect( aPointXMin, SIGNAL( valueChanged( int ) ), this, SLOT( onLambertCoordChanged() ) ); - connect( aPointYMin, SIGNAL( valueChanged( int ) ), this, SLOT( onLambertCoordChanged() ) ); - connect( aPointXSec, SIGNAL( valueChanged( double ) ), this, SLOT( onLambertCoordChanged() ) ); - connect( aPointYSec, SIGNAL( valueChanged( double ) ), this, SLOT( onLambertCoordChanged() ) ); + 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() ) ); @@ -284,10 +288,50 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); - aTransformLayout->setColumnStretch( 1, 1 ); // double - aTransformLayout->setColumnStretch( 3, 1 ); // degrees - aTransformLayout->setColumnStretch( 5, 1 ); // minutes - aTransformLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits) + 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 ); // Common addWidget( myFileNameGroup ); @@ -295,15 +339,17 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co addWidget( myTransformGroup ); addStretch(); - connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + connect( myBrowseBtn, 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::ManualLambert ); + //setTransformationMode( HYDROData_Image::ManualCartesian ); setMinimumWidth( 350 ); } @@ -312,6 +358,16 @@ 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 ); @@ -324,6 +380,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++ ) { @@ -332,27 +392,50 @@ 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 ] ); - myRefPointXMap[ aPointType ]->clear(); - myRefPointYMap[ aPointType ]->clear(); + clearSpins( myRefPointXMap[ aPointType ] ); + clearSpins( myRefPointYMap[ aPointType ] ); - myCartPointXMap[ aPointType ]->clear(); - myCartPointYMap[ aPointType ]->clear(); + clearSpins( myCartPointXMap[ aPointType ] ); + clearSpins( myCartPointYMap[ aPointType ] ); } - myPointCEnabler->setChecked( true ); - myPointCEnabler->toggle(); + 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::ManualLambert ); + setTransformationMode( HYDROData_Image::ManualCartesian ); myPrsPointDataList.clear(); @@ -384,6 +467,18 @@ 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 ) { @@ -430,7 +525,7 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData const bool theIsOnlyInput, const bool theIsRefImage ) { - blockSignalsLambert( true ); + blockSignalsGeodesic( true ); blockSignalsCartesian( true ); for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) @@ -446,12 +541,12 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData if( !theIsOnlyInput && !theIsRefImage ) { - QPointF aLPoint = aData.LambertPoint; + QPointF aLPoint = aData.GeodesicPoint; int aXDeg = 0, aYDeg = 0; int aXMin = 0, aYMin = 0; double aXSec = 0, aYSec = 0; - HYDROData_Lambert93::secToDMS( aLPoint.x(), aXDeg, aXMin, aXSec ); - HYDROData_Lambert93::secToDMS( aLPoint.y(), aYDeg, aYMin, 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 ); @@ -466,7 +561,7 @@ void HYDROGUI_ImportImageDlg::setTransformationDataMap( const TransformationData } } } - blockSignalsLambert( false ); + blockSignalsGeodesic( false ); blockSignalsCartesian( false ); } @@ -508,8 +603,8 @@ bool HYDROGUI_ImportImageDlg::getTransformationDataMap( TransformationDataMap& t return false; double aX2 = 0, aY2 = 0; - HYDROData_Lambert93::DMSToSec( aXDeg, aXMin, aXSec, aX2 ); - HYDROData_Lambert93::DMSToSec( 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 ), QPointF( aXCart, aYCart ) ); theMap[ aPointType ] = aData; @@ -545,50 +640,16 @@ void HYDROGUI_ImportImageDlg::initializePointSelection() myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true ); - // ouv: tmp - /* - blockSignalsLambert( true ); - - myPointXDegMap[ HYDROGUI_PrsImage::PointA ]->setValue( 50 ); - myPointXMinMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 ); - myPointXSecMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 ); - myPointYDegMap[ HYDROGUI_PrsImage::PointA ]->setValue( 50 ); - myPointYMinMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 ); - myPointYSecMap[ HYDROGUI_PrsImage::PointA ]->setValue( 0 ); - - myPointXDegMap[ HYDROGUI_PrsImage::PointB ]->setValue( 50 ); - myPointXMinMap[ HYDROGUI_PrsImage::PointB ]->setValue( 1 ); - myPointXSecMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 ); - myPointYDegMap[ HYDROGUI_PrsImage::PointB ]->setValue( 50 ); - myPointYMinMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 ); - myPointYSecMap[ HYDROGUI_PrsImage::PointB ]->setValue( 0 ); - - myPointXDegMap[ HYDROGUI_PrsImage::PointC ]->setValue( 50 ); - myPointXMinMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 ); - myPointXSecMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 ); - myPointYDegMap[ HYDROGUI_PrsImage::PointC ]->setValue( 50 ); - myPointYMinMap[ HYDROGUI_PrsImage::PointC ]->setValue( 1 ); - myPointYSecMap[ HYDROGUI_PrsImage::PointC ]->setValue( 0 ); - - for( int aPointType = HYDROGUI_PrsImage::PointA; - aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) - onLambertCoordChanged( aPointType ); - - blockSignalsLambert( false ); - */ - - //double aCartX0 = 600000; - //double aCartY0 = 6800000; - double aCartX0 = 0; - double aCartY0 = 0; + double aCartX0 = LAMBERT_X0; + double aCartY0 = LAMBERT_Y0; blockSignalsCartesian( true ); myCartPointXMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartX0 ); - myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + 500 ); + myCartPointYMap[ HYDROGUI_PrsImage::PointA ]->setValue( aCartY0 + IMG_DELTA ); - myCartPointXMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartX0 + 500 ); - myCartPointYMap[ HYDROGUI_PrsImage::PointB ]->setValue( aCartY0 + 500 ); + 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 ); @@ -610,23 +671,24 @@ HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsf double arx = theGlobalPoint.x(); double ary = theGlobalPoint.y(); - if ( theMode == HYDROData_Image::ManualLambert ) + if ( theMode == HYDROData_Image::ManualGeodesic ) { - // Lambert to Cartesian + // Geodesic to Cartesian double aXCart = 0, aYCart = 0; - HYDROData_Lambert93::toXY( arx, ary, aXCart, aYCart ); + // Interpreting arY as attitude and arX as longitude + HYDROData_Lambert93::toXY( ary, arx, aXCart, aYCart ); - aResTrsfData.LambertPoint = theGlobalPoint; + aResTrsfData.GeodesicPoint = theGlobalPoint; aResTrsfData.CartesianPoint = QPointF( aXCart, aYCart ); } else if ( theMode == HYDROData_Image::ManualCartesian ) { - // Cartesian to Lambert + // Cartesian to Geodesic double aLonDeg = 0, aLatDeg = 0; HYDROData_Lambert93::toGeo( arx, ary, aLatDeg, aLonDeg ); aResTrsfData.CartesianPoint = theGlobalPoint; - aResTrsfData.LambertPoint = QPointF( aLonDeg, aLatDeg ); + aResTrsfData.GeodesicPoint = QPointF( aLonDeg, aLatDeg ); } return aResTrsfData; @@ -635,23 +697,46 @@ HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsf void HYDROGUI_ImportImageDlg::onBrowse() { QString aFilter( tr( "IMAGE_FILTER" ) ); - QString aFileName = SUIT_FileDlg::getFileName( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true ); - if( !aFileName.isEmpty() ) + QStringList aFileNamesList = SUIT_FileDlg::getOpenFileNames( this, "", aFilter, tr( "IMPORT_IMAGE_FROM_FILE" ), true ); + emit filesSelected( aFileNamesList ); +} + +void HYDROGUI_ImportImageDlg::ActivateFile( const QString& theFileName, bool isEnableFilesChoice ) +{ + myFileName->setEnabled( isEnableFilesChoice ); + myBrowseBtn->setEnabled( isEnableFilesChoice ); + + if( !theFileName.isEmpty() ) { - QImage anImage( aFileName ); - if( !anImage.isNull() ) + QImage anImage( theFileName ); + if( anImage.isNull() ) { - myFileName->setText( aFileName ); + QString aTitle = QObject::tr( "INPUT_VALID_DATA" ); + QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ). + arg( theFileName ).arg( QFileInfo( theFileName ).suffix() ); + SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage ); + } + else + { + setFileName( theFileName ); + setImageName( "" ); emit createPreview( anImage ); - myImageNameGroup->setEnabled( true ); - myTransformGroup->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 anIsManualLambert = theMode == HYDROData_Image::ManualLambert; + bool anIsManualGeodesic = theMode == HYDROData_Image::ManualGeodesic; bool anIsManualCartesian = theMode == HYDROData_Image::ManualCartesian; bool anIsRefImage = theMode == HYDROData_Image::ReferenceImage; @@ -660,23 +745,23 @@ void HYDROGUI_ImportImageDlg::onModeActivated( int theMode ) for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { - myPointXDegMap[ aPointType ]->setVisible( anIsManualCartesian ); - myPointYDegMap[ aPointType ]->setVisible( anIsManualCartesian ); - myPointXMinMap[ aPointType ]->setVisible( anIsManualCartesian ); - myPointYMinMap[ aPointType ]->setVisible( anIsManualCartesian ); - myPointXSecMap[ aPointType ]->setVisible( anIsManualCartesian ); - myPointYSecMap[ aPointType ]->setVisible( anIsManualCartesian ); + 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( anIsManualLambert ); - myCartPointYMap[ aPointType ]->setVisible( anIsManualLambert ); + myCartPointXMap[ aPointType ]->setVisible( anIsManualCartesian ); + myCartPointYMap[ aPointType ]->setVisible( anIsManualCartesian ); myRefPointXMap[ aPointType ]->setVisible( anIsRefImage ); myRefPointYMap[ aPointType ]->setVisible( anIsRefImage ); } - QListIterator anIter( myLambertLabels ); + QListIterator anIter( myGeodesicLabels ); while( anIter.hasNext() ) - anIter.next()->setVisible( anIsManualLambert ); + anIter.next()->setVisible( anIsManualGeodesic ); emit modeActivated( theMode ); } @@ -733,7 +818,7 @@ void HYDROGUI_ImportImageDlg::onPointCoordChanged( int theValue ) } } -void HYDROGUI_ImportImageDlg::onLambertCoordChanged() +void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged() { QObject* aSender = sender(); if( !aSender ) @@ -749,13 +834,13 @@ void HYDROGUI_ImportImageDlg::onLambertCoordChanged() aSender == myPointXSecMap[ aPointType ] || aSender == myPointYSecMap[ aPointType ] ) { - onLambertCoordChanged( aPointType ); + onGeodesicCoordChanged( aPointType ); return; } } } -void HYDROGUI_ImportImageDlg::onLambertCoordChanged( const int thePointType ) +void HYDROGUI_ImportImageDlg::onGeodesicCoordChanged( const int thePointType ) { bool anIsOk[6]; for( int i = 0; i < 6; i++ ) @@ -827,7 +912,7 @@ void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType ) HYDROData_Lambert93::degToDMS( aLonDeg, aXDeg, aXMin, aXSec ); HYDROData_Lambert93::degToDMS( aLatDeg, aYDeg, aYMin, aYSec ); - blockSignalsLambert( true ); + blockSignalsGeodesic( true ); myPointXDegMap[ thePointType ]->setValue( aXDeg ); myPointYDegMap[ thePointType ]->setValue( aYDeg ); @@ -836,29 +921,67 @@ void HYDROGUI_ImportImageDlg::onCartesianCoordChanged( const int thePointType ) myPointXSecMap[ thePointType ]->setValue( aXSec ); myPointYSecMap[ thePointType ]->setValue( aYSec ); - blockSignalsLambert( false ); + 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; } -void HYDROGUI_ImportImageDlg::blockSignalsLambert( const bool theState ) +bool HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState ) { + bool isBlocked = false; for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { - myPointXDegMap[ aPointType ]->blockSignals( theState ); + 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; } -void HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState ) +bool HYDROGUI_ImportImageDlg::blockSignalsCartesian( const bool theState ) { + bool isBlocked = false; for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ ) { - myCartPointXMap[ aPointType ]->blockSignals( theState ); + isBlocked = + myCartPointXMap[ aPointType ]->blockSignals( theState ) || isBlocked; myCartPointYMap[ aPointType ]->blockSignals( theState ); } + return isBlocked; }