2 // File : GeometryGUI_aParameterDlg.cxx
4 // Author : Lucien PIGNOLONI
6 // Module : GeometryGUI
7 // Copyright : Open CASCADE
10 #include "GeometryGUI_aParameterDlg.h"
11 #include "GeometryGUI.h"
12 #include "QAD_SpinBoxDbl.h"
13 #include "QAD_Tools.h"
17 #include <qgroupbox.h>
19 #include <qpushbutton.h>
22 #include <qvalidator.h>
24 //======================================================================================
25 // function : GeometryGUI_aParameterDlg()
26 // purpose : Constructs a GeometryGUI_aParametertDlg which is a child of 'parent', with the
27 // name 'name' and widget flags set to 'f'
29 // avalue1 : is a float or integer used as default value in edit line
30 // aTitle1 : is the prompt for aValue1
31 // aTitle : is the title for the user in dialog box
33 // bottom : the minimal value to be entered
34 // top : the maximum value to be entered
35 // decimals : number of decimals to be entered
37 // The dialog will by default be modeless, unless you set 'modal' to
38 // TRUE to construct a modal dialog.
40 //======================================================================================
41 GeometryGUI_aParameterDlg::GeometryGUI_aParameterDlg( const char *aValue1,
50 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
53 setName( "MyParameterDialog" );
55 setCaption( name ); /* appears on the title bar */
56 setSizeGripEnabled( TRUE );
58 QGridLayout* topLayout = new QGridLayout( this );
59 topLayout->setSpacing( 6 );
60 topLayout->setMargin( 11 );
62 QGroupBox* mainGrp = new QGroupBox( this, "mainGrp" );
63 mainGrp->setColumnLayout(0, Qt::Vertical );
64 mainGrp->layout()->setSpacing( 0 );
65 mainGrp->layout()->setMargin( 0 );
66 QGridLayout* mainGrpLayout = new QGridLayout( mainGrp->layout() );
67 mainGrpLayout->setAlignment( Qt::AlignTop );
68 mainGrpLayout ->setSpacing( 6 );
69 mainGrpLayout->setMargin( 11 );
70 topLayout->addWidget( mainGrp, 0, 0 );
72 /* aTitle1 : text prompt on left of edit line */
73 QLabel* TextLabel1 = new QLabel( mainGrp, "TextLabel1" );
74 TextLabel1->setText( tr( aTitle1 ) );
75 mainGrpLayout->addWidget( TextLabel1, 0, 0 );
77 mySpinBox = new QAD_SpinBoxDbl( mainGrp, "mySpinBox" );
78 mySpinBox->setPrecision( 12);
79 mySpinBox->setRange( bottom, top );
80 (( QDoubleValidator* )(mySpinBox->validator()))->setRange(bottom, top, decimals);
81 mySpinBox->setValue(QString(aValue1).toDouble());
82 mainGrpLayout->addWidget( mySpinBox, 0, 1 );
84 QGroupBox* btnGrp = new QGroupBox( this, "btnGrp" );
85 btnGrp->setColumnLayout(0, Qt::Vertical );
86 btnGrp->layout()->setSpacing( 0 );
87 btnGrp->layout()->setMargin( 0 );
88 QGridLayout* btnGrpLayout = new QGridLayout( btnGrp->layout() );
89 btnGrpLayout->setAlignment( Qt::AlignTop );
90 btnGrpLayout->setSpacing( 6 );
91 btnGrpLayout->setMargin( 11 );
92 topLayout->addWidget( btnGrp, 1, 0 );
95 myButtonOk = new QPushButton( btnGrp, "buttonOk" );
96 myButtonOk->setText( tr("GEOM_BUT_OK") );
97 myButtonOk->setAutoDefault( TRUE );
98 myButtonOk->setDefault( TRUE );
99 btnGrpLayout->addWidget( myButtonOk, 0, 0 );
101 btnGrpLayout->addItem( new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
104 myButtonCancel = new QPushButton( btnGrp, "buttonCancel" );
105 myButtonCancel->setText( tr("GEOM_BUT_CANCEL") );
106 myButtonCancel->setAutoDefault( TRUE );
107 btnGrpLayout->addWidget( myButtonCancel, 0, 2 );
109 /* signals and slots connections */
110 connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
111 connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
113 /* Retrieve GeomGUI */
114 myGeomGUI = GeometryGUI::GetGeometryGUI() ;
116 /* Move widget on the botton right corner of main widget */
117 QAD_Tools::centerWidget(this, parent);
121 //======================================================================================
122 // function : ~GeometryGUI_aParameterDlg() destructor
123 // purpose : Destroys the object and frees any allocated resources
124 //======================================================================================
125 GeometryGUI_aParameterDlg::~GeometryGUI_aParameterDlg()
126 { // no need to delete child widgets, Qt does it all for us
129 //======================================================================================
130 // function : GeometryGUI_aParameterDlg::setValue
131 // purpose : sets value
132 //======================================================================================
133 void GeometryGUI_aParameterDlg::setValue( double val )
135 mySpinBox->setValue( val );
138 //======================================================================================
139 // function : GeometryGUI_aParameterDlg::getValue
140 // purpose : gets value
141 //======================================================================================
142 double GeometryGUI_aParameterDlg::getValue()
144 return mySpinBox->value();