Version: 6.3.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes

SMESHGUI_MeshOp Class Reference

Operation for mech creation or editing. More...

#include <SMESHGUI_MeshOp.h>

Inheritance diagram for SMESHGUI_MeshOp:
Inheritance graph
[legend]

Public Types

enum  HypType { Algo = 0, MainHyp, AddHyp, NbHypTypes }
typedef std::pair
< SMESH::SMESH_Hypothesis_var,
QString > 
THypItem
typedef QList< THypItemTHypList
typedef int THypType
typedef QMap< THypType, THypListTType2HypList
typedef int THypDim
typedef QMap< THypDim,
TType2HypList
TDim2Type2HypList
typedef QList< intIdList

Public Member Functions

 SMESHGUI_MeshOp (const bool, const bool=true)
 Constructor.
virtual ~SMESHGUI_MeshOp ()
 Destructor.
virtual LightApp_Dialogdlg () const
 Gets dialog of this operation.

Static Public Member Functions

static void extractIds (const QStringList &, IdList &, const QChar)

Protected Types

enum  EntityType { Object, MeshNode, MeshElement }

Protected Slots

virtual bool onApply ()
 Creates or edits mesh.
void onCreateHyp (const int, const int)
 Create hypothesis.
void onEditHyp (const int, const int)
 Calls plugin methods for hypothesis editing.
void onHypoSet (const QString &)
 Creates and selects hypothesis of hypotheses set.
void onGeomSelectionByMesh (bool)
 SLOT.
void onPublishShapeByMeshDlg (SUIT_Operation *)
 SLOT.
void onCloseShapeByMeshDlg (SUIT_Operation *)
 SLOT.
void onAlgoSelected (const int, const int=-1)
 Set available algos and hypos according to the selected algorithm.
void processSet ()
 One step of hypothesis/algorithm list creation.
void onHypoCreated (int)
 Necessary steps after hypothesis creation.
void onHypoEdited (int)
 Necessary steps after hypothesis edition.
virtual void onActivateObject (int)
 Installs filter corresponding to certain object selection widget.
virtual void onDeactivateObject (int)
 Removes filter corresponding to certain object selection widget.
virtual void onSelectionChanged (int)
 Empty default implementation.
virtual void onTextChanged (int, const QStringList &)
 Default implementation allowing user to edit selected ids "by hands".
virtual void onOk ()
virtual void onCancel ()
void onHelp ()

Protected Member Functions

virtual void startOperation ()
 Creates dialog if necessary and shows it.
virtual void commitOperation ()
 Selects a recently created mesh or sub-mesh if necessary.
virtual void selectionDone ()
 Updates dialog's look and feel.
virtual SUIT_SelectionFiltercreateFilter (const int) const
 Creates selection filter.
virtual bool isValid (SUIT_Operation *) const
 Verifies whether given operator is valid for this one.
void extractIds (const QStringList &, IdList &) const
 Find in QStringList correct node or element ids representation and append integer(id) to IdList.
virtual void abortOperation ()
virtual void initDialog ()
 sets the dialog widgets to state just after operation start
void removeCustomFilters ()
 Remove only filters set by this operation (they are in map myFilters )
Selection_Mode selectionMode () const
 Return what selection mode is set in VTK viewer.
void setSelectionMode (const Selection_Mode)
 Set selection mode in VTK viewer.
void highlight (const Handle(SALOME_InteractiveObject)&, const bool, const bool=true)
 Hilight object in VTK viewer.
void addOrRemoveIndex (const Handle(SALOME_InteractiveObject)&, const TColStd_MapOfInteger &, const bool isModeShift)
 Select some nodes or elements in VTK.
SVTK_ViewWindow * viewWindow () const
SVTK_Selector * selector () const
virtual void selected (QStringList &, SMESHGUI_Dialog::TypesList &, QStringList &) const
 Get names, types and ids of selected objects.
virtual int typeById (const QString &, const EntityType) const
 Find type by id.
virtual QChar idChar () const
 Char using to divide <entry> and <id> in string id representation. By default, '#'.
void selectedIds (const int, IdList &) const
 Try to find in certain object selection widget selected node or element ids and return it.
SMESH::SMESH_Mesh_var mesh () const
 Return selected mesh if selection mode isn't ActorSelection and only one object is selected.
SMESH_Actoractor () const
 Return actor according to selected mesh if selection mode isn't ActorSelection.
virtual bool isReadyToStart () const
virtual void setIsApplyAndClose (const bool theFlag)
virtual bool isApplyAndClose () const
virtual void setDialogActive (const bool)
 Set according dialog active or inactive.
SMESHGUIgetSMESHGUI () const
bool isStudyLocked (const bool=true) const
 Verifies whether study of operation is locked.
 _PTR (Study) studyDS() const

Protected Attributes

QString myHelpFileName
bool myIsApplyAndClose

Private Types

typedef QList< HypothesisData * > THypDataList

Private Member Functions

bool isValid (QString &) const
 Verifies validity of input data.
void availableHyps (const int, const int, QStringList &, THypDataList &, HypothesisData *=0) const
 Gets available hypotheses or algorithms.
HypothesisDatahypData (const int, const int, const int)
 access to hypothesis data
void createHypothesis (const int, const int, const QString &)
 Create hypothesis and update dialog.
bool createMesh (QString &, QStringList &)
 Creates mesh.
bool createSubMesh (QString &, QStringList &)
 Creates sub-mesh.
bool editMeshOrSubMesh (QString &)
 Edits mesh or sub-mesh.
int currentHyp (const int, const int) const
 Gets current hypothesis or algorithms.
bool isAccessibleDim (const int) const
 Returns true if hypotheses of given dim can be assigned.
void setCurrentHyp (const int, const int, const int)
 Sets current hypothesis or algorithms.
void setDefaultName () const
 Generates default and sets mesh/submesh name.
SMESH::SMESH_Hypothesis_var getAlgo (const int)
 Gets algorithm or creates it if necessary.
void readMesh ()
 Reads parameters of edited mesh and assigns them to the dialog.
QString name (_PTR(SObject)) const
 Gets name of object.
int find (const SMESH::SMESH_Hypothesis_var &, const THypList &) const
 Finds hypothesis in input list.
SMESH::SMESH_Hypothesis_var getInitParamsHypothesis (const QString &, const QString &) const
 If create or edit a submesh, return a hypothesis holding parameters used to mesh a subshape.
bool isSubshapeOk () const
 check if selected shape is a subshape of the shape to mesh
char * isSubmeshIgnored () const
 Return name of the algorithm that does not support submeshes and makes submesh creation useless.
 _PTR (SObject) getSubmeshByGeom() const
void selectObject (_PTR(SObject)) const
 Selects a SObject.

Static Private Member Functions

static void existingHyps (const int, const int, _PTR(SObject), QStringList &, THypList &, HypothesisData *=0)
 Gets existing hypotheses or algorithms.

Private Attributes

SMESHGUI_MeshDlgmyDlg
SMESHGUI_ShapeByMeshOpmyShapeByMeshOp
bool myToCreate
bool myIsMesh
bool myIsOnGeometry
 TRUE if edited mesh accotiated with geometrical object.
TDim2Type2HypList myExistingHyps
 all hypothesis of SMESH module
TDim2Type2HypList myObjHyps
 hypothesis assigned to the current
THypDataList myAvailableHypData [4][NbHypTypes]
bool myIgnoreAlgoSelection
HypothesesSetmyHypoSet
int myDim
int myType
QString myObjectToSelect

Detailed Description

Operation for mech creation or editing.

This operation is used for mech creation or editing.

Definition at line 45 of file SMESHGUI_MeshOp.h.


Member Typedef Documentation

typedef QList<int> SMESHGUI_SelectionOp.IdList [inherited]

Definition at line 59 of file SMESHGUI_SelectionOp.h.

Definition at line 59 of file SMESHGUI_MeshOp.h.

typedef QList<HypothesisData*> SMESHGUI_MeshOp.THypDataList [private]

Definition at line 88 of file SMESHGUI_MeshOp.h.

Definition at line 58 of file SMESHGUI_MeshOp.h.

typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> SMESHGUI_MeshOp.THypItem

Definition at line 52 of file SMESHGUI_MeshOp.h.

Definition at line 53 of file SMESHGUI_MeshOp.h.

Definition at line 55 of file SMESHGUI_MeshOp.h.

Definition at line 56 of file SMESHGUI_MeshOp.h.


Member Enumeration Documentation

enum SMESHGUI_SelectionOp::EntityType [protected, inherited]
Enumerator:
Object 
MeshNode 
MeshElement 

Definition at line 68 of file SMESHGUI_SelectionOp.h.

Enumerator:
Algo 
MainHyp 
AddHyp 
NbHypTypes 

Definition at line 50 of file SMESHGUI_MeshOp.h.


Constructor & Destructor Documentation

SMESHGUI_MeshOp::SMESHGUI_MeshOp ( const bool  theToCreate,
const bool  theIsMesh = true 
)

Constructor.

Parameters:
theToCreate- if this parameter is true then operation is used for creation, for editing otherwise

Initialize operation

Definition at line 88 of file SMESHGUI_MeshOp.cxx.

References myIsOnGeometry.

: SMESHGUI_SelectionOp(),
  myToCreate( theToCreate ),
  myIsMesh( theIsMesh ),
  myDlg( 0 ),
  myShapeByMeshOp( 0 ),
  myHypoSet( 0 )
{
  if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
    GeometryGUI::InitGeomGen();
  myIsOnGeometry = true;
}
SMESHGUI_MeshOp::~SMESHGUI_MeshOp ( ) [virtual]

Destructor.

Definition at line 106 of file SMESHGUI_MeshOp.cxx.

References myDlg.

{
  if ( myDlg )
    delete myDlg;
}

Member Function Documentation

SMESHGUI_MeshOp._PTR ( SObject  ) const [private]
SMESHGUI_Operation._PTR ( Study  ) const [protected, inherited]
void SMESHGUI_SelectionOp::abortOperation ( ) [protected, virtual, inherited]
SMESH_Actor * SMESHGUI_SelectionOp::actor ( ) const [protected, inherited]

Return actor according to selected mesh if selection mode isn't ActorSelection.

Definition at line 464 of file SMESHGUI_SelectionOp.cxx.

References SMESH.FindActorByObject(), ex30_tepal.m, and SMESHGUI_SelectionOp.mesh().

Referenced by SMESHGUI_Make2DFrom3DOp.compute2DMesh(), SMESHGUI_ShapeByMeshOp.onElemIdChanged(), and SMESHGUI_SelectionOp.onTextChanged().

{
  SMESH::SMESH_Mesh_var m = mesh();
  if( !m->_is_nil() )
    return SMESH::FindActorByObject( m.in() );
  else
    return 0;
}
void SMESHGUI_SelectionOp::addOrRemoveIndex ( const Handle(SALOME_InteractiveObject)&  obj,
const TColStd_MapOfInteger &  indices,
const bool  isModeShift 
) [protected, inherited]

Select some nodes or elements in VTK.

Definition at line 265 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.selector().

Referenced by SMESHGUI_FindElemByPointOp.onElemSelected().

{
  SVTK_Selector* sel = selector();
  if( sel )
    sel->AddOrRemoveIndex( obj, indices, isModeShift );
}
void SMESHGUI_MeshOp::availableHyps ( const int  theDim,
const int  theHypType,
QStringList &  theHyps,
THypDataList theDataList,
HypothesisData theAlgoData = 0 
) const [private]

Gets available hypotheses or algorithms.

Parameters:
theDim- specifies dimension of returned hypotheses/algorifms
theHypType- specifies whether algorims or hypotheses or additional ones are retrieved (possible values are in HypType enumeration)
theHyps- Output list of hypotheses' names
theAlgoData- to select hypos able to be used by this algo (optional)

Gets available hypotheses or algorithm in accordance with input parameters

Definition at line 802 of file SMESHGUI_MeshOp.cxx.

References AddHyp, Algo, SMESH.GetAvailableHypotheses(), SMESH.GetHypothesisData(), isCompatible(), HypothesisData.Label, and myIsOnGeometry.

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

{
  theDataList.clear();
  theHyps.clear();
  bool isAlgo = ( theHypType == Algo );
  bool isAux  = ( theHypType == AddHyp );
  QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );

  QStringList::const_iterator anIter;
  for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
  {
    HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
    if ( isCompatible ( theAlgoData, aData, theHypType )) {
      theDataList.append( aData );
      theHyps.append( aData->Label );
    }
  }
}
void SMESHGUI_MeshOp::commitOperation ( ) [protected, virtual]

Selects a recently created mesh or sub-mesh if necessary.

Virtual method redefined from base class called when operation is commited selects a recently created mesh or sub-mesh if necessary. Allows to perform selection when the custom selection filters are removed.

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 267 of file SMESHGUI_MeshOp.cxx.

References myObjectToSelect.

