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