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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ImmersibleZoneDlg.h"
21 #include "HYDROGUI_Tool.h"
29 HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
30 : HYDROGUI_InputPanel( theModule, theTitle )
33 myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
35 myObjectName = new QLineEdit( myObjectNameGroup );
37 QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
38 aNameLayout->setMargin( 5 );
39 aNameLayout->setSpacing( 5 );
40 aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
41 aNameLayout->addWidget( myObjectName );
44 QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
46 QFrame* aPolylineFrame = new QFrame( aParamGroup );
48 myPolylines = new QComboBox( aPolylineFrame );
49 myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
51 QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
52 aPolyLayout->setMargin( 0 );
53 aPolyLayout->setSpacing( 5 );
54 aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
55 aPolyLayout->addWidget( myPolylines );
57 QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
58 aParamLayout->setMargin( 5 );
59 aParamLayout->setSpacing( 5 );
60 aParamLayout->addWidget( aPolylineFrame );
62 QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() );
64 myBathymetries = new QComboBox( aPolylineFrame );
65 myBathymetries->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
67 QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
68 aBathLayout->setMargin( 5 );
69 aBathLayout->setSpacing( 5 );
70 aBathLayout->addWidget( myBathymetries );
74 addWidget( myObjectNameGroup );
75 addWidget( aParamGroup );
76 addWidget( aBathGroup );
81 // Connect signals and slots
82 connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
85 HYDROGUI_ImmersibleZoneDlg::~HYDROGUI_ImmersibleZoneDlg()
89 void HYDROGUI_ImmersibleZoneDlg::reset()
91 bool isBlocked = blockSignals( true );
93 myObjectName->clear();
96 myBathymetries->clear();
98 blockSignals( isBlocked );
103 void HYDROGUI_ImmersibleZoneDlg::setObjectName( const QString& theName )
105 myObjectName->setText( theName );
108 QString HYDROGUI_ImmersibleZoneDlg::getObjectName() const
110 return myObjectName->text();
113 void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines )
115 bool isBlocked = blockSignals( true );
117 myPolylines->clear();
118 myPolylines->addItems( thePolylines );
120 blockSignals( isBlocked );
123 void HYDROGUI_ImmersibleZoneDlg::setPolylineName( const QString& theName )
125 int aNewIdx = myPolylines->findText( theName );
126 if ( aNewIdx != myPolylines->currentIndex() )
128 myPolylines->setCurrentIndex( aNewIdx );
136 QString HYDROGUI_ImmersibleZoneDlg::getPolylineName() const
138 return myPolylines->currentText();
141 void HYDROGUI_ImmersibleZoneDlg::setBathymetryNames( const QStringList& theBathymetries )
143 bool isBlocked = blockSignals( true );
145 myBathymetries->clear();
146 myBathymetries->addItems( theBathymetries );
148 blockSignals( isBlocked );
151 void HYDROGUI_ImmersibleZoneDlg::setBathymetryName( const QString& theName )
153 int aNewIdx = myBathymetries->findText( theName );
154 myBathymetries->setCurrentIndex( aNewIdx );
157 QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const
159 return myBathymetries->currentText();
162 void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged()
164 if ( signalsBlocked() )
167 QString aPolylineName = getPolylineName();
168 emit CreatePreview( aPolylineName );