{
  SMESHGUI_SelectionOp::commitOperation();

  if ( !myObjectToSelect.isEmpty() ) {
    if ( LightApp_SelectionMgr* aSelectionMgr = selectionMgr() ) {
      SUIT_DataOwnerPtrList aList;
      aList.append( new LightApp_DataOwner( myObjectToSelect ) );
      aSelectionMgr->setSelected( aList );
    }
  }
}
SUIT_SelectionFilter * SMESHGUI_MeshOp::createFilter ( const int  theId) const [protected, virtual]

Creates selection filter.

Parameters:
theId- identifier of current selection widget
Return values:
SUIT_SelectionFilter*- pointer to the created filter or null

Creates selection filter in accordance with identifier of current selection widget

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 289 of file SMESHGUI_MeshOp.cxx.

References SMESHGUI_MeshDlg.Geom, SMESHGUI_MeshDlg.Mesh, MESHorSUBMESH, myToCreate, and SMESHGUI_MeshDlg.Obj.

{
  if ( theId == SMESHGUI_MeshDlg::Geom )
  {
//     TColStd_MapOfInteger allTypesMap;
//     for ( int i = 0; i < 10; i++ )
//       allTypesMap.Add( i );
//     return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
    return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
  }
  else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
    return new SMESH_TypeFilter( MESHorSUBMESH );
  else if ( theId == SMESHGUI_MeshDlg::Mesh )
    return new SMESH_TypeFilter( MESH );
  else
    return 0;
}
void SMESHGUI_MeshOp::createHypothesis ( const int  theDim,
const int  theType,
const QString &  theTypeName 
) [private]

Create hypothesis and update dialog.

Parameters:
theDim- dimension of hypothesis to be created
theType- hypothesis category (algorithm, hypothesis, additional hypothesis)
theTypeName- specifies hypothesis to be created

Definition at line 1061 of file SMESHGUI_MeshOp.cxx.

References _PTR(), HypothesisData.ClientLibName, SMESHGUI_GenericHypothesisCreator.create(), SMESH.CreateHypothesis(), SMESHGUI_MeshDlg.Geom, SMESH.GetHypothesisCreator(), SMESH.GetHypothesisData(), getInitParamsHypothesis(), SMESH.GetShapeOnMeshOrSubMesh(), HypothesisData.Label, SMESHGUI_MeshDlg.Mesh, myDim, myDlg, myExistingHyps, myIsMesh, myToCreate, myType, SMESHGUI_MeshDlg.Obj, onHypoCreated(), SMESHGUI_SelectionOp.removeCustomFilters(), HypothesisData.ServerLibName, SMESHGUI_GenericHypothesisCreator.setMainShapeEntry(), and SMESHGUI_GenericHypothesisCreator.setShapeEntry().

Referenced by onCreateHyp(), and processSet().

{
  HypothesisData* aData = SMESH::GetHypothesisData(theTypeName);
  if (!aData)
    return;

  myDim = theDim;
  myType = theType;
  QStringList aHypNames;
  TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
  for ( ; aDimIter != myExistingHyps.end(); aDimIter++) {
    const TType2HypList& aType2HypList = aDimIter.value();
    TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
    for ( ; aTypeIter != aType2HypList.end(); aTypeIter++) {
      const THypList& aHypList = aTypeIter.value();
      THypList::const_iterator anIter = aHypList.begin();
      for ( ; anIter != aHypList.end(); anIter++) {
        const THypItem& aHypItem = *anIter;
        const QString& aHypName = aHypItem.second;
        aHypNames.append(aHypName);
      }
    }
  }
  QString aHypName = GetUniqueName( aHypNames, aData->Label);

  // existing hypos
  bool dialog = false;

  QString aClientLibName = aData->ClientLibName;
  if (aClientLibName == "") {
    // Call hypothesis creation server method (without GUI)
    SMESH::SMESH_Hypothesis_var aHyp =
      SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ
    if (!CORBA::is_nil(aHyp))
      aHyp->UnRegister();
#endif
  } else {
    // Get hypotheses creator client (GUI)
    // BUG 0020378
    //SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
    SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);

    // Create hypothesis
    if (aCreator) {
      // Get parameters appropriate to initialize a new hypothesis
      SMESH::SMESH_Hypothesis_var initParamHyp =
        getInitParamsHypothesis(theTypeName, aData->ServerLibName);

      removeCustomFilters(); // Issue 0020170

      // Get Entry of the Geom object
      QString aGeomEntry = "";
      QString aMeshEntry = "";
      QString anObjEntry = "";
      aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
      aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
      anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );

      if ( myToCreate && myIsMesh )
        aMeshEntry = aGeomEntry;

      if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
        _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
        GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
        aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
      }

      if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
        _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
        bool isMesh;
        GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
        if ( !aGeomVar->_is_nil() )
        {
          aGeomEntry = aGeomVar->GetStudyEntry();
          if ( isMesh )
            aMeshEntry = aGeomEntry;
        }
      }

      if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
        // take geometry from submesh being created
        _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
        if ( pObj ) {
          // if current object is sub-mesh
          SMESH::SMESH_subMesh_var aSubMeshVar =
            SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
          if ( !aSubMeshVar->_is_nil() ) {
            SMESH::SMESH_Mesh_var aMeshVar =  aSubMeshVar->GetFather();
            if ( !aMeshVar->_is_nil() ) {
              _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
              GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
              if ( !aGeomVar->_is_nil() )
                aMeshEntry = aGeomVar->GetStudyEntry();
            }
          }
        }
      }

      aCreator->setShapeEntry( aGeomEntry );
      if ( aMeshEntry != "" )
        aCreator->setMainShapeEntry( aMeshEntry );
      myDlg->setEnabled( false );
      aCreator->create(initParamHyp, aHypName, myDlg, this, SLOT( onHypoCreated( int ) ) );
      dialog = true;
    }
    else {
     SMESH::SMESH_Hypothesis_var aHyp =
       SMESH::CreateHypothesis(theTypeName, aHypName, false);
#ifdef WITHGENERICOBJ
     if (!CORBA::is_nil(aHyp))
       aHyp->UnRegister();
#endif
    }
  }

  if( !dialog )
    onHypoCreated(2);
}
bool SMESHGUI_MeshOp::createMesh ( QString &  theMess,
QStringList &  theEntryList 
) [private]

Creates mesh.

Parameters:
theMess- Output parameter intended for returning error message
theEntryList- List of entries of published objects
Return values:
bool- TRUE if mesh is created, FALSE otherwise

Creates mesh

Definition at line 1596 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, SMESH.AddHypothesisOnMesh(), currentHyp(), SMESH.DIM_0D, SMESH.DIM_3D, SMESHGUI_MeshDlg.Geom, getAlgo(), SMESHGUI.GetSMESHGen(), isAccessibleDim(), MainHyp, myDlg, myExistingHyps, SMESHGUI_MeshDlg.Obj, and batchmode_smesh.SetName().

Referenced by onApply().

{
  theMess = "";

  //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
  //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );

  QStringList aList;
  myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
  QStringList::Iterator it = aList.begin();
  for ( ; it!=aList.end(); it++)
  {
    QString aGeomEntry = *it;
    _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
    GEOM::GEOM_Object_var aGeomVar =
      GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );

    SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
    if ( aSMESHGen->_is_nil() )
      return false;

    SUIT_OverrideCursor aWaitCursor;

    // create mesh
    SMESH::SMESH_Mesh_var aMeshVar = aSMESHGen->CreateMesh( aGeomVar );
    if ( aMeshVar->_is_nil() )
      return false;
    _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
    if ( aMeshSO ) {
      SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
      theEntryList.append( aMeshSO->GetID().c_str() );
    }

    for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
      if ( !isAccessibleDim( aDim )) continue;

      // assign hypotheses
      for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
        int aHypIndex = currentHyp( aDim, aHypType );
        if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
          SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
          if ( !aHypVar->_is_nil() )
            SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
        }
      }
      // find or create algorithm
      SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
      if ( !anAlgoVar->_is_nil() )
        SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
    }
#ifdef WITHGENERICOBJ
    // obj has been published in study. Its refcount has been incremented.
    // It is safe to decrement its refcount
    // so that it will be destroyed when the entry in study will be removed
    if (aMeshSO)
      aMeshVar->UnRegister();
#endif
  }
  return true;
}
bool SMESHGUI_MeshOp::createSubMesh ( QString &  theMess,
QStringList &  theEntryList 
) [private]

Creates sub-mesh.

Parameters:
theMess- Output parameter intended for returning error message
theEntryList- List of entries of published objects
Return values:
bool- TRUE if sub-mesh is created, FALSE otherwise

Creates sub-mesh

Definition at line 1667 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, SMESH.AddHypothesisOnSubMesh(), currentHyp(), SMESH.DIM_0D, SMESH.DIM_3D, SMESHGUI_MeshDlg.Geom, getAlgo(), SMESH.GetGEOMGen(), SMESHGUI.GetSMESHGen(), isAccessibleDim(), MainHyp, SMESHGUI_MeshDlg.Mesh, myDlg, myExistingHyps, SMESHGUI_MeshDlg.Obj, selectionDone(), selectObject(), and batchmode_smesh.SetName().

Referenced by onApply().

{
  theMess = "";

  SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
  if ( aSMESHGen->_is_nil() )
    return false;

  // get mesh object
  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
  _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
  SMESH::SMESH_Mesh_var aMeshVar =
    SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
  if (aMeshVar->_is_nil())
    return false;

  // GEOM shape of the main mesh
  GEOM::GEOM_Object_var mainGeom = aMeshVar->GetShapeToMesh();

  // Name for the new sub-mesh
  QString aName = myDlg->objectText(SMESHGUI_MeshDlg::Obj);

  // get geom object
  GEOM::GEOM_Object_var aGeomVar;
  QStringList aGEOMs;
  myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
  if (aGEOMs.count() == 1)
  {
    //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
    QString aGeomEntry = aGEOMs.first();
    _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
    aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
  }
  else if (aGEOMs.count() > 1)
  {
    // create a GEOM group
    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
    if (!geomGen->_is_nil() && aStudy) {
      GEOM::GEOM_IGroupOperations_var op =
        geomGen->GetIGroupOperations(aStudy->StudyId());
      if (!op->_is_nil()) {
        // check and add all selected GEOM objects: they must be
        // a sub-shapes of the main GEOM and must be of one type
        int iSubSh = 0;
        TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
        GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
        aSeq->length(aGEOMs.count());
        QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
        for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
          QString aSubGeomEntry = (*aSubShapesIter);
          _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
          GEOM::GEOM_Object_var aSubGeomVar =
            GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
          TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aSubGeomVar->GetShapeType();
          if (iSubSh == 0) {
            aGroupType = aSubShapeType;
          } else {
            if (aSubShapeType != aGroupType)
              aGroupType = TopAbs_SHAPE;
          }
          aSeq[iSubSh] = aSubGeomVar;
        }
        // create a group
        GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
        op->UnionList(aGroupVar, aSeq);

        if (op->IsDone()) {
          aGeomVar = aGroupVar;

          // publish the GEOM group in study
          QString aNewGeomGroupName ("Auto_group_for_");
          aNewGeomGroupName += aName;
          SALOMEDS::SObject_var aNewGroupSO =
            geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
                                aNewGeomGroupName.toLatin1().data(), mainGeom);
        }
      }
    }
  }
  else {
  }
  if (aGeomVar->_is_nil())
    return false;

  SUIT_OverrideCursor aWaitCursor;

  // create sub-mesh
  SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
  _PTR(SObject) aSubMeshSO = SMESH::FindSObject( aSubMeshVar.in() );
  if ( aSubMeshSO ) {
    SMESH::SetName( aSubMeshSO, aName.toLatin1().data() );
    theEntryList.append( aSubMeshSO->GetID().c_str() );
  }

  for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
  {
    if ( !isAccessibleDim( aDim )) continue;

    // find or create algorithm
    SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
    if ( !anAlgoVar->_is_nil() )
      SMESH::AddHypothesisOnSubMesh( aSubMeshVar, anAlgoVar );
    // assign hypotheses
    for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ )
    {
      int aHypIndex = currentHyp( aDim, aHypType );
      if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() )
      {
        SMESH::SMESH_Hypothesis_var aHypVar =
          myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
        if ( !aHypVar->_is_nil() )
          SMESH::AddHypothesisOnSubMesh( aSubMeshVar, aHypVar );
      }
    }
  }

  // deselect geometry: next submesh should be created on other subshape
  myDlg->clearSelection( SMESHGUI_MeshDlg::Geom );
  selectObject( _PTR(SObject)() );
  selectionDone();

  return true;
}
int SMESHGUI_MeshOp::currentHyp ( const int  theDim,
const int  theHypType 
) const [private]

Gets current hypothesis or algorithms.

Parameters:
theDim- dimension of hypothesis or algorithm
theHypType- Type of hypothesis (Algo, MainHyp, AddHyp)
Return values:
int- current hypothesis or algorithms

Gets current hypothesis or algorithms

Definition at line 1802 of file SMESHGUI_MeshOp.cxx.

References SMESHGUI_MeshTab.currentHyp(), myDlg, and SMESHGUI_MeshDlg.tab().

