Salome HOME
Minor changes.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Poly3DDlg.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_Poly3DDlg.h"
24
25 #include "HYDROGUI_ObjSelector.h"
26
27 #include <QCheckBox>
28 #include <QGroupBox>
29 #include <QLabel>
30 #include <QLayout>
31 #include <QLineEdit>
32
33 HYDROGUI_Poly3DDlg::HYDROGUI_Poly3DDlg( HYDROGUI_Module* theModule, const QString& theTitle )
34 : HYDROGUI_InputPanel( theModule, theTitle ),
35   myIsEdit( false )
36 {
37   // Profile name
38   QGroupBox* aNameGroup = new QGroupBox( tr( "POLYLINE_3D_NAME" ) );
39
40   QLabel* aNameLabel = new QLabel( tr( "NAME" ), aNameGroup );
41   myName = new QLineEdit( aNameGroup );
42
43   QGridLayout* aNameLayout = new QGridLayout( aNameGroup );
44   aNameLayout->setMargin( 5 );
45   aNameLayout->setSpacing( 5 );
46   aNameLayout->addWidget( aNameLabel,       0, 0 );
47   aNameLayout->addWidget( myName,           0, 1 );
48
49   // Parameters
50   QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) );
51
52   myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup );
53   myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup );
54
55   myProfileLabel = new QLabel( tr( "PROFILE" ), aParamGroup );
56   myProfile = new HYDROGUI_ObjSelector( theModule, KIND_PROFILE, aParamGroup );
57   
58   myBathLabel = new QLabel( tr( "BATH" ), aParamGroup );
59   myBath = new HYDROGUI_ObjSelector( theModule, KIND_BATHYMETRY, aParamGroup );
60
61   QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
62   aParamLayout->setMargin( 5 );
63   aParamLayout->setSpacing( 5 );
64   aParamLayout->addWidget( myPolylineLabel,  0, 0 );
65   aParamLayout->addWidget( myPolyline,       0, 1 );
66   aParamLayout->addWidget( myProfileLabel,   1, 0 );
67   aParamLayout->addWidget( myProfile,        1, 1 );
68   aParamLayout->addWidget( myBathLabel,      2, 0 );
69   aParamLayout->addWidget( myBath,           2, 1 );
70
71   // Common
72   addWidget( aNameGroup );
73   addWidget( aParamGroup );
74   addStretch();
75
76   setMode( myIsEdit );
77
78   connect( myProfile, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) );
79   connect( myBath, SIGNAL( selectionChanged() ), this, SLOT( OnSelectionChanged() ) );
80 }
81
82 HYDROGUI_Poly3DDlg::~HYDROGUI_Poly3DDlg()
83 {
84 }
85
86 void HYDROGUI_Poly3DDlg::reset()
87 {
88   myName->clear();
89   myProfile->Clear();
90   myPolyline->Clear();
91 }
92
93 void HYDROGUI_Poly3DDlg::setMode( const bool theIsEdit )
94 {
95   myIsEdit = theIsEdit;
96 }
97
98 void HYDROGUI_Poly3DDlg::setResultName( const QString& theName )
99 {
100   myName->setText( theName );
101 }
102
103 QString HYDROGUI_Poly3DDlg::getResultName() const
104 {
105   return myName->text();
106 }
107
108 void HYDROGUI_Poly3DDlg::setSelectedObjects( const QString& theNamePoly,
109                                              const QString& theNameProfile,
110                                              const QString& theNameBath )
111 {
112   myPolyline->SetName( theNamePoly );
113   myProfile->SetName( theNameProfile );
114   myBath->SetName( theNameBath );
115 }
116
117 bool HYDROGUI_Poly3DDlg::getSelectedObjects( QString& theNamePoly,
118                                              QString& theNameProfile,
119                                              QString& theNameBath ) const
120 {
121   theNamePoly = myPolyline->GetName();
122   theNameProfile = myProfile->GetName();
123   theNameBath = myBath->GetName();
124   return !theNamePoly.isEmpty() && ( !theNameProfile.isEmpty() || !theNameBath.isEmpty() );
125 }
126
127 void HYDROGUI_Poly3DDlg::setPreselectedObject( const QString& theName )
128 {
129   myProfile->SetName( theName );
130   myPolyline->SetChecked( true );
131   myPolyline->SetName( QString() );
132 }
133
134 void HYDROGUI_Poly3DDlg::OnSelectionChanged()
135 {
136   if( sender()==myProfile && !myProfile->GetName().isEmpty() )
137     myBath->Clear();
138   if( sender()==myBath && !myBath->GetName().isEmpty() )
139     myProfile->Clear();
140 }