X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_TwoImagesDlg.cxx;h=7ec78132a5c38f10e5f88cba4c5e8eac984442c0;hb=a1431f03eac1d1aed4203d0568d987c41ce939b3;hp=145db26b49c28aff3a077a5aa9e9597692d58cdf;hpb=0006900f9b7798b199a295169d0d798ecaad6340;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx index 145db26b..7ec78132 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesDlg.cxx @@ -25,6 +25,7 @@ #include "HYDROGUI_ColorWidget.h" #include "HYDROGUI_ObjSelector.h" +#include #include #include #include @@ -32,7 +33,9 @@ #include HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ), + myMode( TwoImages ), + myIsEdit( false ) { // Image name QGroupBox* anImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) ); @@ -40,20 +43,27 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), anImageNameGroup ); myImageName = new QLineEdit( anImageNameGroup ); - QBoxLayout* anImageNameLayout = new QHBoxLayout( anImageNameGroup ); + myModifySelectedImage = new QCheckBox( tr( "MODIFY_SELECTED_IMAGE" ) ); + + QGridLayout* anImageNameLayout = new QGridLayout( anImageNameGroup ); anImageNameLayout->setMargin( 5 ); anImageNameLayout->setSpacing( 5 ); - anImageNameLayout->addWidget( anImageNameLabel ); - anImageNameLayout->addWidget( myImageName ); + anImageNameLayout->addWidget( anImageNameLabel, 0, 0 ); + anImageNameLayout->addWidget( myImageName, 0, 1 ); + anImageNameLayout->addWidget( myModifySelectedImage, 1, 0, 1, 2 ); - // Image name + // Parameters QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) ); - QLabel* anImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup ); - myImage1 = new HYDROGUI_ObjSelector( theModule, aParamGroup ); + myImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup ); + myImage1 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup ); + + myImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup ); + myImage2 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup ); - QLabel* anImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup ); - myImage2 = new HYDROGUI_ObjSelector( theModule, aParamGroup ); + myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup ); + myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup, + HYDROGUI_ObjSelector::ClosedPolyline); QFrame* aBackgroundFrame = new QFrame( aParamGroup ); QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame ); @@ -73,16 +83,29 @@ HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QGridLayout* aParamLayout = new QGridLayout( aParamGroup ); aParamLayout->setMargin( 5 ); aParamLayout->setSpacing( 5 ); - aParamLayout->addWidget( anImage1Label, 0, 0 ); + aParamLayout->addWidget( myImage1Label, 0, 0 ); aParamLayout->addWidget( myImage1, 0, 1 ); - aParamLayout->addWidget( anImage2Label, 1, 0 ); + aParamLayout->addWidget( myImage2Label, 1, 0 ); aParamLayout->addWidget( myImage2, 1, 1 ); + aParamLayout->addWidget( myPolylineLabel, 1, 0 ); + aParamLayout->addWidget( myPolyline, 1, 1 ); aParamLayout->addWidget( aBackgroundFrame, 2, 0, 1, 2 ); // Common addWidget( anImageNameGroup ); addWidget( aParamGroup ); addStretch(); + + connect( myModifySelectedImage, SIGNAL( toggled( bool ) ), + this, SLOT( onModifySelectedImage( bool ) ) ); + connect( myTransparent, SIGNAL( toggled( bool ) ), + myColorBox, SLOT( setDisabled( bool ) ) ); + connect( myImage1, SIGNAL( alreadySelected( const QString& ) ), + this, SIGNAL( alreadySelected( const QString& ) ) ); + connect( myImage2, SIGNAL( alreadySelected( const QString& ) ), + this, SIGNAL( alreadySelected( const QString& ) ) ); + + setMode( myMode, myIsEdit ); } HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg() @@ -92,10 +115,35 @@ HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg() void HYDROGUI_TwoImagesDlg::reset() { myImageName->clear(); + myModifySelectedImage->setChecked( false ); myImage1->Clear(); myImage2->Clear(); + myPolyline->Clear(); myTransparent->setChecked( true ); myColorBox->resetColor(); + myColorBox->setDisabled( true ); +} + +void HYDROGUI_TwoImagesDlg::setMode( const int theMode, const bool theIsEdit ) +{ + myMode = theMode; + myIsEdit = theIsEdit; + + bool anIsTwoImages = myMode == TwoImages; + + myModifySelectedImage->setVisible( !anIsTwoImages && !myIsEdit ); + + myImage1Label->setText( anIsTwoImages ? tr( "IMAGE_1" ) : tr( "IMAGE" ) ); + + myImage2Label->setVisible( anIsTwoImages ); + myImage2->setVisible( anIsTwoImages ); + myPolylineLabel->setVisible( !anIsTwoImages ); + myPolyline->setVisible( !anIsTwoImages ); +} + +bool HYDROGUI_TwoImagesDlg::isModifySelected() const +{ + return myModifySelectedImage->isChecked(); } void HYDROGUI_TwoImagesDlg::setImageName( const QString& theName ) @@ -108,21 +156,36 @@ QString HYDROGUI_TwoImagesDlg::getImageName() const return myImageName->text(); } -void HYDROGUI_TwoImagesDlg::setSelectedImages( const QString& theName1, - const QString& theName2 ) +void HYDROGUI_TwoImagesDlg::setSelectedObjects( const QString& theName1, + const QString& theName2 ) { myImage1->SetName( theName1 ); - myImage2->SetName( theName2 ); + if( myMode == TwoImages ) + myImage2->SetName( theName2 ); + else + myPolyline->SetName( theName2 ); } -bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1, - QString& theName2 ) const +bool HYDROGUI_TwoImagesDlg::getSelectedObjects( QString& theName1, + QString& theName2 ) const { theName1 = myImage1->GetName(); - theName2 = myImage2->GetName(); + if( myMode == TwoImages ) + theName2 = myImage2->GetName(); + else + theName2 = myPolyline->GetName(); return !theName1.isEmpty() && !theName2.isEmpty(); } +void HYDROGUI_TwoImagesDlg::setPreselectedObject( const QString& theName ) +{ + myImage1->SetName( theName ); + + HYDROGUI_ObjSelector* aSelector = myMode == TwoImages ? myImage2 : myPolyline; + aSelector->SetChecked( true ); + aSelector->SetName( QString() ); +} + void HYDROGUI_TwoImagesDlg::setColor( const QColor& theColor ) { if( theColor.alpha() == 0 ) // transparent @@ -139,3 +202,8 @@ QColor HYDROGUI_TwoImagesDlg::getColor() const aColor = myColorBox->color(); return aColor; } + +void HYDROGUI_TwoImagesDlg::onModifySelectedImage( bool theState ) +{ + myImageName->setEnabled( !theState ); +}