Referenced by createMesh(), createSubMesh(), editMeshOrSubMesh(), getAlgo(), onAlgoSelected(), onHypoCreated(), and readMesh().

{
  return myDlg->tab( theDim )->currentHyp( theHypType ) - 1;
}
LightApp_Dialog * SMESHGUI_MeshOp::dlg ( ) const [virtual]

Gets dialog of this operation.

Return values:
LightApp_Dialog*- pointer to dialog of this operation

Definition at line 118 of file SMESHGUI_MeshOp.cxx.

References myDlg.

Referenced by onApply(), onEditHyp(), and selectionDone().

{
  return myDlg;
}
bool SMESHGUI_MeshOp::editMeshOrSubMesh ( QString &  theMess) [private]

Edits mesh or sub-mesh.

Parameters:
theMess- Output parameter intended for returning error message
Return values:
bool- TRUE if mesh is edited succesfully, FALSE otherwise

Assigns new name hypotheses and algoriths to the mesh or sub-mesh

Definition at line 2121 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, SMESH.AddHypothesisOnMesh(), SMESH.AddHypothesisOnSubMesh(), Algo, currentHyp(), SMESH.DIM_0D, SMESH.DIM_3D, existingHyps(), find(), getAlgo(), SMESHGUI.GetSMESHGen(), isAccessibleDim(), MainHyp, myDlg, myExistingHyps, myIsOnGeometry, myObjHyps, SMESHGUI_MeshDlg.Obj, SMESH.RemoveHypothesisOrAlgorithmOnMesh(), and batchmode_smesh.SetName().

Referenced by onApply().

{
  theMess = "";

  SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
  if ( aSMESHGen->_is_nil() )
    return false;

  QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
  _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
  if ( !pObj )
    return false;

  SUIT_OverrideCursor aWaitCursor;

  // Set new name
  QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
  SMESH::SetName( pObj, aName );
  int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;

  // First, remove old algos in order to avoid messages on algorithm hiding
  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
  {
    if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
    {
      SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
      SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
      if ( anAlgoVar->_is_nil() || // no new algo selected or
           strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) ) // algo change
      {
        // remove old algorithm
        SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
        myObjHyps[ dim ][ Algo ].clear();
      }
    }
  }

  // Assign new algorithms and hypotheses
  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
  {
    if ( !isAccessibleDim( dim )) continue;

    // find or create algorithm
    SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );

    // assign new algorithm
    if ( !anAlgoVar->_is_nil() && // some algo selected and
         myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
    {
      SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
      CORBA::Object_var anObject = aSObject->GetObject();
      SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
      bool isMesh = !aMeshVar->_is_nil();
      if ( isMesh ) {
        SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
      } else {
        SMESH::SMESH_subMesh_var aVar =
          SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
        if ( !aVar->_is_nil() )
          SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
      }
      myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
    }

    // assign hypotheses
    for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
    {
      int aNewHypIndex = currentHyp( dim, hypType );
      int anOldHypIndex = -1;

      // remove old hypotheses
      if ( myObjHyps[ dim ][ hypType ].count() > 0 )
      {
        anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
                              myExistingHyps[ dim ][ hypType ] );
        if ( aNewHypIndex != anOldHypIndex || // different hyps
             anOldHypIndex == -1 )            // hyps of different algos
        {
          SMESH::RemoveHypothesisOrAlgorithmOnMesh
            ( pObj, myObjHyps[ dim ][ hypType ].first().first );
          myObjHyps[ dim ][ hypType ].clear();
        }
      }

      // assign new hypotheses
      if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
      {
        SMESH::SMESH_Mesh_var aMeshVar =
          SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
        bool isMesh = !aMeshVar->_is_nil();
        if ( isMesh )
        {
          SMESH::AddHypothesisOnMesh
            (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
        }
        else
        {
          SMESH::SMESH_subMesh_var aVar =
            SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
          if ( !aVar->_is_nil() )
            SMESH::AddHypothesisOnSubMesh
              ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
        }
      }
      // reread all hypotheses of mesh if necessary
      QStringList anExisting;
      existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
    }
  }

  return true;
}
void SMESHGUI_MeshOp::existingHyps ( const int  theDim,
const int  theHypType,
_PTR(SObject)  theFather,
QStringList &  theHyps,
THypList theHypList,
HypothesisData theAlgoData = 0 
) [static, private]

Gets existing hypotheses or algorithms.

Parameters:
theDim- specifies dimension of returned hypotheses/algorifms
theHypType- specifies whether algorims or hypotheses or additional ones are retrieved (possible values are in HypType enumeration)
theFather- start object for finding ( may be component, mesh, or sub-mesh )
theHyps- output list of names.
theHypVars- output list of variables.
theAlgoData- to select hypos able to be used by this algo (optional)

Gets existing (i.e. already created) hypotheses or algorithm in accordance with input parameters

Definition at line 840 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, Algo, HypothesisData.Dim, SMESH.GetHypothesisData(), HypothesisData.IsAux, isCompatible(), SMESH.Tag_AlgorithmsRoot, batchmode_smesh.Tag_HypothesisRoot, SMESH.Tag_RefOnAppliedAlgorithms, and batchmode_smesh.Tag_RefOnAppliedHypothesis.

Referenced by editMeshOrSubMesh(), getAlgo(), isSubmeshIgnored(), onAlgoSelected(), onHypoCreated(), and readMesh().

{
  // Clear hypoheses list
  theHyps.clear();
  theHypList.clear();

  if ( !theFather )
    return;

  const bool isAux  = ( theHypType == AddHyp );

  _PTR(SObject)          aHypRoot;
  _PTR(GenericAttribute) anAttr;
  _PTR(AttributeName)    aName;
  _PTR(AttributeIOR)     anIOR;

  bool isMesh = !_CAST( SComponent, theFather );
  int aPart = -1;
  if ( isMesh )
    aPart = theHypType == Algo ? SMESH::Tag_RefOnAppliedAlgorithms : SMESH::Tag_RefOnAppliedHypothesis;
  else
    aPart = theHypType == Algo ? SMESH::Tag_AlgorithmsRoot : SMESH::Tag_HypothesisRoot;

  if ( theFather->FindSubObject( aPart, aHypRoot ) )
  {
    _PTR(ChildIterator) anIter =
      SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
    for ( ; anIter->More(); anIter->Next() )
    {
      _PTR(SObject) anObj = anIter->Value();
      if ( isMesh ) // i.e. mesh or submesh
      {
        _PTR(SObject) aRefObj;
        if ( anObj->ReferencedObject( aRefObj ) )
          anObj = aRefObj;
        else
          continue;
      }
      if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
      {
        aName = anAttr;
        CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
        if ( !CORBA::is_nil( aVar ) )
        {
          SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
          if ( !aHypVar->_is_nil() )
          {
            HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() );
            if ( !aData) continue;
            if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
                 ( isCompatible ( theAlgoData, aData, theHypType )) &&
                 ( isAux == aData->IsAux ))
            {
              std::string aHypName = aName->Value();
              theHyps.append( aHypName.c_str() );
              theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
            }
          }
        }
      }
    }
  }
}
void SMESHGUI_SelectionOp::extractIds ( const QStringList &  ids,
IdList list,
const QChar  idchar 
) [static, inherited]

Definition at line 523 of file SMESHGUI_SelectionOp.cxx.

Referenced by SMESHGUI_SelectionOp.extractIds(), SMESHGUI_SelectionOp.onTextChanged(), and SMESHGUI_SelectionOp.selectedIds().

{
  QStringList::const_iterator anIt = ids.begin(),
                              aLast = ids.end();
  QString id_str;
  for( ; anIt!=aLast; anIt++ )
  {
    id_str = *anIt;
    int pos = idchar=='\0' ? -1 : id_str.indexOf( idchar );
    int id = -1;
    if( idchar=='\0' || pos>=0 )
    {
      id = id_str.mid( pos+1 ).toInt();
      list.append( id );
    }
  }
}
void SMESHGUI_SelectionOp::extractIds ( const QStringList &  ids,
IdList list 
) const [protected, inherited]

Find in QStringList correct node or element ids representation and append integer(id) to IdList.

Definition at line 545 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.extractIds(), and SMESHGUI_SelectionOp.idChar().

{
  extractIds( ids, list, idChar() );
}
int SMESHGUI_MeshOp::find ( const SMESH::SMESH_Hypothesis_var &  theHyp,
const THypList theHypList 
) const [private]

Finds hypothesis in input list.

Parameters:
theHyp- hypothesis to be found
theHypList- input list of hypotheses
Return values:
int- index of hypothesis or -1 if it is not found

Finds position of hypothesis in input list

Definition at line 2091 of file SMESHGUI_MeshOp.cxx.

Referenced by editMeshOrSubMesh(), onAlgoSelected(), and readMesh().

{
  int aRes = -1;
  if ( !theHyp->_is_nil() )
  {
    int i = 0;
    THypList::const_iterator anIter = theHypList.begin();
    for ( ; anIter != theHypList.end(); ++ anIter)
    {
      if ( theHyp->_is_equivalent( (*anIter).first ) )
      {
        aRes = i;
        break;
      }
      i++;
    }
  }
  return aRes;
}
SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo ( const int  theDim) [private]

Gets algorithm or creates it if necessary.

Parameters:
theDim- specifies dimension of returned hypotheses/algorifms
Return values:
SMESH.SMESH_Hypothesis_var- algorithm

Gets algorithm or creates it if necessary

Definition at line 1874 of file SMESHGUI_MeshOp.cxx.

References _PTR(), Algo, HypothesisData.ClientLibName, SMESHGUI_GenericHypothesisCreator.create(), SMESH.CreateHypothesis(), currentHyp(), existingHyps(), SMESH.GetHypothesisCreator(), SMESH.GetHypothesisData(), myAvailableHypData, myDlg, and myExistingHyps.

Referenced by createMesh(), createSubMesh(), and editMeshOrSubMesh().

{
  SMESH::SMESH_Hypothesis_var anAlgoVar;

  // get type of the selected algo
  int aHypIndex = currentHyp( theDim, Algo );
  THypDataList& dataList = myAvailableHypData[ theDim ][ Algo ];
  if ( aHypIndex < 0 || aHypIndex >= dataList.count())
    return anAlgoVar;
  QString aHypName = dataList[ aHypIndex ]->TypeName;

  // get existing algoritms
  _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
  QStringList tmp;
  existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);

  // look for an existing algo of such a type
  THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
  THypList::iterator anIter = aHypVarList.begin();
  for ( ; anIter != aHypVarList.end(); anIter++)
  {
    SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
    CORBA::String_var aName = aHypVar->GetName();
    if ( !aHypVar->_is_nil() && !strcmp(aHypName.toLatin1().data(), aName) )
    {
      anAlgoVar = aHypVar;
      break;
    }
  }

  if (anAlgoVar->_is_nil())
  {
    HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
    if (aHypData)
    {
      QString aClientLibName = aHypData->ClientLibName;
      if (aClientLibName == "")
      {
        // Call hypothesis creation server method (without GUI)
        SMESH::SMESH_Hypothesis_var aHyp =
          SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ
        if (!CORBA::is_nil(aHyp))
          aHyp->UnRegister();
#endif
      }
      else
      {
        // Get hypotheses creator client (GUI)
        // BUG 0020378
        SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);

        // Create algorithm
        if (aCreator)
          aCreator->create(true, aHypName, myDlg, 0, QString::null );
        else {
          SMESH::SMESH_Hypothesis_var aHyp =
            SMESH::CreateHypothesis(aHypName, aHypName, true);
#ifdef WITHGENERICOBJ
          if (!CORBA::is_nil(aHyp))
            aHyp->UnRegister();
#endif
        }
      }
      QStringList tmpList;
      _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
      existingHyps( theDim, Algo, aFather, tmpList, myExistingHyps[ theDim ][ Algo ] );
    }

    THypList& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
    for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
    {
      SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
      CORBA::String_var aName = aHypVar->GetName();
      if ( !aHypVar->_is_nil() && !strcmp(aHypName.toLatin1().data(), aName) )
      {
        anAlgoVar = aHypVar;
        break;
      }
    }
  }

  return anAlgoVar._retn();
}
SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getInitParamsHypothesis ( const QString &  aHypType,
const QString &  aServerLib 
) const [private]

If create or edit a submesh, return a hypothesis holding parameters used to mesh a subshape.

Parameters:
aHypType- The hypothesis type name
aServerLib- Server library name
hypData- The structure holding the hypothesis type etc.
Return values:
SMESH.SMESH_Hypothesis_var- the hypothesis holding parameter values

Definition at line 920 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_MeshDlg.Geom, SMESH.GetShapeOnMeshOrSubMesh(), SMESHGUI.GetSMESHGen(), SMESH_demo_hexa2_upd.hyp, SMESHGUI_MeshDlg.Mesh, myDlg, myIsMesh, myToCreate, and SMESHGUI_MeshDlg.Obj.

Referenced by createHypothesis(), and onEditHyp().

