Salome HOME
LOT 15
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImmersibleZoneDlg.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_ImmersibleZoneDlg.h"
20
21 #include "HYDROGUI_Tool.h"
22
23 #include <QComboBox>
24 #include <QGroupBox>
25 #include <QLabel>
26 #include <QLayout>
27
28 HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
29 : HYDROGUI_BasicZoneDlg( theModule, theTitle,
30                          tr( "ZONE_NAME" ), tr( "NAME" ),
31                          tr( "ZONE_PARAMETERS" ), tr( "ZONE_BATHYMETRY" ) )
32 {
33   myPolylines = new QComboBox( myPolylineFrame );
34   myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
35
36   QBoxLayout* aPolyLayout = new QHBoxLayout( myPolylineFrame );
37   aPolyLayout->setMargin( 0 );
38   aPolyLayout->setSpacing( 5 );
39   aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), myPolylineFrame ) );
40   aPolyLayout->addWidget( myPolylines );
41   
42   QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup );
43   aParamLayout->setMargin( 5 );
44   aParamLayout->setSpacing( 5 );
45   aParamLayout->addWidget( myPolylineFrame );
46
47   // Connect signals and slots
48   connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
49 }
50
51 HYDROGUI_ImmersibleZoneDlg::~HYDROGUI_ImmersibleZoneDlg()
52 {
53 }
54
55 void HYDROGUI_ImmersibleZoneDlg::reset()
56 {
57   bool isBlocked = blockSignals( true );
58
59   HYDROGUI_BasicZoneDlg::reset(); 
60
61   myPolylines->clear();
62   
63   blockSignals( isBlocked );
64
65   onZoneDefChanged();
66 }
67
68 void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines )
69 {
70   bool isBlocked = blockSignals( true );
71
72   myPolylines->clear();
73   myPolylines->addItems( thePolylines );
74
75   blockSignals( isBlocked );
76 }
77
78 void HYDROGUI_ImmersibleZoneDlg::setPolylineName( const QString& theName )
79 {
80   int aNewIdx = myPolylines->findText( theName );
81   if ( aNewIdx != myPolylines->currentIndex() )
82   {
83     myPolylines->setCurrentIndex( aNewIdx );
84   }
85   else
86   {
87     onZoneDefChanged();
88   }
89 }
90
91 QString HYDROGUI_ImmersibleZoneDlg::getPolylineName() const
92 {
93   return myPolylines->currentText();
94 }
95
96 void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged()
97 {
98   if ( signalsBlocked() )
99     return;
100
101   QString aPolylineName = getPolylineName();
102   emit CreatePreview( aPolylineName );
103 }