Version: 6.3.1
Data Structures | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

StdMeshersGUI_DistrTableFrame.Table Class Reference

Table function widget. More...

Inheritance diagram for StdMeshersGUI_DistrTableFrame.Table:
Inheritance graph
[legend]

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< intselectedRows ()

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.

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.

{
}

Member Function Documentation

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().

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

{
  // 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;
}
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.

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().

{
  closePersistentEditor( currentItem() );

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

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

References StdMeshersGUI_DistrTableFrame.ArgColumn, and StdMeshersGUI_DistrTableFrame.FuncColumn.

Referenced by StdMeshersGUI_DistrTableFrame.setData().

{
  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] );
  }
}
void StdMeshersGUI_DistrTableFrame.Table::setEditor ( int  r,
int  c,
SMESHGUI_SpinBox 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
  }
}
void StdMeshersGUI_DistrTableFrame.Table::setValue ( int  r,
int  c,
double  v 
)

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

Field Documentation

Definition at line 158 of file StdMeshersGUI_DistrTable.cxx.

Definition at line 156 of file StdMeshersGUI_DistrTable.cxx.

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS