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

SMESHGUI_Make2DFrom3DOp Class Reference

Operation to compute 2D mesh on 3D. More...

#include <SMESHGUI_Make2DFrom3DOp.h>

Inheritance diagram for SMESHGUI_Make2DFrom3DOp:
Inheritance graph
[legend]

Public Types

typedef QList< intIdList

Public Member Functions

 SMESHGUI_Make2DFrom3DOp ()
virtual ~SMESHGUI_Make2DFrom3DOp ()
virtual LightApp_Dialogdlg () const

Static Public Member Functions

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

Protected Types

enum  EntityType { Object, MeshNode, MeshElement }

Protected Slots

virtual bool onApply ()
void onModeChanged ()
 Set filter corresponding to dimension.
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 ()
 This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements, because node end element ids may overlap.
virtual void selectionDone ()
virtual SUIT_SelectionFiltercreateFilter (const int) const
 Creates filter being used when certain object selection widget is active If no filter must be used, then function must return 0 if id is negative, then function must return filter for common using independently of active widget.
bool isValid (QString &) const
void extractIds (const QStringList &, IdList &) const
 Find in QStringList correct node or element ids representation and append integer(id) to IdList.
virtual void commitOperation ()
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
virtual bool isValid (SUIT_Operation *) const
 Verifies whether given operator is valid for this one.

Protected Attributes

QString myHelpFileName
bool myIsApplyAndClose

Private Member Functions

bool compute2DMesh (QStringList &)

Private Attributes

SMESH::SMESH_Mesh_var mySrcMesh
QPointer
< SMESHGUI_Make2DFrom3DDlg
myDlg
SMESH_TypeFilter myMeshFilter
SMESH_TypeFilter myGroupFilter

Detailed Description

Operation to compute 2D mesh on 3D.

Copy Mesh operation class.

Definition at line 90 of file SMESHGUI_Make2DFrom3DOp.h.


Member Typedef Documentation

typedef QList<int> SMESHGUI_SelectionOp.IdList [inherited]

Definition at line 59 of file SMESHGUI_SelectionOp.h.


Member Enumeration Documentation

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

Definition at line 68 of file SMESHGUI_SelectionOp.h.


Constructor & Destructor Documentation

SMESHGUI_Make2DFrom3DOp::SMESHGUI_Make2DFrom3DOp ( )
SMESHGUI_Make2DFrom3DOp::~SMESHGUI_Make2DFrom3DOp ( ) [virtual]

Definition at line 225 of file SMESHGUI_Make2DFrom3DOp.cxx.

References myDlg.

{
  if ( myDlg )
    delete myDlg;
}

Member Function Documentation

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 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_SelectionOp::commitOperation ( ) [protected, virtual, inherited]
bool SMESHGUI_Make2DFrom3DOp::compute2DMesh ( QStringList &  theEntryList) [private]

Definition at line 406 of file SMESHGUI_Make2DFrom3DOp.cxx.

References SMESHGUI_Operation._PTR(), SMESHGUI.activeStudy(), SMESHGUI_SelectionOp.actor(), SMESH.BND_2DFROM3D, dlg(), FACE, SMESH.FindActorByEntry(), SMESHGUI_Make2DFrom3DDlg.MeshOrGroups, myDlg, mySrcMesh, SMESH.RepaintCurrentView(), SMESH.Update(), and SMESH.VOLUME.

Referenced by onApply().

{
  SUIT_OverrideCursor wc;

  bool ok = false;
  try {
    SMESH::Bnd_Dimension mode = myDlg->mode();
    QString meshName          = myDlg->needNewMesh() ? myDlg->getNewMeshName() : QString();
    QString groupName         = myDlg->needGroup()   ? myDlg->getGroupName()   : QString();
    bool copyAll              = myDlg->copySource();

    QStringList entries;
    dlg()->selectedObject( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups, entries );
    SMESH::ListOfIDSources_var groups = new SMESH::ListOfIDSources;
    QString wrongGroups = "";

    if ( mySrcMesh->_is_nil() ) // get selected groups, find groups of wrong type
    {
      int nbGroups = 0;
      int goodType = ( mode == SMESH::BND_2DFROM3D ? SMESH::VOLUME : SMESH::FACE );
      groups->length( entries.count() );
      for ( int i = 0; i < entries.count(); ++i )
      {
        _PTR(SObject) sobj =
          SMESHGUI::activeStudy()->studyDS()->FindObjectID( entries[i].toLatin1().constData() );
        SMESH::SMESH_IDSource_var grp = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );  
        SMESH::array_of_ElementType_var types = grp->GetTypes();
        if ( types->length() < 1 || types[0] != goodType )
        {
          if ( !wrongGroups.isEmpty() )
            wrongGroups += ", ";
          wrongGroups += sobj->GetName().c_str();
        }
        else
        {
          groups[ nbGroups++ ] = grp;
        }
      }
      groups->length( nbGroups );
      mySrcMesh = groups[0]->GetMesh();
    }

    if ( !CORBA::is_nil( mySrcMesh ) ) {
      SMESH::SMESH_MeshEditor_var aMeshEditor = mySrcMesh->GetMeshEditor();
      SMESH::SMESH_Group_var newGrp;
      SMESH::SMESH_Mesh_var newMesh;
      CORBA::Long nbAdded = aMeshEditor->MakeBoundaryElements( mode,
                                                               groupName.toLatin1().constData(),
                                                               meshName.toLatin1().constData(),
                                                               copyAll,
                                                               groups,
                                                               newMesh.out(),
                                                               newGrp.out() );
      QString msg = tr("NB_ADDED").arg( nbAdded );
      if ( !wrongGroups.isEmpty() )
        msg += ".\n" + tr("WRONG_GROUPS").arg( wrongGroups );
      SUIT_MessageBox::information( myDlg, tr("SMESH_INFORMATION"), msg);

      if ( !newMesh->_is_nil() ) {
        if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( newMesh ) )
          theEntryList.append( aSObject->GetID().c_str() );
#ifdef WITHGENERICOBJ
        newMesh->UnRegister();
#endif
      }
      if ( !newGrp->_is_nil() ) {
#ifdef WITHGENERICOBJ
        newGrp->UnRegister();
#endif
      }
      ok = true;

      for ( int i = 0; i < entries.count(); ++i )
        if ( SMESH_Actor* actor = SMESH::FindActorByEntry( entries[i].toLatin1().constData() ))
          SMESH::Update(actor->getIO(),actor->GetVisibility());
      SMESH::RepaintCurrentView();
    }
  }
  catch ( ... ) {
  }
  return ok;
}
SUIT_SelectionFilter * SMESHGUI_Make2DFrom3DOp::createFilter ( const int  ) const [protected, virtual]

Creates filter being used when certain object selection widget is active If no filter must be used, then function must return 0 if id is negative, then function must return filter for common using independently of active widget.

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 318 of file SMESHGUI_Make2DFrom3DOp.cxx.

References SMESH_LogicalFilter.LO_OR, myGroupFilter, and myMeshFilter.

{
  SMESHGUI_Make2DFrom3DOp* me = (SMESHGUI_Make2DFrom3DOp*) this;

  QList<SUIT_SelectionFilter*> subFilters;
  subFilters.append( & me->myMeshFilter );
  subFilters.append( & me->myGroupFilter );

  SUIT_SelectionFilter* f = new SMESH_LogicalFilter( subFilters, SMESH_LogicalFilter::LO_OR );
  return f;
}
LightApp_Dialog * SMESHGUI_Make2DFrom3DOp::dlg ( ) const [virtual]

Definition at line 231 of file SMESHGUI_Make2DFrom3DOp.cxx.

References myDlg.

Referenced by compute2DMesh(), isValid(), onApply(), and selectionDone().

{
  return myDlg;
}
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() );
}
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 );
}
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_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(), SMESHGUI_MeshOp.onApply(), SMESHGUI_MakeNodeAtPointOp.onApply(), 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;
}
bool SMESHGUI_Operation::isValid ( SUIT_Operation *  theOtherOp) const [protected, virtual, inherited]

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

Virtual 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 in SMESHGUI_BaseComputeOp, and SMESHGUI_MeshOp.

Definition at line 273 of file SMESHGUI_Operation.cxx.

{
  static QStringList anOps;
  if ( anOps.count() == 0 )
  {
    anOps.append( "SMESHGUI_DeleteOp" );
    // to do add other operations here
  }

  return ( theOtherOp &&
         ( ( theOtherOp->inherits("SMESHGUI_Operation") && ( !anOps.contains(theOtherOp->metaObject()->className() ) || anOps.contains(metaObject()->className()) ) ) ||
           ( theOtherOp->inherits("LightApp_ShowHideOp") ) ) );

  return true;
}
bool SMESHGUI_Make2DFrom3DOp::isValid ( QString &  msg) const [protected]

Definition at line 330 of file SMESHGUI_Make2DFrom3DOp.cxx.

References SMESHGUI_Operation._PTR(), SMESHGUI.activeStudy(), SMESH.BND_1DFROM2D, SMESH.BND_2DFROM3D, dlg(), SMESH.FACE, SMESHGUI_Make2DFrom3DDlg.MeshOrGroups, myDlg, mySrcMesh, and SMESH.VOLUME.

