1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_StreamDlg.h"
25 #include "HYDROGUI_Tool.h"
32 #include <QListWidget>
34 HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle )
35 : HYDROGUI_InputPanel( theModule, theTitle )
38 myObjectNameGroup = new QGroupBox( tr( "STREAM_NAME" ), mainFrame() );
40 myObjectName = new QLineEdit( myObjectNameGroup );
42 QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
43 aNameLayout->setMargin( 5 );
44 aNameLayout->setSpacing( 5 );
45 aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
46 aNameLayout->addWidget( myObjectName );
49 QGroupBox* aParamGroup = new QGroupBox( tr( "STREAM_PARAMETERS" ), mainFrame() );
51 myAxises = new QComboBox( aParamGroup );
52 myAxises->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
54 myProfiles = new QListWidget( aParamGroup );
55 myProfiles->setSelectionMode( QListWidget::SingleSelection );
56 myProfiles->setEditTriggers( QListWidget::NoEditTriggers );
57 myProfiles->setViewMode( QListWidget::ListMode );
58 myProfiles->setSortingEnabled( false );
60 QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
61 aParamLayout->setMargin( 5 );
62 aParamLayout->setSpacing( 5 );
63 aParamLayout->addWidget( new QLabel( tr( "STREAM_HYDRAULIC_AXIS" ), aParamGroup ), 0, 0 );
64 aParamLayout->addWidget( myAxises, 0, 1 );
65 aParamLayout->addWidget( myProfiles, 1, 0, 1, 2 );
68 addWidget( myObjectNameGroup );
69 addWidget( aParamGroup );
73 // Connect signals and slots
74 connect( myAxises, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onStreamDefChanged() ) );
77 HYDROGUI_StreamDlg::~HYDROGUI_StreamDlg()
81 void HYDROGUI_StreamDlg::reset()
83 bool isBlocked = blockSignals( true );
85 myObjectName->clear();
90 blockSignals( isBlocked );
95 void HYDROGUI_StreamDlg::setObjectName( const QString& theName )
97 myObjectName->setText( theName );
100 QString HYDROGUI_StreamDlg::getObjectName() const
102 return myObjectName->text();
105 void HYDROGUI_StreamDlg::setAxisNames( const QStringList& theAxises )
107 bool isBlocked = blockSignals( true );
110 myAxises->addItems( theAxises );
112 blockSignals( isBlocked );
115 void HYDROGUI_StreamDlg::setAxisName( const QString& theName )
117 int aNewIdx = myAxises->findText( theName );
118 if ( aNewIdx != myAxises->currentIndex() )
120 myAxises->setCurrentIndex( aNewIdx );
124 onStreamDefChanged();
128 QString HYDROGUI_StreamDlg::getAxisName() const
130 return myAxises->currentText();
133 void HYDROGUI_StreamDlg::setSelectedProfiles( const QStringList& theProfiles )
135 bool isBlocked = blockSignals( true );
137 myProfiles->setUpdatesEnabled( false );
140 for ( int i = 0, n = theProfiles.length(); i < n; ++i )
142 const QString& aProfileName = theProfiles.at( i );
143 QListWidgetItem* aListItem = new QListWidgetItem( aProfileName, myProfiles );
144 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
147 myProfiles->setUpdatesEnabled( true );
149 blockSignals( isBlocked );
151 onStreamDefChanged();
154 QStringList HYDROGUI_StreamDlg::getSelectedProfiles() const
156 QStringList aProfiles;
158 for ( int i = 0, n = myProfiles->count(); i < n; ++i )
160 QListWidgetItem* aListItem = myProfiles->item( i );
164 QString aProfileName = aListItem->text();
165 aProfiles << aProfileName;
171 void HYDROGUI_StreamDlg::onStreamDefChanged()
173 if ( signalsBlocked() )
176 emit CreatePreview();