#include "HYDROGUI_TwoImagesDlg.h"
-#include "HYDROGUI_ObjSelector.h"
#include "HYDROGUI_ColorWidget.h"
+#include "HYDROGUI_ObjSelector.h"
+#include <QGroupBox>
+#include <QLabel>
#include <QLayout>
#include <QLineEdit>
#include <QRadioButton>
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()
{
- return myName->text();
+ myImageName->clear();
+ myImage1->Clear();
+ myImage2->Clear();
+ myTransparent->setChecked( true );
+ myColorBox->resetColor();
}
-void HYDROGUI_TwoImagesDlg::GetSelectedImages( QString& theName1, QString& theName2 ) const
+void HYDROGUI_TwoImagesDlg::setImageName( const QString& theName )
+{
+ myImageName->setText( theName );
+}
+
+QString HYDROGUI_TwoImagesDlg::getImageName() const
+{
+ return myImageName->text();
+}
+
+void HYDROGUI_TwoImagesDlg::setSelectedImages( const QString& theName1,
+ const QString& theName2 )
+{
+ myImage1->SetName( theName1 );
+ myImage2->SetName( theName2 );
+}
+
+bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1,
+ QString& theName2 ) const
{
theName1 = myImage1->GetName();
theName2 = myImage2->GetName();
+ return !theName1.isEmpty() && !theName2.isEmpty();
+}
+
+void HYDROGUI_TwoImagesDlg::setColor( const QColor& theColor )
+{
+ if( theColor.alpha() == 0 ) // transparent
+ myTransparent->setChecked( true );
+ else
+ myColor->setChecked( true );
+ myColorBox->setColor( theColor );
+}
+
+QColor HYDROGUI_TwoImagesDlg::getColor() const
+{
+ QColor aColor( 255, 255, 255, 0 ); // transparent
+ if( myColor->isChecked() )
+ aColor = myColorBox->color();
+ return aColor;
}