]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PAL10953. Add possibility to have a custom widget for a hypo parameter
authoreap <eap@opencascade.com>
Wed, 28 Dec 2005 14:40:18 +0000 (14:40 +0000)
committereap <eap@opencascade.com>
Wed, 28 Dec 2005 14:40:18 +0000 (14:40 +0000)
src/SMESHGUI/SMESHGUI_Hypotheses.cxx
src/SMESHGUI/SMESHGUI_Hypotheses.h

index 676c37cc4a3678198ac2c7e2de1e7439125ea34d..e7e894fcd05fa1462dd3296908643c24dce9b373 100644 (file)
@@ -144,37 +144,38 @@ QFrame* SMESHGUI_GenericHypothesisCreator::buildStdFrame()
     QLabel* lab = new QLabel( (*anIt).myName, GroupC1 );
     GroupC1Layout->addWidget( lab, i, 0 );
 
-    QWidget* w = 0;
-    switch( (*anIt).myValue.type() )
-    {
-    case QVariant::Int:
-      {
-       QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( sb, i );
-       sb->setValue( (*anIt).myValue.toInt() );
-       connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
-       w = sb;
-      }
-      break;
-    case QVariant::Double:
-      {
-       QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( sb, i );
-       sb->setValue( (*anIt).myValue.toDouble() );
-       connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
-       w = sb;
-      }
-      break;
-    case QVariant::String:
+    QWidget* w = getCustomWidget( *anIt, GroupC1 );
+    if ( !w ) 
+      switch( (*anIt).myValue.type() )
       {
-       QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
-       attuneStdWidget( le, i );
-       le->setText( (*anIt).myValue.toString() );
-       connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
-       w = le;
+      case QVariant::Int:
+        {
+          QtxIntSpinBox* sb = new QtxIntSpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toInt() );
+          connect( sb, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::Double:
+        {
+          QtxDblSpinBox* sb = new SMESHGUI_SpinBox( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( sb, i );
+          sb->setValue( (*anIt).myValue.toDouble() );
+          connect( sb, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged() ) );
+          w = sb;
+        }
+        break;
+      case QVariant::String:
+        {
+          QLineEdit* le = new QLineEdit( GroupC1, (*anIt).myName.latin1() );
+          attuneStdWidget( le, i );
+          le->setText( (*anIt).myValue.toString() );
+          connect( le, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) );
+          w = le;
+        }
+        break;
       }
-      break;
-    }
 
     if( w )
     {
@@ -224,7 +225,12 @@ bool SMESHGUI_GenericHypothesisCreator::getStdParamFromDlg( ListOfStdParams& par
       params.append( item );
     }
 
-    else 
+    else if ( getParamFromCustomWidget( item, *anIt ))
+    {
+      params.append( item );
+    }
+
+    else
       res = false;
   }
   return res;
@@ -273,10 +279,15 @@ QString SMESHGUI_GenericHypothesisCreator::type() const
 {
   return QString();
 }
-
-
-
-
+QWidget* SMESHGUI_GenericHypothesisCreator::getCustomWidget( const StdParam & /*param*/,
+                                                             QWidget*   /*parent*/) const
+{
+  return 0;
+}
+bool SMESHGUI_GenericHypothesisCreator::getParamFromCustomWidget( StdParam& , QWidget* ) const
+{
+  return false;
+}
 
 
 
index a4558df89dbcf3bc2c9c8543068e189de451b22c..f48062b8ebcb91a68734c80ec6c633cd6c117f5d 100644 (file)
@@ -77,6 +77,8 @@ protected:
   virtual bool     stdParams     ( ListOfStdParams& ) const;
           bool     getStdParamFromDlg( ListOfStdParams& ) const;
   virtual void     attuneStdWidget( QWidget*, const int ) const;
+  virtual QWidget* getCustomWidget( const StdParam &, QWidget* ) const;
+  virtual bool     getParamFromCustomWidget( StdParam& , QWidget* ) const;
   virtual QString  caption() const;
   virtual QPixmap  icon() const;
   virtual QString  type() const;