{
  if ( aHypType.isEmpty() || aServerLib.isEmpty() )
    return SMESH::SMESH_Hypothesis::_nil();

  const int nbColonsInMeshEntry = 3;
  bool isSubMesh = myToCreate ?
    !myIsMesh :
    myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).count(':') > nbColonsInMeshEntry;

  // get mesh and geom object
  SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
  GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();

  QString anEntry;
  if ( isSubMesh )
  {
    anEntry = myDlg->selectedObject
      ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
    if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
    {
      CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
      if ( myToCreate ) // mesh and geom may be selected
      {
        aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
        anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
        if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
          aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
      }
      else // edition: sub-mesh may be selected
      {
        SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
        if ( !sm->_is_nil() ) {
          aMeshVar = sm->GetFather();
          aGeomVar = sm->GetSubShape();
        }
      }
    }
  }
  else // mesh
  {
    if ( !myToCreate ) // mesh to edit can be selected
    {
      anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
      if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
      {
        aMeshVar = SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
        if ( !aMeshVar->_is_nil() )
          aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pMesh );
      }
    }
    if ( aGeomVar->_is_nil() ) {
      anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
      if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
      {
        aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
      }
    }
  }

  SMESH::SMESH_Hypothesis_var hyp =
    SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
                                                           aServerLib.toLatin1().data(),
                                                           aMeshVar,
                                                           aGeomVar,
                                                           /*byMesh = */isSubMesh);
  if ( hyp->_is_nil() && isSubMesh )
    hyp = SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
                                                                 aServerLib.toLatin1().data(),
                                                                 aMeshVar,
                                                                 aGeomVar,
                                                                 /*byMesh = */false);
  return hyp;
}
SMESHGUI * SMESHGUI_Operation::getSMESHGUI ( ) const [protected, inherited]
void SMESHGUI_SelectionOp::highlight ( const Handle(SALOME_InteractiveObject)&  obj,
const bool  hilight,
const bool  immediately = true 
) [protected, inherited]

Hilight object in VTK viewer.

Definition at line 253 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.viewWindow().

Referenced by SMESHGUI_SelectionOp.onTextChanged().

{
  SVTK_ViewWindow* wnd = viewWindow();
  if( wnd )
    wnd->highlight( obj, hilight, immediately );
}
HypothesisData * SMESHGUI_MeshOp::hypData ( const int  theDim,
const int  theHypType,
const int  theIndex 
) [private]

access to hypothesis data

Parameters:
theDim- hyp dimension
theHypType- hyp type (Algo,MainHyp or AddHyp)
theIndex- index in the list
Return values:
HypothesisData*- result data, may be 0

Definition at line 1331 of file SMESHGUI_MeshOp.cxx.

References SMESH.DIM_3D, myAvailableHypData, and NbHypTypes.

Referenced by onAlgoSelected(), and onHypoCreated().

{
  if ( theDim     > -1 && theDim    <= SMESH::DIM_3D &&
       theHypType > -1 && theHypType < NbHypTypes &&
       theIndex   > -1 && theIndex   < myAvailableHypData[ theDim ][ theHypType ].count() )
    return myAvailableHypData[ theDim ][ theHypType ][ theIndex ];
  return 0;
}
QChar SMESHGUI_SelectionOp::idChar ( ) const [protected, virtual, inherited]

Char using to divide <entry> and <id> in string id representation. By default, '#'.

Definition at line 439 of file SMESHGUI_SelectionOp.cxx.

Referenced by SMESHGUI_SelectionOp.extractIds(), SMESHGUI_SelectionOp.selected(), and SMESHGUI_SelectionOp.typeById().

{
  return '#';
}
void SMESHGUI_SelectionOp::initDialog ( ) [protected, virtual, inherited]

sets the dialog widgets to state just after operation start

Reimplemented from SMESHGUI_Operation.

Definition at line 208 of file SMESHGUI_SelectionOp.cxx.

{
  if( dlg() )
  {
    dlg()->clearSelection();
    dlg()->deactivateAll();
  }
}
bool SMESHGUI_MeshOp::isAccessibleDim ( const int  theDim) const [private]

Returns true if hypotheses of given dim can be assigned.

Parameters:
theDim- hypotheses dimension
Return values:
bool- result

Definition at line 1814 of file SMESHGUI_MeshOp.cxx.

References SMESHGUI_MeshDlg.isTabEnabled(), and myDlg.

Referenced by createMesh(), createSubMesh(), editMeshOrSubMesh(), and onAlgoSelected().

{
  return myDlg->isTabEnabled( theDim );
}
bool SMESHGUI_Operation::isApplyAndClose ( ) const [protected, virtual, inherited]
bool SMESHGUI_Operation::isReadyToStart ( ) const [protected, virtual, inherited]

Definition at line 115 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.getSMESHGUI(), and SMESHGUI_Operation.isStudyLocked().

{
  if ( !LightApp_Operation::isReadyToStart() )
    return false;
  else if ( getSMESHGUI() == 0 )
  {
    SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ),
                              tr( "NO_MODULE" ) );
    return false;
  }
  else if ( isStudyLocked() )
    return false;

  return true;
}
bool SMESHGUI_Operation::isStudyLocked ( const bool  theMess = true) const [protected, inherited]

Verifies whether study of operation is locked.

Parameters:
theMess- specifies whether message box must be shown if study is locked
Returns:
State of study.

Verifies whether study of operation is locked. If second parameter is TRUE and study is locked when corresponding message box appears

Definition at line 247 of file SMESHGUI_Operation.cxx.

References SMESHGUI.desktop().

Referenced by SMESHGUI_Operation.isReadyToStart(), onApply(), SMESHGUI_MakeNodeAtPointOp.onApply(), SMESHGUI_Make2DFrom3DOp.onApply(), and SMESHGUI_GroupOnShapeOp.onApply().

{
  if ( studyDS() )
  {
    if ( studyDS()->GetProperties()->IsLocked() )
    {
      if ( theMess )
        SUIT_MessageBox::warning( SMESHGUI::desktop(), tr( "WRN_WARNING" ),
                                  tr( "WRN_STUDY_LOCKED" ) );
      return true;
    }
  }

  return false;
}
char * SMESHGUI_MeshOp::isSubmeshIgnored ( ) const [private]

Return name of the algorithm that does not support submeshes and makes submesh creation useless.

Return values:
char*- string is to be deleted!!!

Definition at line 379 of file SMESHGUI_MeshOp.cxx.

References _PTR(), ex01_cube2build.algo, Algo, existingHyps(), SMESHGUI_MeshDlg.Geom, SMESH.GetHypothesisData(), HypothesisData.InputTypes, HypothesisData.IsSupportSubmeshes, SMESHGUI_MeshDlg.Mesh, myDlg, myIsMesh, and myToCreate.

Referenced by selectionDone().

{
  if ( myToCreate && !myIsMesh ) {

    QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
    QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
    _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
    if ( pMesh ) {

      QStringList algoNames;
      THypList    algoList;
      existingHyps(3, Algo, pMesh, algoNames, algoList);
      if (!algoList.empty()) {
        HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() );
        if ( algo &&
             algo->InputTypes.empty() && // builds all dimensions it-self
             !algo->IsSupportSubmeshes )
          return CORBA::string_dup( algoNames[0].toLatin1().data() );
      }

//       GEOM::GEOM_Object_var geom;
//       if (_PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() ))
//         geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );

//       if ( !geom->_is_nil() && geom->GetShapeType() >= GEOM::FACE ) { // WIRE, EDGE as well
        existingHyps(2, Algo, pMesh, algoNames, algoList);
        if (!algoList.empty()) {
          HypothesisData* algo = SMESH::GetHypothesisData( algoList[0].first->GetName() );
          if ( algo &&
               algo->InputTypes.empty() && // builds all dimensions it-self
               !algo->IsSupportSubmeshes )
            return CORBA::string_dup( algoNames[0].toLatin1().data() );
        }
//       }
    }
  }
  return 0;
}
bool SMESHGUI_MeshOp::isSubshapeOk ( ) const [private]

check if selected shape is a subshape of the shape to mesh

Return values:
bool- check result

Definition at line 313 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_MeshDlg.Geom, SMESH.GetGEOMGen(), SMESHGUI_SelectionOp.mesh(), SMESHGUI_MeshDlg.Mesh, myDlg, myIsMesh, and myToCreate.

Referenced by isValid().

{
  if ( !myToCreate || myIsMesh ) // not submesh creation
    return false;

  // mesh
  QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
  _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
  if (!pMesh) return false;

  SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
  if (mesh->_is_nil()) return false;

  // main shape of the mesh
  GEOM::GEOM_Object_var mainGeom = mesh->GetShapeToMesh();
  if (mainGeom->_is_nil()) return false;

  // geometry
  QStringList aGEOMs;
  myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);

  if (aGEOMs.count() > 0) {
    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
    if (geomGen->_is_nil() || !aStudy) return false;

    GEOM::GEOM_IGroupOperations_var op =
        geomGen->GetIGroupOperations(aStudy->StudyId());
    if (op->_is_nil()) return false;

    // check all selected shapes
    QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
    for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
      QString aSubGeomEntry = (*aSubShapesIter);
      _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
      if (!pSubGeom) return false;

      GEOM::GEOM_Object_var aSubGeomVar =
        GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
      if (aSubGeomVar->_is_nil()) return false;

      // skl for NPAL14695 - implementation of searching of mainObj
      GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
      //if (mainObj->_is_nil() ||
      //    string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
      while(1) {
        if (mainObj->_is_nil())
          return false;
        if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry()))
          return true;
        mainObj = op->GetMainShape(mainObj);
      }
    }
    //return true;
  }

  return false;
}
bool SMESHGUI_MeshOp::isValid ( QString &  theMess) const [private]

Verifies validity of input data.

Parameters:
theMess- Output parameter intended for returning error message
Return values:
bool- TRUE if input data is valid, false otherwise

Verifies validity of input data. This method is called when "Apply" or "OK" button is pressed before mesh creation or editing.

Definition at line 693 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_MeshDlg.Geom, isSubshapeOk(), SMESHGUI_MeshDlg.Mesh, myDlg, myIsMesh, myToCreate, and SMESHGUI_MeshDlg.Obj.

{
  // Selected object to be  edited
  if ( !myToCreate && myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ) == "" )
  {
    theMess = tr( "THERE_IS_NO_OBJECT_FOR_EDITING" );
    return false;
  }

  // Name
  QString aMeshName = myDlg->objectText( SMESHGUI_MeshDlg::Obj ).trimmed();
  if ( aMeshName.isEmpty() )
  {
    theMess = myIsMesh ? tr( "NAME_OF_MESH_IS_EMPTY" ) : tr( "NAME_OF_SUBMESH_IS_EMPTY" );
    return false;
  }

/*  // Imported mesh, if create sub-mesh or edit mesh
  if ( !myToCreate || ( myToCreate && !myIsMesh ))
  {
    QString aMeshEntry = myDlg->selectedObject
      ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
    if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
      SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
      if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
        theMess = tr( "IMPORTED_MESH" );
        return false;
      }
    }
  }*/

  // Geom
  if ( myToCreate )
  {
    QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
    if ( aGeomEntry == "" )
    {
      theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
      return false;
    }
    _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
    if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
    {
      theMess = tr( "GEOMETRY_OBJECT_IS_NULL" );
      return false;
    }

    // Mesh
    if ( !myIsMesh ) // i.e sub-mesh creation,
    {
      QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
      if ( aMeshEntry == "" )
      {
        theMess = tr( "MESH_IS_NOT_DEFINED" );
        return false;
      }
      _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
      if ( !pMesh || SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() )->_is_nil() )
      {
        theMess = tr( "MESH_IS_NULL" );
        return false;
      }
      if ( !isSubshapeOk() )
      {
        theMess = tr( "INVALID_SUBSHAPE" );
        return false;
      }
    }
  }

  return true;
}
bool SMESHGUI_MeshOp::isValid ( SUIT_Operation *  theOp) const [protected, virtual]

Verifies whether given operator is valid for this one.

Parameters:
theOtherOp- other operation
Returns:
Returns TRUE if the given operator is valid for this one, FALSE otherwise

method redefined from base class verifies whether given operator is valid for this one (i.e. can be started "above" this operator). In current implementation method retuns false if theOtherOp operation is not intended for deleting objects or mesh elements.

Reimplemented from SMESHGUI_Operation.

Definition at line 2246 of file SMESHGUI_MeshOp.cxx.

Referenced by onApply().

{
  return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
}
SMESH::SMESH_Mesh_var SMESHGUI_SelectionOp::mesh ( ) const [protected, inherited]

Return selected mesh if selection mode isn't ActorSelection and only one object is selected.

Definition at line 448 of file SMESHGUI_SelectionOp.cxx.

References SMESH.GetMeshByIO(), and SMESHGUI_SelectionOp.selectionMode().

