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_ChannelDlg.h"
21 #include "HYDROGUI_Tool.h"
29 #include <QtxDoubleSpinBox.h>
30 #include <QRadioButton>
32 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
33 : HYDROGUI_InputPanel( theModule, theTitle )
36 myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
38 myObjectName = new QLineEdit( myObjectNameGroup );
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 );
47 QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
49 //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
50 myGuideLines = new QComboBox( aParamGroup );
51 myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
53 //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
54 myProfiles = new QComboBox( aParamGroup );
55 myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
57 myEquiDistance = new QtxDoubleSpinBox( aParamGroup );
58 myEquiDistance->setRange( 0.01, 9999 );
59 myEquiDistance->setValue( 1.0 );
60 myEquiDistance->setSingleStep( 1.0 );
63 myLCVal = new QtxDoubleSpinBox( aParamGroup );
64 myLCVal->setRange( 0.0, 999999 );
65 myLCVal->setValue( 50 );
66 myLCVal->setSingleStep( 0.1 );
68 myDeltaZVal = new QtxDoubleSpinBox( aParamGroup );
69 myDeltaZVal->setRange( 0.0, 999999 );
70 myDeltaZVal->setValue( 5.0 );
71 myDeltaZVal->setSingleStep( 0.1 );
73 myCoteZVal = new QtxDoubleSpinBox( aParamGroup );
74 myCoteZVal->setRange( 0.0, 999999 );
75 myCoteZVal->setValue( 1.0 );
76 myCoteZVal->setSingleStep( 0.1 );
79 myInvertDirection = new QCheckBox(aParamGroup);
80 myInvertDirection->setChecked(false);
82 myProfileLabel = new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup);
84 myProfileModeButton = new QRadioButton( tr( "VIA_PROFILE" ), myObjectNameGroup );
85 QRadioButton* ProfileModeButton2 = new QRadioButton( tr( "PREDEF" ), myObjectNameGroup );
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 );
93 aParamsLayout->addWidget( myProfileModeButton, 1, 0 );
94 aParamsLayout->addWidget( ProfileModeButton2, 1, 1 );
96 aParamsLayout->addWidget( myProfileLabel, 2, 0 );
97 aParamsLayout->addWidget( myProfiles, 2, 1 );
99 myLCValLabel = new QLabel( tr( "LC_VALUE" ), aParamGroup);
100 myDeltaZValLabel = new QLabel( tr( "DELTAZ_VALUE" ), aParamGroup);
101 myCoteZValLabel = new QLabel( tr( "COTEZ_VALUE" ), aParamGroup);
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 );
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 );
116 addWidget( myObjectNameGroup );
117 addWidget( aParamGroup );
121 // Connect signals and slots
122 connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
123 connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
125 connect( myProfileModeButton, SIGNAL( toggled( bool ) ), this, SLOT( onProfileModeChanged( bool ) ) );
126 myProfileModeButton->setChecked(true);
129 HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
133 void HYDROGUI_ChannelDlg::reset()
135 bool isBlocked = blockSignals( true );
137 myObjectName->clear();
139 myGuideLines->clear();
142 blockSignals( isBlocked );
144 onChannelDefChanged();
147 void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
149 myObjectName->setText( theName );
152 QString HYDROGUI_ChannelDlg::getObjectName() const
154 return myObjectName->text();
157 void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
159 bool isBlocked = blockSignals( true );
161 myGuideLines->clear();
162 myGuideLines->addItems( theGuideLines );
164 blockSignals( isBlocked );
167 void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
169 int aNewIdx = myGuideLines->findText( theGuideLine );
170 if ( aNewIdx != myGuideLines->currentIndex() )
172 myGuideLines->setCurrentIndex( aNewIdx );
176 onChannelDefChanged();
180 QString HYDROGUI_ChannelDlg::getGuideLineName() const
182 return myGuideLines->currentText();
185 void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
187 bool isBlocked = blockSignals( true );
190 myProfiles->addItems( theProfiles );
192 blockSignals( isBlocked );
195 void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
197 int aNewIdx = myProfiles->findText( theProfile );
198 if ( aNewIdx != myProfiles->currentIndex() )
200 myProfiles->setCurrentIndex( aNewIdx );
204 onChannelDefChanged();
208 QString HYDROGUI_ChannelDlg::getProfileName() const
210 return myProfiles->currentText();
213 void HYDROGUI_ChannelDlg::onChannelDefChanged()
215 if ( signalsBlocked() )
218 emit CreatePreview();
221 void HYDROGUI_ChannelDlg::onProfileModeChanged(bool mode)
223 if ( signalsBlocked() )
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);
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);
249 bool HYDROGUI_ChannelDlg::getProfileMode()
251 return myProfileModeButton->isChecked();
254 double HYDROGUI_ChannelDlg::getEquiDistance() const
256 return myEquiDistance->value();
259 void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
261 myEquiDistance->setValue( theValue );
264 bool HYDROGUI_ChannelDlg::getInvertDirection() const
266 return myInvertDirection->isChecked();
269 void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
271 myInvertDirection->setChecked(isChecked);