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 HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle )
30 : HYDROGUI_InputPanel( theModule, theTitle )
33 myObjectNameGroup = new QGroupBox( tr( "CHANNEL_NAME" ), mainFrame() );
35 myObjectName = new QLineEdit( myObjectNameGroup );
37 QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
38 aNameLayout->setMargin( 5 );
39 aNameLayout->setSpacing( 5 );
40 aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
41 aNameLayout->addWidget( myObjectName );
44 QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() );
46 //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup );
47 myGuideLines = new QComboBox( aParamGroup );
48 myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
50 //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup );
51 myProfiles = new QComboBox( aParamGroup );
52 myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
54 QGridLayout* aParamsLayout = new QGridLayout( aParamGroup );
55 aParamsLayout->setMargin( 5 );
56 aParamsLayout->setSpacing( 5 );
57 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 );
58 aParamsLayout->addWidget( myGuideLines, 0, 1 );
59 aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 );
60 aParamsLayout->addWidget( myProfiles, 1, 1 );
63 addWidget( myObjectNameGroup );
64 addWidget( aParamGroup );
68 // Connect signals and slots
69 connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
70 connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) );
73 HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg()
77 void HYDROGUI_ChannelDlg::reset()
79 bool isBlocked = blockSignals( true );
81 myObjectName->clear();
83 myGuideLines->clear();
86 blockSignals( isBlocked );
88 onChannelDefChanged();
91 void HYDROGUI_ChannelDlg::setObjectName( const QString& theName )
93 myObjectName->setText( theName );
96 QString HYDROGUI_ChannelDlg::getObjectName() const
98 return myObjectName->text();
101 void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines )
103 bool isBlocked = blockSignals( true );
105 myGuideLines->clear();
106 myGuideLines->addItems( theGuideLines );
108 blockSignals( isBlocked );
111 void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine )
113 int aNewIdx = myGuideLines->findText( theGuideLine );
114 if ( aNewIdx != myGuideLines->currentIndex() )
116 myGuideLines->setCurrentIndex( aNewIdx );
120 onChannelDefChanged();
124 QString HYDROGUI_ChannelDlg::getGuideLineName() const
126 return myGuideLines->currentText();
129 void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles )
131 bool isBlocked = blockSignals( true );
134 myProfiles->addItems( theProfiles );
136 blockSignals( isBlocked );
139 void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile )
141 int aNewIdx = myProfiles->findText( theProfile );
142 if ( aNewIdx != myProfiles->currentIndex() )
144 myProfiles->setCurrentIndex( aNewIdx );
148 onChannelDefChanged();
152 QString HYDROGUI_ChannelDlg::getProfileName() const
154 return myProfiles->currentText();
157 void HYDROGUI_ChannelDlg::onChannelDefChanged()
159 if ( signalsBlocked() )
162 emit CreatePreview();