Referenced by SMESHGUI_SelectionOp.actor(), SMESHGUI_ConvToQuadOp.ConnectRadioButtons(), isSubshapeOk(), SMESHGUI_GroupOnShapeOp.onApply(), SMESHGUI_ConvToQuadOp.onApply(), selectionDone(), SMESHGUI_ConvToQuadOp.selectionDone(), and SMESHGUI_SelectionOp.typeById().

{
  if( selectionMode()==ActorSelection )
    return SMESH::SMESH_Mesh::_nil();
    
  SALOME_ListIO sel; selectionMgr()->selectedObjects( sel, SVTK_Viewer::Type() );
  if( sel.Extent()==1 )
    return SMESH::GetMeshByIO( sel.First() );
  else
    return SMESH::SMESH_Mesh::_nil();
}
QString SMESHGUI_MeshOp::name ( _PTR(SObject)  theSO) const [private]

Gets name of object.

Parameters:
theSO- SObject
Return values:
QString- name of object

Gets name of object

Definition at line 2065 of file SMESHGUI_MeshOp.cxx.

References _PTR().

Referenced by readMesh().

{
  QString aResName;
  if ( theSO )
  {
    _PTR(GenericAttribute) anAttr;
    _PTR(AttributeName)    aNameAttr;
    if ( theSO->FindAttribute( anAttr, "AttributeName" ) )
    {
      aNameAttr = anAttr;
      aResName = aNameAttr->Value().c_str();
    }
  }
  return aResName;
}
void SMESHGUI_SelectionOp::onActivateObject ( int  id) [protected, virtual, slot, inherited]

Installs filter corresponding to certain object selection widget.

Definition at line 180 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.createFilter(), SMESHGUI_SelectionOp.myFilters, and SMESHGUI_SelectionOp.selectionDone().

Referenced by SMESHGUI_GroupOnShapeOp.init(), SMESHGUI_GroupOnShapeOp.onButtonClick(), onHypoCreated(), onHypoEdited(), and SMESHGUI_SelectionOp.startOperation().

{
  LightApp_SelectionMgr* mgr = selectionMgr();
  if( !mgr )
    return;
    
  if( !myFilters.contains( id ) )
    myFilters[ id ] = createFilter( id );

  if( myFilters[ id ] )
    mgr->installFilter( myFilters[ id ] );

  selectionDone();
}
void SMESHGUI_MeshOp::onAlgoSelected ( const int  theIndex,
const int  theDim = -1 
) [protected, slot]

Set available algos and hypos according to the selected algorithm.

Parameters:
theIndex- algorithm index

Definition at line 1348 of file SMESHGUI_MeshOp.cxx.

References _PTR(), Algo, availableHyps(), currentHyp(), SMESH.DIM_0D, SMESH.DIM_3D, ex10_grid4geometry.dir, existingHyps(), find(), SMESH.GetHypothesisData(), getTabDim(), hypData(), isAccessibleDim(), SMESH.IsAvailableHypothesis(), isCompatible(), MainHyp, SMESHGUI_MeshDlg.Mesh, myAvailableHypData, myDlg, myExistingHyps, myIgnoreAlgoSelection, myIsMesh, myObjHyps, myToCreate, NbHypTypes, SMESHGUI_MeshTab.setAvailableHyps(), setCurrentHyp(), SMESHGUI_MeshTab.setExistingHyps(), and SMESHGUI_MeshDlg.tab().

Referenced by processSet(), readMesh(), selectionDone(), and startOperation().

{
  if ( myIgnoreAlgoSelection )
    return;

  int aDim = theDim < 0 ? getTabDim( sender(), myDlg ): theDim;
  if (aDim == -1)
    return;

  // find highest available dimension, all algos of this dimension are available for choice
  int aTopDim = -1;
  for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
    if (isAccessibleDim( i ))
      aTopDim = i;
  if (aTopDim == -1)
    return;

  const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));

  HypothesisData* algoData = hypData( aDim, Algo, theIndex );
  HypothesisData* algoByDim[4];
  algoByDim[ aDim ] = algoData;

  QStringList anAvailable;
  if ( !algoData ) { // all algos becomes available
    availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
    myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
  }

  // check that algorithms of other dimentions are compatible with
  // the selected one

   // 2 loops: backward and forward from algo dimension
  for ( int forward = false; forward <= true; ++forward )
  {
    int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
    if ( !forward ) {
      dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
    }
    HypothesisData* prevAlgo = algoData;
    bool noCompatible = false;
    for ( ; dim * dir <= lastDim * dir; dim += dir)
    {
      if ( !isAccessibleDim( dim ))
        continue;
      if ( noCompatible ) { // the selected algo has no compatible ones
        anAvailable.clear();
        myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
        myAvailableHypData[dim][Algo].clear();
        algoByDim[ dim ] = 0;
        continue;
      }
      // get currently selected algo
      int algoIndex = currentHyp( dim, Algo );
      HypothesisData* curAlgo = hypData( dim, Algo, algoIndex );
      if ( curAlgo ) { // some algo selected
        if ( !isCompatible( prevAlgo, curAlgo, Algo ))
          curAlgo = 0;
      }
      // set new available algoritms
      availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
      HypothesisData* soleCompatible = 0;
      if ( anAvailable.count() == 1 )
        soleCompatible = myAvailableHypData[dim][Algo][0];
      if ( dim == aTopDim && prevAlgo ) // all available algoritms should be selectable any way
        availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
      myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
      noCompatible = anAvailable.isEmpty();

      // restore previously selected algo
      algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
      if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
        // select the sole compatible algo
        algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
      setCurrentHyp( dim, Algo, algoIndex );

      // remember current algo
      prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
    }
  }

  // set hypotheses corresponding to the found algoritms

  _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");

  for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
  {
    if ( !isAccessibleDim( dim ))
      continue;
    for ( int type = MainHyp; type < NbHypTypes; type++ )
    {
      myAvailableHypData[ dim ][ type ].clear();
      QStringList anAvailable, anExisting;

      HypothesisData* curAlgo = algoByDim[ dim ];
      int hypIndex = currentHyp( dim, type );

      SMESH::SMESH_Hypothesis_var curHyp;
      if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
        curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;

      if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
        // try to find algo by selected hypothesis in order to keep it selected
        bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
        CORBA::String_var curHypType = curHyp->GetName();
        if ( !algoDeselectedByUser &&
             myObjHyps[ dim ][ type ].count() > 0 &&
             !strcmp( curHypType, myObjHyps[ dim ][ type ].first().first->GetName()) )
        {
          HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
          for (int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i) {
            curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
            if (curAlgo && hypData && isCompatible(curAlgo, hypData, type))
              break;
            else
              curAlgo = 0;
          }
        }
      }
      // get hyps compatible with curAlgo
      if ( curAlgo )
      {
        // check if a selected hyp is compatible with the curAlgo
        if ( !curHyp->_is_nil() ) {
          HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
          if ( !isCompatible( curAlgo, hypData, type ))
            curHyp = SMESH::SMESH_Hypothesis::_nil();
        }
        existingHyps( dim, type, pObj, anExisting, myExistingHyps[ dim ][ type ], curAlgo);
        availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo);
      }
      // set list of hypotheses
      myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
      myDlg->tab( dim )->setExistingHyps( type, anExisting );

      // set current existing hypothesis
      if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
        hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
      else
        hypIndex = -1;
      if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
        // none is yet selected => select the sole existing if it is not optional
        CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
        bool isOptional = true;
        if ( algoByDim[ dim ] &&
             SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
             !isOptional )
          hypIndex = 0;
      }
      setCurrentHyp( dim, type, hypIndex );
    }
  }
}
bool SMESHGUI_MeshOp::onApply ( ) [protected, virtual, slot]

Creates or edits mesh.

Return values:
bool- TRUE if operation is performed successfully, FALSE otherwise

Virtual slot redefined from the base class called when "Apply" button is clicked creates or edits mesh

Reimplemented from SMESHGUI_Operation.

Definition at line 132 of file SMESHGUI_MeshOp.cxx.

References createMesh(), createSubMesh(), dlg(), editMeshOrSubMesh(), SMESHGUI_Operation.isApplyAndClose(), SMESHGUI_Operation.isStudyLocked(), isValid(), SMESHGUI.Modified(), myDlg, myIsMesh, myObjectToSelect, myToCreate, and setDefaultName().

{
  if (isStudyLocked())
    return false;

  QString aMess;
  if ( !isValid( aMess ) )
  {
    dlg()->show();
    if ( aMess != "" )
      SUIT_MessageBox::warning( myDlg, tr( "SMESH_WRN_WARNING" ), aMess );
    return false;
  }

  bool aResult = false;
  aMess = "";
  try
  {
    QStringList anEntryList;
    if ( myToCreate && myIsMesh )
      aResult = createMesh( aMess, anEntryList );
    if ( myToCreate && !myIsMesh )
      aResult = createSubMesh( aMess, anEntryList );
    else if ( !myToCreate )
      aResult = editMeshOrSubMesh( aMess );
    if ( aResult )
    {
      SMESHGUI::Modified();
      update( UF_ObjBrowser | UF_Model );
      if( LightApp_Application* anApp =
          dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
        myObjectToSelect = anApp->browseObjects( anEntryList, isApplyAndClose() );
    }
  }
  catch ( const SALOME::SALOME_Exception& S_ex )
  {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
    aResult = false;
  }
  catch ( ... )
  {
    aResult = false;
  }

  if ( aResult )
  {
    if ( myToCreate )
      setDefaultName();
  }
  else
  {
    if ( aMess == "" )
      aMess = tr( "SMESH_OPERATION_FAILED" );
    SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), aMess );
  }

  return aResult;
}
void SMESHGUI_Operation::onCancel ( ) [protected, virtual, slot, inherited]
void SMESHGUI_MeshOp::onCloseShapeByMeshDlg ( SUIT_Operation *  op) [protected, slot]

SLOT.

Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg

Definition at line 2311 of file SMESHGUI_MeshOp.cxx.

References myDlg, myShapeByMeshOp, and SMESHGUI_Dialog.show().

Referenced by onGeomSelectionByMesh().

{
  if ( myShapeByMeshOp == op && myDlg ) {
    myDlg->show();
  }
}
void SMESHGUI_MeshOp::onCreateHyp ( const int  theHypType,
const int  theIndex 
) [protected, slot]

Create hypothesis.

Parameters:
theHypType- hypothesis category (main or additional)
theIndex- index of type of hypothesis to be cerated

Specifies dimension of hypothesis to be created (using sender() method), specifies its type and calls method for hypothesis creation

Definition at line 1023 of file SMESHGUI_MeshOp.cxx.

References createHypothesis(), getTabDim(), myAvailableHypData, and myDlg.

Referenced by startOperation().

{
  // Specifies dimension of hypothesis to be created
  int aDim = getTabDim( sender(), myDlg );
  if (aDim == -1)
    return;

  // Specifies type of hypothesis to be created
  THypDataList& dataList = myAvailableHypData[ aDim ][ theHypType ];
  if (theIndex < 0 || theIndex >= dataList.count())
    return;
  QString aHypTypeName = dataList[ theIndex ]->TypeName;

  // Create hypothesis
  createHypothesis(aDim, theHypType, aHypTypeName);
}
void SMESHGUI_SelectionOp::onDeactivateObject ( int  id) [protected, virtual, slot, inherited]

Removes filter corresponding to certain object selection widget.

Definition at line 199 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.removeCustomFilters().

Referenced by SMESHGUI_SelectionOp.startOperation().

void SMESHGUI_MeshOp::onEditHyp ( const int  theHypType,
const int  theIndex 
) [protected, slot]

Calls plugin methods for hypothesis editing.

Parameters:
theHypType- specifies whether main hypothesis or additional one is edited
theIndex- index of existing hypothesis

Calls plugin methods for hypothesis editing

Definition at line 1227 of file SMESHGUI_MeshOp.cxx.

References _PTR(), dlg(), SMESHGUI_GenericHypothesisCreator.edit(), SMESHGUI_MeshDlg.Geom, SMESH.GetHypothesisCreator(), getInitParamsHypothesis(), SMESH.GetShapeOnMeshOrSubMesh(), getTabDim(), SMESHGUI_MeshDlg.Mesh, myDlg, myExistingHyps, myIsMesh, myToCreate, SMESHGUI_MeshDlg.Obj, onHypoEdited(), SMESHGUI_SelectionOp.removeCustomFilters(), SMESHGUI_GenericHypothesisCreator.setInitParamsHypothesis(), SMESHGUI_GenericHypothesisCreator.setMainShapeEntry(), and SMESHGUI_GenericHypothesisCreator.setShapeEntry().

Referenced by startOperation().