Referenced by onApply().

{
  if ( !dlg() ) return false;

  // check if a mesh is selected
  if ( !myDlg->hasSelection( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups ))
  {
    msg = tr( "SMESH_ERR_NO_INPUT_MESH" );
    return false;
  }
  QStringList entries;
  dlg()->selectedObject( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups, entries );
  const bool isMeshSelected = ( !mySrcMesh->_is_nil() );
  if ( isMeshSelected )
  {
    // only one mesh is allowed
    if ( entries.size() > 1 ) {
      msg = tr( "SMESH_TOO_MANY_MESHES" );
      return false;
    }
  }
  else
  {
    // check if only groups are selected
    for ( int i = 0; i < entries.count(); ++i )
    {
      SMESH::SMESH_GroupBase_var grp;
      if ( _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entries[i].toLatin1().constData() ))
        grp = SMESH::SObjectToInterface<SMESH::SMESH_GroupBase>( sobj );
      if ( grp->_is_nil() ) {
        msg = tr( "SMESH_NOT_ONLY_GROUPS" );
        return false;
      }
    }
  }
  // check if the selected objects contains elements of required type
  bool hasFaces = false, hasVolumes = false;
  SMESH::Bnd_Dimension mode = myDlg->mode();
  for ( int i = 0; i < entries.count(); ++i )
  {
    SMESH::SMESH_IDSource_var idSource;
    if ( _PTR(SObject) sobj = SMESHGUI::activeStudy()->studyDS()->FindObjectID( entries[i].toLatin1().constData() ))
      idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( sobj );
    if ( !idSource->_is_nil() ) {
      SMESH::array_of_ElementType_var types = idSource->GetTypes();
      for ( int j = 0; j < types->length(); ++j )
        if ( types[j] == SMESH::VOLUME )
          hasVolumes = true;
        else if ( types[j] == SMESH::FACE )
          hasFaces = true;
    }
  }
  if ( mode == SMESH::BND_2DFROM3D && !hasVolumes ) {
    msg = tr( "SMESH_ERR_NO_3D_ELEMENTS" );
    return false;
  }
  else if ( mode == SMESH::BND_1DFROM2D && !hasFaces  ) {
    msg = tr( "SMESH_ERR_NO_2D_ELEMENTS" );
    return false;
  }

  // check if new mesh name is specified
  if ( myDlg->needNewMesh() && myDlg->getNewMeshName().isEmpty() ) {
    msg = tr( "SMESH_ERR_MESH_NAME_NOT_SPECIFIED" );
    return false;
  }

  // check if group name is specified
  if ( myDlg->needGroup() && myDlg->getGroupName().isEmpty() ) {
    msg = tr( "SMESH_ERR_GRP_NAME_NOT_SPECIFIED" );
    return false;
  }

  return true;
}
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(), SMESHGUI_MeshOp.isSubshapeOk(), SMESHGUI_GroupOnShapeOp.onApply(), SMESHGUI_ConvToQuadOp.onApply(), SMESHGUI_MeshOp.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();
}
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(), SMESHGUI_MeshOp.onHypoCreated(), SMESHGUI_MeshOp.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();
}
bool SMESHGUI_Make2DFrom3DOp::onApply ( ) [protected, virtual, slot]

Reimplemented from SMESHGUI_Operation.

Definition at line 489 of file SMESHGUI_Make2DFrom3DOp.cxx.

References compute2DMesh(), dlg(), SMESHGUI_Operation.isApplyAndClose(), SMESHGUI_Operation.isStudyLocked(), isValid(), SMESHGUI.Modified(), myDlg, SMESH_AdvancedEditor.res, and SMESH.UniqueName().

{
  if ( isStudyLocked() )
    return false;

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

  QStringList anEntryList;
  bool res = false;
  try {
    res = compute2DMesh( anEntryList );
  }
  catch ( const SALOME::SALOME_Exception& S_ex ) {
    SalomeApp_Tools::QtCatchCorbaException( S_ex );
  }
  catch ( ... ) {
  }

  if ( res ) {
    SMESHGUI::Modified();
    update( UF_ObjBrowser | UF_Model );
    if( LightApp_Application* anApp =
        dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
      anApp->browseObjects( anEntryList, isApplyAndClose() );
    myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
    myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
  }
  else {
    SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ) );
  }

  return res;
}
void SMESHGUI_Operation::onCancel ( ) [protected, virtual, slot, inherited]
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_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_Make2DFrom3DOp::onModeChanged ( ) [protected, slot]

Set filter corresponding to dimension.

Definition at line 265 of file SMESHGUI_Make2DFrom3DOp.cxx.

Referenced by startOperation().

