Table function widget. More...

Data Structures | |
| struct | EditorData |
Public Member Functions | |
| Table (QWidget *, int=2) | |
| ~Table () | |
| QList< double > | data () |
| void | setData (const QList< double > &) |
| double | value (int, int) const |
| void | setValue (int, int, double) |
| double | argMinimum (int) const |
| double | argMaximum (int) const |
| double | argStep (int) const |
| double | funcMinimum (int) const |
| double | funcMaximum (int) const |
| double | funcStep (int) const |
| void | setFuncMinValue (double) |
| QSize | sizeHint () const |
| void | addRow () |
| void | deleteRow () |
| void | setEditor (int, int, SMESHGUI_SpinBox *) |
Protected Member Functions | |
| void | closeEditor (QWidget *, QAbstractItemDelegate::EndEditHint) |
Private Member Functions | |
| void | setUpRows (bool=false) |
| QSize | cachedSizeHint () const |
| void | setCachedSizeHint (const QSize &) const |
| QList< int > | selectedRows () |
Private Attributes | |
| double | myFuncMin |
| QSize | myCachedSizeHint |
| EditorData | myEditorData |
Table function widget.
Definition at line 109 of file StdMeshersGUI_DistrTable.cxx.
Definition at line 238 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.Table.addRow(), and StdMeshersGUI_DistrTableFrame.Table.setUpRows().
: QTableWidget( parent ), myFuncMin( 0.0 ) { setItemDelegate( new StdMeshersGUI_DistrTableFrame::SpinBoxDelegate( this ) ); setColumnCount( 2 ); QStringList labs; labs << "t" << "f(t)"; setHorizontalHeaderLabels( labs ); this->horizontalHeader()->setStretchLastSection(true); this->horizontalHeader()->setDefaultSectionSize(60); while( rows-- ) addRow(); setUpRows( true ); }
| StdMeshersGUI_DistrTableFrame.Table::~Table | ( | ) |
Definition at line 267 of file StdMeshersGUI_DistrTable.cxx.
{
}
| void StdMeshersGUI_DistrTableFrame.Table::addRow | ( | ) |
Definition at line 430 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn, and StdMeshersGUI_DistrTableFrame.FuncColumn.
Referenced by StdMeshersGUI_DistrTableFrame.onInsert(), and StdMeshersGUI_DistrTableFrame.Table.Table().
{
int r = currentRow() >= 0 ? currentRow() : ( rowCount() > 0 ? rowCount() - 1 : 0 );
insertRow( r );
double argMin = argMinimum( r );
double funcMin = funcMinimum( r );
setItem( r, ArgColumn, new QTableWidgetItem( QString::number( argMin ) ) );
setItem( r, FuncColumn, new QTableWidgetItem( QString::number( funcMin ) ) );
}
| double StdMeshersGUI_DistrTableFrame.Table::argMaximum | ( | int | r | ) | const |
Definition at line 343 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
| double StdMeshersGUI_DistrTableFrame.Table::argMinimum | ( | int | r | ) | const |
Definition at line 331 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
| double StdMeshersGUI_DistrTableFrame.Table::argStep | ( | int | ) | const |
Definition at line 356 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
{
// correct this to provide more smart behaviour if needed
return 0.1;
}
| QSize StdMeshersGUI_DistrTableFrame.Table::cachedSizeHint | ( | ) | const [private] |
Definition at line 478 of file StdMeshersGUI_DistrTable.cxx.
{
return myCachedSizeHint;
}
| void StdMeshersGUI_DistrTableFrame.Table::closeEditor | ( | QWidget * | editor, |
| QAbstractItemDelegate::EndEditHint | hint | ||
| ) | [protected] |
Definition at line 453 of file StdMeshersGUI_DistrTable.cxx.
{
myEditorData.reset();
QTableWidget::closeEditor( editor, hint );
}
| QList< double > StdMeshersGUI_DistrTableFrame.Table::data | ( | ) |
Definition at line 273 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn, ex13_hole1partial.d, and StdMeshersGUI_DistrTableFrame.FuncColumn.
Referenced by StdMeshersGUI_DistrTableFrame.data().
| void StdMeshersGUI_DistrTableFrame.Table::deleteRow | ( | ) |
Definition at line 444 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.onRemove().
{
QList<int> selRows = selectedRows();
for ( int r = selRows.count()-1; r >= 0; r-- )
removeRow( r );
}
| double StdMeshersGUI_DistrTableFrame.Table::funcMaximum | ( | int | ) | const |
Definition at line 372 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
{
// correct this to provide more smart behaviour if needed
return 1e20;
}
| double StdMeshersGUI_DistrTableFrame.Table::funcMinimum | ( | int | ) | const |
Definition at line 364 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
{
// correct this to provide more smart behaviour if needed
return myFuncMin;
}
| double StdMeshersGUI_DistrTableFrame.Table::funcStep | ( | int | ) | const |
Definition at line 380 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
{
// correct this to provide more smart behaviour if needed
return 1.0;
}
| QList< int > StdMeshersGUI_DistrTableFrame.Table::selectedRows | ( | ) | [private] |
Definition at line 493 of file StdMeshersGUI_DistrTable.cxx.
{
QList<int> l;
QList<QTableWidgetItem*> selItems = selectedItems();
QTableWidgetItem* i;
foreach( i, selItems )
if ( !l.contains( i->row() ) ) l.append( i->row() );
qSort( l );
return l;
}
| void StdMeshersGUI_DistrTableFrame.Table::setCachedSizeHint | ( | const QSize & | s | ) | const [private] |
Definition at line 485 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.Table.myCachedSizeHint.
| void StdMeshersGUI_DistrTableFrame.Table::setData | ( | const QList< double > & | d | ) |
Definition at line 287 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn, and StdMeshersGUI_DistrTableFrame.FuncColumn.
Referenced by StdMeshersGUI_DistrTableFrame.setData().
| void StdMeshersGUI_DistrTableFrame.Table::setEditor | ( | int | r, |
| int | c, | ||
| SMESHGUI_SpinBox * | sb | ||
| ) |
Definition at line 259 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.SpinBoxDelegate.createEditor().
{
myEditorData.r = r;
myEditorData.c = c;
myEditorData.sb = sb;
}
| void StdMeshersGUI_DistrTableFrame.Table::setFuncMinValue | ( | double | val | ) |
Definition at line 388 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.FuncColumn.
Referenced by StdMeshersGUI_DistrTableFrame.setFuncMinValue().
{
myFuncMin = val;
QTableWidgetItem* i = currentItem();
if ( i &&
i->row() == myEditorData.r &&
i->column() == myEditorData.c &&
i->column() == FuncColumn &&
myEditorData.sb ) {
myEditorData.sb->setMinimum( myFuncMin );
}
else {
closePersistentEditor( currentItem() );
}
for ( int r = 0; r < rowCount(); r++ ) {
double v = item( r, FuncColumn )->text().toDouble();
if ( v < myFuncMin )
item( r, FuncColumn )->setText( QString::number( myFuncMin ) );
}
}
| void StdMeshersGUI_DistrTableFrame.Table::setUpRows | ( | bool | autoset = false | ) | [private] |
Definition at line 461 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn.
Referenced by StdMeshersGUI_DistrTableFrame.Table.Table().
{
if ( rowCount() < 1 )
return;
if ( autoset ) {
double s = argMaximum( rowCount()-1 ) / rowCount();
for ( int r = 0; r < rowCount()-1; r++ )
setValue( r, ArgColumn, r * s );
setValue( rowCount()-1, ArgColumn, argMaximum( rowCount()-1 ) );
}
else {
// TODO
}
}
Definition at line 310 of file StdMeshersGUI_DistrTable.cxx.
References StdMeshersGUI_DistrTableFrame.ArgColumn, and StdMeshersGUI_DistrTableFrame.FuncColumn.
{
if ( r < 0 || r > rowCount() || c < 0 || c > columnCount() )
return;
if ( c == FuncColumn && v < funcMinimum( r ) )
v = funcMinimum( r ); // correct func value according to the valid min value
if ( c == FuncColumn && v > funcMaximum( r ) )
v = funcMaximum( r ); // correct func value according to the valid max value
else if ( r == ArgColumn && v < argMinimum( r ) )
v = argMinimum( r ); // correct arg value according to the valid min value
else if ( r == ArgColumn && v > argMaximum( r ) )
v = argMaximum( r ); // correct arg value according to the valid max value
if ( !item( r, c ) )
setItem( r, c, new QTableWidgetItem );
item( r, c )->setText( QString::number( v ) );
}
| QSize StdMeshersGUI_DistrTableFrame.Table::sizeHint | ( | ) | const |
Definition at line 413 of file StdMeshersGUI_DistrTable.cxx.
{
if( cachedSizeHint().isValid() )
return cachedSizeHint();
return QTableWidget::sizeHint();
// QSize sh = QTableWidget::sizeHint();
// if( sh.width() < 400 )
// sh.setWidth( 400 );
// if( sh.height() < 200 )
// sh.setHeight( 200 );
//
// setCachedSizeHint( sh );
// return sh;
}
Definition at line 300 of file StdMeshersGUI_DistrTable.cxx.
{
if ( r < 0 || r > rowCount() || c < 0 || c > columnCount() || !item( r, c ) )
return 0.0;
return item( r, c )->text().toDouble();
}
QSize StdMeshersGUI_DistrTableFrame.Table.myCachedSizeHint [private] |
Definition at line 157 of file StdMeshersGUI_DistrTable.cxx.
Referenced by StdMeshersGUI_DistrTableFrame.Table.setCachedSizeHint().
Definition at line 158 of file StdMeshersGUI_DistrTable.cxx.
double StdMeshersGUI_DistrTableFrame.Table.myFuncMin [private] |
Definition at line 156 of file StdMeshersGUI_DistrTable.cxx.