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>
31 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
32 : HYDROGUI_InputPanel( theModule, theTitle )
35 myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
37 myObjectName = new QLineEdit( myObjectNameGroup );
39 QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
40 aNameLayout->setMargin( 5 );
41 aNameLayout->setSpacing( 5 );
42 aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
43 aNameLayout->addWidget( myObjectName );
46 QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
48 //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
49 myGuideLines = new QComboBox( aParamGroup );
50 myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
52 //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
53 myProfiles = new QComboBox( aParamGroup );
54 myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
56 myEquiDistance = new QtxDoubleSpinBox( aParamGroup );
57 myEquiDistance->setRange( 0.01, 9999 );
58 myEquiDistance->setValue( 1.0 );
59 myEquiDistance->setSingleStep( 1.0 );
61 myInvertDirection = new QCheckBox(aParamGroup);
62 myInvertDirection->setChecked(false);
64 QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
65 aParamsLayout->setMargin( 5 );
66 aParamsLayout->setSpacing( 5 );
67 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 );
68 aParamsLayout->addWidget( myGuideLines, 0, 1 );
69 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 );
70 aParamsLayout->addWidget( myProfiles, 1, 1 );
71 aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 );
72 aParamsLayout->addWidget( myEquiDistance, 2, 1 );
73 aParamsLayout->addWidget( new QLabel( tr( "INVERT_DIRECTION" ), aParamGroup ), 3, 0 );
74 aParamsLayout->addWidget( myInvertDirection, 3, 1 );
77 addWidget( myObjectNameGroup );
78 addWidget( aParamGroup );
82 // Connect signals and slots
83 connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
84 connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
87 HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
91 void HYDROGUI_ChannelDlg::reset()
93 bool isBlocked = blockSignals( true );
95 myObjectName->clear();
97 myGuideLines->clear();
100 blockSignals( isBlocked );
102 onChannelDefChanged();
105 void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
107 myObjectName->setText( theName );
110 QString HYDROGUI_ChannelDlg::getObjectName() const
112 return myObjectName->text();
115 void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
117 bool isBlocked = blockSignals( true );
119 myGuideLines->clear();
120 myGuideLines->addItems( theGuideLines );
122 blockSignals( isBlocked );
125 void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
127 int aNewIdx = myGuideLines->findText( theGuideLine );
128 if ( aNewIdx != myGuideLines->currentIndex() )
130 myGuideLines->setCurrentIndex( aNewIdx );
134 onChannelDefChanged();
138 QString HYDROGUI_ChannelDlg::getGuideLineName() const
140 return myGuideLines->currentText();
143 void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
145 bool isBlocked = blockSignals( true );
148 myProfiles->addItems( theProfiles );
150 blockSignals( isBlocked );
153 void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
155 int aNewIdx = myProfiles->findText( theProfile );
156 if ( aNewIdx != myProfiles->currentIndex() )
158 myProfiles->setCurrentIndex( aNewIdx );
162 onChannelDefChanged();
166 QString HYDROGUI_ChannelDlg::getProfileName() const
168 return myProfiles->currentText();
171 void HYDROGUI_ChannelDlg::onChannelDefChanged()
173 if ( signalsBlocked() )
176 emit CreatePreview();
179 double HYDROGUI_ChannelDlg::getEquiDistance() const
181 return myEquiDistance->value();
184 void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
186 myEquiDistance->setValue( theValue );
189 bool HYDROGUI_ChannelDlg::getInvertDirection() const
191 return myInvertDirection->isChecked();
194 void HYDROGUI_ChannelDlg::setInvertDirection( bool isChecked )
196 myInvertDirection->setChecked(isChecked);