1 // SMESH SMESHGUI : GUI for SMESH 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 : SMESHGUI_aParameterDlg.cxx
25 // Author : Nicolas REJNERI
30 #include "SMESHGUI_aParameterDlg.h"
32 #include "QAD_SpinBoxDbl.h"
33 #include "QAD_Tools.h"
36 #include <qgroupbox.h>
38 #include <qpushbutton.h>
41 #include <qvalidator.h>
43 //======================================================================================
44 // function : SMESHGUI_aParameterDlg()
45 // purpose : Constructs a SMESHGUI_aParametertDlg for double values
47 // parent : parent widget
48 // title : is the title for the user in dialog box
49 // label : text label for the value
51 // bottom : the minimal value to be entered
52 // top : the maximum value to be entered
53 // decimals : number of decimals to be entered
55 // The dialog will by default be modal, unless you set 'modal' to
56 // false when constructing dialog
58 //======================================================================================
59 SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
66 : QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
67 myIntSpin( 0 ), myDblSpin( 0 )
69 /* creating widgets */
74 myTextLabel->setText( label );
76 myDblSpin->setRange( bottom, top );
77 ((QDoubleValidator*)(myDblSpin->validator()))->setRange( bottom, top, decimals );
79 /* Move widget on the botton right corner of main widget */
80 QAD_Tools::centerWidget( this, parent );
83 //======================================================================================
84 // function : SMESHGUI_aParameterDlg()
85 // purpose : Constructs a SMESHGUI_aParametertDlg for int values
87 // parent : parent widget
88 // title : is the title for the user in dialog box
89 // label : text label for the value
91 // bottom : the minimal value to be entered
92 // top : the maximum value to be entered
94 // The dialog will by default be modal, unless you set 'modal' to
95 // false when constructing dialog
97 //======================================================================================
98 SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
104 : QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
105 myIntSpin( 0 ), myDblSpin( 0 )
107 /* creating widgets */
112 myTextLabel->setText( label );
114 myIntSpin->setRange( bottom, top );
115 ((QIntValidator*)(myIntSpin->validator()))->setRange( bottom, top );
117 /* Move widget on the botton right corner of main widget */
118 QAD_Tools::centerWidget( this, parent );
121 //======================================================================================
122 // function : SMESHGUI_aParameterDlg::init()
123 // purpose : creates dialog's layout
124 //======================================================================================
125 void SMESHGUI_aParameterDlg::init( bool isDouble )
127 setSizeGripEnabled( TRUE );
129 QGridLayout* topLayout = new QGridLayout( this );
130 topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
132 /***************************************************************/
133 QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
134 GroupC1->setColumnLayout(0, Qt::Vertical );
135 GroupC1->layout()->setSpacing( 0 );
136 GroupC1->layout()->setMargin( 0 );
137 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
138 GroupC1Layout->setAlignment( Qt::AlignTop );
139 GroupC1Layout->setSpacing( 6 );
140 GroupC1Layout->setMargin( 11 );
142 /* aTitle1 : text prompt on left of edit line */
143 myTextLabel = new QLabel( GroupC1, "TextLabel" );
144 GroupC1Layout->addWidget( myTextLabel, 0, 0 );
148 myDblSpin = new QAD_SpinBoxDbl( GroupC1 );
149 myDblSpin->setPrecision( 12 );
150 myDblSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
151 myDblSpin->setMinimumSize( 150, 0 );
152 GroupC1Layout->addWidget( myDblSpin, 0, 1 );
156 myIntSpin = new QSpinBox( GroupC1 );
157 myIntSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
158 myIntSpin->setMinimumSize( 150, 0 );
159 GroupC1Layout->addWidget( myIntSpin, 0, 1 );
162 /***************************************************************/
163 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
164 GroupButtons->setColumnLayout(0, Qt::Vertical );
165 GroupButtons->layout()->setSpacing( 0 );
166 GroupButtons->layout()->setMargin( 0 );
167 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
168 GroupButtonsLayout->setAlignment( Qt::AlignTop );
169 GroupButtonsLayout->setSpacing( 6 );
170 GroupButtonsLayout->setMargin( 11 );
172 myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
173 myButtonOk->setText( tr("SMESH_BUT_OK") );
174 myButtonOk->setAutoDefault( TRUE );
175 myButtonOk->setDefault( TRUE );
176 GroupButtonsLayout->addWidget( myButtonOk, 0, 0 );
177 /* add spacer between buttons */
178 GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
180 myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
181 myButtonCancel->setText( tr("SMESH_BUT_CANCEL") );
182 myButtonCancel->setAutoDefault( TRUE );
183 GroupButtonsLayout->addWidget( myButtonCancel, 0, 2 );
185 /***************************************************************/
186 topLayout->addWidget( GroupC1, 0, 0);
187 topLayout->addWidget( GroupButtons, 1, 0);
189 /* signals and slots connections */
190 connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
191 connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
193 /* Retrieve SMESHGUI */
194 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
198 //======================================================================================
199 // function : ~SMESHGUI_aParameterDlg()
200 // purpose : Destructor
201 //======================================================================================
202 SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg()
206 //======================================================================================
207 // function : SMESHGUI_aParameterDlg::setValue
208 // purpose : sets double value
209 //======================================================================================
210 void SMESHGUI_aParameterDlg::setValue( const double val )
213 myDblSpin->setValue( val );
215 //======================================================================================
216 // function : SMESHGUI_aParameterDlg::setValue
217 // purpose : sets int value
218 //======================================================================================
219 void SMESHGUI_aParameterDlg::setValue( const int val )
222 myIntSpin->setValue( val );
224 //======================================================================================
225 // function : SMESHGUI_aParameterDlg::getDblValue
226 // purpose : returns double value entered by user
227 //======================================================================================
228 double SMESHGUI_aParameterDlg::getDblValue()
231 return myDblSpin->value();
235 //======================================================================================
236 // function : SMESHGUI_aParameterDlg::getIntValu
237 // purpose : returns int value entered by user
238 //======================================================================================
239 int SMESHGUI_aParameterDlg::getIntValue()
242 return myIntSpin->value();