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

StdMeshersGUI_LayerDistributionParamWdg Class Reference

Widget controlling hypothesis parameter that is another hypothesis. More...

#include <StdMeshersGUI_LayerDistributionParamWdg.h>

Inheritance diagram for StdMeshersGUI_LayerDistributionParamWdg:
Inheritance graph
[legend]

Public Member Functions

 StdMeshersGUI_LayerDistributionParamWdg (SMESH::SMESH_Hypothesis_ptr, const QString &, QDialog *)
 Constructor initialized by filter.
 ~StdMeshersGUI_LayerDistributionParamWdg ()
 Destructor.
SMESH::SMESH_Hypothesis_var GetHypothesis ()
 Return the hypothesis assigned to the shape.
QString GetValue () const
bool IsOk () const

Private Slots

void onCreate ()
 Show popup with available types.
void onEdit ()
 Edit hypothesis.
void onHypTypePopup (QAction *)
 Create a new hyp of selected type.
void onEdited (int)

Private Member Functions

void init ()
 Create a leayout, initialize fields.
void set (SMESH::SMESH_Hypothesis_ptr)
 initialize fields with hypothesis

Private Attributes

SMESH::SMESH_Hypothesis_var myHyp
SMESHGUImySMESHGUI
QPushButton * myCreateButton
QPushButton * myEditButton
QMenu * myHypTypePopup
QDialogmyDlg
QString myName
QString myParamValue
QStringList myHypTypes

Detailed Description

Widget controlling hypothesis parameter that is another hypothesis.

Definition at line 49 of file StdMeshersGUI_LayerDistributionParamWdg.h.


Constructor & Destructor Documentation

StdMeshersGUI_LayerDistributionParamWdg::StdMeshersGUI_LayerDistributionParamWdg ( SMESH::SMESH_Hypothesis_ptr  hyp,
const QString &  theName,
QDialog dlg 
)

Constructor initialized by filter.

Parameters:
f- object filter

Definition at line 53 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References SMESH_demo_hexa2_upd.hyp.

                                                       : 
  QWidget(), myName(theName), myDlg( dlg )
{
  init();
  set( hyp );
//   if ( IsOk() )
//     onEdit();
}
StdMeshersGUI_LayerDistributionParamWdg::~StdMeshersGUI_LayerDistributionParamWdg ( )

Destructor.

Definition at line 93 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

{
}

Member Function Documentation

const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis ( )

Return the hypothesis assigned to the shape.

Parameters:
aSubShape- the shape to check
aFilter- the hypothesis filter
andAncestors- flag to check hypos assigned to ancestors of the shape
assignedTo- to return the shape the found hypo is assigned to
Return values:
SMESH_Hypothesis*- the first hypo passed through aFilter

Definition at line 59 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by StdMeshersGUI_StdHypothesisCreator.storeParams().

{ return myHyp; }
QString StdMeshersGUI_LayerDistributionParamWdg.GetValue ( ) const
void StdMeshersGUI_LayerDistributionParamWdg::init ( ) [private]

Create a leayout, initialize fields.

Definition at line 103 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References SMESH.GetAvailableHypotheses(), SMESH.GetHypothesisData(), SMESHGUI.GetSMESHGUI(), SMESH.IsAvailableHypothesis(), HypothesisData.Label, myCreateButton, myEditButton, myHypTypePopup, myHypTypes, mySMESHGUI, onCreate(), onEdit(), onHypTypePopup(), SPACING, and HypothesisData.TypeName.

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

  mySMESHGUI = SMESHGUI::GetSMESHGUI();

  myCreateButton = new QPushButton( this );
  myCreateButton->setObjectName( "createBut" );

  myEditButton   = new QPushButton( tr("EDIT"), this );
  myEditButton->setObjectName( "editBut" );

  myHypTypePopup = new QMenu( this );

  // Add to pop-up hypotheses of "Regular_1D" algo
  HypothesisData* algoData = SMESH::GetHypothesisData( "Regular_1D" );
  myHypTypes = SMESH::GetAvailableHypotheses( false, 1 );
  QStringList::const_iterator anIter = myHypTypes.begin();
  for ( ; anIter != myHypTypes.end(); ++anIter )
  {
    HypothesisData* hypData = SMESH::GetHypothesisData( *anIter );
    bool bidon;
    if ( SMESH::IsAvailableHypothesis( algoData, hypData->TypeName, bidon ))
      myHypTypePopup->addAction( hypData->Label );
  }

  aHBox->addWidget( myCreateButton );
  aHBox->addWidget( myEditButton );
  aHBox->addStretch();

  connect( myCreateButton, SIGNAL(clicked()), SLOT(onCreate()));
  connect( myEditButton,   SIGNAL(clicked()), SLOT(onEdit()));
  connect( myHypTypePopup, SIGNAL(triggered( QAction* ) ), SLOT( onHypTypePopup( QAction* ) ) );
}
bool StdMeshersGUI_LayerDistributionParamWdg.IsOk ( ) const

