Back to index

salome-smesh  6.5.0
SMESHGUI_Selection.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // SMESH SMESHGUI_Selection
00024 // File   : SMESHGUI_Selection.cxx
00025 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
00026 // SMESH includes
00027 //
00028 #include "SMESHGUI_Selection.h"
00029 
00030 #include "SMESHGUI_Utils.h"
00031 #include "SMESHGUI_VTKUtils.h"
00032 #include "SMESHGUI_GEOMGenUtils.h"
00033 #include "SMESHGUI_ComputeDlg.h"
00034 
00035 #include <SMESH_Type.h>
00036 #include <SMESH_Actor.h>
00037 #include <SMESH_ScalarBarActor.h>
00038 
00039 // SALOME GUI includes
00040 #include <SalomeApp_Study.h>
00041 #include <LightApp_VTKSelector.h>
00042 #include <SVTK_ViewWindow.h>
00043 
00044 // IDL includes
00045 #include <SALOMEconfig.h>
00046 #include CORBA_CLIENT_HEADER(SMESH_Gen)
00047 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
00048 #include CORBA_CLIENT_HEADER(SMESH_Group)
00049 
00050 //=======================================================================
00051 //function : SMESHGUI_Selection
00052 //purpose  : 
00053 //=======================================================================
00054 SMESHGUI_Selection::SMESHGUI_Selection()
00055 : LightApp_Selection()
00056 {
00057 }
00058 
00059 //=======================================================================
00060 //function : ~SMESHGUI_Selection
00061 //purpose  : 
00062 //=======================================================================
00063 SMESHGUI_Selection::~SMESHGUI_Selection()
00064 {
00065 }
00066 
00067 //=======================================================================
00068 //function : init
00069 //purpose  : 
00070 //=======================================================================
00071 void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
00072 {
00073   LightApp_Selection::init( client, mgr );
00074 
00075   if( mgr && study() )
00076   {
00077     SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
00078     if (!aSStudy)
00079       return;
00080     _PTR(Study) aStudy = aSStudy->studyDS();
00081 
00082     for( int i=0, n=count(); i<n; i++ )
00083       myTypes.append( typeName( type( entry( i ), aStudy ) ) );
00084   }
00085 }
00086 
00087 //=======================================================================
00088 //function : processOwner
00089 //purpose  : 
00090 //=======================================================================
00091 bool SMESHGUI_Selection::processOwner( const LightApp_DataOwner* ow )
00092 {
00093   const LightApp_SVTKDataOwner* owner =
00094     dynamic_cast<const LightApp_SVTKDataOwner*> ( ow );
00095   if( owner )
00096     myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
00097   else
00098     myActors.append( 0 );
00099   return true;
00100 }
00101 
00102 //=======================================================================
00103 //function : parameter
00104 //purpose  : 
00105 //=======================================================================
00106 QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
00107 {
00108   QVariant val;
00109   if      ( p=="client" )        val = QVariant( LightApp_Selection::parameter( p ) );
00110   else if ( p=="type" )          val = QVariant( myTypes[ind] );
00111   else if ( p=="elemTypes" )     val = QVariant( elemTypes( ind ) );
00112   else if ( p=="isAutoColor" )   val = QVariant( isAutoColor( ind ) );
00113   else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) );
00114   else if ( p=="dim" )           val = QVariant( dim( ind ) );
00115   else if ( p=="labeledTypes" )  val = QVariant( labeledTypes( ind ) );
00116   else if ( p=="shrinkMode" )    val = QVariant( shrinkMode( ind ) );
00117   else if ( p=="entityMode" )    val = QVariant( entityMode( ind ) );
00118   else if ( p=="controlMode" )   val = QVariant( controlMode( ind ) );
00119   else if ( p=="isNumFunctor" )  val = QVariant( isNumFunctor( ind ) );
00120   else if ( p=="displayMode" )   val = QVariant( displayMode( ind ) );
00121   else if ( p=="isComputable" )  val = QVariant( isComputable( ind ) );
00122   else if ( p=="isPreComputable" )  val = QVariant( isPreComputable( ind ) );
00123   else if ( p=="hasReference" )  val = QVariant( hasReference( ind ) );
00124   else if ( p=="isImported" )    val = QVariant( isImported( ind ) );
00125   else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
00126   else if ( p=="groupType" )     val = QVariant( groupType( ind ) );
00127   else if ( p=="quadratic2DMode") val =  QVariant(quadratic2DMode(ind));
00128   else if ( p=="isDistributionVisible") val = QVariant(isDistributionVisible(ind));
00129 
00130   if( val.isValid() )
00131     return val;
00132   else
00133     return LightApp_Selection::parameter( ind, p );
00134 }
00135 
00136 //=======================================================================
00137 //function : getVtkOwner
00138 //purpose  : 
00139 //=======================================================================
00140 
00141 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
00142 {
00143   if( ind >= 0 && ind < count() )
00144     return myActors.isEmpty() ? 0 : myActors.at( ind );
00145   else
00146     return 0;
00147 }
00148 
00149 //=======================================================================
00150 //function : elemTypes
00151 //purpose  : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
00152 //=======================================================================
00153 
00154 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
00155 {
00156   QList<QVariant> types;
00157   SMESH_Actor* actor = getActor( ind );
00158   if ( actor ) {
00159     TVisualObjPtr object = actor->GetObject();
00160     if ( object ) {
00161       if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
00162       if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
00163       if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
00164       if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
00165     }
00166   }
00167   return types;
00168 }
00169 
00170 //=======================================================================
00171 //function : labeledTypes
00172 //purpose  : may return {'Point' 'Cell'} at most
00173 //=======================================================================
00174 
00175 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
00176 {
00177   QList<QVariant> types;
00178   SMESH_Actor* actor = getActor( ind );
00179   if ( actor ) {
00180     if ( actor->GetPointsLabeled()) types.append( "Point" );
00181     if ( actor->GetCellsLabeled()) types.append( "Cell" );
00182   }
00183   return types;
00184 }
00185 
00186 //=======================================================================
00187 //function : displayMode
00188 //purpose  : return SMESH_Actor::EReperesent
00189 //=======================================================================
00190 
00191 QString SMESHGUI_Selection::displayMode( int ind ) const
00192 {
00193   SMESH_Actor* actor = getActor( ind );
00194   if ( actor ) {
00195     switch( actor->GetRepresentation() ) {
00196     case SMESH_Actor::eEdge:    return "eEdge";
00197     case SMESH_Actor::eSurface: return "eSurface";
00198     case SMESH_Actor::ePoint:   return "ePoint";
00199     default: break;
00200     }
00201   }
00202   return "Unknown";
00203 }
00204 
00205 
00206 //=======================================================================
00207 //function : quadratic2DMode
00208 //purpose  : return SMESH_Actor::EQuadratic2DRepresentation
00209 //=======================================================================
00210 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
00211 {
00212   SMESH_Actor* actor = getActor( ind );
00213   if ( actor ) {
00214     switch( actor->GetQuadratic2DRepresentation() ) {
00215     case SMESH_Actor::eLines:    return "eLines";
00216     case SMESH_Actor::eArcs: return "eArcs";
00217     default: break;
00218     }
00219   }
00220   return "Unknown";
00221 }
00222 
00223 //=======================================================================
00224 //function : isDistributionVisible
00225 //purpose  : Visible/Invisible distribution of the ScalarBar Actor
00226 //=======================================================================
00227 
00228 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
00229   SMESH_Actor* actor = getActor( ind );
00230   return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
00231 } 
00232 
00233 //=======================================================================
00234 //function : shrinkMode
00235 //purpose  : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
00236 //=======================================================================
00237 
00238 QString SMESHGUI_Selection::shrinkMode( int ind ) const
00239 {
00240   SMESH_Actor* actor = getActor( ind );
00241   if ( actor && actor->IsShrunkable() ) {
00242     if ( actor->IsShrunk() )
00243       return "IsShrunk";
00244     return "IsNotShrunk";
00245   }
00246   return "IsNotShrinkable";
00247 }
00248 
00249 //=======================================================================
00250 //function : entityMode
00251 //purpose  : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
00252 //=======================================================================
00253 
00254 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
00255 {
00256   QList<QVariant> types;
00257   SMESH_Actor* actor = getActor( ind );
00258   if ( actor ) {
00259     unsigned int aMode = actor->GetEntityMode();
00260     if ( aMode & SMESH_Actor::eVolumes    ) types.append( "Volume" );
00261     if ( aMode & SMESH_Actor::eFaces      ) types.append( "Face"   );
00262     if ( aMode & SMESH_Actor::eEdges      ) types.append( "Edge"   );
00263     if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
00264   }
00265   return types;
00266 }
00267 
00268 //=======================================================================
00269 //function : controlMode
00270 //purpose  : return SMESH_Actor::eControl
00271 //=======================================================================
00272 
00273 QString SMESHGUI_Selection::controlMode( int ind ) const
00274 {
00275   SMESH_Actor* actor = getActor( ind );
00276   QString mode = "eNone";
00277   if ( actor ) {
00278     switch( actor->GetControlMode() ) {
00279     case SMESH_Actor::eLength:                mode = "eLength";                break;
00280     case SMESH_Actor::eLength2D:              mode = "eLength2D";              break;
00281     case SMESH_Actor::eFreeEdges:             mode = "eFreeEdges";             break;
00282     case SMESH_Actor::eFreeNodes:             mode = "eFreeNodes";             break;
00283     case SMESH_Actor::eFreeBorders:           mode = "eFreeBorders";           break;
00284     case SMESH_Actor::eFreeFaces:             mode = "eFreeFaces";             break;
00285     case SMESH_Actor::eMultiConnection:       mode = "eMultiConnection";       break;
00286     case SMESH_Actor::eMultiConnection2D:     mode = "eMultiConnection2D";     break;
00287     case SMESH_Actor::eArea:                  mode = "eArea";                  break;
00288     case SMESH_Actor::eVolume3D:              mode = "eVolume3D";              break;
00289     case SMESH_Actor::eMaxElementLength2D:    mode = "eMaxElementLength2D";    break;
00290     case SMESH_Actor::eMaxElementLength3D:    mode = "eMaxElementLength3D";    break;
00291     case SMESH_Actor::eTaper:                 mode = "eTaper";                 break;
00292     case SMESH_Actor::eAspectRatio:           mode = "eAspectRatio";           break;
00293     case SMESH_Actor::eAspectRatio3D:         mode = "eAspectRatio3D";         break;
00294     case SMESH_Actor::eMinimumAngle:          mode = "eMinimumAngle";          break;
00295     case SMESH_Actor::eWarping:               mode = "eWarping";               break;
00296     case SMESH_Actor::eSkew:                  mode = "eSkew";                  break;
00297     case SMESH_Actor::eBareBorderFace:        mode = "eBareBorderFace";        break;
00298     case SMESH_Actor::eBareBorderVolume:      mode = "eBareBorderVolume";      break;
00299     case SMESH_Actor::eOverConstrainedFace:   mode = "eOverConstrainedFace";   break;
00300     case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
00301     case SMESH_Actor::eCoincidentNodes:       mode = "eCoincidentNodes";       break;
00302     case SMESH_Actor::eCoincidentElems1D:     mode = "eCoincidentElems1D";     break;
00303     case SMESH_Actor::eCoincidentElems2D:     mode = "eCoincidentElems2D";     break;
00304     case SMESH_Actor::eCoincidentElems3D:     mode = "eCoincidentElems3D";     break;
00305     default:break;
00306     }
00307   }
00308   return mode;
00309 }
00310 
00311 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
00312 {
00313   bool result = false;
00314   SMESH_Actor* actor = getActor( ind );
00315   if ( actor ) {
00316     switch( actor->GetControlMode() ) {
00317     case SMESH_Actor::eLength:
00318     case SMESH_Actor::eLength2D:
00319     case SMESH_Actor::eMultiConnection:
00320     case SMESH_Actor::eMultiConnection2D:
00321     case SMESH_Actor::eArea:
00322     case SMESH_Actor::eVolume3D:
00323     case SMESH_Actor::eMaxElementLength2D:
00324     case SMESH_Actor::eMaxElementLength3D:
00325     case SMESH_Actor::eTaper:
00326     case SMESH_Actor::eAspectRatio:
00327     case SMESH_Actor::eAspectRatio3D:
00328     case SMESH_Actor::eMinimumAngle:
00329     case SMESH_Actor::eWarping:
00330     case SMESH_Actor::eSkew:
00331       result = true;
00332       break;
00333     default:
00334       break;
00335     }
00336   }
00337   return result;
00338 }
00339 
00340 //=======================================================================
00341 //function : facesOrientationMode
00342 //purpose  : 
00343 //=======================================================================
00344 
00345 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
00346 {
00347   SMESH_Actor* actor = getActor( ind );
00348   if ( actor ) {
00349     if ( actor->GetFacesOriented() )
00350       return "IsOriented";
00351     return "IsNotOriented";
00352   }
00353   return "Unknown";
00354 }
00355 
00356 //=======================================================================
00357 //function : isAutoColor
00358 //purpose  : 
00359 //=======================================================================
00360 
00361 bool SMESHGUI_Selection::isAutoColor( int ind ) const
00362 {
00363   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00364   {
00365     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
00366     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
00367 
00368     if ( ! CORBA::is_nil( obj )) {
00369       SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
00370       if ( ! mesh->_is_nil() )
00371         return mesh->GetAutoColor();
00372     }
00373   }
00374   return false;
00375 }
00376 
00377 //=======================================================================
00378 //function : numberOfNodes
00379 //purpose  : 
00380 //=======================================================================
00381 
00382 int SMESHGUI_Selection::numberOfNodes( int ind ) const
00383 {
00384   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00385   {
00386     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
00387     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
00388 
00389     if ( ! CORBA::is_nil( obj )) {
00390       SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
00391       if ( ! mesh->_is_nil() )
00392         return mesh->NbNodes();
00393       SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
00394       if ( !aSubMeshObj->_is_nil() )
00395         return aSubMeshObj->GetNumberOfNodes(true);
00396       SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
00397       if ( !aGroupObj->_is_nil() )
00398         return aGroupObj->Size();
00399     }
00400   }
00401   return 0;
00402 }
00403 
00404 //================================================================================
00410 //================================================================================
00411 
00412 int SMESHGUI_Selection::dim( int ind ) const
00413 {
00414   int dim = -1;
00415   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00416   {
00417     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
00418     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
00419 
00420     if ( ! CORBA::is_nil( obj )) {
00421       SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
00422       if ( ! idSrc->_is_nil() )
00423       {
00424         SMESH::array_of_ElementType_var types = idSrc->GetTypes();
00425         for ( int i = 0; i < types->length(); ++ i)
00426           switch ( types[i] ) {
00427           case SMESH::EDGE  : dim = std::max( dim, 1 ); break;
00428           case SMESH::FACE  : dim = std::max( dim, 2 ); break;
00429           case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
00430           case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
00431           default:;
00432           }
00433       }
00434     }
00435   }
00436   return dim;
00437 }
00438 
00439 //=======================================================================
00440 //function : isComputable
00441 //purpose  : 
00442 //=======================================================================
00443 
00444 QVariant SMESHGUI_Selection::isComputable( int ind ) const
00445 {
00446   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00447   {
00448 /*    Handle(SALOME_InteractiveObject) io =
00449       static_cast<LightApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
00450     if ( !io.IsNull() ) {
00451       SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io); // m,sm,gr->m
00452       if ( !mesh->_is_nil() ) {*/
00453         _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
00454         //FindSObject( mesh );
00455         if ( so ) {
00456           CORBA::Object_var obj = SMESH::SObjectToObject(so, SMESH::GetActiveStudyDocument());
00457           if(!CORBA::is_nil(obj)){
00458             SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
00459             if (!mesh->_is_nil()){
00460               if(mesh->HasShapeToMesh()) {
00461                 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
00462                 return QVariant( !shape->_is_nil() );
00463               }
00464               else
00465               {
00466                 return QVariant(!mesh->NbFaces()==0);
00467               }
00468             }
00469             else
00470             {
00471               GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
00472               return QVariant( !shape->_is_nil() );
00473             }
00474           }
00475         }
00476 //      }
00477 //    }
00478   }
00479   return QVariant( false );
00480 }
00481 
00482 //=======================================================================
00483 //function : isPreComputable
00484 //purpose  : 
00485 //=======================================================================
00486 
00487 QVariant SMESHGUI_Selection::isPreComputable( int ind ) const
00488 {
00489   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00490   {
00491     QMap<int,int> modeMap;
00492     _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
00493     SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
00494     return QVariant( modeMap.size() > 1 );
00495   }
00496   return QVariant( false );
00497 }
00498 
00499 //=======================================================================
00500 //function : hasReference
00501 //purpose  : 
00502 //=======================================================================
00503 
00504 QVariant SMESHGUI_Selection::hasReference( int ind ) const
00505 {
00506   return QVariant( isReference( ind ) );
00507 }
00508 
00509 //=======================================================================
00510 //function : isVisible
00511 //purpose  : 
00512 //=======================================================================
00513 
00514 QVariant SMESHGUI_Selection::isVisible( int ind ) const
00515 {
00516   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
00517   {
00518     QString ent = entry( ind );
00519     SMESH_Actor* actor = SMESH::FindActorByEntry( ent.toLatin1().data() );
00520     if ( actor && actor->hasIO() ) {
00521       if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView())
00522         return QVariant( aViewWindow->isVisible( actor->getIO() ) );
00523     }
00524   }
00525   return QVariant( false );
00526 }
00527 
00528 //=======================================================================
00529 //function : type
00530 //purpose  : 
00531 //=======================================================================
00532 
00533 int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
00534 {
00535   _PTR(SObject) obj (study->FindObjectID(entry.toLatin1().data()));
00536   if( !obj )
00537     return -1;
00538 
00539   _PTR(SObject) ref;
00540   if( obj->ReferencedObject( ref ) )
00541     obj = ref;
00542 
00543   _PTR(SObject) objFather = obj->GetFather();
00544   _PTR(SComponent) objComponent = obj->GetFatherComponent();
00545 
00546   if( objComponent->ComponentDataType()!="SMESH" )
00547     return -1;
00548 
00549   if( objComponent->GetIOR()==obj->GetIOR() )
00550     return COMPONENT;
00551 
00552   int aLevel = obj->Depth() - objComponent->Depth(),
00553       aFTag = objFather->Tag(),
00554       anOTag = obj->Tag(),
00555       res = -1;
00556 
00557   switch (aLevel)
00558   {
00559   case 1:
00560     if (anOTag >= SMESH::Tag_FirstMeshRoot)
00561       res = MESH;
00562     break;
00563   case 2:
00564     switch (aFTag)
00565     {
00566     case SMESH::Tag_HypothesisRoot:
00567       res = HYPOTHESIS;
00568       break;
00569     case SMESH::Tag_AlgorithmsRoot:
00570       res = ALGORITHM;
00571       break;
00572     }
00573     break;
00574   case 3:
00575     switch (aFTag)
00576     {
00577     case SMESH::Tag_SubMeshOnVertex:
00578       res = SUBMESH_VERTEX;
00579       break;
00580     case SMESH::Tag_SubMeshOnEdge:
00581       res = SUBMESH_EDGE;
00582       break;
00583     case SMESH::Tag_SubMeshOnFace:
00584       res = SUBMESH_FACE;
00585       break;
00586     case SMESH::Tag_SubMeshOnSolid:
00587       res = SUBMESH_SOLID;
00588       break;
00589     case SMESH::Tag_SubMeshOnCompound:
00590       res = SUBMESH_COMPOUND;
00591       break;
00592     default:
00593       if (aFTag >= SMESH::Tag_FirstGroup)
00594         res = GROUP;
00595       else
00596         res = SUBMESH;
00597     }
00598     break;
00599   }
00600 
00601   return res;
00602 }
00603 
00604 //=======================================================================
00605 //function : typeName
00606 //purpose  : 
00607 //=======================================================================
00608 
00609 QString SMESHGUI_Selection::typeName( const int t )
00610 {
00611   switch( t )
00612   {
00613   case HYPOTHESIS:
00614     return "Hypothesis";
00615   case ALGORITHM:
00616     return "Algorithm";
00617   case MESH:
00618     return "Mesh";
00619   case SUBMESH:
00620     return "SubMesh";
00621   case MESHorSUBMESH:
00622     return "Mesh or submesh";
00623   case SUBMESH_VERTEX:
00624     return "Mesh vertex";
00625   case SUBMESH_EDGE:
00626     return "Mesh edge";
00627   case SUBMESH_FACE:
00628     return "Mesh face";
00629   case SUBMESH_SOLID:
00630     return "Mesh solid";
00631   case SUBMESH_COMPOUND:
00632     return "Mesh compound";
00633   case GROUP:
00634     return "Group";
00635   case COMPONENT:
00636     return "Component";
00637   default:
00638     return "Unknown";
00639   }
00640 }
00641 
00642 bool SMESHGUI_Selection::isImported( const int ind ) const
00643 {
00644   QString e = entry( ind );
00645   _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
00646   bool res = false;
00647   if( SO )
00648   {
00649     SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) );
00650     if( !aMesh->_is_nil() )
00651     {
00652       SALOME_MED::MedFileInfo* inf = aMesh->GetMEDFileInfo();
00653       res = strlen( (char*)inf->fileName ) > 0;
00654     }
00655   }
00656   return res;
00657 }
00658 
00659 //=======================================================================
00660 //function : groupType
00661 //purpose  : 
00662 //=======================================================================
00663 
00664 QString SMESHGUI_Selection::groupType( int ind ) const
00665 {
00666   QString e = entry( ind );
00667   _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
00668   if( SO )
00669   {
00670     SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( SO );
00671     if( !g->_is_nil() )
00672       return "Group";
00673 
00674     SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( SO );
00675     if( !gog->_is_nil() )
00676       return "GroupOnGeom";
00677 
00678     SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>(SO);
00679     if ( !gof->_is_nil() )
00680       return "GroupOnFilter";
00681   }
00682   return "";
00683 }