-// 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();
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 );
+ QImage anImage( 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 );
+ setFileName( theFileName );
+ setImageName( "" );
emit createPreview( anImage );
- myImageNameGroup->setEnabled( true );
- myTransformGroup->setEnabled( true );
}
}
}
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;
}