Salome HOME
NRI : Merge from V1_2.
[modules/visu.git] / src / VISUGUI / VisuGUI_PhaseMagnitudeDlg.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_PhaseMagnitudeDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_PhaseMagnitudeDlg.h"
31
32 #include <qgroupbox.h>
33 #include <qlabel.h>
34 #include <qlineedit.h>
35 #include <qpushbutton.h>
36 #include <qlayout.h>
37 #include <qvariant.h>
38 #include <qtooltip.h>
39 #include <qwhatsthis.h>
40
41 /*!
42   Constructor
43 */
44 VisuGUI_PhaseMagnitudeDlg::VisuGUI_PhaseMagnitudeDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
45     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
46 {
47   if ( !name )
48     setName( "VisuGUI_PhaseMagnitudeDlg" );
49   setCaption( tr( "Phase Magnitude" ) );
50   setSizeGripEnabled( TRUE );
51
52   QGridLayout* TopLayout = new QGridLayout( this ); 
53   TopLayout->setSpacing( 6 );
54   TopLayout->setMargin( 11 );
55   
56   TopGroup = new QGroupBox( this, "TopGroup" );
57   TopGroup->setColumnLayout(0, Qt::Vertical );
58   TopGroup->layout()->setSpacing( 0 );
59   TopGroup->layout()->setMargin( 0 );
60   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
61   TopGroupLayout->setAlignment( Qt::AlignTop );
62   TopGroupLayout->setSpacing( 6 );
63   TopGroupLayout->setMargin( 11 );
64   
65   PhaseLabel = new QLabel( tr( "Phase:" ), TopGroup, "PhaseLabel" );
66   PhaseSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 );
67   PhaseSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
68   PhaseSpin->setMinimumSize( 70, 0 );
69   PhaseSpin->setValue( 0.0 );
70
71   MagnLabel = new QLabel( tr( "Magnitude:" ), TopGroup, "MagnLabel" );
72   MagnSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 );
73   MagnSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
74   MagnSpin->setMinimumSize( 70, 0 );
75   MagnSpin->setValue( 0.0 );
76   
77   TopGroupLayout->addWidget( PhaseLabel, 0, 0 );
78   TopGroupLayout->addWidget( PhaseSpin,  0, 1 );
79   TopGroupLayout->addWidget( MagnLabel,  1, 0 );
80   TopGroupLayout->addWidget( MagnSpin,   1, 1 );
81
82   GroupButtons = new QGroupBox( this, "GroupButtons" );
83   GroupButtons->setColumnLayout(0, Qt::Vertical );
84   GroupButtons->layout()->setSpacing( 0 );
85   GroupButtons->layout()->setMargin( 0 );
86   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
87   GroupButtonsLayout->setAlignment( Qt::AlignTop );
88   GroupButtonsLayout->setSpacing( 6 );
89   GroupButtonsLayout->setMargin( 11 );
90
91   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
92   buttonOk->setAutoDefault( TRUE );
93   buttonOk->setDefault( TRUE );
94   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
95   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
96   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
97   buttonCancel->setAutoDefault( TRUE );
98   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
99   
100   TopLayout->addWidget( TopGroup,     0, 0 );
101   TopLayout->addWidget( GroupButtons, 1, 0 );
102
103   // signals and slots connections
104   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
105   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
106 }
107
108 /*!
109   Destructor
110 */
111 VisuGUI_PhaseMagnitudeDlg::~VisuGUI_PhaseMagnitudeDlg()
112 {
113 }
114
115 /*!
116   Sets phase value
117 */
118 void VisuGUI_PhaseMagnitudeDlg::setPhase( const double ph )
119 {
120   PhaseSpin->setValue( ph );
121 }
122
123 /*!
124   Gets phase value
125 */
126 double VisuGUI_PhaseMagnitudeDlg::getPhase()
127 {
128   return PhaseSpin->value();
129 }
130
131 /*!
132   Sets magnitude value
133 */
134 void VisuGUI_PhaseMagnitudeDlg::setMagnitude( const double magn )
135 {
136   MagnSpin->setValue( magn );
137 }
138
139 /*!
140   Gets magnitude value
141 */
142 double VisuGUI_PhaseMagnitudeDlg::getMagnitude()
143 {
144   return MagnSpin->value();
145 }
146