Salome HOME
PAL8238
authorasl <asl@opencascade.com>
Tue, 16 Aug 2005 12:45:13 +0000 (12:45 +0000)
committerasl <asl@opencascade.com>
Tue, 16 Aug 2005 12:45:13 +0000 (12:45 +0000)
src/SMESHGUI/Makefile.in
src/SMESHGUI/SMESHGUI_aParameter.cxx
src/SMESHGUI/SMESHGUI_aParameter.h
src/SMESHGUI/SMESHGUI_aParameterDlg.cxx
src/SMESHGUI/SMESHGUI_aParameterDlg.h

index ec0cf92b5637a7a0e16b22e109d646029e5ab8bb..992a108c590f732c52d543176809823e690401b1 100644 (file)
@@ -150,6 +150,7 @@ LIB_MOC = \
                SMESHGUI_SewingDlg.h \
                SMESHGUI_PrecisionDlg.h \
                SMESHGUI_MergeNodesDlg.h \
                SMESHGUI_SewingDlg.h \
                SMESHGUI_PrecisionDlg.h \
                SMESHGUI_MergeNodesDlg.h \
+               SMESHGUI_aParameter.h \
                SMESHGUI_EditMeshDlg.h \
                SMESHGUI_CreatePolyhedralVolumeDlg.h
 
                SMESHGUI_EditMeshDlg.h \
                SMESHGUI_CreatePolyhedralVolumeDlg.h
 
index d52b641babcb2215caf00420b2a568477dd3d642..3e513f04bd037ec8c8ed5ef7edd1b8991499ea0f 100644 (file)
 
 #include <qspinbox.h>
 #include <qvalidator.h>
 
 #include <qspinbox.h>
 #include <qvalidator.h>
+#include <qlineedit.h>
 #include <qtextedit.h>
 #include <qtextedit.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+#include <qtable.h>
+#include <qvalidator.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
 
 #include <QtxDblSpinBox.h>
 
 SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
 
 
 #include <QtxDblSpinBox.h>
 
 SMESHGUI_aParameter::~SMESHGUI_aParameter() {}
 
+QString SMESHGUI_aParameter::sigValueChanged() const
+{
+  return QString::null;
+}
+
 //=================================================================================
 // class    : SMESHGUI_intParameter
 // purpose  :
 //=================================================================================
 // class    : SMESHGUI_intParameter
 // purpose  :
@@ -44,7 +56,8 @@ SMESHGUI_intParameter::SMESHGUI_intParameter (const int      theInitValue,
                                               const int      theBottom,
                                               const int      theTop)
      :SMESHGUI_aParameter(theLabel),
                                               const int      theBottom,
                                               const int      theTop)
      :SMESHGUI_aParameter(theLabel),
-       _top(theTop), _bottom(theBottom), _initValue(theInitValue)
+       _top(theTop), _bottom(theBottom), _initValue(theInitValue),
+       _newValue( theInitValue )
 {
 }
 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
 {
 }
 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
@@ -64,6 +77,12 @@ bool SMESHGUI_intParameter::GetNewText (QString & Value) const
 {
   return false;
 }
 {
   return false;
 }
+
+QWidget* SMESHGUI_intParameter::CreateWidget( QWidget* parent ) const
+{
+  return new QSpinBox( parent );
+}
+  
 void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
 {
   QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
 void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
 {
   QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
@@ -80,6 +99,11 @@ void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget)
     _newValue = aSpin->value();
 }
 
     _newValue = aSpin->value();
 }
 
+QString SMESHGUI_intParameter::sigValueChanged() const
+{
+  return SIGNAL( valueChanged( int ) );
+}
+
 //=================================================================================
 // class    : SMESHGUI_doubleParameter
 // purpose  :
 //=================================================================================
 // class    : SMESHGUI_doubleParameter
 // purpose  :
@@ -112,6 +136,12 @@ bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const
 {
   return false;
 }
 {
   return false;
 }
+
+QWidget* SMESHGUI_doubleParameter::CreateWidget( QWidget* parent ) const
+{
+  return new QtxDblSpinBox( parent );
+}
+
 void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
 {
   QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
 void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
 {
   QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
@@ -132,6 +162,11 @@ void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget)
     _newValue = aSpin->value();
 }
 
     _newValue = aSpin->value();
 }
 
+QString SMESHGUI_doubleParameter::sigValueChanged() const
+{
+  return SIGNAL( valueChanged( double ) );
+}
+
 //=================================================================================
 // class    : SMESHGUI_strParameter
 // purpose  :
 //=================================================================================
 // class    : SMESHGUI_strParameter
 // purpose  :
@@ -144,7 +179,7 @@ SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue,
 }
 SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
 {
 }
 SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
 {
-  return SMESHGUI_aParameter::TEXT;
+  return SMESHGUI_aParameter::STRING;
 }
 bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
 {
 }
 bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
 {
@@ -159,16 +194,748 @@ bool SMESHGUI_strParameter::GetNewText (QString & theValue) const
   theValue = _newValue;
   return _newValue != _initValue;
 }
   theValue = _newValue;
   return _newValue != _initValue;
 }
+
+QWidget* SMESHGUI_strParameter::CreateWidget( QWidget* parent ) const
+{
+  return new QLineEdit( parent );
+}
+
 void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
 {
 void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
 {
-  QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
+  QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
   if (anEdit) {
     anEdit->setText(_initValue);
   }
 }
 void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
 {
   if (anEdit) {
     anEdit->setText(_initValue);
   }
 }
 void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
 {
-  QTextEdit * anEdit = dynamic_cast< QTextEdit *>(theQWidget);
+  QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
   if (anEdit)
     _newValue = anEdit->text();
 }
   if (anEdit)
     _newValue = anEdit->text();
 }
