Version: 6.3.1
Public Types | Public Member Functions | Private Attributes

SMESHGUI_FilterTable.AdditionalWidget Class Reference

Inheritance diagram for SMESHGUI_FilterTable.AdditionalWidget:
Inheritance graph
[legend]

Public Types

enum  { Tolerance }

Public Member Functions

 AdditionalWidget (QWidget *theParent)
virtual ~AdditionalWidget ()
virtual QList< intGetParameters () const
virtual bool IsValid (const bool=true) const
virtual double GetDouble (const int) const
virtual int GetInteger (const int) const
virtual QString GetString (const int) const
virtual void SetDouble (const int, const double)
virtual void SetInteger (const int, const int)
virtual void SetString (const int, const QString &)
void SetEditable (const int, const bool)
void SetEditable (const bool)
void SetPrecision (const int, const char *=0)

Private Attributes

QMap< int, QWidget * > myWidgets

Detailed Description

Definition at line 147 of file SMESHGUI_FilterDlg.cxx.


Member Enumeration Documentation

anonymous enum
Enumerator:
Tolerance 

Definition at line 150 of file SMESHGUI_FilterDlg.cxx.

{ Tolerance };

Constructor & Destructor Documentation

SMESHGUI_FilterTable.AdditionalWidget::AdditionalWidget ( QWidget theParent)

Definition at line 172 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI_FilterTable.AdditionalWidget.myWidgets, SMESHGUI_SpinBox.RangeStepAndValidator(), SMESHGUI_FilterTable.AdditionalWidget.SetDouble(), SPACING, and SMESHGUI_FilterTable.AdditionalWidget.Tolerance.

  : QWidget(theParent)
{
  QLabel* aLabel = new QLabel(tr("SMESH_TOLERANCE"), this);

  SMESHGUI_SpinBox* sb = new SMESHGUI_SpinBox(this);
  sb->setAcceptNames( false ); // No Notebook variables allowed
  sb->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
  sb->RangeStepAndValidator( 0., 1.e20, 0.1, "len_tol_precision" );
  myWidgets[ Tolerance ] = sb;

  QHBoxLayout* aLay = new QHBoxLayout(this);
  aLay->setSpacing(SPACING);
  aLay->setMargin(0);

  aLay->addWidget(aLabel);
  aLay->addWidget(myWidgets[ Tolerance ]);
  aLay->addStretch();

  SetDouble( Tolerance, Precision::Confusion() );
}
SMESHGUI_FilterTable.AdditionalWidget::~AdditionalWidget ( ) [virtual]

Definition at line 194 of file SMESHGUI_FilterDlg.cxx.

{
}

Member Function Documentation

double SMESHGUI_FilterTable.AdditionalWidget::GetDouble ( const int  theId) const [virtual]

Definition at line 232 of file SMESHGUI_FilterDlg.cxx.

{
  double retval = 0;
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text().toDouble();
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      retval = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue();
  }
  return retval;
}
int SMESHGUI_FilterTable.AdditionalWidget::GetInteger ( const int  theId) const [virtual]

Definition at line 244 of file SMESHGUI_FilterDlg.cxx.

{
  int retval = 0;
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text().toInt();
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      retval = (int)( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue() );
  }
  return retval;
}
QList< int > SMESHGUI_FilterTable.AdditionalWidget::GetParameters ( ) const [virtual]

Definition at line 198 of file SMESHGUI_FilterDlg.cxx.

{
  QList<int> theList;
  theList.append(Tolerance);
  return theList;
}
QString SMESHGUI_FilterTable.AdditionalWidget::GetString ( const int  theId) const [virtual]

Definition at line 256 of file SMESHGUI_FilterDlg.cxx.

{
  QString retval = "";
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      retval = qobject_cast<QLineEdit*>( myWidgets[ theId ] )->text();
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      retval = QString::number( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->GetValue() );
  }
  return retval;
}
bool SMESHGUI_FilterTable.AdditionalWidget::IsValid ( const bool  theMsg = true) const [virtual]

Definition at line 205 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI.desktop().

{
  if (!isEnabled())
    return true;

  QList<int> aParams = GetParameters();
  QList<int>::const_iterator anIter;
  for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter) {
    if ( !myWidgets.contains( *anIter ) ) continue;
    bool valid = true;
    if ( qobject_cast<QLineEdit*>( myWidgets[ *anIter ] ) ) {
      valid = qobject_cast<QLineEdit*>( myWidgets[ *anIter ] )->hasAcceptableInput();
    }
    else if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ *anIter ] ) ) {
      QString foo;
      valid = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ *anIter ] )->isValid( foo, false );
    }
    if (!valid && theMsg) {
      SUIT_MessageBox::information(SMESHGUI::desktop(), tr("SMESH_INSUFFICIENT_DATA"),
                                   tr("SMESHGUI_INVALID_PARAMETERS"));
      return false;
    }
  }

  return true;
}
void SMESHGUI_FilterTable.AdditionalWidget::SetDouble ( const int  theId,
const double  theVal 
) [virtual]

Definition at line 268 of file SMESHGUI_FilterDlg.cxx.

References SMESH.SetValue().

Referenced by SMESHGUI_FilterTable.AdditionalWidget.AdditionalWidget().

{
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( QString::number( theVal ) );
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( theVal );
  }
}
void SMESHGUI_FilterTable.AdditionalWidget::SetEditable ( const int  theId,
const bool  isEditable 
)

Definition at line 298 of file SMESHGUI_FilterDlg.cxx.

{
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setReadOnly( !isEditable );
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->setReadOnly( !isEditable );
  }
}
void SMESHGUI_FilterTable.AdditionalWidget::SetEditable ( const bool  isEditable)

Definition at line 308 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI_FilterTable.SetEditable().

{
  QList<int> aParams = GetParameters();
  QList<int>::const_iterator anIter;
  for (anIter = aParams.begin(); anIter != aParams.end(); ++anIter)
    SetEditable( *anIter,  isEditable );
}
void SMESHGUI_FilterTable.AdditionalWidget::SetInteger ( const int  theId,
const int  theVal 
) [virtual]

Definition at line 278 of file SMESHGUI_FilterDlg.cxx.

References SMESH.SetValue().

{
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( QString::number( theVal ) );
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( (double)theVal );
  }
}
void SMESHGUI_FilterTable.AdditionalWidget::SetPrecision ( const int  theId,
const char *  precision = 0 
)

Definition at line 316 of file SMESHGUI_FilterDlg.cxx.

References SMESHGUI_SpinBox.GetValue(), SMESHGUI_SpinBox.RangeStepAndValidator(), and SMESHGUI_SpinBox.SetValue().

{
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) ) {
      SMESHGUI_SpinBox* sb = qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] );
      double val = sb->GetValue();
      double min = pow(10.0, -(sb->decimals()));
      sb->RangeStepAndValidator( 0., 1.e20, 0.1, precision ? precision : "len_tol_precision" );
      sb->SetValue( qMax( val, min ) );
    }
  }
}
void SMESHGUI_FilterTable.AdditionalWidget::SetString ( const int  theId,
const QString &  theVal 
) [virtual]

Definition at line 288 of file SMESHGUI_FilterDlg.cxx.

References SMESH.SetValue().

{
  if ( myWidgets.contains( theId ) ) {
    if ( qobject_cast<QLineEdit*>( myWidgets[ theId ] ) )
      qobject_cast<QLineEdit*>( myWidgets[ theId ] )->setText( theVal );
    if ( qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] ) )
      qobject_cast<SMESHGUI_SpinBox*>( myWidgets[ theId ] )->SetValue( theVal.toDouble() );
  }
}

Field Documentation

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