1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_aParameter.cxx
28 #include "SMESHGUI_aParameter.h"
31 #include <qvalidator.h>
32 #include <qlineedit.h>
33 #include <qtextedit.h>
34 #include <qcombobox.h>
35 #include <qcheckbox.h>
37 #include <qvalidator.h>
38 #include <qpushbutton.h>
41 #include <QtxDblSpinBox.h>
43 SMESHGUI_aParameter::SMESHGUI_aParameter( const QString& label, const bool preview )
44 : _needPreview( preview ),
49 SMESHGUI_aParameter::~SMESHGUI_aParameter()
53 bool SMESHGUI_aParameter::needPreview() const
58 QString& SMESHGUI_aParameter::Label()
63 QString SMESHGUI_aParameter::sigValueChanged() const
68 //=================================================================================
69 // class : SMESHGUI_intParameter
71 //=================================================================================
72 SMESHGUI_intParameter::SMESHGUI_intParameter (const int theInitValue,
73 const QString& theLabel,
77 :SMESHGUI_aParameter(theLabel, preview),
78 _top(theTop), _bottom(theBottom), _initValue(theInitValue),
79 _newValue( theInitValue )
82 SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const
84 return SMESHGUI_aParameter::INT;
86 bool SMESHGUI_intParameter::GetNewInt (int & theValue) const
89 return _newValue != _initValue;
91 bool SMESHGUI_intParameter::GetNewDouble (double & Value) const
95 bool SMESHGUI_intParameter::GetNewText (QString & Value) const
100 QWidget* SMESHGUI_intParameter::CreateWidget( QWidget* parent ) const
102 return new QSpinBox( parent );
105 void SMESHGUI_intParameter::InitializeWidget (QWidget* theQWidget) const
107 QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
109 aSpin->setMinValue(_bottom);
110 aSpin->setMaxValue(_top);
111 aSpin->setValue(_initValue);
114 void SMESHGUI_intParameter::TakeValue (QWidget* theQWidget)
116 QSpinBox * aSpin = dynamic_cast< QSpinBox *>(theQWidget);
118 _newValue = aSpin->value();
121 QString SMESHGUI_intParameter::sigValueChanged() const
123 return SIGNAL( valueChanged( int ) );
126 //=================================================================================
127 // class : SMESHGUI_doubleParameter
129 //=================================================================================
130 SMESHGUI_doubleParameter::SMESHGUI_doubleParameter (const double theInitValue,
131 const QString& theLabel,
132 const double theBottom,
134 const double theStep,
135 const int theDecimals,
137 :SMESHGUI_aParameter(theLabel, preview),
138 _top(theTop), _bottom(theBottom), _step(theStep),
139 _initValue(theInitValue), _decimals(theDecimals)
142 SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const
144 return SMESHGUI_aParameter::DOUBLE;
146 bool SMESHGUI_doubleParameter::GetNewInt (int & theValue) const
150 bool SMESHGUI_doubleParameter::GetNewDouble (double & Value) const
153 return _newValue != _initValue;
155 bool SMESHGUI_doubleParameter::GetNewText (QString & Value) const
160 QWidget* SMESHGUI_doubleParameter::CreateWidget( QWidget* parent ) const
162 return new QtxDblSpinBox( parent );
165 void SMESHGUI_doubleParameter::InitializeWidget (QWidget* theQWidget) const
167 QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
169 aSpin->setPrecision(_decimals);
171 aSpin->setDblPrecision(_bottom);
173 aSpin->setRange(_bottom, _top);
174 aSpin->setValue(_initValue);
175 aSpin->setLineStep(_step);
178 void SMESHGUI_doubleParameter::TakeValue (QWidget* theQWidget)
180 QtxDblSpinBox* aSpin = dynamic_cast<QtxDblSpinBox*>(theQWidget);
182 _newValue = aSpin->value();
185 QString SMESHGUI_doubleParameter::sigValueChanged() const
187 return SIGNAL( valueChanged( double ) );
190 //=================================================================================
191 // class : SMESHGUI_strParameter
193 //=================================================================================
194 SMESHGUI_strParameter::SMESHGUI_strParameter (const QString& theInitValue,
195 const QString& theLabel,
197 :SMESHGUI_aParameter(theLabel, preview),
198 _initValue(theInitValue)
201 SMESHGUI_aParameter::Type SMESHGUI_strParameter::GetType() const
203 return SMESHGUI_aParameter::STRING;
206 bool SMESHGUI_strParameter::GetNewInt (int & theValue) const
210 bool SMESHGUI_strParameter::GetNewDouble (double & Value) const
214 bool SMESHGUI_strParameter::GetNewText (QString & theValue) const
216 theValue = _newValue;
217 return _newValue != _initValue;
220 QWidget* SMESHGUI_strParameter::CreateWidget( QWidget* parent ) const
222 return new QLineEdit( parent );
225 void SMESHGUI_strParameter::InitializeWidget (QWidget* theQWidget) const
227 QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
229 anEdit->setText(_initValue);
232 void SMESHGUI_strParameter::TakeValue (QWidget* theQWidget)
234 QLineEdit* anEdit = dynamic_cast< QLineEdit* >(theQWidget);
236 _newValue = anEdit->text();
239 QString SMESHGUI_strParameter::sigValueChanged() const
241 return SIGNAL( textChanged( const QString& ) );
246 //=================================================================================
247 // class : SMESHGUI_dependParameter
249 //=================================================================================
250 SMESHGUI_dependParameter::SMESHGUI_dependParameter( const QString& label, const bool preview )
251 : SMESHGUI_aParameter( label, preview )
255 const SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap() const
260 SMESHGUI_dependParameter::ShownMap& SMESHGUI_dependParameter::shownMap()
269 //=================================================================================
270 // class : SMESHGUI_enumParameter
272 //=================================================================================
273 SMESHGUI_enumParameter::SMESHGUI_enumParameter( const QStringList& values,
275 const QString& label,
277 : SMESHGUI_dependParameter( label, preview ),
278 myInitValue( initValue ),
279 myValue( initValue ),
284 SMESHGUI_enumParameter::~SMESHGUI_enumParameter()
288 SMESHGUI_aParameter::Type SMESHGUI_enumParameter::GetType() const
290 return SMESHGUI_aParameter::ENUM;
293 bool SMESHGUI_enumParameter::GetNewInt( int& v ) const
296 return myValue!=myInitValue;
299 bool SMESHGUI_enumParameter::GetNewDouble( double& ) const
304 bool SMESHGUI_enumParameter::GetNewText( QString& v ) const
306 bool res = myValue>=0 && myValue<Count();
309 v = myValues[ myValue ];
311 return res && v!=myInitValue;
314 QWidget* SMESHGUI_enumParameter::CreateWidget( QWidget* parent ) const
316 return new QComboBox( parent );
319 void SMESHGUI_enumParameter::InitializeWidget( QWidget* w ) const
321 if( w && w->inherits( "QComboBox" ) )
323 QComboBox* c = ( QComboBox* ) w;
325 c->insertStringList( myValues );
326 c->setCurrentItem( myInitValue );
330 void SMESHGUI_enumParameter::TakeValue( QWidget* w )
332 if( w && w->inherits( "QComboBox" ) )
334 QComboBox* c = ( QComboBox* ) w;
335 myValue = c->currentItem();
339 int SMESHGUI_enumParameter::Count() const
341 return myValues.count();
344 QString SMESHGUI_enumParameter::sigValueChanged() const
346 return SIGNAL( activated( int ) );
350 //=================================================================================
351 // class : SMESHGUI_boolParameter
353 //=================================================================================
354 SMESHGUI_boolParameter::SMESHGUI_boolParameter( const bool initValue,
355 const QString& label,
357 : SMESHGUI_dependParameter( label, preview ),
358 myInitValue( initValue ),
359 myValue( myInitValue )
363 SMESHGUI_boolParameter::~SMESHGUI_boolParameter()
367 SMESHGUI_aParameter::Type SMESHGUI_boolParameter::GetType() const
372 bool SMESHGUI_boolParameter::GetNewInt( int& v ) const
378 return v!=myInitValue;
381 bool SMESHGUI_boolParameter::GetNewDouble( double& ) const
386 bool SMESHGUI_boolParameter::GetNewText( QString& ) const
391 QWidget* SMESHGUI_boolParameter::CreateWidget( QWidget* parent ) const
393 return new QCheckBox( parent );
396 void SMESHGUI_boolParameter::InitializeWidget( QWidget* w ) const
398 if( w && w->inherits( "QCheckBox" ) )
400 QCheckBox* box = ( QCheckBox* )w;
401 box->setChecked( myInitValue );
405 void SMESHGUI_boolParameter::TakeValue( QWidget* w )
407 if( w && w->inherits( "QCheckBox" ) )
409 QCheckBox* box = ( QCheckBox* )w;
410 myValue = box->isChecked();
414 QString SMESHGUI_boolParameter::sigValueChanged() const
416 return SIGNAL( stateChanged( int ) );
422 //=================================================================================
423 // class : SMESHGUI_doubleItem
424 // purpose : Custom table item which contains double and has double validator
425 //=================================================================================
426 class SMESHGUI_doubleItem: public QTableItem
429 SMESHGUI_doubleItem( QTable*, EditType, const double );
430 virtual ~SMESHGUI_doubleItem();
432 void setValidator( const double, const double, const int );
433 void validator( double&, double&, int& );
434 virtual QWidget* createEditor() const;
437 QDoubleValidator* myValidator;
440 SMESHGUI_doubleItem::SMESHGUI_doubleItem( QTable* t, EditType e, const double num )
441 : QTableItem( t, e, QString( "%1" ).arg( num ) ),
442 myValidator( new QDoubleValidator( 0.0, 1.0, 3, t ) )
446 SMESHGUI_doubleItem::~SMESHGUI_doubleItem()
450 void SMESHGUI_doubleItem::setValidator( const double bot, const double top, const int dec )
452 myValidator->setBottom( bot );
453 myValidator->setTop( top );
454 myValidator->setDecimals( dec );
457 void SMESHGUI_doubleItem::validator( double& bot, double& top, int& dec )
459 bot = myValidator->bottom();
460 top = myValidator->top();
461 dec = myValidator->decimals();
464 QWidget* SMESHGUI_doubleItem::createEditor() const
466 QWidget* res = QTableItem::createEditor();
467 if( res && res->inherits( "QLineEdit" ) )
469 QLineEdit* l = ( QLineEdit* )res;
470 l->setValidator( myValidator );
476 //=================================================================================
477 // class : SMESHGUI_Table
479 //=================================================================================
480 SMESHGUI_Table::SMESHGUI_Table( const SMESHGUI_tableParameter* tab, int numRows, int numCols,
481 QWidget* parent, const char* name )
482 : QTable( numRows, numCols, parent, name ),
483 myParam( ( SMESHGUI_tableParameter* )tab )
487 SMESHGUI_Table::~SMESHGUI_Table()
491 QSize SMESHGUI_Table::sizeHint() const
493 if( cachedSizeHint().isValid() )
494 return cachedSizeHint();
498 QSize sh = QScrollView::sizeHint();
501 if( sh.height()<200 )
504 setCachedSizeHint( sh );
508 void SMESHGUI_Table::stopEditing()
510 endEdit( currEditRow(), currEditCol(), false, false );
513 void SMESHGUI_Table::validator( const int row, const int col, double& minV, double& maxV, int& dec )
515 SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( row, col ) );
517 it->validator( minV, maxV, dec );
520 void SMESHGUI_Table::setValidator( const double minV, const double maxV, const int dec,
521 const int rmin, const int rmax,
522 const int cmin, const int cmax )
524 int r1 = rmin>=0 ? rmin : 0,
525 r2 = rmax>=0 ? rmax : numRows(),
526 c1 = cmin>=0 ? cmin : 0,
527 c2 = cmax>=0 ? cmax : numCols();
529 for( int i=r1; i<=r2; i++ )
530 for( int j=c1; j<=c2; j++ )
532 SMESHGUI_doubleItem* it = dynamic_cast<SMESHGUI_doubleItem*>( item( i, j ) );
534 it->setValidator( minV, maxV, dec );
538 bool SMESHGUI_Table::eventFilter( QObject* o, QEvent* e )
540 if( o && e && e->type()==QEvent::KeyPress )
542 QKeyEvent* ke = ( QKeyEvent* )e;
543 if( ke->key()==Qt::Key_Tab || ke->key()==Qt::Key_Backtab || ke->key()==Qt::Key_Return )
550 return QTable::eventFilter( o, e );
553 void SMESHGUI_Table::keyPressEvent( QKeyEvent* e )
557 bool shift = ( e->state() & Qt::ShiftButton );
558 int col = currentColumn(), row = currentRow();
559 if( e->key()==Qt::Key_Tab || e->key()==Qt::Key_Backtab )
561 if( e->key()==Qt::Key_Tab )
584 else if( e->key()==Qt::Key_Return )
593 else if( row>=numRows() )
596 myParam->onEdit( this, SMESHGUI_TableFrame::ADD_ROW, 1 );
600 if( e->isAccepted() )
603 setCurrentCell( row, col );
606 QTable::keyPressEvent( e );
610 QWidget* SMESHGUI_Table::createEditor( int r, int c, bool init ) const
612 QWidget* w = QTable::createEditor( r, c, init );
614 w->installEventFilter( this );
620 //=================================================================================
621 // class : SMESHGUI_TableFrame
623 //=================================================================================
624 SMESHGUI_TableFrame::SMESHGUI_TableFrame( const SMESHGUI_tableParameter* param, QWidget* parent )
627 QVBoxLayout* main = new QVBoxLayout( this, 0, 0 );
629 myTable = new SMESHGUI_Table( param, 1, 1, this );
630 connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SIGNAL( valueChanged( int, int ) ) );
632 QFrame* aButFrame = new QFrame( this );
633 QHBoxLayout* butLay = new QHBoxLayout( aButFrame, 5, 5 );
635 myAddColumn = new QPushButton( "Add column", aButFrame );
637 myRemoveColumn = new QPushButton( "Remove column", aButFrame );
639 myAddRow = new QPushButton( "Add row", aButFrame );
641 myRemoveRow = new QPushButton( "Remove row", aButFrame );
643 butLay->addWidget( myAddColumn, 0 );
644 butLay->addWidget( myRemoveColumn, 0 );
645 butLay->addWidget( myAddRow, 0 );
646 butLay->addWidget( myRemoveRow, 0 );
647 butLay->addStretch( 1 );
649 main->addWidget( myTable, 1 );
650 main->addWidget( aButFrame, 0 );
652 connect( myAddColumn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
653 connect( myRemoveColumn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
654 connect( myAddRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
655 connect( myRemoveRow, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
658 SMESHGUI_TableFrame::~SMESHGUI_TableFrame()
662 SMESHGUI_Table* SMESHGUI_TableFrame::table() const
667 void SMESHGUI_TableFrame::setShown( const Button b, const bool sh )
670 button( b )->setShown( sh );
673 bool SMESHGUI_TableFrame::isShown( const Button b ) const
677 res = button( b )->isShown();
681 QButton* SMESHGUI_TableFrame::button( const Button b ) const
691 res = myRemoveColumn;
705 void SMESHGUI_TableFrame::onButtonClicked()
707 if( sender()==button( ADD_COLUMN ) )
708 emit toEdit( ADD_COLUMN, table()->currentColumn() );
710 else if( sender()==button( REMOVE_COLUMN ) )
711 emit toEdit( REMOVE_COLUMN, table()->currentColumn() );
713 else if( sender()==button( ADD_ROW ) )
714 emit toEdit( ADD_ROW, table()->currentRow() );
716 else if( sender()==button( REMOVE_ROW ) )
717 emit toEdit( REMOVE_ROW, table()->currentRow() );
721 //=================================================================================
722 // class : SMESHGUI_tableParameter
724 //=================================================================================
725 SMESHGUI_tableParameter::SMESHGUI_tableParameter( const double init,
726 const QString& label,
728 : SMESHGUI_aParameter( label, preview ),
737 SMESHGUI_tableParameter::~SMESHGUI_tableParameter()
741 bool operator<( const QPair<double,double>& p1, const QPair<double,double>& p2 )
743 return p1.first < p2.first;
746 void SMESHGUI_tableParameter::sortData( SMESH::double_array& arr )
748 QValueList< QPair<double,double> > aData;
749 if( arr.length()%2==1 )
750 arr.length( arr.length()-1 );
752 int aLen = arr.length();
753 for( int i=0; i<aLen/2; i++ )
754 aData.append( QPair<double,double>( arr[2*i], arr[2*i+1] ) );
758 QValueList< QPair<double,double> >::const_iterator anIt = aData.begin(), aLast = aData.end();
759 QValueList<double> unique_values;
760 double prev; int i=0;
761 if( (*anIt).first>0.0 )
763 unique_values.append( 0.0 );
764 unique_values.append( 0.0 );
767 for( ; anIt!=aLast; anIt++ )
769 if( i==0 || (*anIt).first>prev )
771 unique_values.append( (*anIt).first );
772 unique_values.append( (*anIt).second );
775 prev = (*anIt).first;
779 unique_values.append( 1.0 );
780 unique_values.append( 0.0 );
783 arr.length( unique_values.count() );
784 QValueList<double>::const_iterator anIt1 = unique_values.begin(), aLast1 = unique_values.end();
785 for( int j=0; anIt1!=aLast1; anIt1++, j++ )
789 SMESHGUI_aParameter::Type SMESHGUI_tableParameter::GetType() const
794 bool SMESHGUI_tableParameter::GetNewInt( int& ) const
799 bool SMESHGUI_tableParameter::GetNewDouble( double& ) const
804 bool SMESHGUI_tableParameter::GetNewText( QString& ) const
809 QWidget* SMESHGUI_tableParameter::CreateWidget( QWidget* par ) const
811 SMESHGUI_TableFrame* t = new SMESHGUI_TableFrame( this, par );
812 connect( t, SIGNAL( toEdit( SMESHGUI_TableFrame::Button, int ) ),
813 this, SLOT ( onEdit( SMESHGUI_TableFrame::Button, int ) ) );
819 void SMESHGUI_tableParameter::setItems( QWidget* w,
820 int old_row, int new_row,
821 int old_col, int new_col ) const
823 if( w && w->inherits( "SMESHGUI_TableFrame" ) )
825 QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
830 new_row = tab->numRows();
834 new_col = tab->numCols();
836 for( int i=old_row, m=new_row; i<m; i++ )
837 for( int j=0, n=new_col; j<n; j++ )
838 tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
840 for( int i=0, m=new_row; i<m; i++ )
841 for( int j=old_col, n=new_col; j<n; j++ )
842 tab->setItem( i, j, new SMESHGUI_doubleItem( tab, QTableItem::WhenCurrent, myInitValue ) );
844 for( int j=old_col; j<new_col; j++ )
845 tab->setColumnWidth( j, 50 );
849 void SMESHGUI_tableParameter::InitializeWidget( QWidget* w ) const
853 if( w && w->inherits( "SMESHGUI_TableFrame" ) )
855 SMESHGUI_Table* tab = ( ( SMESHGUI_TableFrame* )w )->table();
858 int col = tab->numCols(),
859 row = tab->numRows();
861 for( int i=0, m=row; i<m; i++ )
862 for( int j=0, n=col; j<n; j++ )
863 if( row*j+i<myData.length() )
864 tab->item( i, j )->setText( QString( "%1" ).arg( myData[col*i+j] ) );
868 void SMESHGUI_tableParameter::TakeValue( QWidget* w )
870 if( w && w->inherits( "SMESHGUI_TableFrame" ) )
872 QTable* tab = ( ( SMESHGUI_TableFrame* )w )->table();
874 int col = tab->numCols(),
875 row = tab->numRows();
877 myData.length( col*row );
878 for( int i=0; i<row; i++ )
879 for( int j=0; j<col; j++ )
880 myData[ col*i+j ] = tab->text( i, j ).toDouble();
884 void SMESHGUI_tableParameter::data( SMESH::double_array& v ) const
890 void SMESHGUI_tableParameter::setData( const SMESH::double_array& d )
896 void SMESHGUI_tableParameter::update( QWidget* w ) const
898 if( w && w->inherits( "SMESHGUI_TableFrame" ) )
900 SMESHGUI_TableFrame* tabfr = ( SMESHGUI_TableFrame* ) w;
901 SMESHGUI_Table* tab = tabfr->table();
903 int old_col = tab->numCols(),
904 old_row = tab->numRows();
906 int col = myColsInt, row = myRowsInt;
908 myCols->GetNewInt( col );
911 myRows->GetNewInt( row );
918 if( col!=tab->numCols() )
919 tab->setNumCols( col );
921 if( row!=tab->numRows() )
922 tab->setNumRows( row );
924 tabfr->setShown( SMESHGUI_TableFrame::ADD_COLUMN, myEditCols );
925 tabfr->setShown( SMESHGUI_TableFrame::REMOVE_COLUMN, myEditCols );
926 tabfr->setShown( SMESHGUI_TableFrame::ADD_ROW, myEditRows );
927 tabfr->setShown( SMESHGUI_TableFrame::REMOVE_ROW, myEditRows );
929 setItems( w, old_row, row, old_col, col );
931 QMap< int, QString >::const_iterator aNIt = myColNames.begin(),
932 aNLast = myColNames.end();
933 for( ; aNIt!=aNLast; aNIt++ )
934 tab->horizontalHeader()->setLabel( aNIt.key(), aNIt.data() );
936 ValidatorsMap::const_iterator anIt = myValidators.begin(),
937 aLast = myValidators.end();
938 for( ; anIt!=aLast; anIt++ )
940 int row = anIt.key(), dec;
942 validator( row, minV, maxV, dec );
943 tab->setValidator( minV, maxV, dec, -1, -1, col, col );
946 QSize s = tab->sizeHint();
947 tab->resize( s.width(), s.height() );
951 void SMESHGUI_tableParameter::setColCount( const int c, QWidget* w )
957 void SMESHGUI_tableParameter::setRowCount( const int c, QWidget* w )
963 void SMESHGUI_tableParameter::setColCount( const SMESHGUI_aParameterPtr p, QWidget* w )
972 void SMESHGUI_tableParameter::setRowCount( const SMESHGUI_aParameterPtr p, QWidget* w )
981 QString SMESHGUI_tableParameter::sigValueChanged() const
983 return SIGNAL( valueChanged( int, int ) );
986 void SMESHGUI_tableParameter::setValidator( const int ind, const double minV, const double maxV, const int dec )
991 inf.myDecimals = dec;
992 myValidators[ ind ] = inf;
995 void SMESHGUI_tableParameter::validator( const int ind, double& minV, double& maxV, int& dec ) const
997 if( myValidators.contains( ind ) )
999 const ValidatorInfo& inf = myValidators[ ind ];
1002 dec = inf.myDecimals;
1006 void SMESHGUI_tableParameter::setEditCols( const bool ed )
1011 void SMESHGUI_tableParameter::setEditRows( const bool ed )
1016 void SMESHGUI_tableParameter::setColName( const int ind, const QString& name )
1018 myColNames.insert( ind, name );
1021 QString SMESHGUI_tableParameter::colName( const int ind ) const
1023 if( myColNames.contains( ind ) )
1024 return myColNames[ ind ];
1026 return QString::null;
1029 void SMESHGUI_tableParameter::onEdit( SMESHGUI_TableFrame::Button b, int n )
1031 if( sender() && sender()->inherits( "SMESHGUI_TableFrame" ) )
1033 SMESHGUI_TableFrame* fr = ( SMESHGUI_TableFrame* )sender();
1034 SMESHGUI_Table* tab = fr->table();
1035 onEdit( tab, b, n );
1039 void SMESHGUI_tableParameter::onEdit( SMESHGUI_Table* tab, SMESHGUI_TableFrame::Button b, int n )
1044 SMESHGUI_TableFrame* fr = dynamic_cast<SMESHGUI_TableFrame*>( tab->parent() );
1048 case SMESHGUI_TableFrame::ADD_COLUMN:
1050 if( !myEditCols || myCols.get() )
1053 myColsInt++; update( fr );
1055 for( int i=0; i<myRowsInt; i++ )
1056 for( int j=myColsInt-1; j>=n; j-- )
1058 tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
1060 tab->setText( i, j, tab->text( i, j-1 ) );
1064 case SMESHGUI_TableFrame::REMOVE_COLUMN:
1066 if( !myEditCols || myCols.get() || myColsInt<=1 )
1070 for( int i=0; i<myRowsInt; i++ )
1071 for( int j=n; j<myColsInt-1; j++ )
1072 tab->setText( i, j, tab->text( i, j+1 ) );
1073 myColsInt--; update( fr );
1078 case SMESHGUI_TableFrame::ADD_ROW:
1080 if( !myEditRows || myRows.get() )
1083 myRowsInt++; update( fr );
1085 for( int i=myRowsInt-1; i>=n; i-- )
1086 for( int j=0; j<myColsInt; j++ )
1088 tab->setText( i, j, QString( "%1" ).arg( myInitValue ) );
1090 tab->setText( i, j, tab->text( i-1, j ) );
1094 case SMESHGUI_TableFrame::REMOVE_ROW:
1096 if( !myEditRows || myRows.get() || myRowsInt<=1 )
1100 for( int i=n; i<myRowsInt-1; i++ )
1101 for( int j=0; j<myColsInt; j++ )
1102 tab->setText( i, j, tab->text( i+1, j ) );
1103 myRowsInt--; update( fr );