Salome HOME
epaisseur des polylignes = 2
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_RiverBottomDlg.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_RiverBottomDlg.h"
20
21 #include "HYDROGUI_Tool.h"
22 #include "HYDROGUI_ObjComboBox.h"
23
24 #include <HYDROData_Stream.h>
25 #include <HYDROData_Polyline3D.h>
26
27 #include <QLabel>
28 #include <QLayout>
29 #include <QComboBox>
30 #include <QGroupBox>
31
32 HYDROGUI_RiverBottomDlg::HYDROGUI_RiverBottomDlg( HYDROGUI_Module* theModule, const QString& theTitle )
33     : HYDROGUI_InputPanel( theModule, theTitle ),
34     HYDROGUI_ObjComboBoxFilter()
35 {
36     // Channel name
37     QGroupBox* group = new QGroupBox( mainFrame() );
38     QBoxLayout* base = new QVBoxLayout( group );
39
40     base->addWidget( myRivers = new HYDROGUI_ObjComboBox( theModule, tr( "STREAM_OBJECT" ), KIND_STREAM, group ) );
41     myRivers->setObjectFilter( this );
42
43     addWidget( group );
44
45     addStretch();
46
47     connect( myRivers, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onRiverChanged( const QString& ) ) );
48
49     updateState();
50 }
51
52 HYDROGUI_RiverBottomDlg::~HYDROGUI_RiverBottomDlg()
53 {
54 }
55
56 void HYDROGUI_RiverBottomDlg::reset()
57 {
58     bool isBlocked = blockSignals( true );
59
60     myRivers->reset();
61
62     blockSignals( isBlocked );
63
64     updateState();
65 }
66
67 QString HYDROGUI_RiverBottomDlg::getRiverName() const
68 {
69     return myRivers->selectedObject();
70 }
71
72 void HYDROGUI_RiverBottomDlg::setRiverName( const QString& theName )
73 {
74     myRivers->setSelectedObject( theName );
75 }
76
77 bool HYDROGUI_RiverBottomDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
78 {
79     Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast(theEntity);
80     return !aStream.IsNull() && aStream->GetBottomPolyline().IsNull();
81 }
82
83 void HYDROGUI_RiverBottomDlg::onRiverChanged( const QString& )
84 {
85     updateState();
86 }
87
88 void HYDROGUI_RiverBottomDlg::updateState()
89 {
90     setApplyEnabled( !getRiverName().isEmpty() );
91 }