X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_Selection.cxx;h=86a9292141693bf30ae063814bd47c386ffec12d;hb=2bdf78860bac95bce77d8b33ba7f4c4f1681092c;hp=8fff50e3ca6bd80df6765f8e38f7f5c948130ee1;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_Selection.cxx b/src/SMESHGUI/SMESHGUI_Selection.cxx index 8fff50e3c..86a929214 100644 --- a/src/SMESHGUI/SMESHGUI_Selection.cxx +++ b/src/SMESHGUI/SMESHGUI_Selection.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -127,6 +127,9 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p=="groupType" ) val = QVariant( groupType( ind ) ); else if ( p=="quadratic2DMode") val = QVariant(quadratic2DMode(ind)); else if ( p=="isDistributionVisible") val = QVariant(isDistributionVisible(ind)); + else if ( p=="hasChildren") val = QVariant(hasChildren(ind)); + else if ( p=="nbChildren") val = QVariant(nbChildren(ind)); + else if ( p=="isContainer") val = QVariant(isContainer(ind)); if( val.isValid() ) return val; @@ -529,6 +532,50 @@ QVariant SMESHGUI_Selection::isVisible( int ind ) const return QVariant( false ); } +//======================================================================= +//function : hasChildren +//purpose : +//======================================================================= + +bool SMESHGUI_Selection::hasChildren( int ind ) const +{ + if ( ind >= 0 ) + { + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj ); + } + return false; +} + +//======================================================================= +//function : hasChildren +//purpose : +//======================================================================= + +int SMESHGUI_Selection::nbChildren( int ind ) const +{ + int nb = 0; + if ( ind >= 0 ) + { + _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() ); + if ( sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) { + _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj ); + for (it->Init(false); it->More(); it->Next()) nb++; + } + } + return nb; +} + +//======================================================================= +//function : isContainer +//purpose : +//======================================================================= + +bool SMESHGUI_Selection::isContainer( int ind ) const +{ + return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown"; +} + //======================================================================= //function : type //purpose : @@ -551,7 +598,7 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) return -1; if( objComponent->GetIOR()==obj->GetIOR() ) - return COMPONENT; + return SMESH::COMPONENT; int aLevel = obj->Depth() - objComponent->Depth(), aFTag = objFather->Tag(), @@ -562,16 +609,16 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) { case 1: if (anOTag >= SMESH::Tag_FirstMeshRoot) - res = MESH; + res = SMESH::MESH; break; case 2: switch (aFTag) { case SMESH::Tag_HypothesisRoot: - res = HYPOTHESIS; + res = SMESH::HYPOTHESIS; break; case SMESH::Tag_AlgorithmsRoot: - res = ALGORITHM; + res = SMESH::ALGORITHM; break; } break; @@ -579,25 +626,25 @@ int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study ) switch (aFTag) { case SMESH::Tag_SubMeshOnVertex: - res = SUBMESH_VERTEX; + res = SMESH::SUBMESH_VERTEX; break; case SMESH::Tag_SubMeshOnEdge: - res = SUBMESH_EDGE; + res = SMESH::SUBMESH_EDGE; break; case SMESH::Tag_SubMeshOnFace: - res = SUBMESH_FACE; + res = SMESH::SUBMESH_FACE; break; case SMESH::Tag_SubMeshOnSolid: - res = SUBMESH_SOLID; + res = SMESH::SUBMESH_SOLID; break; case SMESH::Tag_SubMeshOnCompound: - res = SUBMESH_COMPOUND; + res = SMESH::SUBMESH_COMPOUND; break; default: if (aFTag >= SMESH::Tag_FirstGroup) - res = GROUP; + res = SMESH::GROUP; else - res = SUBMESH; + res = SMESH::SUBMESH; } break; } @@ -614,29 +661,29 @@ QString SMESHGUI_Selection::typeName( const int t ) { switch( t ) { - case HYPOTHESIS: + case SMESH::HYPOTHESIS: return "Hypothesis"; - case ALGORITHM: + case SMESH::ALGORITHM: return "Algorithm"; - case MESH: + case SMESH::MESH: return "Mesh"; - case SUBMESH: + case SMESH::SUBMESH: return "SubMesh"; - case MESHorSUBMESH: + case SMESH::MESHorSUBMESH: return "Mesh or submesh"; - case SUBMESH_VERTEX: + case SMESH::SUBMESH_VERTEX: return "Mesh vertex"; - case SUBMESH_EDGE: + case SMESH::SUBMESH_EDGE: return "Mesh edge"; - case SUBMESH_FACE: + case SMESH::SUBMESH_FACE: return "Mesh face"; - case SUBMESH_SOLID: + case SMESH::SUBMESH_SOLID: return "Mesh solid"; - case SUBMESH_COMPOUND: + case SMESH::SUBMESH_COMPOUND: return "Mesh compound"; - case GROUP: + case SMESH::GROUP: return "Group"; - case COMPONENT: + case SMESH::COMPONENT: return "Component"; default: return "Unknown"; @@ -653,7 +700,7 @@ bool SMESHGUI_Selection::isImported( const int ind ) const SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) ); if( !aMesh->_is_nil() ) { - SALOME_MED::MedFileInfo* inf = aMesh->GetMEDFileInfo(); + SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo(); res = strlen( (char*)inf->fileName ) > 0; } }