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

SMESHGUI_MeshTab Class Reference

Tab for tab widget containing controls for definition of algorithms and hypotheses. More...

#include <SMESHGUI_MeshDlg.h>

Inheritance diagram for SMESHGUI_MeshTab:
Inheritance graph
[legend]

Public Types

enum  HypType { Algo = 0, MainHyp, AddHyp }
 

To differ main algorithms, hypotheses and additional ones.

More...

Signals

void createHyp (const int, const int)
 Emited when "Create hypothesis" button clicked.
void editHyp (const int, const int)
 Emited when "Edit hypothesis" button clicked.
void selectAlgo (const int)
 Emited when an algorithm is selected.

Public Member Functions

 SMESHGUI_MeshTab (QWidget *)
 Tab for tab widget containing controls for definition of algorithms and hypotheses.
virtual ~SMESHGUI_MeshTab ()
 Destructor.
void setAvailableHyps (const int, const QStringList &)
 Sets available hypothesis or algorithms.
void setExistingHyps (const int, const QStringList &)
 Sets existing hypothesis.
void addHyp (const int, const QString &)
 Adds hypothesis in combo box of available ones.
void renameHyp (const int, const int, const QString &)
 Renames hypothesis.
void setCurrentHyp (const int, const int)
 Sets current hypothesis.
int currentHyp (const int) const
 Gets current hypothesis.
void reset ()
 Resets all tab fields.

Private Slots

void onCreateHyp ()
 Emits createHyp( const int ) signal.
void onEditHyp ()
 Emits editHyp( const int ) signal.
void onHyp (int)
 Updates "Edit hypothesis" button state.

Private Attributes

QMap< int, QComboBox * > myHyp
QMap< int, QToolButton * > myCreateHyp
QMap< int, QToolButton * > myEditHyp
QMap< int, QStringList > myAvailableHyps
QMap< int, QStringList > myExistingHyps

Detailed Description

Tab for tab widget containing controls for definition of algorithms and hypotheses.

Definition at line 99 of file SMESHGUI_MeshDlg.h.


Member Enumeration Documentation

To differ main algorithms, hypotheses and additional ones.

Enumerator:
Algo 

algorithms

MainHyp 

main hypothesis

AddHyp 

additional hypothesis

Definition at line 105 of file SMESHGUI_MeshDlg.h.

  { 
    Algo = 0, 
    MainHyp,  
    AddHyp    
  };            

Constructor & Destructor Documentation

SMESHGUI_MeshTab::SMESHGUI_MeshTab ( QWidget theParent)

Tab for tab widget containing controls for definition of algorithms and hypotheses.

Constructor

Parameters:
theParent- Parent widget for this tab

Makes tab's look and feel

Definition at line 62 of file SMESHGUI_MeshDlg.cxx.

