Salome HOME
*** empty log message ***
[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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : GEOMBase_aParameterDlg.cxx
23 // Author : Lucien PIGNOLONI
24 //
25
26 #include "GEOMBase_aParameterDlg.h"
27 #include <QtxDoubleSpinBox.h>
28
29 #include <QGroupBox>
30 #include <QLabel>
31 #include <QPushButton>
32 #include <QGridLayout>
33
34 #ifndef WNT
35 using namespace std;
36 #endif
37
38
39 //====================================================================================== 
40 // function : GEOMBase_aParameterDlg()
41 // purpose  : Constructs a GEOMBase_aParametertDlg which is a child of 'parent', with the 
42 //            name 'name' and widget flags set to 'f'
43 //
44 //  avalue1    : is a float or integer used as default value in edit line
45 //  aTitle1    : is the prompt for aValue1
46 //  aTitle     : is the title for the user in dialog box
47 //
48 //  bottom     : the minimal value to be entered
49 //  top        : the maximum value to be entered
50 //  decimals   : number of decimals to be entered
51 //
52 //  The dialog will by default be modeless, unless you set 'modal' to
53 //  TRUE to construct a modal dialog.
54 // 
55 //====================================================================================== 
56 GEOMBase_aParameterDlg::GEOMBase_aParameterDlg(const char *aValue1, const char *aTitle1, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl, const double bottom, const double top, const int decimals)
57   :QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint )
58 {
59   if(!name)
60     setObjectName( "MyParameterDialog" );
61   else
62     setObjectName( name );
63
64   setModal( modal );
65
66   resize(288, 81); 
67   setWindowTitle(name); /* appears on the title bar */
68   setSizeGripEnabled(TRUE);
69
70   QGridLayout* topLayout = new QGridLayout(this); 
71   topLayout->setSpacing(6);
72   topLayout->setMargin(11);
73
74   QGroupBox* mainGrp = new QGroupBox(this);
75   mainGrp->setObjectName("mainGrp");
76   QGridLayout* mainGrpLayout = new QGridLayout(mainGrp);
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);
84   TextLabel1->setObjectName("TextLabel1");
85   TextLabel1->setText(tr(aTitle1));  
86   mainGrpLayout->addWidget(TextLabel1, 0, 0);
87
88   mySpinBox = new QtxDoubleSpinBox(mainGrp);
89   mySpinBox->setObjectName("mySpinBox");
90   mySpinBox->setDecimals(decimals);
91   mySpinBox->setRange(bottom, top);
92   mySpinBox->setValue(QString(aValue1).toDouble());
93   mainGrpLayout->addWidget(mySpinBox, 0, 1);
94   
95   QGroupBox* btnGrp = new QGroupBox(this);
96   btnGrp->setObjectName("btnGrp");
97   QGridLayout* btnGrpLayout = new QGridLayout(btnGrp);
98   btnGrpLayout->setAlignment(Qt::AlignTop);
99   btnGrpLayout->setSpacing(6);
100   btnGrpLayout->setMargin(11);
101   topLayout->addWidget(btnGrp, 1, 0);
102
103   /* Ok button */
104   myButtonOk = new QPushButton(btnGrp);
105   myButtonOk->setObjectName("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);
115   myButtonCancel->setObjectName("buttonCancel");
116   myButtonCancel->setText(tr("GEOM_BUT_CANCEL"));
117   myButtonCancel->setAutoDefault(TRUE);
118   btnGrpLayout->addWidget(myButtonCancel, 0, 2);
119
120   /* signals and slots connections */
121   connect(myButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
122   connect(myButtonCancel, SIGNAL(clicked()), this, SLOT(reject()));
123   
124   /* Move widget on the botton right corner of main widget */
125   //mzn: QAD_Tools::centerWidget(this, parent);
126 }
127
128
129 //====================================================================================== 
130 // function : ~GEOMBase_aParameterDlg() destructor
131 // purpose  : Destroys the object and frees any allocated resources
132 //====================================================================================== 
133 GEOMBase_aParameterDlg::~GEOMBase_aParameterDlg()
134 {
135   // no need to delete child widgets, Qt does it all for us
136 }
137
138
139 //====================================================================================== 
140 // function : GEOMBase_aParameterDlg::setValue
141 // purpose  : sets value
142 //====================================================================================== 
143 void GEOMBase_aParameterDlg::setValue(double val)
144 {
145   mySpinBox->setValue(val);
146 }
147
148
149 //====================================================================================== 
150 // function : GEOMBase_aParameterDlg::getValue
151 // purpose  : gets value
152 //====================================================================================== 
153 double GEOMBase_aParameterDlg::getValue()
154 {
155   return mySpinBox->value();
156 }