Salome HOME
PAL7705: Support for string parameters of hypothesis added in GUI
authorsan <san@opencascade.com>
Fri, 28 Jan 2005 08:57:30 +0000 (08:57 +0000)
committersan <san@opencascade.com>
Fri, 28 Jan 2005 08:57:30 +0000 (08:57 +0000)
src/SMESHGUI/SMESHGUI_aParameter.cxx
src/SMESHGUI/SMESHGUI_aParameter.h
src/SMESHGUI/SMESHGUI_aParameterDlg.cxx
src/StdMeshersGUI/Makefile.in
src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx
src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx

index 7d40358d3758c34747c3dc05c55cc231a088dd29..37a2f329b0cd350c2174e500556da9493792f565 100644 (file)
   
 #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();
+}
index dd392f68462ca4a051d210799f5c9c9e0c265090..a4360b5fd83096b28cad8000d918436e69f8da4d 100644 (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
index 24560d0ef13e90dc541d1556ef224895075d93b0..67a11b56ce5ddea5b6e6ffe9ebecff00ce8d7c48 100644 (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 );
+    }
   }
   
   /***************************************************************/
index fd44b0e5d0bd48fe276179a2c1f2022cefffe4f6..4cf3c4e2b166d3511fae68642ba169f09c41c5b7 100644 (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 \
index 90c3632f5e523404dfb4c32c7f20123e34763f6e..e1485700818147e2ad40689e079e1ab63e9fa07f 100644 (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 );
index caa67da1499b715095f4b0ecb42b3a1d0e207f42..2a292ea5a1902965f6b9e95e316d842f6539d83b 100644 (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);;
     }
   }
 }