From: ouv Date: Thu, 15 Aug 2013 13:32:40 +0000 (+0000) Subject: Image composing. X-Git-Tag: BR_hydro_v_0_1~113 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0b4df27e9f347d6187dbf30bacf80b45c21813d4;p=modules%2Fhydro.git Image composing. --- diff --git a/src/HYDROGUI/HYDROGUI_ColorWidget.cxx b/src/HYDROGUI/HYDROGUI_ColorWidget.cxx index 68ad84a7..c6ad0db1 100644 --- a/src/HYDROGUI/HYDROGUI_ColorWidget.cxx +++ b/src/HYDROGUI/HYDROGUI_ColorWidget.cxx @@ -22,6 +22,7 @@ #include "HYDROGUI_ColorWidget.h" +#include #include HYDROGUI_ColorWidget::HYDROGUI_ColorWidget( QWidget* parent ) @@ -52,6 +53,13 @@ void HYDROGUI_ColorWidget::setColor( const QColor& c ) setPalette( aPalette ); } +void HYDROGUI_ColorWidget::resetColor() +{ + QPalette aDefPalette = QApplication::palette(); + QColor aColor = aDefPalette.color( QPalette::Window ); + setColor( aColor ); +} + void HYDROGUI_ColorWidget::mouseDoubleClickEvent( QMouseEvent* ) { QColor c = QColorDialog::getColor( color(), this ); diff --git a/src/HYDROGUI/HYDROGUI_ColorWidget.h b/src/HYDROGUI/HYDROGUI_ColorWidget.h index 800486a6..c80439e7 100644 --- a/src/HYDROGUI/HYDROGUI_ColorWidget.h +++ b/src/HYDROGUI/HYDROGUI_ColorWidget.h @@ -44,6 +44,8 @@ public: QColor color() const; /** Sets color value */ void setColor( const QColor& ); + /** Resets the default color value */ + void resetColor(); /** \return color value in the integer form */ //int intColor() const; /** Sets color value in the integer form */ diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 71fe1237..abcc6274 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -148,8 +148,7 @@ bool HYDROGUI_DataModel::close() bool HYDROGUI_DataModel::isModified() const { - int aStudyId = module()->application()->activeStudy()->id(); - return HYDROData_Document::Document( aStudyId )->IsModified(); + return getDocument()->IsModified(); } bool HYDROGUI_DataModel::isSaved() const @@ -256,8 +255,7 @@ void HYDROGUI_DataModel::updateModel() Handle(HYDROData_Object) HYDROGUI_DataModel::objectByEntry( const QString& theEntry, const ObjectKind theObjectKind ) { - const int aStudyId = module()->application()->activeStudy()->id(); - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + Handle(HYDROData_Document) aDocument = getDocument(); if( !aDocument.IsNull() ) { HYDROData_Iterator anIterator( aDocument, theObjectKind ); diff --git a/src/HYDROGUI/HYDROGUI_Displayer.cxx b/src/HYDROGUI/HYDROGUI_Displayer.cxx index a99292ae..7a254ac8 100644 --- a/src/HYDROGUI/HYDROGUI_Displayer.cxx +++ b/src/HYDROGUI/HYDROGUI_Displayer.cxx @@ -97,13 +97,9 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId ) void HYDROGUI_Displayer::DisplayAll( const int theViewerId, const bool theIsForced ) { - HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); - if( aModel ) - { - HYDROData_SequenceOfObjects aSeq; - HYDROGUI_Tool::GetPrsSubObjects( aModel, theViewerId, aSeq ); - Update( aSeq, theViewerId, theIsForced ); - } + HYDROData_SequenceOfObjects aSeq; + HYDROGUI_Tool::GetPrsSubObjects( myModule, theViewerId, aSeq ); + Update( aSeq, theViewerId, theIsForced ); } void HYDROGUI_Displayer::Update( const HYDROData_SequenceOfObjects& theObjs, diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 9e3e173b..a5c99edd 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -193,11 +193,10 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co aMappingLayout->setColumnStretch( 7, 2 ); // seconds (double with 4 digits) // Common - addWidget( myFileNameGroup, 0, 0 ); - addWidget( myImageNameGroup, 1, 0 ); - addWidget( myMappingGroup, 2, 0 ); - - setRowStretch(); + addWidget( myFileNameGroup ); + addWidget( myImageNameGroup ); + addWidget( myMappingGroup ); + addStretch(); connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); } diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 3d844bc1..14c08125 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -29,8 +29,6 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" -#include - #include #include #include @@ -138,7 +136,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) { // check that there are no other objects with the same name in the document - Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN ); + Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName ); if( !anObject.IsNull() ) { theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName ); @@ -257,18 +255,7 @@ void HYDROGUI_ImportImageOp::onCreatePreview( QImage theImage ) anImageName = myEditedObject->GetName(); } else - { - int anImageId = 1; - while( anImageId < 100 ) - { - anImageName = QString( "Image_%1" ).arg( QString::number( anImageId++ ) ); - - // check that there are no other objects with the same name in the document - Handle(HYDROData_Object) anObject = findObjectByName( anImageName, KIND_UNKNOWN ); - if( anObject.IsNull() ) - break; - } - } + anImageName = HYDROGUI_Tool::GenerateObjectName( module(), "Image" ); aPanel->setImageName( anImageName ); aPanel->initializePointSelection(); diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 2186f279..78b42ede 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -41,12 +41,12 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr setWidget( aFrame ); QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); - myMainFrame = new QFrame( this ); - QGridLayout* aMainLayout = new QGridLayout( myMainFrame ); + myMainFrame = new QFrame( aFrame ); + QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); aMainLayout->setMargin( 0 ); aMainLayout->setSpacing( 5 ); - myBtnFrame = new QFrame( this ); + myBtnFrame = new QFrame( aFrame ); aLayout->addWidget( myMainFrame, 1 ); aLayout->addWidget( myBtnFrame, 0 ); @@ -91,37 +91,14 @@ void HYDROGUI_InputPanel::onHelp() { } -void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget ) +void HYDROGUI_InputPanel::addWidget( QWidget* theWidget ) { - QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - int aRow = aMainLayout->rowCount(); - aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 ); - aMainLayout->addWidget( theWidget, aRow, 1 ); + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addWidget( theWidget ); } -void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, - const int theRow, - const int theColumn ) +void HYDROGUI_InputPanel::addStretch() { - QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addWidget( theWidget, theRow, theColumn ); -} - -void HYDROGUI_InputPanel::addSeparator() -{ - QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - int aRow = aMainLayout->rowCount(); - - QFrame* aLine = new QFrame(); - aLine->setFrameShape( QFrame::HLine ); - aLine->setFrameShadow( QFrame::Sunken ); - - aMainLayout->addWidget( aLine, aRow, 0, 1, 2 ); -} - -void HYDROGUI_InputPanel::setRowStretch() -{ - QGridLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - int aRow = aMainLayout->rowCount(); - aMainLayout->setRowStretch( aRow, 1 ); + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addStretch(); } diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index b05302e8..6799c247 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -41,10 +41,8 @@ public: HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_InputPanel(); - void addWidget( const QString& theLabel, QWidget* theWidget ); - void addWidget( QWidget* theWidget, const int theRow, const int theColumn ); - void addSeparator(); - void setRowStretch(); + void addWidget( QWidget* theWidget ); + void addStretch(); HYDROGUI_Module* module() const; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 91276860..ea02a008 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -220,16 +220,10 @@ void HYDROGUI_Module::update( const int flags ) setUpdateEnabled( false ); if( ( flags & UF_Model ) && getDataModel() ) - { getDataModel()->update( getStudyId() ); - } - else - { - /* to do - if( ( flags & UF_ObjBrowser ) && getObjectBrowser() ) - updateObjectBrowser(); - */ - } + + if( ( flags & UF_ObjBrowser ) && getApp() ) + getApp()->updateObjectBrowser( true ); if( ( flags & UF_Viewer ) ) updateGV( flags & UF_GV_Init, diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx index f087c09d..737b19f3 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.cxx @@ -32,6 +32,9 @@ #include #include +#include +#include + #include #include #include @@ -40,6 +43,8 @@ HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* : QAbstractButton( theParent ), myModule( theModule ) { QHBoxLayout* aLayout = new QHBoxLayout( this ); + aLayout->setMargin( 0 ); + aLayout->setSpacing( 5 ); myBtn = new QToolButton( this ); myBtn->setCheckable( true ); myBtn->setChecked( false ); @@ -48,6 +53,9 @@ HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* aLayout->addWidget( myBtn, 0 ); aLayout->addWidget( myObjName, 1 ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + myBtn->setIcon( QIcon( aResMgr->loadPixmap( "HYDRO", tr( "SELECT_ICO" ) ) ) ); + SUIT_SelectionMgr* aSelMgr = theModule->getApp()->selectionMgr(); connect( myBtn, SIGNAL( toggled( bool ) ), this, SLOT( OnToggled( bool ) ) ); @@ -114,3 +122,9 @@ QString HYDROGUI_ObjSelector::GetName() const { return myObjName->text(); } + +void HYDROGUI_ObjSelector::Clear() +{ + myObjName->clear(); + myBtn->setChecked( false ); +} diff --git a/src/HYDROGUI/HYDROGUI_ObjSelector.h b/src/HYDROGUI/HYDROGUI_ObjSelector.h index b3e1019e..7327df51 100644 --- a/src/HYDROGUI/HYDROGUI_ObjSelector.h +++ b/src/HYDROGUI/HYDROGUI_ObjSelector.h @@ -37,6 +37,8 @@ public: HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent ); virtual ~HYDROGUI_ObjSelector(); + void Clear(); + QString GetName() const; protected: diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index aacf5dfc..9bdf11e0 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -128,19 +128,7 @@ void HYDROGUI_Operation::processCancel() Handle_HYDROData_Document HYDROGUI_Operation::doc() const { - int aStudyId = myModule->application()->activeStudy()->id(); - return HYDROData_Document::Document( aStudyId ); -} - -Handle_HYDROData_Object HYDROGUI_Operation::findObjectByName( const QString& theName, int theKind ) const -{ - HYDROData_Iterator anIt( doc(), theKind ); - for( ; anIt.More(); anIt.Next() ) - { - if( anIt.Current()->GetName() == theName ) - return anIt.Current(); - } - return Handle_HYDROData_Object(); + return HYDROData_Document::Document( myModule->getStudyId() ); } void HYDROGUI_Operation::onApply() diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 6ab80bd1..76eab370 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -57,7 +57,6 @@ protected: virtual void processCancel(); Handle_HYDROData_Document doc() const; - Handle_HYDROData_Object findObjectByName( const QString& theName, int theKind ) const; protected slots: virtual void onApply(); diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index ef39f2af..384a0cee 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -28,15 +28,15 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { - CurveCreator_Curve *aStaticCurve = NULL; + CurveCreator_Curve *aStaticCurve = NULL; - aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d); + aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d); - CurveCreator_Widget *aWidget = - new CurveCreator_Widget( this, aStaticCurve); + CurveCreator_Widget *aWidget = + new CurveCreator_Widget( this, aStaticCurve); - addWidget( aWidget, 0, 0 ); - setRowStretch(); + addWidget( aWidget ); + addStretch(); } HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg() diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index dbe77659..a159f81a 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -161,16 +161,11 @@ void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule, aWorkstack->setActiveWindow( aViewWindow ); } -void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theModel, +void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule, const int theViewerId, // currently unused HYDROData_SequenceOfObjects& theSeq ) { - if( !theModel ) - return; - - const int aStudyId = theModel->module()->application()->activeStudy()->id(); - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId ); + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() ); if( aDocument.IsNull() ) return; @@ -245,3 +240,43 @@ Handle(HYDROData_Object) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theM return aSeq.First(); return NULL; } + +Handle(HYDROData_Object) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule, + const QString& theName, + const ObjectKind theObjectKind ) +{ + Handle(HYDROData_Object) anObject; + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() ); + if( aDocument.IsNull() ) + return anObject; + + HYDROData_Iterator anIter( aDocument, theObjectKind ); + for( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Object) anObjectRef = anIter.Current(); + if( !anObjectRef.IsNull() && anObjectRef->GetName() == theName ) + { + anObject = anObjectRef; + break; + } + } + return anObject; +} + +QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module* theModule, + const QString& thePrefix ) +{ + QString aName; + int anId = 1; + while( anId < 100 ) + { + aName = QString( "%1_%2" ).arg( thePrefix ).arg( QString::number( anId++ ) ); + + // check that there are no other objects with the same name in the document + Handle(HYDROData_Object) anObject = FindObjectByName( theModule, aName, KIND_UNKNOWN ); + if( anObject.IsNull() ) + break; + } + return aName; +} diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index dc2427b7..1af2f5d7 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -112,11 +112,11 @@ public: /** * \brief Get sub-objects to build presentations. - * \param theModel data model + * \param theModule module * \param theViewerId viewer id * \param theSeq sequence of sub-objects */ - static void GetPrsSubObjects( const HYDROGUI_DataModel* theModel, + static void GetPrsSubObjects( HYDROGUI_Module* theModule, const int theViewerId, HYDROData_SequenceOfObjects& theSeq ); @@ -149,6 +149,26 @@ public: * \return selected data object */ static Handle(HYDROData_Object) GetSelectedObject( HYDROGUI_Module* theModule ); + + /** + * \brief Find the data object with the specified name. + * \param theModule module + * \param theName name + * \param theObjectKind kind of object + * \return data object + */ + static Handle(HYDROData_Object) FindObjectByName( HYDROGUI_Module* theModule, + const QString& theName, + const ObjectKind theObjectKind = KIND_UNKNOWN ); + + /** + * \brief Generate name for new object. + * \param theModule module + * \param thePrefix name prefix + * \return generated name + */ + static QString GenerateObjectName( HYDROGUI_Module* theModule, + const QString& thePrefix ); }; #endif diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx index 82fc2b7f..8a313ec9 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -22,9 +22,11 @@ #include "HYDROGUI_TwoImagesDlg.h" -#include "HYDROGUI_ObjSelector.h" #include "HYDROGUI_ColorWidget.h" +#include "HYDROGUI_ObjSelector.h" +#include +#include #include #include #include @@ -32,41 +34,84 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { - myName = new QLineEdit(); - myImage1 = new HYDROGUI_ObjSelector( module(), 0 ); - myImage2 = new HYDROGUI_ObjSelector( module(), 0 ); - myTransparent = new QRadioButton( tr( "TRANSPARENT" ) ); + // Image name + QGroupBox* anImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) ); + + QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), anImageNameGroup ); + myImageName = new QLineEdit( anImageNameGroup ); + + QBoxLayout* anImageNameLayout = new QHBoxLayout( anImageNameGroup ); + anImageNameLayout->setMargin( 5 ); + anImageNameLayout->setSpacing( 5 ); + anImageNameLayout->addWidget( anImageNameLabel ); + anImageNameLayout->addWidget( myImageName ); + + // Image name + QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) ); + + QLabel* anImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup ); + myImage1 = new HYDROGUI_ObjSelector( theModule, aParamGroup ); + + QLabel* anImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup ); + myImage2 = new HYDROGUI_ObjSelector( theModule, aParamGroup ); + + QFrame* aBackgroundFrame = new QFrame( aParamGroup ); + QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame ); + myTransparent = new QRadioButton( tr( "TRANSPARENT" ), aBackgroundFrame ); myTransparent->setChecked( true ); - myColor = new QRadioButton( tr( "COLOR" ) ); - myColorBox = new HYDROGUI_ColorWidget( 0 ); - - addWidget( tr( "NAME" ), myName ); - addSeparator(); - addWidget( tr( "IMAGE_1" ), myImage1 ); - addWidget( tr( "IMAGE_2" ), myImage2 ); - - QFrame* aBackground = new QFrame(); - QGridLayout* aLayout = new QGridLayout( aBackground ); - aLayout->addWidget( myTransparent, 0, 0 ); - aLayout->addWidget( myColor, 1, 0 ); - aLayout->addWidget( myColorBox, 1, 1 ); - - addWidget( tr( "BACKGROUND" ), aBackground ); - addSeparator(); - setRowStretch(); + myColor = new QRadioButton( tr( "COLOR" ), aBackgroundFrame ); + myColorBox = new HYDROGUI_ColorWidget( aBackgroundFrame ); + + QGridLayout* aBackgroundLayout = new QGridLayout( aBackgroundFrame ); + aBackgroundLayout->setMargin( 0 ); + aBackgroundLayout->setSpacing( 5 ); + aBackgroundLayout->addWidget( aBackgroundLabel, 0, 0, 2, 1 ); + aBackgroundLayout->addWidget( myTransparent, 0, 1 ); + aBackgroundLayout->addWidget( myColor, 1, 1 ); + aBackgroundLayout->addWidget( myColorBox, 1, 2 ); + + QGridLayout* aParamLayout = new QGridLayout( aParamGroup ); + aParamLayout->setMargin( 5 ); + aParamLayout->setSpacing( 5 ); + aParamLayout->addWidget( anImage1Label, 0, 0 ); + aParamLayout->addWidget( myImage1, 0, 1 ); + aParamLayout->addWidget( anImage2Label, 1, 0 ); + aParamLayout->addWidget( myImage2, 1, 1 ); + aParamLayout->addWidget( aBackgroundFrame, 2, 0, 1, 2 ); + + // Common + addWidget( anImageNameGroup ); + addWidget( aParamGroup ); + addStretch(); } HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg() { } -QString HYDROGUI_TwoImagesDlg::GetName() const +void HYDROGUI_TwoImagesDlg::reset() +{ + myImageName->clear(); + myImage1->Clear(); + myImage2->Clear(); + myTransparent->setChecked( true ); + myColorBox->resetColor(); +} + +void HYDROGUI_TwoImagesDlg::setImageName( const QString& theName ) +{ + myImageName->setText( theName ); +} + +QString HYDROGUI_TwoImagesDlg::getImageName() const { - return myName->text(); + return myImageName->text(); } -void HYDROGUI_TwoImagesDlg::GetSelectedImages( QString& theName1, QString& theName2 ) const +bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1, + QString& theName2 ) const { theName1 = myImage1->GetName(); theName2 = myImage2->GetName(); + return !theName1.isEmpty() && !theName2.isEmpty(); } diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h index 441a0ad6..e9d38d53 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h @@ -39,14 +39,21 @@ public: HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_TwoImagesDlg(); - QString GetName() const; - void GetSelectedImages( QString& theEntry1, QString& theEntry2 ) const; + void reset(); + + void setImageName( const QString& theName ); + QString getImageName() const; + + bool getSelectedImages( QString& theName1, + QString& theName2 ) const; private: - QLineEdit* myName; - HYDROGUI_ObjSelector *myImage1, *myImage2; - QRadioButton *myTransparent, *myColor; - HYDROGUI_ColorWidget* myColorBox; + QLineEdit* myImageName; + HYDROGUI_ObjSelector* myImage1; + HYDROGUI_ObjSelector* myImage2; + QRadioButton* myTransparent; + QRadioButton* myColor; + HYDROGUI_ColorWidget* myColorBox; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 872a0977..dec0f974 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_TwoImagesOp.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" #include "HYDROGUI_TwoImagesDlg.h" #include "HYDROGUI_UpdateFlags.h" @@ -57,23 +58,42 @@ HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const return new HYDROGUI_TwoImagesDlg( module(), getName() ); } +void HYDROGUI_TwoImagesOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel(); + aPanel->reset(); + + QString anImageName = HYDROGUI_Tool::GenerateObjectName( module(), getName() ); + aPanel->setImageName( anImageName ); +} + bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, QString& theErrorMsg ) { HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast( inputPanel() ); - QString aNewName = aPanel->GetName(); + QString anImageName = aPanel->getImageName(); + if( anImageName.isEmpty() ) + return false; - QString aName1, aName2; - aPanel->GetSelectedImages( aName1, aName2 ); + QString aSelectedName1, aSelectedName2; + if( !aPanel->getSelectedImages( aSelectedName1, aSelectedName2 ) ) + return false; - if( aNewName.isEmpty() || aName1.isEmpty() || aName2.isEmpty() ) + // check that there are no other objects with the same name in the document + Handle(HYDROData_Object) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName ); + if( !anObject.IsNull() ) + { + theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName ); return false; + } Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast( - findObjectByName( aName1, KIND_IMAGE ) ); + HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_IMAGE ) ); Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast( - findObjectByName( aName2, KIND_IMAGE ) ); + HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_IMAGE ) ); if( anImage1.IsNull() || anImage2.IsNull() ) return false; @@ -93,7 +113,7 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, if( aResult.IsNull() ) return false; - aResult->SetName( aNewName ); + aResult->SetName( anImageName ); aResult->AppendReference( anImage1 ); aResult->AppendReference( anImage2 ); aFactory->UpdateImage( doc(), aResult ); diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.h b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h index d5b3306d..ee3bbda7 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.h +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h @@ -37,9 +37,11 @@ public: virtual ~HYDROGUI_TwoImagesOp(); protected: + virtual void startOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); private: int myType; diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index cbfb166d..633906cf 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -14,6 +14,10 @@ REDO_ICO icon_redo.png + + SELECT_ICO + icon_select.png + UNDO_ICO icon_undo.png diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e6ff1d24..b2d571e6 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -10,6 +10,10 @@ INPUT_VALID_DATA Please enter valid data and try again. + + OBJECT_EXISTS_IN_DOCUMENT + Object with name '%1' already exists in the document. + HYDROGUI_DataModel @@ -109,10 +113,6 @@ MAPPING Mapping - - OBJECT_EXISTS_IN_DOCUMENT - Object with name '%1' already exists in the document. - POINTS_A_B_C_BELONG_TO_SINGLE_LINE Points A, B, C belong to a single line. @@ -353,10 +353,18 @@ IMAGE_2 Image 2 + + IMAGE_NAME + Image name + NAME Name + + PARAMETERS + Parameters + TRANSPARENT Transparent diff --git a/src/HYDROGUI/resources/icon_select.png b/src/HYDROGUI/resources/icon_select.png new file mode 100644 index 00000000..cd126ad0 Binary files /dev/null and b/src/HYDROGUI/resources/icon_select.png differ diff --git a/src/HYDROOperations/HYDROOperations_Factory.cxx b/src/HYDROOperations/HYDROOperations_Factory.cxx index d327fc98..bfbfbdbf 100644 --- a/src/HYDROOperations/HYDROOperations_Factory.cxx +++ b/src/HYDROOperations/HYDROOperations_Factory.cxx @@ -78,11 +78,13 @@ void HYDROOperations_Factory::UpdateImage( // fill by arguments and process the operation ImageComposer_Operator* anOp = Operator(theImage); if (anOp) { // update image only if there is an operation + QTransform aTransform; ImageComposer_Image anImage1; // first referenced image if (theImage->NbReferences()) { Handle(HYDROData_Image) anImage = theImage->Reference(0); anImage1 = anImage->Image(); anImage1.setTransform(anImage->Trsf()); + aTransform = anImage1.transform(); } ImageComposer_Image anImage2; // second referenced image if (theImage->NbReferences() > 1) { @@ -92,6 +94,7 @@ void HYDROOperations_Factory::UpdateImage( } ImageComposer_Image aResImg = anOp->process(anImage1, anImage2); theImage->SetImage(aResImg); + theImage->SetTrsf(aTransform); } // change the states of this and all depended images theImage->MustBeUpdated(true);