Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_TransparencyDlg.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_TransparencyDlg.h"
20
21 #include <QtxDoubleSpinBox.h>
22
23 #include <QLabel>
24 #include <QLayout>
25 #include <QPushButton>
26
27 const double RANGE = 1;
28 const double STEP = 0.1;
29 const double PREC = 2;
30
31 /**
32   Constructor.
33   @param theParent the parent widget
34 */
35 HYDROGUI_TransparencyDlg::HYDROGUI_TransparencyDlg( QWidget* theParent )
36   : QDialog( theParent )
37 {
38   myTransparency = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, this );
39   myTransparency->setValue( 0.5 );
40
41   // Apply and close buttons
42   myApplyAndClose = new QPushButton( tr("APPLY_AND_CLOSE") );
43   myApplyAndClose->setDefault( true );
44   myApply = new QPushButton( tr("APPLY") );
45   myClose = new QPushButton( tr("CLOSE") );
46
47   // Layout
48   // Spin-box layout
49   QHBoxLayout* aLayout = new QHBoxLayout();
50   aLayout->setMargin( 5 );
51   aLayout->setSpacing( 5 );
52   aLayout->addWidget( new QLabel( tr( "TRANSPARENCY" ), this ) );
53   aLayout->addWidget( myTransparency );
54   // Apply and close buttons layout
55   QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); 
56   aDlgButtonsLayout->addWidget( myApplyAndClose );
57   aDlgButtonsLayout->addWidget( myApply );
58   aDlgButtonsLayout->addWidget( myClose );
59   aDlgButtonsLayout->addStretch();
60   // Main layout
61   QVBoxLayout* aMainLayout = new QVBoxLayout( this );
62   aMainLayout->setMargin( 5 );
63   aMainLayout->setSpacing( 5 );
64   aMainLayout->addLayout( aLayout );
65   aMainLayout->addLayout( aDlgButtonsLayout );
66
67   // Connections
68   connect( myApplyAndClose, SIGNAL( clicked() ), this, SIGNAL( applyAndClose() ) );
69   connect( myApply, SIGNAL( clicked() ), this, SIGNAL( apply() ) );
70   connect( myClose, SIGNAL( clicked() ), this, SLOT( reject() ) );  
71
72   setFixedSize( 300, 90 );
73 }
74
75 /**
76   Destructor.
77 */
78 HYDROGUI_TransparencyDlg::~HYDROGUI_TransparencyDlg()
79 {
80 }
81
82 void HYDROGUI_TransparencyDlg::setTransparency( const double& theValue )
83 {
84   myTransparency->setValue( theValue );
85 }
86
87 double HYDROGUI_TransparencyDlg::getTransparency() const
88 {
89   return myTransparency->value();
90 }