Salome HOME
NRI : Merge from V1_2.
[modules/visu.git] / src / VISUGUI / VisuGUI_PhaseDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_PhaseDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_PhaseDlg.h"
31 #include <qlayout.h>
32
33 /*!
34   Constructor
35 */
36 VisuGUI_PhaseDlg::VisuGUI_PhaseDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
37     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
38 {
39   if ( !name )
40     setName( "VisuGUI_PhaseDlg" );
41   setCaption( tr( "Set Phase" ) );
42   setSizeGripEnabled( TRUE );
43   
44   QGridLayout* TopLayout = new QGridLayout( this ); 
45   TopLayout->setSpacing( 6 );
46   TopLayout->setMargin( 11 );
47   
48   TopGroup = new QGroupBox( this, "TopGroup" );
49   TopGroup->setColumnLayout(0, Qt::Vertical );
50   TopGroup->layout()->setSpacing( 0 );
51   TopGroup->layout()->setMargin( 0 );
52   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
53   TopGroupLayout->setAlignment( Qt::AlignTop );
54   TopGroupLayout->setSpacing( 6 );
55   TopGroupLayout->setMargin( 11 );
56   
57   PhaseLabel = new QLabel( tr( "VISU_MEN_PHASE" ), TopGroup, "PhaseLabel" );
58   PhaseSpin = new QAD_SpinBoxDbl( TopGroup, -360.00, 360.00, 1.0 );
59   PhaseSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
60   PhaseSpin->setMinimumSize( 70, 0 );
61   PhaseSpin->setValue( 0.0 );
62   
63   TopGroupLayout->addWidget( PhaseLabel, 0, 0 );
64   TopGroupLayout->addWidget( PhaseSpin,  0, 1 );
65
66   GroupButtons = new QGroupBox( this, "GroupButtons" );
67   GroupButtons->setColumnLayout(0, Qt::Vertical );
68   GroupButtons->layout()->setSpacing( 0 );
69   GroupButtons->layout()->setMargin( 0 );
70   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
71   GroupButtonsLayout->setAlignment( Qt::AlignTop );
72   GroupButtonsLayout->setSpacing( 6 );
73   GroupButtonsLayout->setMargin( 11 );
74
75   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
76   buttonOk->setAutoDefault( TRUE );
77   buttonOk->setDefault( TRUE );
78   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
79   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
80   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
81   buttonCancel->setAutoDefault( TRUE );
82   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
83   
84   TopLayout->addWidget( TopGroup,     0, 0 );
85   TopLayout->addWidget( GroupButtons, 1, 0 );
86
87   // signals and slots connections
88   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
89   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
90 }
91
92 /*!
93   Destructor
94 */
95 VisuGUI_PhaseDlg::~VisuGUI_PhaseDlg()
96 {
97 }
98
99 /*!
100   Sets phase value
101 */
102 void VisuGUI_PhaseDlg::setPhase( const double ph )
103 {
104   PhaseSpin->setValue( ph );
105 }
106
107 /*!
108   Gets phase value
109 */
110 double VisuGUI_PhaseDlg::getPhase()
111 {
112   return PhaseSpin->value();
113 }