From: san Date: Fri, 28 Jan 2005 08:57:30 +0000 (+0000) Subject: PAL7705: Support for string parameters of hypothesis added in GUI X-Git-Tag: V2_2_0b2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=3036ecaa2577a1fb892f75e20ba11e91cbe42b37 PAL7705: Support for string parameters of hypothesis added in GUI --- diff --git a/src/SMESHGUI/SMESHGUI_aParameter.cxx b/src/SMESHGUI/SMESHGUI_aParameter.cxx index 7d40358d3..37a2f329b 100644 --- a/src/SMESHGUI/SMESHGUI_aParameter.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameter.cxx @@ -29,8 +29,12 @@ #include #include +#include + #include "QAD_SpinBoxDbl.h" +#include + SMESHGUI_aParameter::~SMESHGUI_aParameter() {} //================================================================================= @@ -58,6 +62,10 @@ bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const { return false; } +bool SMESHGUI_intParameter::GetNewText( QString & Value ) const +{ + return false; +} void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const { QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget ); @@ -101,6 +109,10 @@ bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const Value = _newValue; return _newValue != _initValue; } +bool SMESHGUI_doubleParameter::GetNewText( QString & Value ) const +{ + return false; +} void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const { QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget ); @@ -117,3 +129,47 @@ void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget) if ( aSpin ) _newValue = aSpin->value(); } + +//================================================================================= +// class : SMESHGUI_strParameter +// purpose : +//================================================================================= +SMESHGUI_strParameter::SMESHGUI_strParameter(const QString& theInitValue, + const QString& theLabel) + :SMESHGUI_aParameter(theLabel), + _initValue( theInitValue ) +{ + MESSAGE("SMESHGUI_strParameter::SMESHGUI_strParameter") +} +SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const +{ + return SMESHGUI_aParameter::TEXT; +} +bool SMESHGUI_strParameter::GetNewInt( int & theValue ) const +{ + return false; +} +bool SMESHGUI_strParameter::GetNewDouble( double & Value ) const +{ + return false; +} +bool SMESHGUI_strParameter::GetNewText( QString & theValue ) const +{ + theValue = _newValue; + return _newValue != _initValue; +} +void SMESHGUI_strParameter::InitializeWidget( QWidget* theQWidget) const +{ + MESSAGE("SMESHGUI_strParameter::InitializeWidget") + QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget ); + if ( anEdit ) { + anEdit->setText( _initValue ); + } +} +void SMESHGUI_strParameter::TakeValue( QWidget* theQWidget) +{ + MESSAGE("SMESHGUI_strParameter::TakeValue") + QTextEdit * anEdit = dynamic_cast< QTextEdit *>( theQWidget ); + if ( anEdit ) + _newValue = anEdit->text(); +} diff --git a/src/SMESHGUI/SMESHGUI_aParameter.h b/src/SMESHGUI/SMESHGUI_aParameter.h index dd392f684..a4360b5fd 100644 --- a/src/SMESHGUI/SMESHGUI_aParameter.h +++ b/src/SMESHGUI/SMESHGUI_aParameter.h @@ -46,10 +46,11 @@ public: SMESHGUI_aParameter(const QString& label):_label(label) {} virtual ~SMESHGUI_aParameter(); - enum Type { INT, DOUBLE }; + enum Type { INT, DOUBLE, TEXT }; virtual Type GetType() const = 0; virtual bool GetNewInt( int & Value ) const = 0; virtual bool GetNewDouble( double & Value ) const = 0; + virtual bool GetNewText( QString & Value ) const = 0; virtual void InitializeWidget( QWidget* ) const = 0; virtual void TakeValue( QWidget* ) = 0; @@ -76,6 +77,7 @@ public: virtual Type GetType() const; virtual bool GetNewInt( int & Value ) const; virtual bool GetNewDouble( double & Value ) const; + virtual bool GetNewText( QString & Value ) const; virtual void InitializeWidget( QWidget* ) const; virtual void TakeValue( QWidget* ); @@ -105,6 +107,7 @@ public: virtual Type GetType() const; virtual bool GetNewInt( int & Value ) const; virtual bool GetNewDouble( double & Value ) const; + virtual bool GetNewText( QString & Value ) const; virtual void InitializeWidget( QWidget* ) const; virtual void TakeValue( QWidget* ); @@ -114,4 +117,26 @@ public: int _decimals; }; + +//================================================================================= +// class : SMESHGUI_strParameter +// purpose : +//================================================================================= +class SMESHGUI_strParameter: public SMESHGUI_aParameter +{ +public: + SMESHGUI_strParameter(const QString& initValue = "", + const QString& label = QString::null); + QString InitValue() { return _initValue; } + virtual Type GetType() const; + virtual bool GetNewInt( int & Value ) const; + virtual bool GetNewDouble( double & Value ) const; + virtual bool GetNewText( QString & Value ) const; + virtual void InitializeWidget( QWidget* ) const; + virtual void TakeValue( QWidget* ); + + private: + QString _initValue, _newValue; +}; + #endif // SMESHGUI_aParameter.h diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx index 24560d0ef..67a11b56c 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx @@ -42,6 +42,7 @@ #include #include #include +#include using namespace std; @@ -97,7 +98,7 @@ void SMESHGUI_aParameterDlg::init() QLabel * label = new QLabel( GroupC1, "TextLabel" ); GroupC1Layout->addWidget( label, row, 0 ); label->setText( param->Label() ); - QWidget* aSpinWidget; + QWidget* aSpinWidget = 0; switch ( param->GetType() ) { case SMESHGUI_aParameter::DOUBLE: { SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 ); @@ -110,13 +111,22 @@ void SMESHGUI_aParameterDlg::init() aSpinWidget = spin; break; } + case SMESHGUI_aParameter::TEXT: { + QTextEdit* edit = new QTextEdit( GroupC1 ); + edit->setWordWrap( QTextEdit::NoWrap ); + edit->setTextFormat( Qt::PlainText ); + aSpinWidget = edit; + break; + } default:; } - GroupC1Layout->addWidget( aSpinWidget, row, 1 ); - aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - aSpinWidget->setMinimumSize( 150, 0 ); - param->InitializeWidget( aSpinWidget ); - mySpinList.push_back( aSpinWidget ); + if ( aSpinWidget ) { + GroupC1Layout->addWidget( aSpinWidget, row, 1 ); + aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aSpinWidget->setMinimumSize( 150, 0 ); + param->InitializeWidget( aSpinWidget ); + mySpinList.push_back( aSpinWidget ); + } } /***************************************************************/ diff --git a/src/StdMeshersGUI/Makefile.in b/src/StdMeshersGUI/Makefile.in index fd44b0e5d..4cf3c4e2b 100644 --- a/src/StdMeshersGUI/Makefile.in +++ b/src/StdMeshersGUI/Makefile.in @@ -50,7 +50,8 @@ LIB_MOC = \ StdMeshersGUI_CreateHypothesisDlg.h \ StdMeshersGUI_CreateStdHypothesisDlg.h -EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h +EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h \ + StdMeshersGUI_Parameters.h LIB_CLIENT_IDL = \ SALOME_Exception.idl \ diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx index 90c3632f5..e14857008 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx @@ -51,6 +51,7 @@ #include #include #include +#include using namespace std; @@ -126,7 +127,7 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti QLabel * label = new QLabel( GroupC1, "TextLabel" ); GroupC1Layout->addWidget( label, row, 0 ); label->setText( param->Label() ); - QWidget* aSpinWidget; + QWidget* aSpinWidget = 0; switch ( param->GetType() ) { case SMESHGUI_aParameter::DOUBLE: { SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 ); @@ -139,13 +140,23 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti aSpinWidget = spin; break; } + case SMESHGUI_aParameter::TEXT: { + QTextEdit* edit = new QTextEdit( GroupC1 ); + edit->setWordWrap( QTextEdit::NoWrap ); + edit->setTextFormat( Qt::PlainText ); + aSpinWidget = edit; + break; + } default:; } - GroupC1Layout->addWidget( aSpinWidget, row, 1 ); - aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - aSpinWidget->setMinimumSize( 150, 0 ); - param->InitializeWidget( aSpinWidget ); - mySpinList.push_back( aSpinWidget ); + + if ( aSpinWidget ) { + GroupC1Layout->addWidget( aSpinWidget, row, 1 ); + aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aSpinWidget->setMinimumSize( 150, 0 ); + param->InitializeWidget( aSpinWidget ); + mySpinList.push_back( aSpinWidget ); + } } StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); diff --git a/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx b/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx index caa67da14..2a292ea5a 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx @@ -207,16 +207,22 @@ void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr params = ""; list::iterator paramIt = paramList.begin(); for ( ; paramIt != paramList.end(); paramIt++) { - int aIntValue; - double aDoubleValue; if (params.compare("")) params += " ; "; - if ((*paramIt)->GetType() == SMESHGUI_aParameter::INT) { - (*paramIt)->GetNewInt(aIntValue); - params += QString::number(aIntValue);; + + if ((*paramIt)->GetType() == SMESHGUI_aParameter::DOUBLE ) { + double aDoubleValue = 0.; + (*paramIt)->GetNewDouble(aDoubleValue); + params += QString::number(aDoubleValue); + } + else if ((*paramIt)->GetType() == SMESHGUI_aParameter::TEXT ) { + QString aStrValue( "" ); + (*paramIt)->GetNewText(aStrValue); + params += aStrValue.simplifyWhiteSpace(); } else { - (*paramIt)->GetNewDouble(aDoubleValue); - params += QString::number(aDoubleValue); + int aIntValue = 0; + (*paramIt)->GetNewInt(aIntValue); + params += QString::number(aIntValue);; } } }