References AddHyp, Algo, MainHyp, MARGIN, myCreateHyp, myEditHyp, myHyp, onCreateHyp(), onEditHyp(), onHyp(), setAvailableHyps(), and SPACING.

  : QFrame( theParent )
{
  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
  QIcon aCreateIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO" ) ) );
  QIcon aEditIcon( aResMgr->loadPixmap( "SMESH", tr( "ICON_HYPO_EDIT" ) ) );
  
  // Algorifm
  QLabel* anAlgoLbl = new QLabel( tr( "ALGORITHM" ), this );
  myHyp[ Algo ] = new QComboBox( this );
  
  // Hypothesis
  QLabel* aHypLbl = new QLabel( tr( "HYPOTHESIS" ), this );
  myHyp[ MainHyp ] = new QComboBox( this );
  myHyp[ MainHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
  myCreateHyp[ MainHyp ] = new QToolButton( this );
  myCreateHyp[ MainHyp ]->setIcon( aCreateIcon );
  myEditHyp[ MainHyp ] = new QToolButton( this );
  myEditHyp[ MainHyp ]->setIcon( aEditIcon );
  
  // Line
  QFrame* aLine = new QFrame( this );
  aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken );
  
  // Add. hypothesis
  QLabel* anAddHypLbl = new QLabel( tr( "ADD_HYPOTHESIS" ), this );
  myHyp[ AddHyp ] = new QComboBox( this );
  myHyp[ AddHyp ]->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
  myCreateHyp[ AddHyp ] = new QToolButton( this );
  myCreateHyp[ AddHyp ]->setIcon( aCreateIcon );
  myEditHyp[ AddHyp ] = new QToolButton( this );
  myEditHyp[ AddHyp ]->setIcon( aEditIcon );
  
  // Fill layout
  QGridLayout* aLay = new QGridLayout( this );
  aLay->setMargin( MARGIN );
  aLay->setSpacing( SPACING );

  aLay->addWidget( anAlgoLbl, 0, 0 );
  aLay->addWidget( myHyp[ Algo ], 0, 1 );
  aLay->addWidget( aHypLbl, 1, 0 );
  aLay->addWidget( myHyp[ MainHyp ], 1, 1 );
  aLay->addWidget( myCreateHyp[ MainHyp ], 1, 2 );
  aLay->addWidget( myEditHyp[ MainHyp ], 1, 3 );
  aLay->addWidget( aLine, 2, 0, 1, 4 );
  aLay->addWidget( anAddHypLbl, 3, 0 );
  aLay->addWidget( myHyp[ AddHyp ], 3, 1 );
  aLay->addWidget( myCreateHyp[ AddHyp ], 3, 2 );
  aLay->addWidget( myEditHyp[ AddHyp ], 3, 3 );
  aLay->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ), 4, 0 );
    
  // Connect signals and slots
  for ( int i = MainHyp; i <= AddHyp; i++ )
  {
    connect( myCreateHyp[ i ], SIGNAL( clicked() )       ,  SLOT( onCreateHyp() ) );
    connect( myEditHyp[ i ]  , SIGNAL( clicked() )       ,  SLOT( onEditHyp() ) );
    connect( myHyp[ i ]      , SIGNAL( activated( int ) ),  SLOT( onHyp( int ) ) );
  }
  connect( myHyp[ Algo ], SIGNAL( activated( int ) ), SLOT( onHyp( int ) ) );
  
  // Initialize controls
  
  setAvailableHyps( Algo, QStringList() );
  setAvailableHyps( MainHyp, QStringList() );
  setAvailableHyps( AddHyp, QStringList() );
}
SMESHGUI_MeshTab::~SMESHGUI_MeshTab ( ) [virtual]

Destructor.

Definition at line 134 of file SMESHGUI_MeshDlg.cxx.

{
}

Member Function Documentation

void SMESHGUI_MeshTab::addHyp ( const int  theId,
const QString &  theHyp 
)

Adds hypothesis in combo box of available ones.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
theHyp- name of hypothesis to be added

Adds hypothesis in combo box of available ones. This method is called by operation after creation of new hypothesis.

Definition at line 198 of file SMESHGUI_MeshDlg.cxx.

References myEditHyp, and myHyp.

Referenced by SMESHGUI_MeshOp.onHypoCreated().

{
  myHyp[ theId ]->addItem( theHyp );
  myHyp[ theId ]->setCurrentIndex( myHyp[ theId ]->count() - 1 );
  myEditHyp[ theId ]->setEnabled( true );
  myHyp[ theId ]->setEnabled( true );
}
void SMESHGUI_MeshTab.createHyp ( const int  ,
const int   
) [signal]

Emited when "Create hypothesis" button clicked.

Referenced by onCreateHyp().

int SMESHGUI_MeshTab::currentHyp ( const int  theId) const

Gets current hypothesis.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
Return values:
int- index of current hypothesis

Gets current hypothesis

Definition at line 252 of file SMESHGUI_MeshDlg.cxx.

References myHyp.

Referenced by SMESHGUI_MeshOp.currentHyp().

{
  return myHyp[ theId ]->currentIndex();
}
void SMESHGUI_MeshTab.editHyp ( const int  ,
const int   
) [signal]

