]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GeometryGUI_aParameterDlg.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/geom.git] / src / GEOMGUI / GeometryGUI_aParameterDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry 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   : GeometryGUI_aParameterDlg.cxx
25 //  Author : Lucien PIGNOLONI
26 //  Module : GEOM
27 //  $Header$
28
29 using namespace std;
30 #include "GeometryGUI_aParameterDlg.h"
31 #include "GeometryGUI.h"
32 #include "QAD_SpinBoxDbl.h"
33 #include "QAD_Tools.h"
34
35 #include <stdio.h>
36
37 #include <qgroupbox.h>
38 #include <qlabel.h>
39 #include <qpushbutton.h>
40 #include <qlayout.h>
41 #include <qvariant.h>
42 #include <qvalidator.h>
43
44 //====================================================================================== 
45 // function : GeometryGUI_aParameterDlg()
46 // purpose  : Constructs a GeometryGUI_aParametertDlg which is a child of 'parent', with the 
47 //            name 'name' and widget flags set to 'f'
48 //
49 //  avalue1    : is a float or integer used as default value in edit line
50 //  aTitle1    : is the prompt for aValue1
51 //  aTitle     : is the title for the user in dialog box
52 //
53 //  bottom     : the minimal value to be entered
54 //  top        : the maximum value to be entered
55 //  decimals   : number of decimals to be entered
56 //
57 //  The dialog will by default be modeless, unless you set 'modal' to
58 //  TRUE to construct a modal dialog.
59 // 
60 //====================================================================================== 
61 GeometryGUI_aParameterDlg::GeometryGUI_aParameterDlg( const char *aValue1,
62                                                       const char *aTitle1,
63                                                       QWidget* parent,
64                                                       const char* name,
65                                                       bool modal,
66                                                       WFlags fl,
67                                                       const double bottom,
68                                                       const double top,
69                                                       const int decimals )
70   : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
71 {
72   if ( !name )
73     setName( "MyParameterDialog" );
74   resize( 288, 81 ); 
75   setCaption( name ); /* appears on the title bar */
76   setSizeGripEnabled( TRUE );
77   
78   QGridLayout* topLayout = new QGridLayout( this ); 
79   topLayout->setSpacing( 6 );
80   topLayout->setMargin( 11 );
81
82   QGroupBox* mainGrp = new QGroupBox( this, "mainGrp" );
83   mainGrp->setColumnLayout(0, Qt::Vertical );
84   mainGrp->layout()->setSpacing( 0 );
85   mainGrp->layout()->setMargin( 0 );
86   QGridLayout* mainGrpLayout = new QGridLayout( mainGrp->layout() );
87   mainGrpLayout->setAlignment( Qt::AlignTop );
88   mainGrpLayout ->setSpacing( 6 );
89   mainGrpLayout->setMargin( 11 );
90   topLayout->addWidget( mainGrp, 0, 0 );
91
92   /* aTitle1 : text prompt on left of edit line */
93   QLabel* TextLabel1 = new QLabel( mainGrp, "TextLabel1" );
94   TextLabel1->setText( tr( aTitle1  ) );  
95   mainGrpLayout->addWidget( TextLabel1, 0, 0 );
96
97   mySpinBox = new QAD_SpinBoxDbl( mainGrp, "mySpinBox" );
98   mySpinBox->setPrecision( 12);
99   mySpinBox->setRange( bottom, top );
100   (( QDoubleValidator* )(mySpinBox->validator()))->setRange(bottom, top, decimals);
101   mySpinBox->setValue(QString(aValue1).toDouble());
102   mainGrpLayout->addWidget( mySpinBox, 0, 1 );
103   
104   QGroupBox* btnGrp = new QGroupBox( this, "btnGrp" );
105   btnGrp->setColumnLayout(0, Qt::Vertical );
106   btnGrp->layout()->setSpacing( 0 );
107   btnGrp->layout()->setMargin( 0 );
108   QGridLayout* btnGrpLayout = new QGridLayout( btnGrp->layout() );
109   btnGrpLayout->setAlignment( Qt::AlignTop );
110   btnGrpLayout->setSpacing( 6 );
111   btnGrpLayout->setMargin( 11 );
112   topLayout->addWidget( btnGrp, 1, 0 );
113
114   /* Ok button */
115   myButtonOk = new QPushButton( btnGrp, "buttonOk" );
116   myButtonOk->setText( tr("GEOM_BUT_OK") );
117   myButtonOk->setAutoDefault( TRUE );
118   myButtonOk->setDefault( TRUE );
119   btnGrpLayout->addWidget( myButtonOk, 0, 0 );
120
121   btnGrpLayout->addItem( new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
122
123   /* Cancel button */
124   myButtonCancel = new QPushButton( btnGrp, "buttonCancel" );
125   myButtonCancel->setText( tr("GEOM_BUT_CANCEL") );
126   myButtonCancel->setAutoDefault( TRUE );
127   btnGrpLayout->addWidget( myButtonCancel, 0, 2 );
128
129   /* signals and slots connections */
130   connect( myButtonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
131   connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
132  
133   /* Retrieve GeomGUI */
134   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
135   
136   /* Move widget on the botton right corner of main widget */
137   QAD_Tools::centerWidget(this, parent);
138 }
139
140
141 //====================================================================================== 
142 // function : ~GeometryGUI_aParameterDlg() destructor
143 // purpose  : Destroys the object and frees any allocated resources
144 //====================================================================================== 
145 GeometryGUI_aParameterDlg::~GeometryGUI_aParameterDlg()
146 {    // no need to delete child widgets, Qt does it all for us
147 }
148
149 //====================================================================================== 
150 // function : GeometryGUI_aParameterDlg::setValue
151 // purpose  : sets value
152 //====================================================================================== 
153 void GeometryGUI_aParameterDlg::setValue( double val )
154 {
155   mySpinBox->setValue( val );
156 }
157
158 //====================================================================================== 
159 // function : GeometryGUI_aParameterDlg::getValue
160 // purpose  : gets value
161 //====================================================================================== 
162 double GeometryGUI_aParameterDlg::getValue()
163 {
164   return mySpinBox->value();
165 }
166