From c6ea841032889efc8150795a11f81106f7149dcd Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 20 May 2015 13:34:34 +0300 Subject: [PATCH] refs #530: import of several images --- src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx | 27 ++++++++++++++-------- src/HYDROGUI/HYDROGUI_ImportImageDlg.h | 5 ++++ src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 29 ++++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ImportImageOp.h | 5 ++++ src/HYDROGUI/HYDROGUI_Operation.cxx | 2 +- 5 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 59c706eb..2a65913e 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -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 ); @@ -339,7 +339,7 @@ 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 ) ) ); @@ -697,20 +697,29 @@ 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 ); + 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 { - setFileName( aFileName ); + setFileName( theFileName ); + setImageName( "" ); emit createPreview( anImage ); } } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h index 9072a3e2..2adcb895 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h @@ -39,6 +39,7 @@ class QCheckBox; class QtxDoubleSpinBox; class QtxIntSpinBox; class QAbstractSpinBox; +class QToolButton; class HYDROGUI_ImportImageDlg : public HYDROGUI_InputPanel { @@ -105,6 +106,8 @@ public: void initializePointSelection(); + void ActivateFile( const QString& theFileName, bool isEnableFilesChoice ); + public: static TransformationData ComputeTrsfData( const int theMode, @@ -142,10 +145,12 @@ signals: void modeActivated( int ); void refImageActivated( const QString& ); void setCIsUsed( bool theIsByTwoPoints ); + void filesSelected( const QStringList& ); private: QGroupBox* myFileNameGroup; //!< The group for the source image file selection QLineEdit* myFileName; //!< Source image file name input field + QToolButton* myBrowseBtn; QGroupBox* myImageNameGroup; //!< The group for the image name input field QLineEdit* myImageName; //!< The image name input field diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index b0cda46b..6d661e9a 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -274,6 +274,8 @@ HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const connect( aPanel, SIGNAL( refImageActivated( const QString& ) ), SLOT( onRefImageActivated( const QString& ) ) ); connect( aPanel, SIGNAL( setCIsUsed( bool ) ), SLOT( onSetCIsUsed( bool ) ) ); + connect( aPanel, SIGNAL( filesSelected( const QStringList& ) ), + SLOT( onFilesSelected( const QStringList& ) ) ); return aPanel; } @@ -501,6 +503,14 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, anImageObj->Update(); theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced; + + if( SetNextFile() ) + { + theErrorMsg = ""; + commitDocOperation(); // to save the modifications in the data model + return false; // and to continue the operation + } + return true; } @@ -881,3 +891,22 @@ void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr ) aViewMgr = 0; } } + +void HYDROGUI_ImportImageOp::onFilesSelected( const QStringList& theFileNames ) +{ + myFiles = theFileNames; + myFileIndex = -1; + SetNextFile(); +} + +bool HYDROGUI_ImportImageOp::SetNextFile() +{ + myFileIndex++; + bool isEnabledEdit = myFiles.count()==1 || myFileIndex==myFiles.count(); + bool isValid = ( myFileIndex>=0 && myFileIndex( inputPanel() ); + aPanel->ActivateFile( aFile, isEnabledEdit ); + return isValid; +} diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index 6ab54d21..f59c3725 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -64,6 +64,7 @@ protected slots: void onPointSelected(); void onRefPointSelected(); void onPointSelected( bool theIsRefImage ); + void onFilesSelected( const QStringList& ); private: void closePreview(); @@ -106,6 +107,8 @@ private: void getReferenceDataList( HYDROGUI_ImportImageDlg::PrsPointDataList& theList ) const; + bool SetNextFile(); + private: bool myIsEdit; Handle(HYDROData_Image) myEditedObject; @@ -120,6 +123,8 @@ private: QImage myImage; //!< The loaded image to import int myPointType; + QStringList myFiles; + int myFileIndex; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index b01e4494..75d9c7b3 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -313,7 +313,7 @@ void HYDROGUI_Operation::onApply() commit(); browseObjects( aBrowseObjectsEntries ); } - else + else if( !anErrorMsg.isEmpty() ) { // Abort document opeartion only if requested if ( isToAbortOnApply() ) -- 2.39.2