{
//   QRadioButton* b = dynamic_cast<QRadioButton*>( sender());
//   if ( b && !b->isChecked() )
//     return;

//   // enable "2D groups" field
//   bool enableGroups = ( myDlg->mode() == SMESH::BND_1DFROM3D );
//   myDlg->setObjectEnabled( SMESHGUI_Make2DFrom3DDlg::Groups, enableGroups );
//   ((QToolButton*) myDlg->objectWg( SMESHGUI_Make2DFrom3DDlg::Groups,
//                                    SMESHGUI_Make2DFrom3DDlg::Btn ))->setChecked( enableGroups );
  
//   // install filter
//   int id =  enableGroups ? SMESHGUI_Make2DFrom3DDlg::Groups : SMESHGUI_Make2DFrom3DDlg::Mesh;
//   onDeactivateObject( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups );
//   onActivateObject  ( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups );
//   selectionDone();
}
void SMESHGUI_Operation::onOk ( ) [protected, virtual, slot, inherited]
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_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(), SMESHGUI_MeshOp.createHypothesis(), SMESHGUI_GroupOnShapeOp.init(), SMESHGUI_GroupOnShapeOp.onApply(), SMESHGUI_GroupOnShapeOp.onButtonClick(), SMESHGUI_SelectionOp.onDeactivateObject(), SMESHGUI_MeshOp.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(), 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_Make2DFrom3DOp::selectionDone ( ) [protected, virtual]

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 284 of file SMESHGUI_Make2DFrom3DOp.cxx.

References SMESHGUI_Operation._PTR(), SMESHGUI.activeStudy(), dlg(), SMESH_test.ids, SMESHGUI_Make2DFrom3DDlg.MeshOrGroups, myDlg, mySrcMesh, SMESH_reg.names, and SMESHGUI_SelectionOp.selected().

Referenced by startOperation().

{
  myDlg->clearSelection( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups );
  mySrcMesh = SMESH::SMESH_Mesh::_nil();

  if ( !dlg() ) return;

  
  if ( dlg()->isVisible() ) {
    try {
      QStringList names, ids;
      LightApp_Dialog::TypesList types;
      selected( names, types, ids );
      myDlg->selectObject( names, types, ids );

      // enable/desable "new mesh" button
      bool isMesh = true;
      for ( int i = 0; i < ids.count() && isMesh; ++i )
      {
        _PTR(SObject) sobj =
          SMESHGUI::activeStudy()->studyDS()->FindObjectID( ids[i].toLatin1().constData() );
        mySrcMesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( sobj );  
        isMesh = !mySrcMesh->_is_nil();
      }
      myDlg->setNewMeshEnabled( isMesh );
    }
    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;
}
SVTK_Selector * SMESHGUI_SelectionOp::selector ( ) const [protected, inherited]
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_Make2DFrom3DOp::startOperation ( ) [protected, virtual]

This enumeration is used in typeById method to distinguish objects, mesh nodes and mesh elements, because node end element ids may overlap.

Reimplemented from SMESHGUI_SelectionOp.

Definition at line 236 of file SMESHGUI_Make2DFrom3DOp.cxx.

References SMESHGUI_Make2DFrom3DDlg.MeshOrGroups, myDlg, SMESHGUI_Operation.myHelpFileName, onModeChanged(), selectionDone(), and SMESH.UniqueName().

{
  if( !myDlg )
    myDlg = new SMESHGUI_Make2DFrom3DDlg( desktop() );

  myHelpFileName = "make_2dmesh_from_3d_page.html";

  SMESHGUI_SelectionOp::startOperation();

  myDlg->setNewMeshName( SMESH::UniqueName( "Mesh_1" ) );
  myDlg->setGroupName( SMESH::UniqueName( "Group" ) );
  myDlg->show();

  connect( myDlg->my2dFrom3dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );
  connect( myDlg->my1dFrom2dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );
  //connect( myDlg->my1dFrom3dRB, SIGNAL( toggled(bool) ), this, SLOT( onModeChanged() ) );

  //onModeChanged();

  myDlg->activateObject( SMESHGUI_Make2DFrom3DDlg::MeshOrGroups );
  selectionDone();
}
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 118 of file SMESHGUI_Make2DFrom3DOp.h.

Referenced by createFilter().

QString SMESHGUI_Operation.myHelpFileName [protected, inherited]

Definition at line 117 of file SMESHGUI_Make2DFrom3DOp.h.

Referenced by createFilter().

SMESH::SMESH_Mesh_var SMESHGUI_Make2DFrom3DOp.mySrcMesh [private]

Definition at line 114 of file SMESHGUI_Make2DFrom3DOp.h.

Referenced by compute2DMesh(), isValid(), and selectionDone().

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