Emited when "Edit hypothesis" button clicked.

Referenced by onEditHyp().

void SMESHGUI_MeshTab::onCreateHyp ( ) [private, slot]

Emits createHyp( const int ) signal.

SLOT called when "Create hypothesis" button clicked specifies sender and emits createHyp( const int ) signal

Definition at line 265 of file SMESHGUI_MeshDlg.cxx.

References SMESH_demo_hexa2_upd.a, AddHyp, createHyp(), MainHyp, myAvailableHyps, and myCreateHyp.

Referenced by SMESHGUI_MeshTab().

{
  bool isMainHyp = sender() == myCreateHyp[ MainHyp ];

  QMenu aPopup( this );
  
  QStringList aHypNames = isMainHyp ? 
    myAvailableHyps[ MainHyp ] : myAvailableHyps[ AddHyp ];

  QList<QAction*> actions;
  for ( int i = 0, n = aHypNames.count(); i < n; i++ )
    actions.append( aPopup.addAction( aHypNames[ i ] ) );

  QAction* a = aPopup.exec( QCursor::pos() );
  if ( a )
    emit createHyp( isMainHyp ? MainHyp : AddHyp, actions.indexOf( a ) );
}
void SMESHGUI_MeshTab::onEditHyp ( ) [private, slot]

Emits editHyp( const int ) signal.

SLOT called when "Edit hypothesis" button clicked specifies sender and emits editHyp( const int ) signal

Definition at line 291 of file SMESHGUI_MeshDlg.cxx.

References AddHyp, editHyp(), MainHyp, myEditHyp, and myHyp.

Referenced by SMESHGUI_MeshTab().

{
  const QObject* aSender = sender();
  int aHypType = aSender == myEditHyp[ MainHyp ] ? MainHyp : AddHyp;
  emit editHyp( aHypType, myHyp[ aHypType ]->currentIndex() - 1 );  // - 1 because there is NONE on the top
}
void SMESHGUI_MeshTab::onHyp ( int  theIndex) [private, slot]

Updates "Edit hypothesis" button state.

SLOT called when current hypothesis changed. Disables "Edit hypothesis" button if current hypothesis is <None>, enables otherwise. If an algorithm changed, emits selectAlgo( theIndex ) signal

Definition at line 307 of file SMESHGUI_MeshDlg.cxx.

References AddHyp, Algo, MainHyp, myEditHyp, myHyp, and selectAlgo().

Referenced by SMESHGUI_MeshTab().

{
  const QObject* aSender = sender();
  if ( aSender == myHyp[ Algo ] )
    emit selectAlgo( theIndex - 1 ); // - 1 because there is NONE on the top
  else {
    int anIndex = aSender == myHyp[ MainHyp ] ? MainHyp : AddHyp;
    myEditHyp[ anIndex ]->setEnabled( theIndex > 0 );
  }
}
void SMESHGUI_MeshTab::renameHyp ( const int  theId,
const int  theIndex,
const QString &  theNewName 
)

Renames hypothesis.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
theIndex- index of hypothesis to be renamed
theNewName- new name of hypothesis to be renamed

Renames hypothesis

Definition at line 216 of file SMESHGUI_MeshDlg.cxx.

References myHyp.

{
  if ( theIndex > 0 && theIndex < myHyp[ theId ]->count() )
    myHyp[ theId ]->setItemText( theIndex, theNewName );
}                                  
void SMESHGUI_MeshTab::reset ( )

Resets all tab fields.

Resets all tab fields

Definition at line 325 of file SMESHGUI_MeshDlg.cxx.

References AddHyp, Algo, myEditHyp, and myHyp.

{
  for ( int i = Algo; i <= AddHyp; i++ )
  {
    myHyp[ i ]->setCurrentIndex( 0 );
    if ( myEditHyp[ i ] )
      myEditHyp[ i ]->setEnabled( false );
  }
}
void SMESHGUI_MeshTab.selectAlgo ( const int  ) [signal]

