PAL7705: Support for string parameters of hypothesis added in GUI

This commit is contained in:
san 2005-01-28 08:57:30 +00:00
parent de3819055c
commit 3036ecaa25
6 changed files with 130 additions and 21 deletions

View File

@ -29,8 +29,12 @@
#include <qspinbox.h>
#include <qvalidator.h>
#include <qtextedit.h>
#include "QAD_SpinBoxDbl.h"
#include <utilities.h>
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();
}

View File

@ -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

View File

@ -42,6 +42,7 @@
#include <qlayout.h>
#include <qspinbox.h>
#include <qvalidator.h>
#include <qtextedit.h>
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 );
}
}
/***************************************************************/

View File

@ -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 \

View File

@ -51,6 +51,7 @@
#include <qlayout.h>
#include <qpixmap.h>
#include <qspinbox.h>
#include <qtextedit.h>
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 );

View File

@ -207,16 +207,22 @@ void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr
params = "";
list<SMESHGUI_aParameterPtr>::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);;
}
}
}