+
+QString SMESHGUI_strParameter::sigValueChanged() const
+{
+  return SIGNAL( textChanged( const QString& ) );
+}
+
+
+
+//=================================================================================
+// class    : SMESHGUI_dependParameter
+// purpose  :
+//=================================================================================
+SMESHGUI_dependParameter::SMESHGUI_dependParameter( const QString& label )
+: SMESHGUI_aParameter( label )
+{
+}
+
+const SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap() const
+{
+  return myShownMap;
+}
+
+SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap()
+{
+  return myShownMap;
+}
+
+
+  
+
+
+//=================================================================================
+// class    : SMESHGUI_enumParameter
+// purpose  :
+//=================================================================================
+SMESHGUI_enumParameter::SMESHGUI_enumParameter( const QStringList& values,
+                                                const int initValue,
+                                                const QString& label )
+: SMESHGUI_dependParameter( label ),
+  myInitValue( initValue ),
+  myValue( initValue ),
+  myValues( values )
+{
+}
+
+SMESHGUI_enumParameter::~SMESHGUI_enumParameter()
+{
+}
+
+SMESHGUI_aParameter::Type SMESHGUI_enumParameter::GetType() const
+{
+  return SMESHGUI_aParameter::ENUM;
+}
+
+bool SMESHGUI_enumParameter::GetNewInt( int& v ) const
+{
+  v = myValue;
+  return myValue!=myInitValue;
+}
+
+bool SMESHGUI_enumParameter::GetNewDouble( double& ) const
+{
+  return false;
+}
+
+bool SMESHGUI_enumParameter::GetNewText( QString& v ) const
+{
+  bool res = myValue>=0 && myValue<Count();
+
+  if( res )
+    v = myValues[ myValue ];
+
+  return res && v!=myInitValue;
+}
+
+QWidget* SMESHGUI_enumParameter::CreateWidget( QWidget* parent ) const
+{
+  return new QComboBox( parent );
+}
+
+void SMESHGUI_enumParameter::InitializeWidget( QWidget* w ) const
+{
+  if( w && w->inherits( "QComboBox" ) )
+  {
+    QComboBox* c = ( QComboBox* ) w;
+    c->clear();
+    c->insertStringList( myValues );
+    c->setCurrentItem( myInitValue );
+  }
+}
+
+void SMESHGUI_enumParameter::TakeValue( QWidget* w )
+{
+  if( w && w->inherits( "QComboBox" ) )
+  {
+    QComboBox* c = ( QComboBox* ) w;
+    myValue = c->currentItem();
+  }
+}
+
+int SMESHGUI_enumParameter::Count() const
+{
+  return myValues.count();
+}
+
+QString SMESHGUI_enumParameter::sigValueChanged() const
+{
+  return SIGNAL( activated( int ) );
+}
+
+
+//=================================================================================
+// class    : SMESHGUI_boolParameter
+// purpose  :
+//=================================================================================
+SMESHGUI_boolParameter::SMESHGUI_boolParameter( const bool initValue,
+                                                const QString& label )
+: SMESHGUI_dependParameter( label ),
+  myInitValue( initValue ),
+  myValue( myInitValue )
+{
+}
+
+SMESHGUI_boolParameter::~SMESHGUI_boolParameter()
+{
+}
+
+SMESHGUI_aParameter::Type SMESHGUI_boolParameter::GetType() const
+{
+  return BOOL;
+}
+
+bool SMESHGUI_boolParameter::GetNewInt( int& v ) const
+{
+  if( myValue )
+    v = 1;
+  else
+    v = 0;
+  return v!=myInitValue;
+}
+
+bool SMESHGUI_boolParameter::GetNewDouble( double& ) const
+{
+  return false;
+}
+
+bool SMESHGUI_boolParameter::GetNewText( QString& ) const
+{
+  return false;
+}
+
+QWidget* SMESHGUI_boolParameter::CreateWidget( QWidget* parent ) const
+{
+  return new QCheckBox( parent );
+}
+
+void SMESHGUI_boolParameter::InitializeWidget( QWidget* w ) const
+{
+  if( w && w->inherits( "QCheckBox" ) )
+  {
+    QCheckBox* box = ( QCheckBox* )w;
+    box->setChecked( myInitValue );
+  }
+}
+
+void SMESHGUI_boolParameter::TakeValue( QWidget* w )
+{
+  if( w && w->inherits( "QCheckBox" ) )
+  {
+    QCheckBox* box = ( QCheckBox* )w;
+    myValue = box->isChecked();
+  }  
+}
+
+QString SMESHGUI_boolParameter::sigValueChanged() const
+{
+  return SIGNAL( stateChanged( int ) );
+}
+
+
+
+
+//=================================================================================
+// class    : SMESHGUI_doubleItem
+// purpose  : Custom table item which contains double and has double validator
+//=================================================================================
+class SMESHGUI_doubleItem: public QTableItem
+{
+public:
+  SMESHGUI_doubleItem( QTable*, EditType, const double );
+  virtual ~SMESHGUI_doubleItem();
+
+  void setValidator( const double, const double, const int );
+  void validator( double&, double&, int& );
+  virtual QWidget* createEditor() const;
+
+private:
+  QDoubleValidator*  myValidator;
+};
+
+SMESHGUI_doubleItem::SMESHGUI_doubleItem( QTable* t, EditType e, const double num )
+: QTableItem( t, e, QString( "%1" ).arg( num ) ),
+  myValidator( new QDoubleValidator( 0.0, 1.0, 3, t ) )
+{
+}
+
+SMESHGUI_doubleItem::~SMESHGUI_doubleItem()
+{
+}
+
+void SMESHGUI_doubleItem::setValidator( const double bot, const double top, const int dec )
+{
+  myValidator->setBottom( bot );
+  myValidator->setTop( top );
+  myValidator->setDecimals( dec );
+}
+
+void SMESHGUI_doubleItem::validator( double& bot, double& top, int& dec )
+{
+  bot = myValidator->bottom();
+  top = myValidator->top();
+  dec = myValidator->decimals();
+}
+
+QWidget* SMESHGUI_doubleItem::createEditor() const
+{
+  QWidget* res = QTableItem::createEditor();
+  if( res && res->inherits( "QLineEdit" ) )
+  {
+    QLineEdit* l = ( QLineEdit* )res;
+    l->setValidator( myValidator );
+  }
+  return res;
+}
+
+
+//=================================================================================
+// class    : SMESHGUI_Table
+// purpose  :
+//=================================================================================
+SMESHGUI_Table::SMESHGUI_Table( int numRows, int numCols, QWidget* parent, const char* name )
+: QTable( numRows, numCols, parent, name )
+{
+}
+
+SMESHGUI_Table::~SMESHGUI_Table()
+{
+}
+
+QSize SMESHGUI_Table::sizeHint() const
+{
+  if( cachedSizeHint().isValid() )
+    return cachedSizeHint();
+
+  constPolish();
+
+  QSize sh = QScrollView::sizeHint();
+  if( sh.width()<400 )
+    sh.setWidth( 400 );
+  if( sh.height()<200 )
+    sh.setHeight( 200 );
+
+  setCachedSizeHint( sh );
+  return sh;
+}
+
+void SMESHGUI_Table::stopEditing()
+{
+  endEdit( currEditRow(), currEditCol(), false, false );
+}
+
+void SMESHGUI_Table::validator( const int row, const int col, double& minV, double& maxV, int& dec )
+{
+  SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( row, col ) );
+  if( it )
+    it->validator( minV, maxV, dec );
+}
+
+void SMESHGUI_Table::setValidator( const double minV, const double maxV, const int dec,
+                                   const int rmin, const int rmax,
+                                   const int cmin, const int cmax )
+{
+  int r1 = rmin>=0 ? rmin : 0,
+      r2 = rmax>=0 ? rmax : numRows(),
+      c1 = cmin>=0 ? cmin : 0,
+      c2 = cmax>=0 ? cmax : numCols();
+
+  for( int i=r1; i<=r2; i++ )
+    for( int j=c1; j<=c2; j++ )
+    {
+      SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( i, j ) );
+      if( it )
+        it->setValidator( minV, maxV, dec );
+    }
+}
+
+
+
+//=================================================================================
+// class    : SMESHGUI_TableFrame
+// purpose  :
+//=================================================================================
+SMESHGUI_TableFrame::SMESHGUI_TableFrame( QWidget* parent )
+: QFrame( parent )
+{
+  QVBoxLayout* main = new QVBoxLayout( this, 0, 0 );
+
+  myTable = new SMESHGUI_Table( 1, 1, this );
+  
+  QFrame* aButFrame = new QFrame( this );
+  QHBoxLayout* butLay = new QHBoxLayout( aButFrame, 5, 5 );
+
+  myAddColumn = new QPushButton( "Add column", aButFrame );
+
+  myRemoveColumn = new QPushButton( "Remove column", aButFrame );
+
+  myAddRow = new QPushButton( "Add row", aButFrame );
+
+  myRemoveRow = new QPushButton( "Remove row", aButFrame );
+
+  butLay->addWidget( myAddColumn, 0 );
+  butLay->addWidget( myRemoveColumn, 0 );
+  butLay->addWidget( myAddRow, 0 );
+  butLay->addWidget( myRemoveRow, 0 );
+  butLay->addStretch( 1 );
+
+  main->addWidget( myTable, 1 );
+  main->addWidget( aButFrame, 0 );
+
+  connect( myAddColumn,    SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+  connect( myRemoveColumn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+  connect( myAddRow,       SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+  connect( myRemoveRow,    SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+}
+
+SMESHGUI_TableFrame::~SMESHGUI_TableFrame()
+{
+}
+
+SMESHGUI_Table* SMESHGUI_TableFrame::table() const
+{
+  return myTable;
+}
+
+void SMESHGUI_TableFrame::setShown( const Button b, const bool sh )
+{
+  if( button( b ) )
+    button( b )->setShown( sh );
+}
+
+bool SMESHGUI_TableFrame::isShown( const Button b ) const
+{
+  bool res = false;
+  if( button( b ) )
+    res = button( b )->isShown();
+  return res;
+}
+
+QButton* SMESHGUI_TableFrame::button( const Button b ) const
+{
+  QButton* res = 0;
+  switch( b )
+  {
+    case ADD_COLUMN:
+      res = myAddColumn;
+      break;
+
+    case REMOVE_COLUMN:
+      res = myRemoveColumn;
+      break;
+
+    case ADD_ROW:
+      res = myAddRow;
+      break;
+
+    case REMOVE_ROW:
+      res = myRemoveRow;
+      break;
+  }
+  return res;
+}
+
+void SMESHGUI_TableFrame::onButtonClicked()
+{
+  if( sender()==button( ADD_COLUMN ) )
+    emit toEdit( ADD_COLUMN, table()->currentColumn() );
+    
+  else if( sender()==button( REMOVE_COLUMN ) )
+    emit toEdit( REMOVE_COLUMN, table()->currentColumn() );
+    
+  else if( sender()==button( ADD_ROW ) )
+    emit toEdit( ADD_ROW, table()->currentRow() );
+    
+  else if( sender()==button( REMOVE_ROW ) )
+    emit toEdit( REMOVE_ROW, table()->currentRow() );
+}
+
+
+//=================================================================================
+// class    : SMESHGUI_tableParameter
+// purpose  :
+//=================================================================================
+SMESHGUI_tableParameter::SMESHGUI_tableParameter( const double init,
+                                                  const QString& label )
+: SMESHGUI_aParameter( label ),
+  myInitValue( init ),
+  myColsInt( 1 ),
+  myRowsInt( 1 ),
+  myEditCols( false ),
+  myEditRows( false )
+{
+}
+
+SMESHGUI_tableParameter::~SMESHGUI_tableParameter()
+{
+}
+
+SMESHGUI_aParameter::Type SMESHGUI_tableParameter::GetType() const
+{
+  return TABLE;
+}
+
+bool SMESHGUI_tableParameter::GetNewInt( int& ) const
+{
+  return false;
+}
+
+bool SMESHGUI_tableParameter::GetNewDouble( double& ) const
+{
+  return false;
+}
+
+bool SMESHGUI_tableParameter::GetNewText( QString& ) const
+{
+  return false;
+}
+
+QWidget* SMESHGUI_tableParameter::CreateWidget( QWidget* par ) const
+{
+  SMESHGUI_TableFrame* t = new SMESHGUI_TableFrame( par );
+  connect( t,    SIGNAL( toEdit( SMESHGUI_TableFrame::Button, int ) ),
+           this, SLOT  ( onEdit( SMESHGUI_TableFrame::Button, int ) ) );
+  
+  update( t );
+  return t;
+}
+
+void SMESHGUI_tableParameter::setItems( QWidget* w,
+                                        int old_row, int new_row,
+                                        int old_col, int new_col ) const
+{
+  if( w && w->inherits( "SMESHGUI_TableFrame" ) )
+  {
+    QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
+    
+    if( old_row<0 )
+      old_row = 0;
+    if( new_row<0 )
+      new_row = tab->numRows();
+    if( old_col<0 )
+      old_col = 0;
+    if( new_col<0 )
+      new_col = tab->numCols();
+    
+    for( int i=old_row, m=new_row; i<m; i++ )
+      for( int j=0, n=new_col; j<n; j++ )
+        tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
+    
+    for( int i=0, m=new_row; i<m; i++ )
+      for( int j=old_col, n=new_col; j<n; j++ )
+        tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
+
+    for( int j=old_col; j<new_col; j++ )
+      tab->setColumnWidth( j, 50 );
+  }
+}
+
+void SMESHGUI_tableParameter::InitializeWidget( QWidget* w ) const
+{
+  setItems( w );
+
+  if( w && w->inherits( "SMESHGUI_TableFrame" ) )
+  {
+    SMESHGUI_Table* tab = ( ( SMESHGUI_TableFrame* )w )->table();
+    tab->stopEditing();
+
+    int col = tab->numCols(),
+        row = tab->numRows();
+    
+    for( int i=0, m=row; i<m; i++ )
+      for( int j=0, n=col; j<n; j++ )
+        if( row*j+i<myData.length() )
+          tab->item( i, j )->setText( QString( "%1" ).arg( myData[row*j+i] ) );
+  }
+}
+
+void SMESHGUI_tableParameter::TakeValue( QWidget* w )
+{
+  if( w && w->inherits( "SMESHGUI_TableFrame" ) )
+  {
+    QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
+
+    int col = tab->numCols(),
+        row = tab->numRows();
+
+    myData.length( col*row );
+    for( int i=0; i<row; i++ )
+      for( int j=0; j<col; j++ )
+        myData[ col*i+j ] = tab->text( i, j ).toDouble();
+  }
+}
+
+void SMESHGUI_tableParameter::data( SMESH::double_array& v ) const
+{
+  v = myData;
+}
+
+void SMESHGUI_tableParameter::setData( const SMESH::double_array& d )
+{
+  myData = d;
+}
+
+void SMESHGUI_tableParameter::update( QWidget* w ) const
+{
+  if( w && w->inherits( "SMESHGUI_TableFrame" ) )
+  {
+    SMESHGUI_TableFrame* tabfr = ( SMESHGUI_TableFrame* ) w;
+    SMESHGUI_Table* tab = tabfr->table();
+
+    int old_col = tab->numCols(),
+        old_row = tab->numRows();
+        
+    int col = myColsInt, row = myRowsInt;
+    if( myCols.get() )
+      myCols->GetNewInt( col );
+        
+    if( myRows.get() )
+      myRows->GetNewInt( row );
+
+    if( col<=0 )
+      col = 1;
+    if( row<=0 )
+      row = 1;
+
+    if( col!=tab->numCols() )
+      tab->setNumCols( col );
+
+    if( row!=tab->numRows() )
+      tab->setNumRows( row );
+
+    tabfr->setShown( SMESHGUI_TableFrame::ADD_COLUMN, myEditCols );
+    tabfr->setShown( SMESHGUI_TableFrame::REMOVE_COLUMN, myEditCols );
+    tabfr->setShown( SMESHGUI_TableFrame::ADD_ROW, myEditRows );
+    tabfr->setShown( SMESHGUI_TableFrame::REMOVE_ROW, myEditRows );
+
+    setItems( w, old_row, row, old_col, col );
+
+    QMap< int, QString >::const_iterator aNIt = myColNames.begin(),
+                                         aNLast = myColNames.end();
+    for( ; aNIt!=aNLast; aNIt++ )
+      tab->horizontalHeader()->setLabel( aNIt.key(), aNIt.data() );
+    
+    ValidatorsMap::const_iterator anIt = myValidators.begin(),
+                                  aLast = myValidators.end();
+    for( ; anIt!=aLast; anIt++ )
+    {
+      int row = anIt.key(), dec;
+      double minV, maxV;
+      validator( row, minV, maxV, dec );
+      tab->setValidator( minV, maxV, dec, -1, -1, col, col );
+    }
+
+    QSize s = tab->sizeHint();
+    tab->resize( s.width(), s.height() );
+  }
+}
+
+void SMESHGUI_tableParameter::setColCount( const int c, QWidget* w )
+{
+  myColsInt = c;
+  update( w );
+}
+
+void SMESHGUI_tableParameter::setRowCount( const int c, QWidget* w )
+{
+  myRowsInt = c;
+  update( w );
+}
+
+void SMESHGUI_tableParameter::setColCount( const SMESHGUI_aParameterPtr p, QWidget* w )
+{
+  if( p.get() )
+  {
+    myCols = p;
+    update( w );
+  }
+}
+
+void SMESHGUI_tableParameter::setRowCount( const SMESHGUI_aParameterPtr p, QWidget* w )
+{
+  if( p.get() )
+  {
+    myRows = p;
+    update( w );
+  }
+}
+
+QString SMESHGUI_tableParameter::sigValueChanged() const
+{
+  return SIGNAL( valueChanged( int, int ) );
+}
+
+void SMESHGUI_tableParameter::setValidator( const int ind, const double minV, const double maxV, const int dec )
+{
+  ValidatorInfo inf;
+  inf.myMin = minV;
+  inf.myMax = maxV;
+  inf.myDecimals = dec;
+  myValidators[ ind ] = inf;
+}
+
+void SMESHGUI_tableParameter::validator( const int ind, double& minV, double& maxV, int& dec ) const
+{
+  if( myValidators.contains( ind ) )
+  {
+    const ValidatorInfo& inf = myValidators[ ind ];
+    minV = inf.myMin;
+    maxV = inf.myMax;
+    dec = inf.myDecimals;
+  }
+}
+
+void SMESHGUI_tableParameter::setEditCols( const bool ed )
+{
+  myEditCols = ed;
+}
+
+void SMESHGUI_tableParameter::setEditRows( const bool ed )
+{
+  myEditRows = ed;
+}
+
+void SMESHGUI_tableParameter::setColName( const int ind, const QString& name )
+{
+  myColNames.insert( ind, name );
+}
+
+QString SMESHGUI_tableParameter::colName( const int ind ) const
+{
+  if( myColNames.contains( ind ) )
+    return myColNames[ ind ];
+  else
+    return QString::null;
+}
+
+void SMESHGUI_tableParameter::onEdit( SMESHGUI_TableFrame::Button b, int n )
+{
+  if( sender() && sender()->inherits( "SMESHGUI_TableFrame" ) )
+  {
+    SMESHGUI_TableFrame* fr = ( SMESHGUI_TableFrame* )sender();
+    SMESHGUI_Table* tab = fr->table();
+
+    switch( b )
+    {
+      case SMESHGUI_TableFrame::ADD_COLUMN:
+      {
+        if( !myEditCols || myCols.get() )
+          return;
+
+        myColsInt++; update( fr );
+        if( n>=0 )
+          for( int i=0; i<myRowsInt; i++ )
+            for( int j=myColsInt-1; j>=n; j-- )
+              if( j==n )
+                tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
+              else
+                tab->setText( i, j, tab->text( i, j-1 ) );
+        break;
+      }
+      
+      case SMESHGUI_TableFrame::REMOVE_COLUMN:
+      {
+        if( !myEditCols || myCols.get() || myColsInt<=1 )
+          return;
+
+        if( n>=0 )
+          for( int i=0; i<myRowsInt; i++ )
+            for( int j=n; j<myColsInt-1; j++ )
+              tab->setText( i, j, tab->text( i, j+1 ) );
+        myColsInt--; update( fr );
+
+        break;
+      }
+      
+      case SMESHGUI_TableFrame::ADD_ROW:
+      {
+        if( !myEditRows || myRows.get() )
+          return;
+
+        myRowsInt++; update( fr );
+        if( n>=0 )
+          for( int i=myRowsInt-1; i>=n; i-- )
+            for( int j=0; j<myColsInt; j++ )
+              if( i==n )
+                tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
+              else
+                tab->setText( i, j, tab->text( i-1, j ) );
+        break;        
+      }
+      
+      case SMESHGUI_TableFrame::REMOVE_ROW:
+      {
+        if( !myEditRows || myRows.get() || myRowsInt<=1 )
+          return;
+
+        if( n>=0 )
+          for( int i=n; i<myRowsInt-1; i++ )
+            for( int j=0; j<myColsInt; j++ )
+              tab->setText( i, j, tab->text( i+1, j ) );
+        myRowsInt--; update( fr );
+
+        break;
+      }
+    }
+  }
+}
index a4360b5fd83096b28cad8000d918436e69f8da4d..8613b50dd1a8a2ef1b7a6891e566d56bcb73aa7a 100644 (file)
 #define SMESHGUI_aParameter_H
 
 #include <boost/shared_ptr.hpp>
 #define SMESHGUI_aParameter_H
 
 #include <boost/shared_ptr.hpp>
-#include <qstring.h>
+#include <qstringlist.h>
+#include <qmap.h>
+#include <qtable.h>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
 
 class QWidget;
 class SMESHGUI_aParameter;
 
 typedef boost::shared_ptr<SMESHGUI_aParameter> SMESHGUI_aParameterPtr;
 
 
 class QWidget;
 class SMESHGUI_aParameter;
 
 typedef boost::shared_ptr<SMESHGUI_aParameter> SMESHGUI_aParameterPtr;
 
-//=================================================================================
-// class    : SMESHGUI_aParameter
-// purpose  :
-//=================================================================================
+/*!
+ *  \brief This class is the base class of all parameters
+ */
 class SMESHGUI_aParameter
 { 
 public:
   SMESHGUI_aParameter(const QString& label):_label(label) {}
   virtual ~SMESHGUI_aParameter();
 
 class SMESHGUI_aParameter
 { 
 public:
   SMESHGUI_aParameter(const QString& label):_label(label) {}
   virtual ~SMESHGUI_aParameter();
 
-  enum Type { INT, DOUBLE, TEXT };
+  enum Type { INT, DOUBLE, STRING, ENUM, BOOL, TABLE };
   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 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;
   virtual void TakeValue( QWidget* ) = 0;
+  virtual QWidget* CreateWidget( QWidget* ) const = 0;
+  virtual void InitializeWidget( QWidget* ) const = 0;
 
 
-  QString & Label() { return _label; }
+  /*!
+   *  \brief Returns string representation of signal emitted when value in corrsponding widget is changed
+   */
+  virtual QString sigValueChanged() const;
 
 
- private:
+  QString & Label() { return _label; }
+  
+private:
   QString _label;
 };
 
   QString _label;
 };
 
-//=================================================================================
-// class    : SMESHGUI_intParameter
-// purpose  :
-//=================================================================================
+/*!
+ *  \brief This class provides parameter with integer value
+ */
 class SMESHGUI_intParameter: public SMESHGUI_aParameter
 { 
 public:
 class SMESHGUI_intParameter: public SMESHGUI_aParameter
 { 
 public:
@@ -78,18 +87,20 @@ public:
   virtual bool GetNewInt( int & Value ) const;
   virtual bool GetNewDouble( double & Value ) const;
   virtual bool GetNewText( QString & Value ) 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* );
   virtual void TakeValue( QWidget* );
+  virtual QWidget* CreateWidget( QWidget* ) const;
+  virtual void InitializeWidget( QWidget* ) const;
 
 
- private:
+  virtual QString sigValueChanged() const;
+  
+private:
   int _top, _bottom;
   int _initValue, _newValue;
 };
 
   int _top, _bottom;
   int _initValue, _newValue;
 };
 
-//=================================================================================
-// class    : SMESHGUI_doubleParameter
-// purpose  :
-//=================================================================================
+/*!
+ *  \brief This class provides parameter with double value
+ */
 class SMESHGUI_doubleParameter: public SMESHGUI_aParameter
 { 
 public:
 class SMESHGUI_doubleParameter: public SMESHGUI_aParameter
 { 
 public:
@@ -108,35 +119,324 @@ public:
   virtual bool GetNewInt( int & Value ) const;
   virtual bool GetNewDouble( double & Value ) const;
   virtual bool GetNewText( QString & Value ) const;
   virtual bool GetNewInt( int & Value ) const;
   virtual bool GetNewDouble( double & Value ) const;
   virtual bool GetNewText( QString & Value ) const;
+  virtual QWidget* CreateWidget( QWidget* ) const;
   virtual void InitializeWidget( QWidget* ) const;
   virtual void TakeValue( QWidget* );
 
   virtual void InitializeWidget( QWidget* ) const;
   virtual void TakeValue( QWidget* );
 
- private:
+  virtual QString sigValueChanged() const;
+  
+private:
   double _top, _bottom, _step;
   double _initValue, _newValue;
   int _decimals;
 };
 
   double _top, _bottom, _step;
   double _initValue, _newValue;
   int _decimals;
 };
 
-
-//=================================================================================
-// class    : SMESHGUI_strParameter
-// purpose  :
-//=================================================================================
+/*!
+ *  \brief This class provides parameter with string value
+ */
 class SMESHGUI_strParameter: public SMESHGUI_aParameter
 { 
 public:
 class SMESHGUI_strParameter: public SMESHGUI_aParameter
 { 
 public:
-  SMESHGUI_strParameter(const QString& initValue = "",
-                       const QString& label     = QString::null);
-  QString InitValue() { return _initValue; }
+  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 Type GetType() const;
   virtual bool GetNewInt( int & Value ) const;
   virtual bool GetNewDouble( double & Value ) const;
   virtual bool GetNewText( QString & Value ) const;
+  virtual QWidget* CreateWidget( QWidget* ) const;
   virtual void InitializeWidget( QWidget* ) const;
   virtual void TakeValue( QWidget* );
 
   virtual void InitializeWidget( QWidget* ) const;
   virtual void TakeValue( QWidget* );
 
- private:
+  virtual QString sigValueChanged() const;
+  
+private:
   QString _initValue, _newValue;
 };
 
   QString _initValue, _newValue;
 };
 
+
+/*!
+ *  \brief This class represents the base parameter which contains dependency of
+ *  shown state of other parameters on value of current
+ */
+class SMESHGUI_dependParameter: public SMESHGUI_aParameter
+{
+public:
+  /*!
+   *  \brief This map describes what parameters must be shown when this parameter has value as key
+   *  The list contains some indices of parameters (for example, order in some list)
+   *  Value is integer based 0. If map is empty, it means that there is no dependencies.
+   */
+  typedef QValueList< int > IntList;
+  typedef QMap< int, IntList >  ShownMap;
+
+public:
+  SMESHGUI_dependParameter( const QString& = QString::null );
+
+  const ShownMap&    shownMap() const;
+  ShownMap&          shownMap();
+  
+private:
+  ShownMap     myShownMap;
+};
+
+/*!
+ *  \brief This class represents parameter which can have value from fixed set
+ */
+class SMESHGUI_enumParameter: public SMESHGUI_dependParameter
+{
+public:
+  /*!
+   *  \brief Creates parameter with set of values 'values', default value 'init' and title 'label'
+   *  Every value can be described both by integer based 0 or by string value
+   */
+  SMESHGUI_enumParameter( const QStringList& values,
+                          const int init = 0,
+                          const QString& label = QString::null );
+  virtual ~SMESHGUI_enumParameter();
+
+  /*!
+   *  \brief Returns count of possible values
+   */
+  int            Count() const;
+
+  int& InitValue() { return myInitValue; }
+  virtual Type GetType() const;
+  virtual bool GetNewInt( int& ) const;
+  virtual bool GetNewDouble( double& ) const;
+  virtual bool GetNewText( QString& ) const;
+  virtual QWidget* CreateWidget( QWidget* ) const;
+  virtual void InitializeWidget( QWidget* ) const;
+  virtual void TakeValue( QWidget* );
+
+  virtual QString sigValueChanged() const;
+    
+private:
+  int         myInitValue, myValue;
+  QStringList myValues;
+};
+
+
+/*!
+ *  \brief This class represents parameter which can have value true or false
+ */
+class SMESHGUI_boolParameter: public SMESHGUI_dependParameter
+{
+public:
+  SMESHGUI_boolParameter( const bool = false,
+                          const QString& = QString::null );
+  virtual ~SMESHGUI_boolParameter();
+
+  bool& InitValue() { return myInitValue; }
+  virtual Type GetType() const;
+  virtual bool GetNewInt( int& ) const;
+  virtual bool GetNewDouble( double& ) const;
+  virtual bool GetNewText( QString& ) const;
+  virtual QWidget* CreateWidget( QWidget* ) const;
+  virtual void InitializeWidget( QWidget* ) const;
+  virtual void TakeValue( QWidget* );
+
+  virtual QString sigValueChanged() const;
+  
+private:
+  bool myInitValue, myValue;
+};
+
+
+class QButton;
+
+/*!
+ *  \brief This class represents custom table. It has only double values and
+    editor for every cell has validator
+ */
+class SMESHGUI_Table : public QTable
+{
+  Q_OBJECT
+  
+public:
+  SMESHGUI_Table( int numRows, int numCols, QWidget* = 0, const char* = 0 );
+  virtual ~SMESHGUI_Table();
+
+/*!
+ *  \brief Hides current editor of cell
+ */
+  void stopEditing();
+  
+  virtual QSize sizeHint() const;
+
+/*!
+ *  \brief Returns parameters of double validator corresponding to cell (row,col)
+ */
+  void validator( const int row, const int col, double&, double&, int& );
+  
+/*!
+ *  \brief Sets the double validator parameters to every cell in row range [rmin,rmax]
+ *         and column range [cmin,cmax].
+ *         If rmin=-1 then rmin is set to 0, if rmax=-1 then rmax = last row.
+ *         Analogically cmin and cmax are set
+ */
+  void setValidator( const double, const double, const int,
+                     const int rmin = -1, const int rmax = -1,
+                     const int cmin = -1, const int cmax = -1 );  
+};
+
+
+/*!
+ *  \brief This class represents frame for table and buttons
+ */
+class SMESHGUI_TableFrame : public QFrame
+{
+  Q_OBJECT
+  
+public:
+/*!
+ *  \brief Values corresponding to buttons for table resize
+ */
+  typedef enum { ADD_COLUMN, REMOVE_COLUMN, ADD_ROW, REMOVE_ROW } Button;
+
+public:
+  SMESHGUI_TableFrame( QWidget* );
+  ~SMESHGUI_TableFrame();
+
+  SMESHGUI_Table* table() const;
+
+/*!
+ *  \brief Changes shown state of some button for table resize
+ */   
+  void setShown( const Button, const bool );
+
+/*!
+ *  \brief Returns shown state of some button for table resize
+ */
+  bool isShown( const Button ) const;
+  
+private:
+  QButton* button( const Button ) const;
+
+private slots:
+  void onButtonClicked();
+  
+signals:
+/*!
+ *  \brief This signal is emitted if some of button for table resize is clicked
+ *         Second parameter is current column for ADD_COLUMN, REMOVE_COLUMN buttons
+ *         and current row for ADD_ROW, REMOVE_ROW buttons. Take into account that
+ *         this object resize table ( returned by table() ) automatically
+ */
+  void toEdit( SMESHGUI_TableFrame::Button, int );
+
+private:
+  QButton *myAddColumn, *myRemoveColumn, *myAddRow, *myRemoveRow;
+  SMESHGUI_Table*  myTable;
+};
+
+
+/*!
+ *  \brief This class represents parameter which can have two-dimensional array of values
+ */
+class SMESHGUI_tableParameter: public QObject, public SMESHGUI_aParameter
+{
+  Q_OBJECT
+  
+public:
+/*!
+ *  \brief Creates table parameter with default value 'init' and title 'label'.
+ *         The default value means that by default the table is filled with default value
+ *         and if new column or row is added then it is filled with default value
+ */
+  SMESHGUI_tableParameter( const double init = 0.0,
+                           const QString& label = QString::null );
+  virtual ~SMESHGUI_tableParameter();
+
+  virtual Type GetType() const;
+  virtual bool GetNewInt( int& ) const;
+  virtual bool GetNewDouble( double& ) const;
+  virtual bool GetNewText( QString& ) const;
+  virtual QWidget* CreateWidget( QWidget* ) const;
+  virtual void InitializeWidget( QWidget* ) const;
+  virtual void TakeValue( QWidget* );
+
+/*!
+ *  \brief Updates look of widget in accordance with all parameters of this object
+ */
+  void update( QWidget* ) const;
+  
+/*!
+ *  \brief Returns data taken from widget. Please don't forget to call TakeValue before.
+ */
+  void data( SMESH::double_array& ) const;
+
+/*!
+ *  \brief Sets data. The InitializeWidget must be called in order to change values in widget
+ */
+  void setData( const SMESH::double_array& );
+
+/*!
+ *  \brief Sets count of columns and updates widget
+ */
+  void setColCount( const int, QWidget* = 0 );
+
+/*!
+ *  \brief Sets count of rows and updates widget
+ */
+  void setRowCount( const int, QWidget* = 0 );
+  
+/*!
+ *  \brief Binds count of columns to some parameter and updates widget. Take into account that
+ *         if this parameter is changed, the update() must be called to resize table
+ */
+  void setColCount( const SMESHGUI_aParameterPtr, QWidget* = 0 );
+
+/*!
+ *  \brief Binds count of rows to some parameter and updates widget. Take into account that
+ *         if this parameter is changed, the update() must be called to resize table
+ */
+  void setRowCount( const SMESHGUI_aParameterPtr, QWidget* = 0 );
+  
+/*!
+ *  \brief Enables or disables to change count of columns by buttons
+ */
+  void setEditCols( const bool );
+
+/*!
+ *  \brief Enables or disables to change count of rows by buttons
+ */
+  void setEditRows( const bool );  
+
+  virtual QString sigValueChanged() const;
+  
+  void setValidator( const int col, const double, const double, const int );
+  void validator( const int col, double&, double&, int& ) const;
+
+/*!
+ *  \brief These methods allow to read and change name of column
+ */
+  void    setColName( const int, const QString& );
+  QString colName( const int ) const;
+
+private slots:
+  void onEdit( SMESHGUI_TableFrame::Button, int );
+
+private:
+  void setItems( QWidget*, int = -1, int = -1, int = -1, int = -1 ) const;
+
+private:
+  typedef struct
+  {
+    double myMin, myMax;
+    int    myDecimals;
+  } ValidatorInfo;
+
+  typedef QMap<int, ValidatorInfo>  ValidatorsMap;
+  
+private:
+  int                      myColsInt, myRowsInt;
+  SMESHGUI_aParameterPtr   myCols, myRows;
+  double                   myInitValue;
+  SMESH::double_array      myData;
+  ValidatorsMap            myValidators;
+  bool                     myEditCols, myEditRows;
+  QMap< int, QString >     myColNames;
+};
+
 #endif // SMESHGUI_aParameter.h
 #endif // SMESHGUI_aParameter.h
index 03145925ff81be452f060bfa901cb6b6bcb34c8b..7e824a7b9031c2875a6b1014d40788468617a394 100644 (file)
@@ -42,7 +42,7 @@
 #include <qlayout.h>
 #include <qspinbox.h>
 #include <qvalidator.h>
 #include <qlayout.h>
 #include <qspinbox.h>
 #include <qvalidator.h>
-#include <qtextedit.h>
+#include <qlineedit.h>
 
 using namespace std;
 
 
 using namespace std;
 
@@ -80,7 +80,7 @@ void SMESHGUI_aParameterDlg::init()
 {
   setSizeGripEnabled(TRUE);
 
 {
   setSizeGripEnabled(TRUE);
 
-  QGridLayout* topLayout = new QGridLayout(this);
+  QVBoxLayout* topLayout = new QVBoxLayout(this);
   topLayout->setMargin(11); topLayout->setSpacing(6);
 
   /***************************************************************/
   topLayout->setMargin(11); topLayout->setSpacing(6);
 
   /***************************************************************/
@@ -100,37 +100,28 @@ void SMESHGUI_aParameterDlg::init()
     QLabel * label = new QLabel(GroupC1, "TextLabel");
     GroupC1Layout->addWidget(label, row, 0);
     label->setText(param->Label());
     QLabel * label = new QLabel(GroupC1, "TextLabel");
     GroupC1Layout->addWidget(label, row, 0);
     label->setText(param->Label());
-    QWidget* aSpinWidget = 0;
-    switch (param->GetType()) {
-    case SMESHGUI_aParameter::DOUBLE: {
-      SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox(GroupC1);
-      aSpinWidget = spin;
-      spin->setPrecision(12);
-      break;
-    }
-    case SMESHGUI_aParameter::INT: {
-      QSpinBox* spin = new QSpinBox(GroupC1);
-      aSpinWidget = spin;
-      break;
-    }
-    case SMESHGUI_aParameter::TEXT: {
-      QTextEdit* edit = new QTextEdit(GroupC1);
-      edit->setWordWrap(QTextEdit::NoWrap);
-      edit->setTextFormat(Qt::PlainText);
-      aSpinWidget = edit;
-      break;
-    }
-    default:;
-    }
+    QWidget* aSpinWidget = param->CreateWidget( GroupC1 );
     if (aSpinWidget) {
       GroupC1Layout->addWidget(aSpinWidget, row, 1);
       aSpinWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
       aSpinWidget->setMinimumSize(150, 0);
     if (aSpinWidget) {
       GroupC1Layout->addWidget(aSpinWidget, row, 1);
       aSpinWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
       aSpinWidget->setMinimumSize(150, 0);
+
+      QString sig = param->sigValueChanged();
+      if( !sig.isEmpty() && param->GetType()!=SMESHGUI_aParameter::TABLE )
+        connect( aSpinWidget, sig.latin1(), this, SLOT( onValueChanged() ) );
+      
       param->InitializeWidget(aSpinWidget);
       mySpinList.push_back(aSpinWidget);
       param->InitializeWidget(aSpinWidget);
       mySpinList.push_back(aSpinWidget);
+      myLabelList.push_back(label);
     }
   }
 
     }
   }
 
+  paramIt = myParamList.begin();
+  std::list<QWidget*>::const_iterator anIt = mySpinList.begin();
+  for( ; paramIt!=myParamList.end(); paramIt++, anIt++ )
+    UpdateShown( *paramIt, *anIt );
+  
+
   /***************************************************************/
   QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
   GroupButtons->setColumnLayout(0, Qt::Vertical);
   /***************************************************************/
   QGroupBox* GroupButtons = new QGroupBox(this, "GroupButtons");
   GroupButtons->setColumnLayout(0, Qt::Vertical);
@@ -155,8 +146,8 @@ void SMESHGUI_aParameterDlg::init()
   GroupButtonsLayout->addWidget(myButtonCancel, 0, 2);
 
   /***************************************************************/
   GroupButtonsLayout->addWidget(myButtonCancel, 0, 2);
 
   /***************************************************************/
-  topLayout->addWidget(GroupC1,      0, 0);
-  topLayout->addWidget(GroupButtons, 1, 0);
+  topLayout->addWidget(GroupC1,      );
+  topLayout->addWidget(GroupButtons, );
 
   /* signals and slots connections */
   connect(myButtonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
 
   /* signals and slots connections */
   connect(myButtonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
@@ -204,3 +195,61 @@ bool SMESHGUI_aParameterDlg::Parameters( SMESHGUI* theModule,
   }
   return false;
 }
   }
   return false;
 }
+
+//=======================================================================
+// function : onValueChanged
+// purpose  : 
+//=======================================================================
+void SMESHGUI_aParameterDlg::onValueChanged()
+{
+  if( sender()->inherits( "QWidget" ) )
+  {
+    QWidget* w = ( QWidget* )sender();
+
+    SMESHGUI_aParameterPtr param;
+
+    std::list<QWidget*>::const_iterator anIt = mySpinList.begin(),
+                                        aLast = mySpinList.end();
+    std::list<SMESHGUI_aParameterPtr>::const_iterator aPIt = myParamList.begin();
+    for( ; anIt!=aLast; anIt++, aPIt++ )
+      if( *anIt == w )
+      {
+        (*aPIt)->TakeValue( w );
+        UpdateShown( *aPIt, w );
+        break;
+      }
+  }
+}
+
+//=======================================================================
+// function : onValueChanged
+// purpose  :
+//=======================================================================
+void SMESHGUI_aParameterDlg::UpdateShown( const SMESHGUI_aParameterPtr param, QWidget* w )
+{
+  SMESHGUI_dependParameter* depPar = dynamic_cast<SMESHGUI_enumParameter*>( param.get() );
+  if( !depPar )
+    depPar = dynamic_cast<SMESHGUI_boolParameter*>( param.get() );
+
+  if( !depPar )
+    return;
+
+  SMESHGUI_dependParameter::ShownMap& map = depPar->shownMap();
+  if( map.isEmpty() )
+    return;
+
+  int val;
+  depPar->TakeValue( w );
+  depPar->GetNewInt( val );
+  bool hasValue = map.contains( val );
+
+  std::list<QWidget*>::const_iterator anIt = mySpinList.begin(),
+                                      aLast = mySpinList.end(),
+                                      aLIt = myLabelList.begin();
+  for( int i=0; anIt!=aLast; anIt++, aLIt++, i++ )
+  {
+    bool shown = hasValue && map[ val ].contains( i );
+    (*anIt)->setShown( shown );
+    (*aLIt)->setShown( shown );
+  }
+}
index 0c53672b2e01eaad64c34b11c5f040fb4cd09e2c..7fd28a96f564bcf3b3e8cf03371a943cf709402e 100644 (file)
@@ -62,8 +62,12 @@ public:
 protected:
     void init();
 
 protected:
     void init();
 
+protected slots:
+    virtual void onValueChanged();
+    
 private slots:
     void ClickOnOk();
 private slots:
     void ClickOnOk();
+    void UpdateShown( const SMESHGUI_aParameterPtr, QWidget* );
 
 private:
     SMESHGUI*       mySMESHGUI;
 
 private:
     SMESHGUI*       mySMESHGUI;
@@ -71,7 +75,7 @@ private:
     QPushButton*    myButtonOk;
     QPushButton*    myButtonCancel;
 
     QPushButton*    myButtonOk;
     QPushButton*    myButtonCancel;
 
-    std::list<QWidget*>               mySpinList;
+    std::list<QWidget*>               mySpinList, myLabelList;
     std::list<SMESHGUI_aParameterPtr> myParamList;
 };
 
     std::list<SMESHGUI_aParameterPtr> myParamList;
 };