Emited when an algorithm is selected.

Referenced by onHyp().

void SMESHGUI_MeshTab::setAvailableHyps ( const int  theId,
const QStringList &  theHyps 
)

Sets available hypothesis or algorithms.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
theHyps- list of available hypothesis names

Sets available main or additional hypothesis for this tab

Definition at line 147 of file SMESHGUI_MeshDlg.cxx.

References Algo, myAvailableHyps, myCreateHyp, myEditHyp, and myHyp.

Referenced by SMESHGUI_MeshOp.onAlgoSelected(), SMESHGUI_MeshOp.processSet(), SMESHGUI_MeshOp.selectionDone(), SMESHGUI_MeshTab(), and SMESHGUI_MeshOp.startOperation().

{
  myAvailableHyps[ theId ] = theHyps;

  bool enable = ! theHyps.isEmpty();
  if ( theId == Algo )
  {
    myHyp[ Algo ]->clear();
    myHyp[ Algo ]->addItem( tr( "NONE" ) );
    myHyp[ Algo ]->addItems( theHyps );
    myHyp[ Algo ]->setCurrentIndex( 0 );
  }
  else {
    myCreateHyp[ theId ]->setEnabled( enable );
    myEditHyp[ theId ]->setEnabled( false );
  }
  myHyp[ theId ]->setEnabled( enable );
}
void SMESHGUI_MeshTab::setCurrentHyp ( const int  theId,
const int  theIndex 
)

Sets current hypothesis.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
theIndex- index of hypothesis to be set as current

Sets current hypothesis

Definition at line 233 of file SMESHGUI_MeshDlg.cxx.

References myEditHyp, and myHyp.

Referenced by SMESHGUI_MeshOp.setCurrentHyp().

{
  if ( theIndex >= 0 && theIndex < myHyp[ theId ]->count() )
  {
    myHyp[ theId ]->setCurrentIndex( theIndex );
    if ( myEditHyp[ theId ] )
      myEditHyp[ theId ]->setEnabled( theIndex > 0 );
  }
}
void SMESHGUI_MeshTab::setExistingHyps ( const int  theId,
const QStringList &  theHyps 
)

Sets existing hypothesis.

Parameters:
theId- identifier of hypothesis (main or additional, see HypType enumeration)
theHyps- list of available hypothesis names

Sets existing main or additional hypothesis for this tab

Definition at line 175 of file SMESHGUI_MeshDlg.cxx.

References Algo, myEditHyp, and myHyp.

Referenced by SMESHGUI_MeshOp.onAlgoSelected(), SMESHGUI_MeshOp.readMesh(), and SMESHGUI_MeshOp.startOperation().

{
  if ( theId != Algo )
  {
    myHyp[ theId ]->clear();
    myHyp[ theId ]->addItem( tr( "NONE" ) );
    myHyp[ theId ]->addItems( theHyps );
    myHyp[ theId ]->setCurrentIndex( 0 );
    myHyp[ theId ]->setEnabled( !theHyps.isEmpty() );
    myEditHyp[ theId ]->setEnabled( false );
  }
}

Field Documentation

QMap<int, QStringList> SMESHGUI_MeshTab.myAvailableHyps [private]

Definition at line 142 of file SMESHGUI_MeshDlg.h.

Referenced by onCreateHyp(), and setAvailableHyps().

QMap<int, QToolButton*> SMESHGUI_MeshTab.myCreateHyp [private]

Definition at line 139 of file SMESHGUI_MeshDlg.h.

Referenced by onCreateHyp(), setAvailableHyps(), and SMESHGUI_MeshTab().

QMap<int, QToolButton*> SMESHGUI_MeshTab.myEditHyp [private]
QMap<int, QStringList> SMESHGUI_MeshTab.myExistingHyps [private]

Definition at line 143 of file SMESHGUI_MeshDlg.h.

QMap<int, QComboBox*> SMESHGUI_MeshTab.myHyp [private]
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