-// 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
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 );
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 ) ) );
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++ )
{
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 ] );
}
+ blockSignalsPoints( isPBlocked );
+ blockSignalsGeodesic( isGBlocked );
+ blockSignalsCartesian( isCBlocked );
// Emulate turning off C point usage
myPointCEnabler->blockSignals( true );
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();
blockSignalsCartesian( false );
}
+void HYDROGUI_ImportImageDlg::ECW_initializePointSelection(HYDROData_Image::ECW_FileInfo* theECW_FileInfo)
+{
+ if( myIsInitialized )
+ return;
+
+ myIsInitialized = true;
+
+ myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->setChecked( true );
+ myPointBtnMap[ HYDROGUI_PrsImage::PointB ]->setChecked( true );
+ myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->setChecked( true );
+
+ setByTwoPoints(false);
+
+ HYDROData_Image::ECW_CellUnits Units = theECW_FileInfo->myCellSizeUnits;
+
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Deg)
+ {
+ blockSignalsGeodesic( true );
+ double Xa, Ya, Xb, Yb, Xc, Yc;
+ Xa = theECW_FileInfo->myOriginX;
+ Ya = theECW_FileInfo->myOriginY;
+ Xb = theECW_FileInfo->myOriginX;
+ Yb = theECW_FileInfo->myOriginY + theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myYSize;
+ Xc = theECW_FileInfo->myOriginX + theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myXSize;
+ Yc = theECW_FileInfo->myOriginY;
+
+ int Deg = 0, Min = 0;
+ double Sec = 0.0;
+ //
+ HYDROData_Lambert93::degToDMS( Xa, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Ya, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointA]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointA]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointA]->setValue(Sec);
+ //
+ HYDROData_Lambert93::degToDMS( Xb, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Yb, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointB]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointB]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointB]->setValue(Sec);
+ //
+ HYDROData_Lambert93::degToDMS( Xc, Deg, Min, Sec );
+ myPointXDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
+ myPointXMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
+ myPointXSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
+ HYDROData_Lambert93::degToDMS( Yc, Deg, Min, Sec );
+ myPointYDegMap[HYDROGUI_PrsImage::PointC]->setValue(Deg);
+ myPointYMinMap[HYDROGUI_PrsImage::PointC]->setValue(Min);
+ myPointYSecMap[HYDROGUI_PrsImage::PointC]->setValue(Sec);
+ //
+ for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
+ onGeodesicCoordChanged( aPointType );
+ blockSignalsGeodesic( false );
+ setTransformationMode( HYDROData_Image::ManualGeodesic );
+ }
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Meters ||
+ Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet )
+ {
+ double Coeff = 1;
+ if (Units == HYDROData_Image::ECW_CellUnits::ECW_CellUnits_Feet)
+ Coeff = 0.3048; //feets
+ blockSignalsCartesian( true );
+ double X1 = 0, Y1 = 0, X2 = 0, Y2 = 0, X3 = 0, Y3 = 0;
+ X1 = theECW_FileInfo->myOriginX;
+ Y1 = theECW_FileInfo->myOriginY;
+ X2 = theECW_FileInfo->myOriginX;
+ Y2 = theECW_FileInfo->myOriginY + Coeff * theECW_FileInfo->myCellIncrementY * theECW_FileInfo->myXSize;
+ X3 = theECW_FileInfo->myOriginX + Coeff * theECW_FileInfo->myCellIncrementX * theECW_FileInfo->myYSize;
+ Y3 = theECW_FileInfo->myOriginY;
+
+ //extract to A-point (top-left), B-point (bottom-left), C-Point (top-right)
+ double Xa = 0, Ya = 0, Xb = 0, Yb = 0, Xc = 0, Yc = 0;
+ Xa = Min(X1, Min(X2, X3));
+ Ya = Max(Y1, Max(Y2, Y3));
+ Xb = Max(X1, Max(X2, X3));
+ Yb = Ya;
+ Xc = Xa;
+ Yc = Min(Y1, Min(Y2, Y3));
+
+ myCartPointXMap[HYDROGUI_PrsImage::PointA]->setValue(Xa);
+ myCartPointYMap[HYDROGUI_PrsImage::PointA]->setValue(Ya);
+ //
+ myCartPointXMap[HYDROGUI_PrsImage::PointB]->setValue(Xb);
+ myCartPointYMap[HYDROGUI_PrsImage::PointB]->setValue(Yb);
+ //
+ myCartPointXMap[HYDROGUI_PrsImage::PointC]->setValue(Xc);
+ myCartPointYMap[HYDROGUI_PrsImage::PointC]->setValue(Yc);
+ //
+ for( int aPointType = HYDROGUI_PrsImage::PointA; aPointType <= HYDROGUI_PrsImage::PointC; aPointType++ )
+ onCartesianCoordChanged( aPointType );
+ blockSignalsCartesian( false );
+ setTransformationMode( HYDROData_Image::ManualCartesian );
+ }
+}
+
+
HYDROGUI_ImportImageDlg::TransformationData HYDROGUI_ImportImageDlg::ComputeTrsfData(
const int theMode,
const QPoint& theLocalPoint,
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() )
+ QString aFilter( tr( "IMAGE_FILTER_IMPORT" ) );
+ 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 );
+ QFileInfo aFI( theFileName );
+ QImage anImage;
+ HYDROData_Image::ECW_FileInfo* theECWInfo = NULL;
+ if (aFI.suffix().toLower() == "ecw")
+ {
+ theECWInfo = new HYDROData_Image::ECW_FileInfo;
+ HYDROData_Image::OpenECW(theFileName.toLatin1().data(), anImage, theECWInfo);
+ }
+ else
+ anImage = QImage(theFileName);
if( anImage.isNull() )
{
QString aTitle = QObject::tr( "INPUT_VALID_DATA" );
QString aMessage = QObject::tr( "FILE_CAN_NOT_BE_IMPORTED" ).
- arg( aFileName ).arg( QFileInfo( aFileName ).suffix() );
+ arg( theFileName ).arg( QFileInfo( theFileName ).suffix() );
SUIT_MessageBox::warning( module()->getApp()->desktop(), aTitle, aMessage );
}
else
{
- myFileName->setText( aFileName );
- emit createPreview( anImage );
- myImageNameGroup->setEnabled( true );
- myTransformGroup->setEnabled( true );
+ setFileName( theFileName );
+ setImageName( "" );
+ emit createPreview( anImage, theECWInfo );
}
}
}
blockSignalsGeodesic( false );
}
-void HYDROGUI_ImportImageDlg::blockSignalsGeodesic( const bool theState )
+void HYDROGUI_ImportImageDlg::clearSpins( QAbstractSpinBox* theSpin )
+{
+ if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
+ {
+ QtxIntSpinBox* aSpin = dynamic_cast<QtxIntSpinBox*>( theSpin );
+ aSpin->setValue( aSpin->minimum() );
+ }
+ else if ( dynamic_cast<QtxIntSpinBox*>( theSpin ) )
+ {
+ QtxDoubleSpinBox* aDblSpin = dynamic_cast<QtxDoubleSpinBox*>( 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++ )
{
- 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;
}