Salome HOME
Merge branch 'BR_LAND_COVER_MAP' into BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_TranslateObstacleDlg.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_TranslateObstacleDlg.h"
20
21 #include <QtxDoubleSpinBox.h>
22
23 #include <QLabel>
24 #include <QLineEdit>
25 #include <QGroupBox>
26 #include <QGridLayout>
27
28 #include <limits>
29
30 HYDROGUI_TranslateObstacleDlg::HYDROGUI_TranslateObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle )
31 : HYDROGUI_InputPanel( theModule, theTitle )
32 {
33   // Obstacle name
34   QGroupBox* aNameGroup = new QGroupBox( tr( "OBSTACLE_NAME" ), this );
35
36   QLabel* aNameLabel = new QLabel( tr( "NAME" ), aNameGroup );
37   myName = new QLineEdit( aNameGroup );
38   myName->setEnabled( false );
39   
40   QBoxLayout* aNameLayout = new QHBoxLayout( aNameGroup );
41   aNameLayout->setMargin( 5 );
42   aNameLayout->setSpacing( 5 );
43   aNameLayout->addWidget( aNameLabel );
44   aNameLayout->addWidget( myName );
45
46   // Translation arguments
47   QGroupBox* anArgGroup = new QGroupBox( tr( "TRANSLATION_ARGUMENTS" ), this );
48
49   QLabel* aDxLabel = new QLabel( tr( "DX" ), anArgGroup );
50   myDxSpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
51
52   QLabel* aDyLabel = new QLabel( tr( "DY" ), anArgGroup );
53   myDySpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
54
55   QLabel* aDzLabel = new QLabel( tr( "DZ" ), anArgGroup );
56   myDzSpin = new QtxDoubleSpinBox( -1e+15, +1e+15, 10, anArgGroup );
57
58   QGridLayout* anArgLayout = new QGridLayout( anArgGroup );
59   anArgLayout->setMargin( 5 );
60   anArgLayout->setSpacing( 5 );
61   
62   anArgLayout->addWidget( aDxLabel, 0, 0 );
63   anArgLayout->addWidget( myDxSpin, 0, 1 );
64   anArgLayout->addWidget( aDyLabel, 1, 0 );
65   anArgLayout->addWidget( myDySpin, 1, 1 );
66   anArgLayout->addWidget( aDzLabel, 2, 0 );
67   anArgLayout->addWidget( myDzSpin, 2, 1 );
68
69   // Layout
70   addWidget( aNameGroup );
71   addWidget( anArgGroup );
72   addStretch();
73
74   // Connect signals and slots
75   connect( myDxSpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
76   connect( myDySpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
77   connect( myDzSpin, SIGNAL( valueChanged( double ) ), this, SIGNAL( argumentsChanged() ) );
78 }
79
80 HYDROGUI_TranslateObstacleDlg::~HYDROGUI_TranslateObstacleDlg()
81 {
82 }
83
84 void HYDROGUI_TranslateObstacleDlg::reset()
85 {
86   myName->clear();
87
88   myDxSpin->setValue( 0 );
89   myDySpin->setValue( 0 );
90   myDzSpin->setValue( 0 );
91 }
92
93 void HYDROGUI_TranslateObstacleDlg::setName( const QString& theName )
94 {
95   myName->setText( theName );
96 }
97
98 double HYDROGUI_TranslateObstacleDlg::getDx() const
99 {
100   return myDxSpin->value();
101 }
102
103 double HYDROGUI_TranslateObstacleDlg::getDy() const
104 {
105   return myDySpin->value();
106 }
107
108 double HYDROGUI_TranslateObstacleDlg::getDz() const
109 {
110   return myDzSpin->value();
111 }