From: nds Date: Tue, 28 Jan 2014 08:41:20 +0000 (+0000) Subject: Refs #336 - Disparity between real and defined backgrounds of cut image X-Git-Tag: BR_hydro_v_1_0~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=02880c5b83e61adae2f6af57ee3216bd4c788531;p=modules%2Fhydro.git Refs #336 - Disparity between real and defined backgrounds of cut image --- diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx index 7ec78132..65dff63b 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -34,7 +34,7 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ), - myMode( TwoImages ), + myMode( TwoFuseImage ), myIsEdit( false ) { // Image name @@ -65,14 +65,14 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup, HYDROGUI_ObjSelector::ClosedPolyline); - QFrame* aBackgroundFrame = new QFrame( aParamGroup ); - QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame ); - myTransparent = new QRadioButton( tr( "TRANSPARENT" ), aBackgroundFrame ); + myBackgroundFrame = new QFrame( aParamGroup ); + QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), myBackgroundFrame ); + myTransparent = new QRadioButton( tr( "TRANSPARENT" ), myBackgroundFrame ); myTransparent->setChecked( true ); - myColor = new QRadioButton( tr( "COLOR" ), aBackgroundFrame ); - myColorBox = new HYDROGUI_ColorWidget( aBackgroundFrame ); + myColor = new QRadioButton( tr( "COLOR" ), myBackgroundFrame ); + myColorBox = new HYDROGUI_ColorWidget( myBackgroundFrame ); - QGridLayout* aBackgroundLayout = new QGridLayout( aBackgroundFrame ); + QGridLayout* aBackgroundLayout = new QGridLayout( myBackgroundFrame ); aBackgroundLayout->setMargin( 0 ); aBackgroundLayout->setSpacing( 5 ); aBackgroundLayout->addWidget( aBackgroundLabel, 0, 0, 2, 1 ); @@ -89,7 +89,7 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const aParamLayout->addWidget( myImage2, 1, 1 ); aParamLayout->addWidget( myPolylineLabel, 1, 0 ); aParamLayout->addWidget( myPolyline, 1, 1 ); - aParamLayout->addWidget( aBackgroundFrame, 2, 0, 1, 2 ); + aParamLayout->addWidget( myBackgroundFrame, 2, 0, 1, 2 ); // Common addWidget( anImageNameGroup ); @@ -129,7 +129,9 @@ void HYDROGUI_TwoImagesDlg::setMode( const int theMode, const bool theIsEdit ) myMode = theMode; myIsEdit = theIsEdit; - bool anIsTwoImages = myMode == TwoImages; + bool anIsTwoImages = isTwoImagesMode(); + + myBackgroundFrame->setVisible( theMode != TwoCutImage ); myModifySelectedImage->setVisible( !anIsTwoImages && !myIsEdit ); @@ -160,7 +162,7 @@ void HYDROGUI_TwoImagesDlg::setSelectedObjects( const QString& theName1, const QString& theName2 ) { myImage1->SetName( theName1 ); - if( myMode == TwoImages ) + if( isTwoImagesMode() ) myImage2->SetName( theName2 ); else myPolyline->SetName( theName2 ); @@ -170,7 +172,7 @@ bool HYDROGUI_TwoImagesDlg::getSelectedObjects( QString& theName1, QString& theName2 ) const { theName1 = myImage1->GetName(); - if( myMode == TwoImages ) + if( isTwoImagesMode() ) theName2 = myImage2->GetName(); else theName2 = myPolyline->GetName(); @@ -181,18 +183,21 @@ void HYDROGUI_TwoImagesDlg::setPreselectedObject( const QString& theName ) { myImage1->SetName( theName ); - HYDROGUI_ObjSelector* aSelector = myMode == TwoImages ? myImage2 : myPolyline; + HYDROGUI_ObjSelector* aSelector = isTwoImagesMode() ? myImage2 : myPolyline; aSelector->SetChecked( true ); aSelector->SetName( QString() ); } void HYDROGUI_TwoImagesDlg::setColor( const QColor& theColor ) { - if( theColor.alpha() == 0 ) // transparent + if( theColor.alpha() == 0 ) { // transparent myTransparent->setChecked( true ); - else + myColorBox->resetColor(); + } + else { myColor->setChecked( true ); - myColorBox->setColor( theColor ); + myColorBox->setColor( theColor ); + } } QColor HYDROGUI_TwoImagesDlg::getColor() const @@ -207,3 +212,8 @@ void HYDROGUI_TwoImagesDlg::onModifySelectedImage( bool theState ) { myImageName->setEnabled( !theState ); } + +bool HYDROGUI_TwoImagesDlg::isTwoImagesMode() const +{ + return myMode == TwoFuseImage || myMode == TwoCutImage; +} diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h index 76dbe97c..92e1799d 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.h @@ -29,6 +29,7 @@ class QCheckBox; class QLabel; class QLineEdit; class QRadioButton; +class QFrame; class HYDROGUI_ColorWidget; class HYDROGUI_ObjSelector; @@ -38,7 +39,7 @@ class HYDROGUI_TwoImagesDlg : public HYDROGUI_InputPanel Q_OBJECT public: - enum Mode { TwoImages = 0, ImageAndPolyline }; + enum Mode { TwoFuseImage = 0, TwoCutImage, ImageAndPolyline }; public: HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ); @@ -73,6 +74,12 @@ signals: protected slots: void onModifySelectedImage( bool theState ); +private: + /** + * Returns whether the mode is to select two images, that corresponds to cut or fuse mode + */ + bool isTwoImagesMode() const; + private: int myMode; bool myIsEdit; @@ -89,6 +96,7 @@ private: QLabel* myPolylineLabel; HYDROGUI_ObjSelector* myPolyline; + QFrame* myBackgroundFrame; QRadioButton* myTransparent; QRadioButton* myColor; HYDROGUI_ColorWidget* myColorBox; diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 885fff83..f57f39c0 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -75,10 +75,14 @@ void HYDROGUI_TwoImagesOp::startOperation() HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel(); aPanel->reset(); - if( myType == Fuse || myType == Cut ) - aPanel->setMode( HYDROGUI_TwoImagesDlg::TwoImages, myIsEdit ); + int aMode; + if( myType == Fuse ) + aMode = HYDROGUI_TwoImagesDlg::TwoFuseImage; + if ( myType == Cut ) + aMode = HYDROGUI_TwoImagesDlg::TwoCutImage; else if( myType == Split ) - aPanel->setMode( HYDROGUI_TwoImagesDlg::ImageAndPolyline, myIsEdit ); + aMode = HYDROGUI_TwoImagesDlg::ImageAndPolyline; + aPanel->setMode( aMode, myIsEdit ); QString anImageName; if( myIsEdit )