Salome HOME
refs #740 (p.1 + p.2)
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_BasicZoneDlg.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_BasicZoneDlg.h"
20
21 #include <QComboBox>
22 #include <QGroupBox>
23 #include <QLabel>
24 #include <QLayout>
25 #include <QLineEdit>
26
27 HYDROGUI_BasicZoneDlg::HYDROGUI_BasicZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle,
28                                               const QString& theLabel1, const QString& theLabel2,
29                                               const QString& theLabel3, const QString& theLabel4 )
30 : HYDROGUI_InputPanel( theModule, theTitle )
31 {
32   // Zone name
33   myObjectNameGroup = new QGroupBox( theLabel1, mainFrame() );
34
35   myObjectName = new QLineEdit( myObjectNameGroup );
36
37   QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
38   aNameLayout->setMargin( 5 );
39   aNameLayout->setSpacing( 5 );
40   aNameLayout->addWidget( new QLabel( theLabel2, myObjectNameGroup ) );
41   aNameLayout->addWidget( myObjectName );
42
43   // Main parameters: group-box and frame
44   myParamGroup = new QGroupBox( theLabel3, mainFrame() );
45
46   myPolylineFrame = new QFrame( myParamGroup );
47
48   // Additional parameter defined with help of combo-box control
49   myAdditionalParamsGroup = new QGroupBox( theLabel4, mainFrame() );
50
51   myAdditionalParams = new QComboBox( myPolylineFrame );
52   myAdditionalParams->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
53
54   QBoxLayout* aBathLayout = new QHBoxLayout( myAdditionalParamsGroup );
55   aBathLayout->setMargin( 5 );
56   aBathLayout->setSpacing( 5 );
57   aBathLayout->addWidget( myAdditionalParams );
58
59   // Common
60   addWidget( myObjectNameGroup );
61   addWidget( myParamGroup );
62   addWidget( myAdditionalParamsGroup );
63
64   addStretch();  
65 }
66
67 HYDROGUI_BasicZoneDlg::~HYDROGUI_BasicZoneDlg()
68 {
69 }
70
71 void HYDROGUI_BasicZoneDlg::reset()
72 {
73   myObjectName->clear();
74   myAdditionalParams->clear();  
75 }
76
77 void HYDROGUI_BasicZoneDlg::setObjectName( const QString& theName )
78 {
79   myObjectName->setText( theName );
80 }
81
82 QString HYDROGUI_BasicZoneDlg::getObjectName() const
83 {
84   return myObjectName->text();
85 }
86
87 void HYDROGUI_BasicZoneDlg::setAdditionalParams( const QStringList& thePrams )
88 {
89   bool isBlocked = blockSignals( true );
90
91   myAdditionalParams->clear();
92   myAdditionalParams->addItems( thePrams );
93
94   blockSignals( isBlocked );
95 }
96
97 void HYDROGUI_BasicZoneDlg::setSelectedAdditionalParamName( const QString& theParam )
98 {
99   int aNewIdx = myAdditionalParams->findText( theParam );
100   myAdditionalParams->setCurrentIndex( aNewIdx );
101 }
102
103 QString HYDROGUI_BasicZoneDlg::getSelectedAdditionalParamName() const
104 {
105   return myAdditionalParams->currentText();
106 }