Definition at line 63 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by StdMeshersGUI_StdHypothesisCreator.checkParams().

{ return !myHyp->_is_nil(); }
void StdMeshersGUI_LayerDistributionParamWdg::onCreate ( ) [private, slot]

Show popup with available types.

Definition at line 185 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References myHypTypePopup.

Referenced by init().

{
  myHypTypePopup->exec( QCursor::pos() );
}
void StdMeshersGUI_LayerDistributionParamWdg::onEdit ( ) [private, slot]

Edit hypothesis.

Definition at line 196 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References SMESHGUI_GenericHypothesisCreator.edit(), SMESH.GetHypothesisCreator(), myDlg, myHyp, myName, and onEdited().

Referenced by init(), and onHypTypePopup().

{
  if ( myHyp->_is_nil() )
    return;

  CORBA::String_var hypType = myHyp->GetName();
  // BUG 0020378
  //SMESHGUI_GenericHypothesisCreator* editor = SMESH::GetHypothesisCreator(hypType.in());
  SMESHGUI_GenericHypothesisCreator* editor = SMESH::GetHypothesisCreator(hypType.in());
  if ( !editor ) return;

  if ( myDlg )
    myDlg->hide();

  try {
    QWidget* parent = this;
    if ( myDlg )
      parent = myDlg->parentWidget();
    editor->edit( myHyp, myName, parent, this, SLOT( onEdited( int ) ) );
  }
  catch(...)
  {
  }
}
void StdMeshersGUI_LayerDistributionParamWdg::onEdited ( int  result) [private, slot]

Definition at line 221 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References myDlg.

Referenced by onEdit().

{
  if ( myDlg )
    myDlg->show();
}
void StdMeshersGUI_LayerDistributionParamWdg::onHypTypePopup ( QAction *  a) [private, slot]

Create a new hyp of selected type.

Parameters:
int- selected type index

Definition at line 147 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References SMESH.GetHypothesisData(), SMESHGUI.GetSMESHGen(), HypothesisData.Label, myHypTypes, mySMESHGUI, onEdit(), HypothesisData.ServerLibName, and HypothesisData.TypeName.

Referenced by init().

{
  SMESH::SMESH_Gen_var gen = mySMESHGUI->GetSMESHGen();

  // avoid publishing a new 1D hyp
  gen->SetCurrentStudy( SALOMEDS::Study::_nil() );

  // create a hyp
  HypothesisData* aHypData = 0;
  QStringList::const_iterator anIter = myHypTypes.begin();

  for ( ; !aHypData && anIter != myHypTypes.end(); ++anIter )
  {
    HypothesisData* hypData = SMESH::GetHypothesisData( *anIter );
    if ( a->text() == hypData->Label )
      aHypData = hypData;
  }
  QString aServLib = aHypData->ServerLibName;
  QString aHypType = aHypData->TypeName;
  try {
    set( gen->CreateHypothesis(aHypType.toLatin1().data(), aServLib.toLatin1().data()));
  }
  catch (const SALOME::SALOME_Exception & S_ex) {
    SalomeApp_Tools::QtCatchCorbaException(S_ex);
  }

  // restore current study
  mySMESHGUI->GetSMESHGen();

  onEdit();
}
void StdMeshersGUI_LayerDistributionParamWdg::set ( SMESH::SMESH_Hypothesis_ptr  hyp) [private]

initialize fields with hypothesis

Parameters:
hyp- hypothesis

Definition at line 71 of file StdMeshersGUI_LayerDistributionParamWdg.cxx.

References myCreateButton, myEditButton, myHyp, and myParamValue.

{
  myHyp = SMESH::SMESH_Hypothesis::_nil();
  if ( !CORBA::is_nil( hyp )) {
    myHyp = SMESH::SMESH_Hypothesis::_duplicate( hyp );
    myEditButton->setEnabled( true );
    myCreateButton->setText( tr("CHANGE_TYPE"));
    myParamValue = hyp->GetName();
  }
  else {
    myEditButton->setEnabled( false );
    myCreateButton->setText( tr("CREATE"));
    myParamValue = "";
  }
}

Field Documentation

Definition at line 79 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by init(), and set().

Definition at line 82 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by onEdit(), and onEdited().

Definition at line 80 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by init(), and set().

SMESH::SMESH_Hypothesis_var StdMeshersGUI_LayerDistributionParamWdg.myHyp [private]

Definition at line 76 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by onEdit(), and set().

Definition at line 81 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by init(), and onCreate().

Definition at line 86 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by init(), and onHypTypePopup().

Definition at line 83 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by onEdit().

Definition at line 84 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by set().

Definition at line 77 of file StdMeshersGUI_LayerDistributionParamWdg.h.

Referenced by init(), and onHypTypePopup().

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