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"
28 #include <QtxDoubleSpinBox.h>
30 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
31 : HYDROGUI_InputPanel( theModule, theTitle )
34 myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
36 myObjectName = new QLineEdit( myObjectNameGroup );
38 QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
39 aNameLayout->setMargin( 5 );
40 aNameLayout->setSpacing( 5 );
41 aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
42 aNameLayout->addWidget( myObjectName );
45 QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
47 //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
48 myGuideLines = new QComboBox( aParamGroup );
49 myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
51 //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
52 myProfiles = new QComboBox( aParamGroup );
53 myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
55 myEquiDistance = new QtxDoubleSpinBox( aParamGroup );
56 myEquiDistance->setRange( 0.01, 9999 );
57 myEquiDistance->setValue( 1.0 );
58 myEquiDistance->setSingleStep( 1.0 );
60 QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
61 aParamsLayout->setMargin( 5 );
62 aParamsLayout->setSpacing( 5 );
63 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 );
64 aParamsLayout->addWidget( myGuideLines, 0, 1 );
65 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 );
66 aParamsLayout->addWidget( myProfiles, 1, 1 );
67 aParamsLayout->addWidget( new QLabel( tr( "EQUI_DISTANCE" ), aParamGroup ), 2, 0 );
68 aParamsLayout->addWidget( myEquiDistance, 2, 1 );
71 addWidget( myObjectNameGroup );
72 addWidget( aParamGroup );
76 // Connect signals and slots
77 connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
78 connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
81 HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
85 void HYDROGUI_ChannelDlg::reset()
87 bool isBlocked = blockSignals( true );
89 myObjectName->clear();
91 myGuideLines->clear();
94 blockSignals( isBlocked );
96 onChannelDefChanged();
99 void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
101 myObjectName->setText( theName );
104 QString HYDROGUI_ChannelDlg::getObjectName() const
106 return myObjectName->text();
109 void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
111 bool isBlocked = blockSignals( true );
113 myGuideLines->clear();
114 myGuideLines->addItems( theGuideLines );
116 blockSignals( isBlocked );
119 void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
121 int aNewIdx = myGuideLines->findText( theGuideLine );
122 if ( aNewIdx != myGuideLines->currentIndex() )
124 myGuideLines->setCurrentIndex( aNewIdx );
128 onChannelDefChanged();
132 QString HYDROGUI_ChannelDlg::getGuideLineName() const
134 return myGuideLines->currentText();
137 void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
139 bool isBlocked = blockSignals( true );
142 myProfiles->addItems( theProfiles );
144 blockSignals( isBlocked );
147 void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
149 int aNewIdx = myProfiles->findText( theProfile );
150 if ( aNewIdx != myProfiles->currentIndex() )
152 myProfiles->setCurrentIndex( aNewIdx );
156 onChannelDefChanged();
160 QString HYDROGUI_ChannelDlg::getProfileName() const
162 return myProfiles->currentText();
165 void HYDROGUI_ChannelDlg::onChannelDefChanged()
167 if ( signalsBlocked() )
170 emit CreatePreview();
173 double HYDROGUI_ChannelDlg::getEquiDistance() const
175 return myEquiDistance->value();
178 void HYDROGUI_ChannelDlg::setEquiDistance( double theValue )
180 myEquiDistance->setValue( theValue );