Salome HOME
Polyline3D creation/edit dialog and operation are added.
[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   myProfileLabel = new QLabel( tr( "PROFILE" ), aParamGroup );
53   myProfile = new HYDROGUI_ObjSelector( theModule, KIND_PROFILE, aParamGroup );
54
55   myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup );
56   myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINEXY, aParamGroup );
57
58   QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
59   aParamLayout->setMargin( 5 );
60   aParamLayout->setSpacing( 5 );
61   aParamLayout->addWidget( myProfileLabel,   0, 0 );
62   aParamLayout->addWidget( myProfile,        0, 1 );
63   aParamLayout->addWidget( myPolylineLabel,  1, 0 );
64   aParamLayout->addWidget( myPolyline,       1, 1 );
65
66   // Common
67   addWidget( aNameGroup );
68   addWidget( aParamGroup );
69   addStretch();
70
71   setMode( myIsEdit );
72 }
73
74 HYDROGUI_Poly3DDlg::~HYDROGUI_Poly3DDlg()
75 {
76 }
77
78 void HYDROGUI_Poly3DDlg::reset()
79 {
80   myName->clear();
81   myProfile->Clear();
82   myPolyline->Clear();
83 }
84
85 void HYDROGUI_Poly3DDlg::setMode( const bool theIsEdit )
86 {
87   myIsEdit = theIsEdit;
88 }
89
90 void HYDROGUI_Poly3DDlg::setResultName( const QString& theName )
91 {
92   myName->setText( theName );
93 }
94
95 QString HYDROGUI_Poly3DDlg::getResultName() const
96 {
97   return myName->text();
98 }
99
100 void HYDROGUI_Poly3DDlg::setSelectedObjects( const QString& theName1,
101                                              const QString& theName2 )
102 {
103   myProfile->SetName( theName1 );
104   myPolyline->SetName( theName2 );
105 }
106
107 bool HYDROGUI_Poly3DDlg::getSelectedObjects( QString& theName1,
108                                              QString& theName2 ) const
109 {
110   theName1 = myProfile->GetName();
111   theName2 = myPolyline->GetName();
112   return !theName1.isEmpty() && !theName2.isEmpty();
113 }
114
115 void HYDROGUI_Poly3DDlg::setPreselectedObject( const QString& theName )
116 {
117   myProfile->SetName( theName );
118   myPolyline->SetChecked( true );
119   myPolyline->SetName( QString() );
120 }