-// Copyright (C) 2007-2015 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
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 ) ) );
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
{
- setFileName( aFileName );
- emit createPreview( anImage );
+ setFileName( theFileName );
+ setImageName( "" );
+ emit createPreview( anImage, theECWInfo );
}
}
}