{
  // Speicfies dimension of hypothesis to be created
  int aDim = getTabDim( sender(), myDlg );
  if (aDim == -1)
    return;

  const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
  if ( theIndex < 0 || theIndex >= aList.count() )
    return;
  const THypItem& aHypItem = aList[ theIndex ];
  SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
  if ( aHyp->_is_nil() )
    return;

  SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHyp->GetName());
  if ( aCreator )
  {
    // Get initial parameters
    SMESH::SMESH_Hypothesis_var initParamHyp =
      getInitParamsHypothesis( aHyp->GetName(), aHyp->GetLibName());
    aCreator->setInitParamsHypothesis( initParamHyp );

    // Get Entry of the Geom object
    QString aGeomEntry = "";
    QString aMeshEntry = "";
    QString anObjEntry = "";
    aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
    aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
    anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );

    if ( myToCreate && myIsMesh )
      aMeshEntry = aGeomEntry;

    if ( aMeshEntry != aGeomEntry ) { // Get Geom object from Mesh of a sub-mesh being edited
      _PTR(SObject) pObj = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
      GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
      aMeshEntry = ( aGeomVar->_is_nil() ) ? "" : aMeshEntry = aGeomVar->GetStudyEntry();
    }

    if ( aMeshEntry == "" && aGeomEntry == "" ) { // get geom of an object being edited
      _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
      bool isMesh;
      GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj, &isMesh );
      if ( !aGeomVar->_is_nil() )
      {
        aGeomEntry = aGeomVar->GetStudyEntry();
        if ( isMesh )
          aMeshEntry = aGeomEntry;
      }
    }

    if ( anObjEntry != "" && aGeomEntry != "" && aMeshEntry == "" ) {
      // take geometry from submesh being created
      _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
      if ( pObj ) {
        // if current object is sub-mesh
        SMESH::SMESH_subMesh_var aSubMeshVar =
          SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
        if ( !aSubMeshVar->_is_nil() ) {
          SMESH::SMESH_Mesh_var aMeshVar =  aSubMeshVar->GetFather();
          if ( !aMeshVar->_is_nil() ) {
            _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
            GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO );
            if ( !aGeomVar->_is_nil() )
              aMeshEntry = aGeomVar->GetStudyEntry();
          }
        }
      }
    }

    aCreator->setShapeEntry( aGeomEntry );
    if ( aMeshEntry != "" )
      aCreator->setMainShapeEntry( aMeshEntry );
    removeCustomFilters(); // Issue 0020170
    myDlg->setEnabled( false );
    aCreator->edit( aHyp.in(), aHypItem.second, dlg(), this, SLOT( onHypoEdited( int ) ) );
  }
}
void SMESHGUI_MeshOp::onGeomSelectionByMesh ( bool  theByMesh) [protected, slot]

SLOT.

Is called when the user selects a way of geometry selection

Parameters:
theByMesh- true if the user wants to find geometry by mesh element

Definition at line 2257 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_Operation.getSMESHGUI(), SMESHGUI_MeshDlg.Mesh, myDlg, myShapeByMeshOp, onCloseShapeByMeshDlg(), onPublishShapeByMeshDlg(), and SMESHGUI_ShapeByMeshOp.SetMesh().

Referenced by startOperation().

{
  if ( theByMesh ) {
    if ( !myShapeByMeshOp ) {
      myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
      connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
              SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
      connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
              SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
    }
    // set mesh object to SMESHGUI_ShapeByMeshOp and start it
    QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
    if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
      SMESH::SMESH_Mesh_var aMeshVar =
        SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
      if ( !aMeshVar->_is_nil() ) {
        myDlg->hide(); // stop processing selection
        myShapeByMeshOp->setModule( getSMESHGUI() );
        myShapeByMeshOp->setStudy( 0 ); // it's really necessary
        myShapeByMeshOp->SetMesh( aMeshVar );
        myShapeByMeshOp->start();
      }
    }
  }
}
void SMESHGUI_Operation::onHelp ( ) [protected, slot, inherited]

Definition at line 191 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.getSMESHGUI(), and SMESHGUI_Operation.myHelpFileName.

Referenced by SMESHGUI_Operation.startOperation(), and SMESHGUI_PrecomputeOp.startOperation().

{
  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
  if (app)
    app->onHelpContextModule(getSMESHGUI() ? app->moduleName(getSMESHGUI()->moduleName()) : QString(""), myHelpFileName);
  else {
    QString platform;
#ifdef WIN32
    platform = "winapplication";
#else
    platform = "application";
#endif
    SUIT_MessageBox::warning( desktop(), tr("WRN_WARNING"),
                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
                                                                  platform)).
                              arg(myHelpFileName) );
  }
}
void SMESHGUI_MeshOp::onHypoCreated ( int  result) [protected, slot]

Necessary steps after hypothesis creation.

Parameters:
result- creation result: 0 = rejected 1 = accepted 2 = additional value meaning that slot is called not from dialog box

Definition at line 1192 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_MeshTab.addHyp(), Algo, currentHyp(), existingHyps(), SMESHGUI_MeshDlg.getActiveObject(), hypData(), myDim, myDlg, myExistingHyps, myHypoSet, myType, SMESHGUI_SelectionOp.onActivateObject(), processSet(), and SMESHGUI_MeshDlg.tab().

Referenced by createHypothesis().

{
  if( result != 2 )
  {
    int obj = myDlg->getActiveObject();
    onActivateObject( obj ); // Issue 0020170. Restore filters
    myDlg->setEnabled( true );
  }

  _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");

  int nbHyp = myExistingHyps[myDim][myType].count();
  HypothesisData* algoData = hypData( myDim, Algo, currentHyp( myDim, Algo ));
  QStringList aNewHyps;
  existingHyps(myDim, myType, aFather, aNewHyps, myExistingHyps[myDim][myType], algoData);
  if (aNewHyps.count() > nbHyp)
  {
    for (int i = nbHyp; i < aNewHyps.count(); i++)
      myDlg->tab(myDim)->addHyp(myType, aNewHyps[i]);
  }

  if( result!=2 && myHypoSet )
    processSet();
}
void SMESHGUI_MeshOp::onHypoEdited ( int  result) [protected, slot]

Necessary steps after hypothesis edition.

Parameters:
result- creation result: 0 = rejected 1 = accepted

Definition at line 1315 of file SMESHGUI_MeshOp.cxx.

References SMESHGUI_MeshDlg.getActiveObject(), myDlg, and SMESHGUI_SelectionOp.onActivateObject().

Referenced by onEditHyp().

{
  int obj = myDlg->getActiveObject();
  onActivateObject( obj ); // Issue 0020170. Restore filters
  myDlg->setEnabled( true );
}
void SMESHGUI_MeshOp::onHypoSet ( const QString &  theSetName) [protected, slot]

Creates and selects hypothesis of hypotheses set.

Parameters:
theSetName- The name of hypotheses set

Definition at line 1509 of file SMESHGUI_MeshOp.cxx.

References AddHyp, Algo, SMESH.DIM_0D, SMESH.DIM_3D, SMESH.GetHypothesesSet(), HypothesesSet.init(), MainHyp, myHypoSet, processSet(), and setCurrentHyp().

Referenced by startOperation().

{
  myHypoSet = SMESH::GetHypothesesSet(theSetName);
  if (!myHypoSet)
    return;

  // clear all hyps
  for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
    setCurrentHyp(dim, Algo, -1);
    setCurrentHyp(dim, AddHyp, -1);
    setCurrentHyp(dim, MainHyp, -1);
  }

  myHypoSet->init(true); //algorithms
  processSet();
  myHypoSet->init(false); //hypotheses
  processSet();
  myHypoSet = 0;
}
void SMESHGUI_Operation::onOk ( ) [protected, virtual, slot, inherited]
void SMESHGUI_MeshOp::onPublishShapeByMeshDlg ( SUIT_Operation *  op) [protected, slot]

SLOT.

Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg

Definition at line 2288 of file SMESHGUI_MeshOp.cxx.

References _PTR(), SMESHGUI_ShapeByMeshOp.GetShape(), SMESHGUI.GetSMESHGUI(), myDlg, myShapeByMeshOp, selectionDone(), selectObject(), and SMESHGUI_Dialog.show().

Referenced by onGeomSelectionByMesh().

{
  if ( myShapeByMeshOp == op ) {
    SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006  IPAL13980 - Object Browser update added
    myDlg->show();
    // Select a found geometry object
    GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
    if ( !aGeomVar->_is_nil() )
    {
      QString ID = aGeomVar->GetStudyEntry();
      if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.toLatin1().data() )) {
        selectObject( aGeomSO );
        selectionDone();
      }
    }
  }
}
void SMESHGUI_SelectionOp::onSelectionChanged ( int  ) [protected, virtual, slot, inherited]

Empty default implementation.

In successors it may be used for more advanced selection checking. This slot is connected to signal when the selection changed in some object selection widget

Definition at line 221 of file SMESHGUI_SelectionOp.cxx.

Referenced by SMESHGUI_SelectionOp.startOperation().

{
}
void SMESHGUI_SelectionOp::onTextChanged ( int  ,
const QStringList &  list 
) [protected, virtual, slot, inherited]

Default implementation allowing user to edit selected ids "by hands".

In order to run default mechanism, you must set for some object selection widget the "name indication" to "ListOfNames", "read only" state to false and connect the dialog's signal "objectChanged" to this slot Warning: this mechanism can process only integer ids, NOT MESH OR GROUP NAMES!!!

Definition at line 477 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.actor(), SMESHGUI_SelectionOp.extractIds(), SMDS_Mesh.FindNode(), SMESH_Actor.GetObject(), SMESHGUI_SelectionOp.highlight(), SMESH_test.ids, SMESH_reg.names, SMESHGUI_SelectionOp.selected(), and SMESHGUI_SelectionOp.selector().

{
    if( !dlg() )
      return;

    TColStd_MapOfInteger newIndices;

    SALOME_ListIO sel; selectionMgr()->selectedObjects( sel );
    SMESH_Actor* anActor = actor();
    if( sel.Extent()==0 || !anActor )
      return;

    SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();

    IdList ids; extractIds( list, ids, '\0' );
    IdList::const_iterator anIt = ids.begin(),
                           aLast = ids.end();
    for( ; anIt!=aLast; anIt++ )
      if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) )
        newIndices.Add( n->GetID() );

    selector()->AddOrRemoveIndex( sel.First(), newIndices, false );
    highlight( sel.First(), true, true );

    QStringList names, _ids; LightApp_Dialog::TypesList types;
    selected( names, types, _ids );
    dlg()->selectObject( names, types, _ids, false );
}
void SMESHGUI_MeshOp::processSet ( ) [protected, slot]

One step of hypothesis/algorithm list creation.

Creates a hypothesis or an algorithm for current item of internal list of names myHypoSet

Definition at line 1536 of file SMESHGUI_MeshOp.cxx.

References AddHyp, Algo, availableHyps(), createHypothesis(), HypothesesSet.current(), HypothesisData.Dim, SMESH.GetHypothesisData(), HypothesesSet.isAlgo(), MainHyp, HypothesesSet.more(), myAvailableHypData, myDlg, myHypoSet, HypothesesSet.next(), onAlgoSelected(), SMESHGUI_MeshTab.setAvailableHyps(), setCurrentHyp(), and SMESHGUI_MeshDlg.tab().

Referenced by onHypoCreated(), and onHypoSet().

{
  myHypoSet->next();
  if( !myHypoSet->more() )
    return;

  bool isAlgo = myHypoSet->isAlgo();
  QString aHypoTypeName = myHypoSet->current();
  HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
  if (!aHypData)
  {
    processSet();
    return;
  }

  int aDim = aHypData->Dim[0];
  // create or/and set
  if (isAlgo)
  {
    int index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
    if ( index < 0 )
    {
      QStringList anAvailable;
      availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
      myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
      index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
    }
    setCurrentHyp( aDim, Algo, index );
    onAlgoSelected( index, aDim );
    processSet();
  }
  else
  {
    bool mainHyp = true;
    QStringList anAvailable;
    availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
    myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
    int index = myAvailableHypData[aDim][MainHyp].indexOf( aHypData );
    if ( index < 0 )
    {
      mainHyp = false;
      index = myAvailableHypData[aDim][AddHyp].indexOf( aHypData );
    }
    if (index >= 0)
      createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
    else
      processSet();
  }
}
void SMESHGUI_MeshOp::readMesh ( ) [private]

Reads parameters of edited mesh and assigns them to the dialog.

Reads parameters of edited mesh and assigns them to the dialog (called when mesh is edited only)

Definition at line 1967 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, Algo, currentHyp(), SMESH.DIM_0D, SMESH.DIM_3D, existingHyps(), find(), SMESHGUI_MeshDlg.Geom, SMESH.GetHypothesisData(), SMESH.GetShapeOnMeshOrSubMesh(), MainHyp, SMESHGUI_MeshDlg.Mesh, myAvailableHypData, myDlg, myExistingHyps, myIsOnGeometry, myObjHyps, name(), SMESHGUI_MeshDlg.Obj, onAlgoSelected(), setCurrentHyp(), SMESHGUI_MeshTab.setExistingHyps(), and SMESHGUI_MeshDlg.tab().

Referenced by selectionDone().

