]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_ChannelDlg.cxx
Salome HOME
lot 12 GUI p.1
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ChannelDlg.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_ChannelDlg.h"
20
21 #include "HYDROGUI_Tool.h"
22
23 #include <QComboBox>
24 #include <QGroupBox>
25 #include <QLabel>
26 #include <QLayout>
27 #include <QLineEdit>
28 #include <QCheckBox>
29 #include <QtxDoubleSpinBox.h>
30 #include <QRadioButton>
31
32 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
33 : HYDROGUI_InputPanel( theModule, theTitle )
34 {
35   // Channel name
36   myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
37
38   myObjectName = new QLineEdit( myObjectNameGroup );
39
40   QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
41   aNameLayout->setMargin( 5 );
42   aNameLayout->setSpacing( 5 );
43   aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
44   aNameLayout->addWidget( myObjectName );
45
46   // Channel parameters
47   QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
48
49   //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
50   myGuideLines = new QComboBox( aParamGroup );
51   myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
52
53   //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
54   myProfiles = new QComboBox( aParamGroup );
55   myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
56
57   myEquiDistance = new QtxDoubleSpinBox( aParamGroup );
58   myEquiDistance->setRange( 0.01, 9999 );
59   myEquiDistance->setValue( 1.0 );
60   myEquiDistance->setSingleStep( 1.0 );
61
62   //for digue
63   myLCVal = new QtxDoubleSpinBox( aParamGroup );
64   myLCVal->setRange( 0.0, 999999 );
65   myLCVal->setValue( 50 );
66   myLCVal->setSingleStep( 0.1 );
67
68   myDeltaZVal = new QtxDoubleSpinBox( aParamGroup );
69   myDeltaZVal->setRange( 0.0, 999999 );
70   myDeltaZVal->setValue( 5.0 );
71   myDeltaZVal->setSingleStep( 0.1 );
72
73   myCoteZVal = new QtxDoubleSpinBox( aParamGroup );
74   myCoteZVal->setRange( 0.0, 999999 );
75   myCoteZVal->setValue( 1.0 );
76   myCoteZVal->setSingleStep( 0.1 );
77   //END for digue
78
79   myInvertDirection = new QCheckBox(aParamGroup);
80   myInvertDirection->setChecked(false);
81
82   myProfileLabel = new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup);
83
84   myProfileModeButton = new QRadioButton( tr( "VIA_PROFILE" ), myObjectNameGroup );
85   QRadioButton* ProfileModeButton2 = new QRadioButton( tr( "PREDEF" ), myObjectNameGroup );
86
87   QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
88   aParamsLayout->setMargin( 5 );
89   aParamsLayout->setSpacing( 5 );
90   aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 );
91   aParamsLayout->addWidget( myGuideLines, 0, 1 );
92     
93   aParamsLayout->addWidget( myProfileModeButton, 1, 0 );
94   aParamsLayout->addWidget( ProfileModeButton2, 1, 1 );
95
96   aParamsLayout->addWidget( myProfileLabel, 2, 0 );
97   aParamsLayout->addWidget( myProfiles, 2, 1 );
98
99   myLCValLabel = new QLabel( tr( "LC_VALUE" ), aParamGroup);
100   myDeltaZValLabel = new QLabel( tr( "DELTAZ_VALUE" ), aParamGroup);
101   myCoteZValLabel = new QLabel( tr( "COTEZ_VALUE" ), aParamGroup);
102
103   aParamsLayout->addWidget( myLCValLabel, 3, 0 );
104   aParamsLayout->addWidget( myLCVal, 3, 1 );
105   aParamsLayout->addWidget( myDeltaZValLabel, 4, 0 );
106   aParamsLayout->addWidget( myDeltaZVal, 4, 1 );
107   aParamsLayout->addWidget( myCoteZValLabel, 5, 0 );
108   aParamsLayout->addWidget( myCoteZVal, 5, 1 );
109
110   aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 6, 0 );
111   aParamsLayout->addWidget( myEquiDistance, 6, 1 );
112   aParamsLayout->addWidget( new QLabel( tr( "INVERT_DIRECTION" ), aParamGroup ), 7, 0 );
113   aParamsLayout->addWidget( myInvertDirection, 7, 1 );
114
115   // Common
116   addWidget( myObjectNameGroup );
117   addWidget( aParamGroup );
118
119   addStretch();
120
121   // Connect signals and slots
122   connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
123   connect( myProfiles, SIGNAL(  currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
124   
125   connect( myProfileModeButton, SIGNAL( toggled( bool ) ), this, SLOT( onProfileModeChanged( bool ) ) );
126   myProfileModeButton->setChecked(true);
127 }
128
129 HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
130 {
131 }
132
133 void HYDROGUI_ChannelDlg::reset()
134 {
135   bool isBlocked = blockSignals( true );
136
137   myObjectName->clear();
138
139   myGuideLines->clear();
140   myProfiles->clear();
141
142   blockSignals( isBlocked );
143
144   onChannelDefChanged();
145 }
146
147 void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
148 {
149   myObjectName->setText( theName );
150 }
151
152 QString HYDROGUI_ChannelDlg::getObjectName() const
153 {
154   return myObjectName->text();
155 }
156
157 void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
158 {
159   bool isBlocked = blockSignals( true );
160
161   myGuideLines->clear();
162   myGuideLines->addItems( theGuideLines );
163
164   blockSignals( isBlocked );
165 }
166
167 void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
168 {
169   int aNewIdx = myGuideLines->findText( theGuideLine );
170   if ( aNewIdx != myGuideLines->currentIndex() )
171   {
172     myGuideLines->setCurrentIndex( aNewIdx );
173   }
174   else
175   {
176     onChannelDefChanged();
177   }
178 }
179
180 QString HYDROGUI_ChannelDlg::getGuideLineName() const
181 {
182   return myGuideLines->currentText();
183 }
184
185 void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
186 {
187   bool isBlocked = blockSignals( true );
188
189   myProfiles->clear();
190   myProfiles->addItems( theProfiles );
191
192   blockSignals( isBlocked );
193 }
194
195 void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
196 {
197   int aNewIdx = myProfiles->findText( theProfile );
198   if ( aNewIdx != myProfiles->currentIndex() )
199   {
200     myProfiles->setCurrentIndex( aNewIdx );
201   }
202   else
203   {
204     onChannelDefChanged();
205   }
206 }
207
208 QString HYDROGUI_ChannelDlg::getProfileName() const
209 {
210   return myProfiles->currentText();
211 }
212
213 void HYDROGUI_ChannelDlg::onChannelDefChanged()
214 {
215   if ( signalsBlocked() )
216     return;
217
218   emit CreatePreview();
219 }
220
221 void HYDROGUI_ChannelDlg::onProfileModeChanged(bool mode)
222 {
223   if ( signalsBlocked() )
224     return;
225   if (mode)
226   {
227     myProfiles->setVisible(true);
228     myProfileLabel->setVisible(true);
229     myLCValLabel->setVisible(false);
230     myLCVal->setVisible(false);
231     myDeltaZValLabel->setVisible(false);
232     myDeltaZVal->setVisible(false);
233     myCoteZValLabel->setVisible(false);
234     myCoteZVal->setVisible(false);
235   }
236   else
237   {
238     myProfiles->setVisible(false);
239     myProfileLabel->setVisible(false);
240     myLCValLabel->setVisible(true);
241     myLCVal->setVisible(true);
242     myDeltaZValLabel->setVisible(true);
243     myDeltaZVal->setVisible(true);
244     myCoteZValLabel->setVisible(true);
245     myCoteZVal->setVisible(true);
246   }
247 }
248
249 bool HYDROGUI_ChannelDlg::getProfileMode()
250 {
251   return myProfileModeButton->isChecked();
252 }
253
254 double HYDROGUI_ChannelDlg::getEquiDistance() const
255 {
256   return myEquiDistance->value();
257 }
258
259 void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
260 {
261   myEquiDistance->setValue( theValue );
262 }
263
264 bool HYDROGUI_ChannelDlg::getInvertDirection() const
265 {
266   return myInvertDirection->isChecked();
267 }
268
269 void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
270 {
271   myInvertDirection->setChecked(isChecked);
272 }
273