From a0117b464fa250ef7b5c9893dfa802a66745f3c8 Mon Sep 17 00:00:00 2001 From: san Date: Tue, 6 Apr 2010 06:54:28 +0000 Subject: [PATCH] Issue 0020580: improved validation in integer and double spin boxes, possibility to adjust input field precision through preferences --- src/GUI/NETGENPluginGUI_HypothesisCreator.cxx | 26 +++++++------------ src/GUI/NETGENPluginGUI_HypothesisCreator.h | 10 +++---- src/GUI/NETGENPluginGUI_SimpleCreator.cxx | 6 ++--- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx index f3a1b7f..c603ea1 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include CORBA_SERVER_HEADER(NETGENPlugin_Algorithm) @@ -38,8 +39,6 @@ #include -#include - #include #include #include @@ -110,11 +109,8 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() } aGroupLayout->addWidget( new QLabel( tr( "NETGEN_MAX_SIZE" ), GroupC1 ), row, 0 ); - myMaxSize = new SalomeApp_DoubleSpinBox( GroupC1 ); - myMaxSize->setDecimals( 7 ); - myMaxSize->setMinimum( 1e-07 ); - myMaxSize->setMaximum( 1e+06 ); - myMaxSize->setSingleStep( 10 ); + myMaxSize = new SMESHGUI_SpinBox( GroupC1 ); + myMaxSize->RangeStepAndValidator( 1e-07, 1e+06, 10., "length_precision" ); aGroupLayout->addWidget( myMaxSize, row, 1 ); row++; @@ -132,26 +128,22 @@ QFrame* NETGENPluginGUI_HypothesisCreator::buildFrame() row++; aGroupLayout->addWidget( new QLabel( tr( "NETGEN_GROWTH_RATE" ), GroupC1 ), row, 0 ); - myGrowthRate = new SalomeApp_DoubleSpinBox( GroupC1 ); - myGrowthRate->setMinimum( 0.1 ); - myGrowthRate->setMaximum( 10 ); - myGrowthRate->setSingleStep( 0.1 ); + myGrowthRate = new SMESHGUI_SpinBox( GroupC1 ); + myGrowthRate->RangeStepAndValidator( .1, 10., .1, "parametric_precision" ); aGroupLayout->addWidget( myGrowthRate, row, 1 ); row++; const double VALUE_MAX = 1.0e+6; aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_EDGE" ), GroupC1 ), row, 0 ); - myNbSegPerEdge = new SalomeApp_DoubleSpinBox( GroupC1 ); - myNbSegPerEdge->setMinimum( 0.2 ); - myNbSegPerEdge->setMaximum( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 + myNbSegPerEdge = new SMESHGUI_SpinBox( GroupC1 ); + myNbSegPerEdge->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" ); aGroupLayout->addWidget( myNbSegPerEdge, row, 1 ); row++; aGroupLayout->addWidget( new QLabel( tr( "NETGEN_SEG_PER_RADIUS" ), GroupC1 ), row, 0 ); - myNbSegPerRadius = new SalomeApp_DoubleSpinBox( GroupC1 ); - myNbSegPerRadius->setMinimum( 0.2 ); - myNbSegPerRadius->setMaximum( VALUE_MAX ); // (PAL14890) max value in native netgen gui is 5 + myNbSegPerRadius = new SMESHGUI_SpinBox( GroupC1 ); + myNbSegPerRadius->RangeStepAndValidator( .2, VALUE_MAX, .1, "parametric_precision" ); aGroupLayout->addWidget( myNbSegPerRadius, row, 1 ); row++; diff --git a/src/GUI/NETGENPluginGUI_HypothesisCreator.h b/src/GUI/NETGENPluginGUI_HypothesisCreator.h index a23739e..d646838 100644 --- a/src/GUI/NETGENPluginGUI_HypothesisCreator.h +++ b/src/GUI/NETGENPluginGUI_HypothesisCreator.h @@ -32,7 +32,7 @@ #include -class SalomeApp_DoubleSpinBox; +class SMESHGUI_SpinBox; class QComboBox; class QCheckBox; class QLineEdit; @@ -79,13 +79,13 @@ private: private: QLineEdit* myName; - SalomeApp_DoubleSpinBox* myMaxSize; + SMESHGUI_SpinBox* myMaxSize; QCheckBox* mySecondOrder; QCheckBox* myOptimize; QComboBox* myFineness; - SalomeApp_DoubleSpinBox* myGrowthRate; - SalomeApp_DoubleSpinBox* myNbSegPerEdge; - SalomeApp_DoubleSpinBox* myNbSegPerRadius; + SMESHGUI_SpinBox* myGrowthRate; + SMESHGUI_SpinBox* myNbSegPerEdge; + SMESHGUI_SpinBox* myNbSegPerRadius; QCheckBox* myAllowQuadrangles; bool myIs2D; diff --git a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx index 3a9c871..29c9551 100644 --- a/src/GUI/NETGENPluginGUI_SimpleCreator.cxx +++ b/src/GUI/NETGENPluginGUI_SimpleCreator.cxx @@ -151,7 +151,7 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * local length myLengthRadioBut = new QRadioButton( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ), dimGroup ); myLength = new SMESHGUI_SpinBox( dimGroup ); - myLength->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 0.1, 6 ); + myLength->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 0.1, "length_precision" ); myLength->setValue( 1. ); dimLay->addWidget( myLengthRadioBut, dimRow, 0 ); dimLay->addWidget( myLength, dimRow, 1 ); @@ -178,7 +178,7 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * max area dimLay->addWidget( new QLabel( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ), dimGroup), dimRow, 0); myArea = new SMESHGUI_SpinBox( dimGroup ); - myArea->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 0.1, 6 ); + myArea->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 0.1, "area_precision" ); myArea->setValue( 1. ); dimLay->addWidget( myArea, dimRow, 1 ); dimRow++; @@ -205,7 +205,7 @@ QFrame* NETGENPluginGUI_SimpleCreator::buildFrame() // * max volume dimLay->addWidget(new QLabel( tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"), dimGroup), dimRow, 0); myVolume = new SMESHGUI_SpinBox( dimGroup ); - myVolume->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 0.1, 6 ); + myVolume->RangeStepAndValidator( VALUE_SMALL_3, VALUE_MAX_3, 0.1, "volume_precision" ); myVolume->setValue( 1. ); dimLay->addWidget( myVolume, dimRow, 1 ); dimRow++; -- 2.39.2