{
  QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
  _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
  if ( !pObj )
    return;

  if (myIsOnGeometry) {
    // Get name of mesh if current object is sub-mesh
    SMESH::SMESH_subMesh_var aSubMeshVar =
      SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
    if ( !aSubMeshVar->_is_nil() )
    {
      SMESH::SMESH_Mesh_var aMeshVar =  aSubMeshVar->GetFather();
      if ( !aMeshVar->_is_nil() )
      {
        _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
        QString aMeshName = name( aMeshSO );
        myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
      }
    }

    // Get name of geometry object
    GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
    if ( !aGeomVar->_is_nil() )
    {
      _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
      QString aShapeName = name( aGeomSO );
      myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
    }
  }

  // Get hypotheses and algorithms assigned to the mesh/sub-mesh
  QStringList anExisting;
  const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
  {
    // get algorithm
    existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
    // find algo index among available ones
    int aHypIndex = -1;
    if ( myObjHyps[ dim ][ Algo ].count() > 0 )
    {
      SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first().first;
      HypothesisData* algoData = SMESH::GetHypothesisData( aVar->GetName() );
      aHypIndex = myAvailableHypData[ dim ][ Algo ].indexOf ( algoData );
//       if ( aHypIndex < 0 && algoData ) {
//         // assigned algo is incompatible with other algorithms
//         myAvailableHypData[ dim ][ Algo ].push_back( algoData );
//         aHypIndex = myAvailableHypData[ dim ][ hypType ].count() - 1;
//       }
    }
    setCurrentHyp( dim, Algo, aHypIndex );
    // set existing and available hypothesis according to the selected algo
    onAlgoSelected( aHypIndex, dim );
  }

  // get hypotheses
  bool hypWithoutAlgo = false;
  for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
  {
    for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
    {
      // get hypotheses
      existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
      // find index of requered hypothesis among existing ones for this dimension and type
      int aHypIndex = -1;
      if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
        aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
                          myExistingHyps[ dim ][ hypType ] );
        if ( aHypIndex < 0 ) {
          // assigned hypothesis is incompatible with the algorithm
          if ( currentHyp( dim, Algo ) < 0 )
          { // none algo selected; it is edition for sure, of submesh maybe
            hypWithoutAlgo = true;
            myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
            aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
            myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
          }
        }
      }
      setCurrentHyp( dim, hypType, aHypIndex );
    }
  }
  // make available other hyps of same type as one without algo
  if ( hypWithoutAlgo )
    onAlgoSelected( currentHyp( 0, Algo ), 0 );
}
void SMESHGUI_SelectionOp::removeCustomFilters ( ) [protected, inherited]

Remove only filters set by this operation (they are in map myFilters )

Definition at line 101 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.myFilters.

Referenced by SMESHGUI_SelectionOp.abortOperation(), SMESHGUI_SelectionOp.commitOperation(), createHypothesis(), SMESHGUI_GroupOnShapeOp.init(), SMESHGUI_GroupOnShapeOp.onApply(), SMESHGUI_GroupOnShapeOp.onButtonClick(), SMESHGUI_SelectionOp.onDeactivateObject(), onEditHyp(), and SMESHGUI_SelectionOp.~SMESHGUI_SelectionOp().

{
  if (myFilters.count() > 0) {
    LightApp_SelectionMgr* mgr = selectionMgr();
    Filters::const_iterator anIt = myFilters.begin(),
                            aLast = myFilters.end();
    for ( ; anIt != aLast; anIt++) {
      if (anIt.value()) {
        if (mgr) mgr->removeFilter(anIt.value());
        delete anIt.value();
      }
    }

    myFilters.clear();
  }
}
void SMESHGUI_SelectionOp::selected ( QStringList &  ,
SMESHGUI_Dialog::TypesList &  ,
QStringList &   
) const [protected, virtual, inherited]

Get names, types and ids of selected objects.

Definition at line 359 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_Operation._PTR(), SMESHGUI_SelectionOp.idChar(), SMESHGUI_SelectionOp.MeshElement, SMESHGUI_SelectionOp.MeshNode, SMESHGUI_SelectionOp.Object, SMESHGUI_SelectionOp.selectionMode(), and SMESHGUI_SelectionOp.typeById().

Referenced by SMESHGUI_SelectionOp.onTextChanged(), SMESHGUI_BoundingBox.selectionChanged(), SMESHGUI_MinDistance.selectionChanged(), SMESHGUI_SelectionOp.selectionDone(), SMESHGUI_Make2DFrom3DOp.selectionDone(), and SMESHGUI_GroupOnShapeOp.selectionDone().

{
/*  SUIT_DataOwnerPtrList list; selectionMgr()->selected( list );
  SUIT_DataOwnerPtrList::const_iterator anIt = list.begin(),
                                        aLast = list.end();
  for( ; anIt!=aLast; anIt++ )
  {
    LightApp_DataOwner* owner = dynamic_cast<LightApp_DataOwner*>( (*anIt).operator->() );
    LightApp_SVTKDataOwner* vtkowner = dynamic_cast<LightApp_SVTKDataOwner*>( (*anIt).operator->() );

    if( vtkowner )
    {
      QString id_str = QString( "%1%2%3" ).arg( vtkowner->entry() ).arg( idChar() ), current_id_str;
      Selection_Mode mode = vtkowner->GetMode();
      EntityType objtype = mode == NodeSelection ? MeshNode : MeshElement;
      const TColStd_IndexedMapOfInteger& ownerids = vtkowner->GetIds();

      for( int i=1, n=ownerids.Extent(); i<=n; i++ )
      {
        int curid = ownerids( i );
        current_id_str = id_str.arg( curid );
        ids.append( current_id_str );
        types.append( typeById( current_id_str, objtype ) );
        names.append( QString( "%1" ).arg( curid ) );
      }
    }

    else if( owner )
    {
      QString id = owner->entry();
      ids.append( id );
      types.append( typeById( id, Object ) );
      names.append( owner->IO()->getName() );
    }
  }*/

  SALOME_ListIO selObjs;
  TColStd_IndexedMapOfInteger selIndices;
  selectionMgr()->selectedObjects( selObjs );
  Selection_Mode mode = selectionMode();
  EntityType objtype = mode == NodeSelection ? MeshNode : MeshElement;

  for( SALOME_ListIteratorOfListIO anIt( selObjs ); anIt.More(); anIt.Next() )
  {
    selIndices.Clear();
    selectionMgr()->GetIndexes( anIt.Value(), selIndices );
    if( selIndices.Extent() > 0 )
    {
      QString id_str = QString( "%1%2%3" ).arg( anIt.Value()->getEntry() ).arg( idChar() ), current_id_str;
      for( int i=1, n=selIndices.Extent(); i<=n; i++ )
      {
        int curid = selIndices( i );
        current_id_str = id_str.arg( curid );
        ids.append( current_id_str );
        types.append( typeById( current_id_str, objtype ) );
        names.append( QString( "%1" ).arg( curid ) );
      }
    }
    else
    {
      QString id = anIt.Value()->getEntry();
      ids.append( id );
      types.append( typeById( id, Object ) );
      SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
      if( _study )
      {
        _PTR(SObject) obj = _study->studyDS()->FindObjectID( anIt.Value()->getEntry() );
        if( obj )
          names.append( obj->GetName().c_str() );
      }
    }
  }
}
void SMESHGUI_SelectionOp::selectedIds ( const int  id,
IdList list 
) const [protected, inherited]

Try to find in certain object selection widget selected node or element ids and return it.

Definition at line 510 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.extractIds(), and SMESH_test.ids.

{
  if( !dlg() )
    return;

  QStringList ids; dlg()->selectedObject( id, ids );
  extractIds( ids, list );
}
void SMESHGUI_MeshOp::selectionDone ( ) [protected, virtual]

Updates dialog's look and feel.

Virtual method redefined from the base class updates dialog's look and feel

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 476 of file SMESHGUI_MeshOp.cxx.

References _PTR(), Algo, SMESH_fixation.aShape, availableHyps(), SMESH.DIM_0D, SMESH.DIM_3D, SMESHGUI_MeshDlg.disableTab(), dlg(), EDGE, SMESHGUI_MeshDlg.enableTab(), FACE, SMESHGUI_MeshDlg.Geom, SMESH.GetHypothesesSets(), SMESH.GetShapeOnMeshOrSubMesh(), SMESHGUI.GetSMESHGUI(), isSubmeshIgnored(), SMESHGUI_SelectionOp.mesh(), SMESHGUI_MeshDlg.Mesh, myAvailableHypData, myDlg, myIsMesh, myIsOnGeometry, myToCreate, SMESHGUI_MeshDlg.Obj, onAlgoSelected(), readMesh(), SMESHGUI_MeshDlg.reset(), selectObject(), SMESHGUI_MeshTab.setAvailableHyps(), SMESHGUI_MeshDlg.setGeomPopupEnabled(), SMESHGUI_MeshDlg.setHypoSets(), SMESHGUI_MeshDlg.setMaxHypoDim(), SMESHGUI.switchToOperation(), and SMESHGUI_MeshDlg.tab().

Referenced by createSubMesh(), onPublishShapeByMeshDlg(), and startOperation().

{
  if (!dlg()->isVisible() || !myDlg->isEnabled())
    return;

  SMESHGUI_SelectionOp::selectionDone();

  try
  {
    myIsOnGeometry = true;

    //Check geometry for mesh
    QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
    _PTR(SObject) pObj = studyDS()->FindObjectID(anObjEntry.toLatin1().data());
    if (pObj)
    {
      SMESH::SMESH_Mesh_var aMeshVar =
        SMESH::SMESH_Mesh::_narrow(_CAST(SObject,pObj)->GetObject());
      if (!aMeshVar->_is_nil()) {
        if (!myToCreate && !aMeshVar->HasShapeToMesh())
          myIsOnGeometry = false;
      }
    }

    if (myIsOnGeometry)
    {
      // Enable tabs according to shape dimension

      int shapeDim = 3;

      QStringList aGEOMs;
      myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
      GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;

      if (aGEOMs.count() > 0) {
        // one or more GEOM shape selected
        aSeq->length(aGEOMs.count());
        QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
        int iSubSh = 0;
        for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
          QString aSubGeomEntry = (*aSubShapesIter);
          _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
          GEOM::GEOM_Object_var aSubGeomVar =
            GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
          aSeq[iSubSh] = aSubGeomVar;
        }
      } else {
        // get geometry by selected sub-mesh
        QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
        _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
        GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
        if (!aGeomVar->_is_nil()) {
          aSeq->length(1);
          aSeq[0] = aGeomVar;
        }
      }

      if (aSeq->length() > 0) {
        shapeDim = -1;
        for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
          GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
          switch ( aGeomVar->GetShapeType() ) {
          case GEOM::SOLID:  shapeDim = 3; break;
          case GEOM::SHELL:
            {
              //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
              TopoDS_Shape aShape;
              bool isClosed = GEOMBase::GetShape(aGeomVar, aShape) && /*aShape.Closed()*/BRep_Tool::IsClosed(aShape);
              shapeDim = qMax(isClosed ? 3 : 2, shapeDim);
            }
            break;
          case GEOM::FACE:   shapeDim = qMax(2, shapeDim); break;
          case GEOM::WIRE:
          case GEOM::EDGE:   shapeDim = qMax(1, shapeDim); break;
          case GEOM::VERTEX: shapeDim = qMax(0, shapeDim); break;
          default:
            {
              TopoDS_Shape aShape;
              if (GEOMBase::GetShape(aGeomVar, aShape)) {
                TopExp_Explorer exp (aShape, TopAbs_SHELL);
                if (exp.More()) {
                  //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
                  shapeDim = qMax(2, shapeDim);
                  for (; exp.More() && shapeDim == 2; exp.Next()) {
                    if (/*exp.Current().Closed()*/BRep_Tool::IsClosed(exp.Current()))
                      shapeDim = 3;
                  }
                }
                else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
                  shapeDim = qMax(2, shapeDim);
                else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
                  shapeDim = qMax(1, shapeDim);
                else if ( exp.Init( aShape, TopAbs_VERTEX ), exp.More() )
                  shapeDim = qMax(0, shapeDim);
              }
            }
          }
        }
      }
      for (int i = SMESH::DIM_3D; i > shapeDim; i--) {
        // reset algos before disabling tabs (0020138)
        onAlgoSelected(-1, i);
      }
      myDlg->setMaxHypoDim( shapeDim );
      myDlg->setHypoSets( SMESH::GetHypothesesSets( shapeDim ));

      if (!myToCreate) // edition: read hypotheses
      {
        if (pObj != 0)
        {
          SMESH::SMESH_subMesh_var aVar =
            SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
          myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
          myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
          myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
          myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
          myDlg->updateGeometry();
          myDlg->adjustSize();
          readMesh();
        }
        else
          myDlg->reset();
      }
      else if ( !myIsMesh ) // submesh creation
      {
        // if a submesh on the selected shape already exist, pass to submesh edition mode
        if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
          SMESH::SMESH_subMesh_var sm =
            SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
          bool editSubmesh = ( !sm->_is_nil() &&
                               SUIT_MessageBox::question( myDlg, tr( "SMESH_WARNING" ),
                                                          tr( "EDIT_SUBMESH_QUESTION"),
                                                          SUIT_MessageBox::Yes |
                                                          SUIT_MessageBox::No,
                                                          SUIT_MessageBox::No )
                               == SUIT_MessageBox::Yes );
          if ( editSubmesh )
          {
            selectionMgr()->clearFilters();
            selectObject( pSubmesh );
            SMESHGUI::GetSMESHGUI()->switchToOperation(704);
            return;
          }
          else
          {
            myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
            selectObject( _PTR(SObject)() );
            selectionDone();
            return;
          }
        }
        // discard selected mesh if submesh creation not allowed because of
        // a global algorithm that does not support submeshes
        if ( char* algoName = isSubmeshIgnored() ) {
          SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ),
                                    tr("SUBMESH_NOT_ALLOWED").arg(algoName));
          CORBA::string_free( algoName );
          myDlg->selectObject( "", SMESHGUI_MeshDlg::Mesh, "" );
          selectObject( _PTR(SObject)() );
          selectionDone();
          return;
        }

        // enable/disable popup for choice of geom selection way
        bool enable = false;
        QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
        if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
          SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
          if ( !mesh->_is_nil() ) {
            //rnv: issue 21056: EDF 1608 SMESH: Dialog Box "Create Sub Mesh": focus should automatically switch to geometry
            QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
            _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
            if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
              myDlg->activateObject(SMESHGUI_MeshDlg::Geom);
            enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
          }
        }
        myDlg->setGeomPopupEnabled( enable );
      }
    }
    else { // no geometry defined
      myDlg->enableTab( SMESH::DIM_3D );
      QStringList hypList;
      availableHyps( SMESH::DIM_3D, Algo, hypList,
                     myAvailableHypData[SMESH::DIM_3D][Algo]);

      SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
      aTab->setAvailableHyps( Algo, hypList );
      for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
        myDlg->disableTab(i);
      }
      //Hide labels and fields (Mesh ang Geometry)
      myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
      myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
      myDlg->adjustSize();
      readMesh();
    }
  }
  catch ( const SALOME::SALOME_Exception& S_ex )
  {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  }
  catch ( ... )
  {
  }
}
Selection_Mode SMESHGUI_SelectionOp::selectionMode ( ) const [protected, inherited]

