Back to index

salome-smesh  6.5.0
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
StdMeshersGUI_DistrTableFrame::Table Class Reference

Table function widget. More...

Collaboration diagram for StdMeshersGUI_DistrTableFrame::Table:
Collaboration graph
[legend]

List of all members.

Classes

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

Detailed Description

Table function widget.

Definition at line 109 of file StdMeshersGUI_DistrTable.cxx.


Constructor & Destructor Documentation

StdMeshersGUI_DistrTableFrame::Table::Table ( QWidget *  parent,
int  rows = 2 
)

Definition at line 238 of file StdMeshersGUI_DistrTable.cxx.

  : 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 );
}

Here is the call graph for this function:

Definition at line 267 of file StdMeshersGUI_DistrTable.cxx.

{
}

Member Function Documentation

Definition at line 430 of file StdMeshersGUI_DistrTable.cxx.

{
  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 ) ) );
}

Here is the caller graph for this function:

Definition at line 343 of file StdMeshersGUI_DistrTable.cxx.

{
  // for the last row the maximum value is always 1.0
  // for the other rows the maxumum value is the below row's value
  double val = 1.0;
  if ( r >= 0 && r < rowCount()-1 ) {
    val = value( r+1, ArgColumn );
  }
  return val;
}

Here is the caller graph for this function:

Definition at line 331 of file StdMeshersGUI_DistrTable.cxx.

{
  // for the first row the minimum value is always 0.0
  // for the other rows the minumum value is the above row's value
  double val = 0.0;
  if ( r > 0 && r < rowCount() )
    val = value( r-1, ArgColumn );
  return val;
}

Here is the caller graph for this function:

Definition at line 356 of file StdMeshersGUI_DistrTable.cxx.

{
  // correct this to provide more smart behaviour if needed
  return 0.1;
}

Here is the caller graph for this function:

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.

Definition at line 273 of file StdMeshersGUI_DistrTable.cxx.

{
  closePersistentEditor( currentItem() );

  QList<double> d;
  for ( int r = 0; r < rowCount(); r++ ) {
    d.append( value( r, ArgColumn ) );
    d.append( value( r, FuncColumn ) );
  }
  return d;
}

Here is the caller graph for this function:

Definition at line 444 of file StdMeshersGUI_DistrTable.cxx.

{
  QList<int> selRows = selectedRows();
  for ( int r = selRows.count()-1; r >= 0; r-- )
    removeRow( r );
}

Here is the caller graph for this function:

Definition at line 372 of file StdMeshersGUI_DistrTable.cxx.

{
  // correct this to provide more smart behaviour if needed
  return 1e20;
}

Here is the caller graph for this function:

Definition at line 364 of file StdMeshersGUI_DistrTable.cxx.

{
  // correct this to provide more smart behaviour if needed
  return myFuncMin;
}

Here is the caller graph for this function:

Definition at line 380 of file StdMeshersGUI_DistrTable.cxx.

{
  // correct this to provide more smart behaviour if needed
  return 1.0;
}

Here is the caller graph for this function:

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.

{
  Table* that = const_cast<Table*>( this );
  that->myCachedSizeHint = s;
}
void StdMeshersGUI_DistrTableFrame::Table::setData ( const QList< double > &  d)

Definition at line 287 of file StdMeshersGUI_DistrTable.cxx.

{
  closePersistentEditor( currentItem() );

  setRowCount( d.count() / 2 );
  for ( int r = 0; r < rowCount(); r++ ) {
    setValue( r, ArgColumn,  d[r*2]   );
    setValue( r, FuncColumn, d[r*2+1] );
  }
}

Here is the caller graph for this function:

void StdMeshersGUI_DistrTableFrame::Table::setEditor ( int  r,
int  c,
SMESHGUI_SpinBox *  sb 
)

Definition at line 259 of file StdMeshersGUI_DistrTable.cxx.

Here is the caller graph for this function:

Definition at line 388 of file StdMeshersGUI_DistrTable.cxx.

{
  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 ) );
  }
}

Here is the caller graph for this function:

void StdMeshersGUI_DistrTableFrame::Table::setUpRows ( bool  autoset = false) [private]

Definition at line 461 of file StdMeshersGUI_DistrTable.cxx.

{
  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
  }
}

Here is the caller graph for this function:

void StdMeshersGUI_DistrTableFrame::Table::setValue ( int  r,
int  c,
double  v 
)

Definition at line 310 of file StdMeshersGUI_DistrTable.cxx.

{
  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 ) );
}

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;
}
double StdMeshersGUI_DistrTableFrame::Table::value ( int  r,
int  c 
) const

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();
}

Member Data Documentation

Definition at line 157 of file StdMeshersGUI_DistrTable.cxx.

Definition at line 158 of file StdMeshersGUI_DistrTable.cxx.

Definition at line 156 of file StdMeshersGUI_DistrTable.cxx.


The documentation for this class was generated from the following file: