mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-12 01:30:34 +05:00
PAL7705: Support for string parameters of hypothesis added in GUI
This commit is contained in:
parent
de3819055c
commit
3036ecaa25
@ -29,8 +29,12 @@
|
|||||||
|
|
||||||
#include <qspinbox.h>
|
#include <qspinbox.h>
|
||||||
#include <qvalidator.h>
|
#include <qvalidator.h>
|
||||||
|
#include <qtextedit.h>
|
||||||
|
|
||||||
#include "QAD_SpinBoxDbl.h"
|
#include "QAD_SpinBoxDbl.h"
|
||||||
|
|
||||||
|
#include <utilities.h>
|
||||||
|
|
||||||
SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
|
SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -58,6 +62,10 @@ bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bool SMESHGUI_intParameter::GetNewText( QString & Value ) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const
|
void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const
|
||||||
{
|
{
|
||||||
QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
|
QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget );
|
||||||
@ -101,6 +109,10 @@ bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const
|
|||||||
Value = _newValue;
|
Value = _newValue;
|
||||||
return _newValue != _initValue;
|
return _newValue != _initValue;
|
||||||
}
|
}
|
||||||
|
bool SMESHGUI_doubleParameter::GetNewText( QString & Value ) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const
|
void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const
|
||||||
{
|
{
|
||||||
QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
|
QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget );
|
||||||
@ -117,3 +129,47 @@ void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget)
|
|||||||
if ( aSpin )
|
if ( aSpin )
|
||||||
_newValue = aSpin->value();
|
_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();
|
||||||
|
}
|
||||||
|
@ -46,10 +46,11 @@ public:
|
|||||||
SMESHGUI_aParameter(const QString& label):_label(label) {}
|
SMESHGUI_aParameter(const QString& label):_label(label) {}
|
||||||
virtual ~SMESHGUI_aParameter();
|
virtual ~SMESHGUI_aParameter();
|
||||||
|
|
||||||
enum Type { INT, DOUBLE };
|
enum Type { INT, DOUBLE, TEXT };
|
||||||
virtual Type GetType() const = 0;
|
virtual Type GetType() const = 0;
|
||||||
virtual bool GetNewInt( int & Value ) const = 0;
|
virtual bool GetNewInt( int & Value ) const = 0;
|
||||||
virtual bool GetNewDouble( double & 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 InitializeWidget( QWidget* ) const = 0;
|
||||||
virtual void TakeValue( QWidget* ) = 0;
|
virtual void TakeValue( QWidget* ) = 0;
|
||||||
|
|
||||||
@ -76,6 +77,7 @@ public:
|
|||||||
virtual Type GetType() const;
|
virtual Type GetType() const;
|
||||||
virtual bool GetNewInt( int & Value ) const;
|
virtual bool GetNewInt( int & Value ) const;
|
||||||
virtual bool GetNewDouble( double & Value ) const;
|
virtual bool GetNewDouble( double & Value ) const;
|
||||||
|
virtual bool GetNewText( QString & Value ) const;
|
||||||
virtual void InitializeWidget( QWidget* ) const;
|
virtual void InitializeWidget( QWidget* ) const;
|
||||||
virtual void TakeValue( QWidget* );
|
virtual void TakeValue( QWidget* );
|
||||||
|
|
||||||
@ -105,6 +107,7 @@ public:
|
|||||||
virtual Type GetType() const;
|
virtual Type GetType() const;
|
||||||
virtual bool GetNewInt( int & Value ) const;
|
virtual bool GetNewInt( int & Value ) const;
|
||||||
virtual bool GetNewDouble( double & Value ) const;
|
virtual bool GetNewDouble( double & Value ) const;
|
||||||
|
virtual bool GetNewText( QString & Value ) const;
|
||||||
virtual void InitializeWidget( QWidget* ) const;
|
virtual void InitializeWidget( QWidget* ) const;
|
||||||
virtual void TakeValue( QWidget* );
|
virtual void TakeValue( QWidget* );
|
||||||
|
|
||||||
@ -114,4 +117,26 @@ public:
|
|||||||
int _decimals;
|
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
|
#endif // SMESHGUI_aParameter.h
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qspinbox.h>
|
#include <qspinbox.h>
|
||||||
#include <qvalidator.h>
|
#include <qvalidator.h>
|
||||||
|
#include <qtextedit.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ void SMESHGUI_aParameterDlg::init()
|
|||||||
QLabel * label = new QLabel( GroupC1, "TextLabel" );
|
QLabel * label = new QLabel( GroupC1, "TextLabel" );
|
||||||
GroupC1Layout->addWidget( label, row, 0 );
|
GroupC1Layout->addWidget( label, row, 0 );
|
||||||
label->setText( param->Label() );
|
label->setText( param->Label() );
|
||||||
QWidget* aSpinWidget;
|
QWidget* aSpinWidget = 0;
|
||||||
switch ( param->GetType() ) {
|
switch ( param->GetType() ) {
|
||||||
case SMESHGUI_aParameter::DOUBLE: {
|
case SMESHGUI_aParameter::DOUBLE: {
|
||||||
SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 );
|
SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 );
|
||||||
@ -110,13 +111,22 @@ void SMESHGUI_aParameterDlg::init()
|
|||||||
aSpinWidget = spin;
|
aSpinWidget = spin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SMESHGUI_aParameter::TEXT: {
|
||||||
|
QTextEdit* edit = new QTextEdit( GroupC1 );
|
||||||
|
edit->setWordWrap( QTextEdit::NoWrap );
|
||||||
|
edit->setTextFormat( Qt::PlainText );
|
||||||
|
aSpinWidget = edit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
GroupC1Layout->addWidget( aSpinWidget, row, 1 );
|
if ( aSpinWidget ) {
|
||||||
aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
|
GroupC1Layout->addWidget( aSpinWidget, row, 1 );
|
||||||
aSpinWidget->setMinimumSize( 150, 0 );
|
aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
|
||||||
param->InitializeWidget( aSpinWidget );
|
aSpinWidget->setMinimumSize( 150, 0 );
|
||||||
mySpinList.push_back( aSpinWidget );
|
param->InitializeWidget( aSpinWidget );
|
||||||
|
mySpinList.push_back( aSpinWidget );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
@ -50,7 +50,8 @@ LIB_MOC = \
|
|||||||
StdMeshersGUI_CreateHypothesisDlg.h \
|
StdMeshersGUI_CreateHypothesisDlg.h \
|
||||||
StdMeshersGUI_CreateStdHypothesisDlg.h
|
StdMeshersGUI_CreateStdHypothesisDlg.h
|
||||||
|
|
||||||
EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h
|
EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h \
|
||||||
|
StdMeshersGUI_Parameters.h
|
||||||
|
|
||||||
LIB_CLIENT_IDL = \
|
LIB_CLIENT_IDL = \
|
||||||
SALOME_Exception.idl \
|
SALOME_Exception.idl \
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
#include <qspinbox.h>
|
#include <qspinbox.h>
|
||||||
|
#include <qtextedit.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -126,7 +127,7 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti
|
|||||||
QLabel * label = new QLabel( GroupC1, "TextLabel" );
|
QLabel * label = new QLabel( GroupC1, "TextLabel" );
|
||||||
GroupC1Layout->addWidget( label, row, 0 );
|
GroupC1Layout->addWidget( label, row, 0 );
|
||||||
label->setText( param->Label() );
|
label->setText( param->Label() );
|
||||||
QWidget* aSpinWidget;
|
QWidget* aSpinWidget = 0;
|
||||||
switch ( param->GetType() ) {
|
switch ( param->GetType() ) {
|
||||||
case SMESHGUI_aParameter::DOUBLE: {
|
case SMESHGUI_aParameter::DOUBLE: {
|
||||||
SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 );
|
SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 );
|
||||||
@ -139,13 +140,23 @@ void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCapti
|
|||||||
aSpinWidget = spin;
|
aSpinWidget = spin;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SMESHGUI_aParameter::TEXT: {
|
||||||
|
QTextEdit* edit = new QTextEdit( GroupC1 );
|
||||||
|
edit->setWordWrap( QTextEdit::NoWrap );
|
||||||
|
edit->setTextFormat( Qt::PlainText );
|
||||||
|
aSpinWidget = edit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
GroupC1Layout->addWidget( aSpinWidget, row, 1 );
|
|
||||||
aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
|
if ( aSpinWidget ) {
|
||||||
aSpinWidget->setMinimumSize( 150, 0 );
|
GroupC1Layout->addWidget( aSpinWidget, row, 1 );
|
||||||
param->InitializeWidget( aSpinWidget );
|
aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
|
||||||
mySpinList.push_back( aSpinWidget );
|
aSpinWidget->setMinimumSize( 150, 0 );
|
||||||
|
param->InitializeWidget( aSpinWidget );
|
||||||
|
mySpinList.push_back( aSpinWidget );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 );
|
StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 );
|
||||||
|
@ -207,16 +207,22 @@ void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr
|
|||||||
params = "";
|
params = "";
|
||||||
list<SMESHGUI_aParameterPtr>::iterator paramIt = paramList.begin();
|
list<SMESHGUI_aParameterPtr>::iterator paramIt = paramList.begin();
|
||||||
for ( ; paramIt != paramList.end(); paramIt++) {
|
for ( ; paramIt != paramList.end(); paramIt++) {
|
||||||
int aIntValue;
|
|
||||||
double aDoubleValue;
|
|
||||||
if (params.compare("")) params += " ; ";
|
if (params.compare("")) params += " ; ";
|
||||||
if ((*paramIt)->GetType() == SMESHGUI_aParameter::INT) {
|
|
||||||
(*paramIt)->GetNewInt(aIntValue);
|
if ((*paramIt)->GetType() == SMESHGUI_aParameter::DOUBLE ) {
|
||||||
params += QString::number(aIntValue);;
|
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 {
|
else {
|
||||||
(*paramIt)->GetNewDouble(aDoubleValue);
|
int aIntValue = 0;
|
||||||
params += QString::number(aDoubleValue);
|
(*paramIt)->GetNewInt(aIntValue);
|
||||||
|
params += QString::number(aIntValue);;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user