Return what selection mode is set in VTK viewer.

Definition at line 229 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_SelectionOp.viewWindow().

Referenced by SMESHGUI_ShapeByMeshOp.activateSelection(), SMESHGUI_SelectionOp.mesh(), SMESHGUI_FindElemByPointOp.onElemSelected(), SMESHGUI_FindElemByPointOp.onElemTypeChange(), SMESHGUI_SelectionOp.selected(), SMESHGUI_SelectionOp.selectionDone(), and SMESHGUI_SelectionOp.startOperation().

{
  SVTK_ViewWindow* wnd = viewWindow();
  if( wnd )
    return wnd->SelectionMode();
  else
    return ActorSelection;
}
void SMESHGUI_MeshOp::selectObject ( _PTR(SObject)  theSObj) const [private]

Selects a SObject.

Parameters:
theSObj- the SObject to select

Definition at line 2324 of file SMESHGUI_MeshOp.cxx.

References Handle().

Referenced by createSubMesh(), onPublishShapeByMeshDlg(), and selectionDone().

{
  if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
    SALOME_ListIO anIOList;
    if ( theSObj ) {
      Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
        ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
      anIOList.Append( anIO );
    }
    sm->setSelectedObjects( anIOList, false );
  }
}
SVTK_Selector * SMESHGUI_SelectionOp::selector ( ) const [protected, inherited]
void SMESHGUI_MeshOp::setCurrentHyp ( const int  theDim,
const int  theHypType,
const int  theIndex 
) [private]

Sets current hypothesis or algorithms.

Parameters:
theDim- dimension of hypothesis or algorithm
theHypType- Type of hypothesis (Algo, MainHyp, AddHyp)
theIndex- Index of hypothesis

Gets current hypothesis or algorithms

Definition at line 1829 of file SMESHGUI_MeshOp.cxx.

References myDlg, myIgnoreAlgoSelection, SMESHGUI_MeshTab.setCurrentHyp(), and SMESHGUI_MeshDlg.tab().

Referenced by onAlgoSelected(), onHypoSet(), processSet(), and readMesh().

{
  myIgnoreAlgoSelection = true;
  myDlg->tab( theDim )->setCurrentHyp( theHypType, theIndex + 1 );
  myIgnoreAlgoSelection = false;
}
void SMESHGUI_MeshOp::setDefaultName ( ) const [private]

Generates default and sets mesh/submesh name.

Generates and sets default mesh/submesh name(Mesh_1, Mesh_2, etc.)

Definition at line 1845 of file SMESHGUI_MeshOp.cxx.

References _PTR(), Control(), myDlg, myIsMesh, and SMESHGUI_MeshDlg.Obj.

Referenced by onApply(), and startOperation().

{
  QString aResName;

  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
  int i = 1;
  QString aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
  _PTR(SObject) anObj;
  do
  {
    aResName = aPrefix + QString::number( i++ );
    anObj = aStudy->FindObject( aResName.toLatin1().data() );
  }
  while ( anObj );

  QLineEdit* aControl = ( QLineEdit* )myDlg->objectWg(
    SMESHGUI_MeshDlg::Obj, SMESHGUI_MeshDlg::Control );
  aControl->setText( aResName );
}
void SMESHGUI_Operation::setDialogActive ( const bool  active) [protected, virtual, inherited]

Set according dialog active or inactive.

Definition at line 135 of file SMESHGUI_Operation.cxx.

References ex13_hole1partial.d, and SMESHGUI_Dialog.setContentActive().

{
  LightApp_Operation::setDialogActive( active );

  SMESHGUI_Dialog* d = dynamic_cast<SMESHGUI_Dialog*>( dlg() );
  if( d )
    d->setContentActive( active );

}
void SMESHGUI_Operation::setIsApplyAndClose ( const bool  theFlag) [protected, virtual, inherited]

Definition at line 224 of file SMESHGUI_Operation.cxx.

References SMESHGUI_Operation.myIsApplyAndClose.

Referenced by SMESHGUI_Operation.onOk().

{
  myIsApplyAndClose = theFlag;
}
void SMESHGUI_SelectionOp::setSelectionMode ( const Selection_Mode  mode) [protected, inherited]
void SMESHGUI_MeshOp::startOperation ( ) [protected, virtual]

Creates dialog if necessary and shows it.

Virtual method redefined from base class called when operation is started creates dialog if necessary and shows it, activates selection

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 199 of file SMESHGUI_MeshOp.cxx.

References _PTR(), AddHyp, Algo, availableHyps(), SMESH.DIM_0D, SMESH.DIM_3D, SMESHGUI_MeshDlg.Geom, MainHyp, SMESHGUI_MeshDlg.Mesh, myAvailableHypData, myDlg, myExistingHyps, SMESHGUI_Operation.myHelpFileName, myIgnoreAlgoSelection, myIsMesh, myObjectToSelect, myToCreate, SMESHGUI_MeshDlg.Obj, onAlgoSelected(), onCreateHyp(), onEditHyp(), onGeomSelectionByMesh(), onHypoSet(), selectionDone(), SMESHGUI_MeshTab.setAvailableHyps(), SMESHGUI_MeshDlg.setCurrentTab(), setDefaultName(), SMESHGUI_MeshTab.setExistingHyps(), SMESHGUI_MeshDlg.setGeomPopupEnabled(), SMESHGUI_Dialog.show(), and SMESHGUI_MeshDlg.tab().

{
  if (!myDlg)
  {
    myDlg = new SMESHGUI_MeshDlg( myToCreate, myIsMesh );
    for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
    {
      connect( myDlg->tab( i ), SIGNAL( createHyp( const int, const int ) ),
              this, SLOT( onCreateHyp( const int, const int ) ) );
      connect( myDlg->tab( i ), SIGNAL( editHyp( const int, const int ) ),
              this, SLOT( onEditHyp( const int, const int ) ) );
      connect( myDlg->tab( i ), SIGNAL( selectAlgo( const int ) ),
              this, SLOT( onAlgoSelected( const int ) ) );
    }
    connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
    connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));

    if ( myToCreate )
      if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
      else myHelpFileName = "constructing_submeshes_page.html";
    else myHelpFileName = "editing_meshes_page.html";
  }
  SMESHGUI_SelectionOp::startOperation();

  // iterate through dimensions and get available algoritms, set them to the dialog
  _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
  for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
  {
    SMESHGUI_MeshTab* aTab = myDlg->tab( i );
    QStringList hypList;
    // clear available hypotheses
    aTab->setAvailableHyps( MainHyp, hypList );
    aTab->setAvailableHyps( AddHyp, hypList );
    aTab->setExistingHyps( MainHyp, hypList );
    aTab->setExistingHyps( AddHyp, hypList );
    myExistingHyps[ i ][ MainHyp ].clear();
    myExistingHyps[ i ][ AddHyp ].clear();
    // set algos
    availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
    aTab->setAvailableHyps( Algo, hypList );
  }
  if ( myToCreate )
  {
    setDefaultName();
    myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh );
  }
  else
    myDlg->activateObject( SMESHGUI_MeshDlg::Obj );

  myDlg->setCurrentTab( SMESH::DIM_3D );
  myDlg->show();
  myDlg->setGeomPopupEnabled(false);
  selectionDone();

  myIgnoreAlgoSelection = false;

  myObjectToSelect.clear();
}
int SMESHGUI_SelectionOp::typeById ( const QString &  str,
const EntityType  objtype 
) const [protected, virtual, inherited]

Find type by id.

Definition at line 297 of file SMESHGUI_SelectionOp.cxx.

References SMESHGUI_Operation._PTR(), SMESHGUI_SelectionOp.idChar(), SMESHGUI_SelectionOp.mesh(), SMESHGUI_SelectionOp.MeshElement, SMESHGUI_SelectionOp.Object, SMESHGUI_Dialog.prefix(), SMESH_AdvancedEditor.res, SMESH_test4.submesh, and SMESHGUI_Selection.type().

Referenced by SMESHGUI_SelectionOp.selected().

{
  SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
  if( !_study )
    return -1;

  _PTR( Study ) st = _study->studyDS();

  int res = -1;
  if( objtype == Object )
  {
    SalomeApp_Study* _study = dynamic_cast<SalomeApp_Study*>( study() );
    if( _study )
    {
      int t = SMESHGUI_Selection::type( str, _study->studyDS() );
      if( t<0 )
      {
        //try to get GEOM type
        _PTR( SObject ) sobj = st->FindObjectID( str.toLatin1().data() );
        if( sobj )
        {
          GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow(
            dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
          if( !CORBA::is_nil( obj ) )
            res = SMESHGUI_Dialog::prefix( "GEOM" ) + obj->GetType();
        }
      }
      else
        res = SMESHGUI_Dialog::prefix( "SMESH" ) + t;
    }
  }
  else
  {
    int pos = str.indexOf( idChar() );
    QString entry = str.left( pos ),
            _id = str.mid( pos+1 );
    bool ok;
    int id = _id.toInt( &ok );
    if( ok )
    {
      _PTR( SObject ) sobj = st->FindObjectID( entry.toLatin1().data() );
      SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( 
        dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
      SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( 
        dynamic_cast<SALOMEDS_SObject*>( sobj.get() )->GetObject() );
      if( !CORBA::is_nil( mesh ) )
        res = SMESHGUI_Dialog::prefix( "SMESH element" ) + 
          mesh->GetElementType( id, objtype==MeshElement );

      else if( !CORBA::is_nil( submesh ) )
        res = SMESHGUI_Dialog::prefix( "SMESH element" ) + 
          submesh->GetElementType( id, objtype==MeshElement );
    }
  }

  return res;
}
SVTK_ViewWindow * SMESHGUI_SelectionOp::viewWindow ( ) const [protected, inherited]

Field Documentation

Definition at line 145 of file SMESHGUI_MeshOp.h.

Referenced by createHypothesis(), and onHypoCreated().

QString SMESHGUI_Operation.myHelpFileName [protected, inherited]

Definition at line 144 of file SMESHGUI_MeshOp.h.

Referenced by onHypoCreated(), onHypoSet(), and processSet().

Definition at line 143 of file SMESHGUI_MeshOp.h.

Referenced by onAlgoSelected(), setCurrentHyp(), and startOperation().

TRUE if edited mesh accotiated with geometrical object.

Definition at line 134 of file SMESHGUI_MeshOp.h.

Referenced by availableHyps(), editMeshOrSubMesh(), readMesh(), selectionDone(), and SMESHGUI_MeshOp().

Definition at line 147 of file SMESHGUI_MeshOp.h.

Referenced by commitOperation(), onApply(), and startOperation().

hypothesis assigned to the current

Definition at line 137 of file SMESHGUI_MeshOp.h.

Referenced by editMeshOrSubMesh(), onAlgoSelected(), and readMesh().

Definition at line 145 of file SMESHGUI_MeshOp.h.

Referenced by createHypothesis(), and onHypoCreated().

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