1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GeometryGUI_aParameterDlg.cxx
25 // Author : Lucien PIGNOLONI
30 #include "GeometryGUI_aParameterDlg.h"
31 #include "GeometryGUI.h"
32 #include "QAD_SpinBoxDbl.h"
33 #include "QAD_Tools.h"
37 #include <qgroupbox.h>
39 #include <qpushbutton.h>
42 #include <qvalidator.h>
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'
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
53 // bottom : the minimal value to be entered
54 // top : the maximum value to be entered
55 // decimals : number of decimals to be entered
57 // The dialog will by default be modeless, unless you set 'modal' to
58 // TRUE to construct a modal dialog.
60 //======================================================================================
61 GeometryGUI_aParameterDlg::GeometryGUI_aParameterDlg( const char *aValue1,
70 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
73 setName( "MyParameterDialog" );
75 setCaption( name ); /* appears on the title bar */
76 setSizeGripEnabled( TRUE );
78 QGridLayout* topLayout = new QGridLayout( this );
79 topLayout->setSpacing( 6 );
80 topLayout->setMargin( 11 );
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 );
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 );
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 );
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 );
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 );
121 btnGrpLayout->addItem( new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
124 myButtonCancel = new QPushButton( btnGrp, "buttonCancel" );
125 myButtonCancel->setText( tr("GEOM_BUT_CANCEL") );
126 myButtonCancel->setAutoDefault( TRUE );
127 btnGrpLayout->addWidget( myButtonCancel, 0, 2 );
129 /* signals and slots connections */
130 connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
131 connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
133 /* Retrieve GeomGUI */
134 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
136 /* Move widget on the botton right corner of main widget */
137 QAD_Tools::centerWidget(this, parent);
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
149 //======================================================================================
150 // function : GeometryGUI_aParameterDlg::setValue
151 // purpose : sets value
152 //======================================================================================
153 void GeometryGUI_aParameterDlg::setValue( double val )
155 mySpinBox->setValue( val );
158 //======================================================================================
159 // function : GeometryGUI_aParameterDlg::getValue
160 // purpose : gets value
161 //======================================================================================
162 double GeometryGUI_aParameterDlg::getValue()
164 return mySpinBox->value();