Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Selection.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI_Selection
24 // File   : SMESHGUI_Selection.cxx
25 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
26 // SMESH includes
27 //
28 #include "SMESHGUI_Selection.h"
29
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_GEOMGenUtils.h"
33 #include "SMESHGUI_ComputeDlg.h"
34
35 #include <SMESH_Type.h>
36 #include <SMESH_Actor.h>
37 #include <SMESH_ScalarBarActor.h>
38
39 // SALOME GUI includes
40 #include <SalomeApp_Study.h>
41 #include <LightApp_VTKSelector.h>
42 #include <SVTK_ViewWindow.h>
43
44 // IDL includes
45 #include <SALOMEconfig.h>
46 #include CORBA_CLIENT_HEADER(SMESH_Gen)
47 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
48 #include CORBA_CLIENT_HEADER(SMESH_Group)
49
50 //=======================================================================
51 //function : SMESHGUI_Selection
52 //purpose  : 
53 //=======================================================================
54 SMESHGUI_Selection::SMESHGUI_Selection()
55 : LightApp_Selection()
56 {
57 }
58
59 //=======================================================================
60 //function : ~SMESHGUI_Selection
61 //purpose  : 
62 //=======================================================================
63 SMESHGUI_Selection::~SMESHGUI_Selection()
64 {
65 }
66
67 //=======================================================================
68 //function : init
69 //purpose  : 
70 //=======================================================================
71 void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
72 {
73   LightApp_Selection::init( client, mgr );
74
75   if( mgr && study() )
76   {
77     SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
78     if (!aSStudy)
79       return;
80     _PTR(Study) aStudy = aSStudy->studyDS();
81
82     for( int i=0, n=count(); i<n; i++ )
83       myTypes.append( typeName( type( entry( i ), aStudy ) ) );
84   }
85 }
86
87 //=======================================================================
88 //function : processOwner
89 //purpose  : 
90 //=======================================================================
91 bool SMESHGUI_Selection::processOwner( const LightApp_DataOwner* ow )
92 {
93   const LightApp_SVTKDataOwner* owner =
94     dynamic_cast<const LightApp_SVTKDataOwner*> ( ow );
95   if( owner )
96     myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
97   else
98     myActors.append( 0 );
99   return true;
100 }
101
102 //=======================================================================
103 //function : parameter
104 //purpose  : 
105 //=======================================================================
106 QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
107 {
108   QVariant val;
109   if      ( p=="client" )        val = QVariant( LightApp_Selection::parameter( p ) );
110   else if ( p=="type" )          val = QVariant( myTypes[ind] );
111   else if ( p=="elemTypes" )     val = QVariant( elemTypes( ind ) );
112   else if ( p=="isAutoColor" )   val = QVariant( isAutoColor( ind ) );
113   else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) );
114   else if ( p=="dim" )           val = QVariant( dim( ind ) );
115   else if ( p=="labeledTypes" )  val = QVariant( labeledTypes( ind ) );
116   else if ( p=="shrinkMode" )    val = QVariant( shrinkMode( ind ) );
117   else if ( p=="entityMode" )    val = QVariant( entityMode( ind ) );
118   else if ( p=="controlMode" )   val = QVariant( controlMode( ind ) );
119   else if ( p=="isNumFunctor" )  val = QVariant( isNumFunctor( ind ) );
120   else if ( p=="displayMode" )   val = QVariant( displayMode( ind ) );
121   else if ( p=="isComputable" )  val = QVariant( isComputable( ind ) );
122   else if ( p=="isPreComputable" )  val = QVariant( isPreComputable( ind ) );
123   else if ( p=="hasReference" )  val = QVariant( hasReference( ind ) );
124   else if ( p=="isImported" )    val = QVariant( isImported( ind ) );
125   else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
126   else if ( p=="groupType" )     val = QVariant( groupType( ind ) );
127   else if ( p=="quadratic2DMode") val =  QVariant(quadratic2DMode(ind));
128   else if ( p=="isDistributionVisible") val = QVariant(isDistributionVisible(ind));
129
130   if( val.isValid() )
131     return val;
132   else
133     return LightApp_Selection::parameter( ind, p );
134 }
135
136 //=======================================================================
137 //function : getVtkOwner
138 //purpose  : 
139 //=======================================================================
140
141 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
142 {
143   if( ind >= 0 && ind < count() )
144     return myActors.isEmpty() ? 0 : myActors.at( ind );
145   else
146     return 0;
147 }
148
149 //=======================================================================
150 //function : elemTypes
151 //purpose  : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
152 //=======================================================================
153
154 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
155 {
156   QList<QVariant> types;
157   SMESH_Actor* actor = getActor( ind );
158   if ( actor ) {
159     TVisualObjPtr object = actor->GetObject();
160     if ( object ) {
161       if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
162       if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
163       if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
164       if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
165     }
166   }
167   return types;
168 }
169
170 //=======================================================================
171 //function : labeledTypes
172 //purpose  : may return {'Point' 'Cell'} at most
173 //=======================================================================
174
175 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
176 {
177   QList<QVariant> types;
178   SMESH_Actor* actor = getActor( ind );
179   if ( actor ) {
180     if ( actor->GetPointsLabeled()) types.append( "Point" );
181     if ( actor->GetCellsLabeled()) types.append( "Cell" );
182   }
183   return types;
184 }
185
186 //=======================================================================
187 //function : displayMode
188 //purpose  : return SMESH_Actor::EReperesent
189 //=======================================================================
190
191 QString SMESHGUI_Selection::displayMode( int ind ) const
192 {
193   SMESH_Actor* actor = getActor( ind );
194   if ( actor ) {
195     switch( actor->GetRepresentation() ) {
196     case SMESH_Actor::eEdge:    return "eEdge";
197     case SMESH_Actor::eSurface: return "eSurface";
198     case SMESH_Actor::ePoint:   return "ePoint";
199     default: break;
200     }
201   }
202   return "Unknown";
203 }
204
205
206 //=======================================================================
207 //function : quadratic2DMode
208 //purpose  : return SMESH_Actor::EQuadratic2DRepresentation
209 //=======================================================================
210 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
211 {
212   SMESH_Actor* actor = getActor( ind );
213   if ( actor ) {
214     switch( actor->GetQuadratic2DRepresentation() ) {
215     case SMESH_Actor::eLines:    return "eLines";
216     case SMESH_Actor::eArcs: return "eArcs";
217     default: break;
218     }
219   }
220   return "Unknown";
221 }
222
223 //=======================================================================
224 //function : isDistributionVisible
225 //purpose  : Visible/Invisible distribution of the ScalarBar Actor
226 //=======================================================================
227
228 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
229   SMESH_Actor* actor = getActor( ind );
230   return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
231
232
233 //=======================================================================
234 //function : shrinkMode
235 //purpose  : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
236 //=======================================================================
237
238 QString SMESHGUI_Selection::shrinkMode( int ind ) const
239 {
240   SMESH_Actor* actor = getActor( ind );
241   if ( actor && actor->IsShrunkable() ) {
242     if ( actor->IsShrunk() )
243       return "IsShrunk";
244     return "IsNotShrunk";
245   }
246   return "IsNotShrinkable";
247 }
248
249 //=======================================================================
250 //function : entityMode
251 //purpose  : may return {'Elem0d' 'Edge' 'Face' 'Volume'} at most
252 //=======================================================================
253
254 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
255 {
256   QList<QVariant> types;
257   SMESH_Actor* actor = getActor( ind );
258   if ( actor ) {
259     unsigned int aMode = actor->GetEntityMode();
260     if ( aMode & SMESH_Actor::eVolumes    ) types.append( "Volume" );
261     if ( aMode & SMESH_Actor::eFaces      ) types.append( "Face"   );
262     if ( aMode & SMESH_Actor::eEdges      ) types.append( "Edge"   );
263     if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
264   }
265   return types;
266 }
267
268 //=======================================================================
269 //function : controlMode
270 //purpose  : return SMESH_Actor::eControl
271 //=======================================================================
272
273 QString SMESHGUI_Selection::controlMode( int ind ) const
274 {
275   SMESH_Actor* actor = getActor( ind );
276   QString mode = "eNone";
277   if ( actor ) {
278     switch( actor->GetControlMode() ) {
279     case SMESH_Actor::eLength:                mode = "eLength";                break;
280     case SMESH_Actor::eLength2D:              mode = "eLength2D";              break;
281     case SMESH_Actor::eFreeEdges:             mode = "eFreeEdges";             break;
282     case SMESH_Actor::eFreeNodes:             mode = "eFreeNodes";             break;
283     case SMESH_Actor::eFreeBorders:           mode = "eFreeBorders";           break;
284     case SMESH_Actor::eFreeFaces:             mode = "eFreeFaces";             break;
285     case SMESH_Actor::eMultiConnection:       mode = "eMultiConnection";       break;
286     case SMESH_Actor::eMultiConnection2D:     mode = "eMultiConnection2D";     break;
287     case SMESH_Actor::eArea:                  mode = "eArea";                  break;
288     case SMESH_Actor::eVolume3D:              mode = "eVolume3D";              break;
289     case SMESH_Actor::eMaxElementLength2D:    mode = "eMaxElementLength2D";    break;
290     case SMESH_Actor::eMaxElementLength3D:    mode = "eMaxElementLength3D";    break;
291     case SMESH_Actor::eTaper:                 mode = "eTaper";                 break;
292     case SMESH_Actor::eAspectRatio:           mode = "eAspectRatio";           break;
293     case SMESH_Actor::eAspectRatio3D:         mode = "eAspectRatio3D";         break;
294     case SMESH_Actor::eMinimumAngle:          mode = "eMinimumAngle";          break;
295     case SMESH_Actor::eWarping:               mode = "eWarping";               break;
296     case SMESH_Actor::eSkew:                  mode = "eSkew";                  break;
297     case SMESH_Actor::eBareBorderFace:        mode = "eBareBorderFace";        break;
298     case SMESH_Actor::eBareBorderVolume:      mode = "eBareBorderVolume";      break;
299     case SMESH_Actor::eOverConstrainedFace:   mode = "eOverConstrainedFace";   break;
300     case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
301     case SMESH_Actor::eCoincidentNodes:       mode = "eCoincidentNodes";       break;
302     case SMESH_Actor::eCoincidentElems1D:     mode = "eCoincidentElems1D";     break;
303     case SMESH_Actor::eCoincidentElems2D:     mode = "eCoincidentElems2D";     break;
304     case SMESH_Actor::eCoincidentElems3D:     mode = "eCoincidentElems3D";     break;
305     default:break;
306     }
307   }
308   return mode;
309 }
310
311 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
312 {
313   bool result = false;
314   SMESH_Actor* actor = getActor( ind );
315   if ( actor ) {
316     switch( actor->GetControlMode() ) {
317     case SMESH_Actor::eLength:
318     case SMESH_Actor::eLength2D:
319     case SMESH_Actor::eMultiConnection:
320     case SMESH_Actor::eMultiConnection2D:
321     case SMESH_Actor::eArea:
322     case SMESH_Actor::eVolume3D:
323     case SMESH_Actor::eMaxElementLength2D:
324     case SMESH_Actor::eMaxElementLength3D:
325     case SMESH_Actor::eTaper:
326     case SMESH_Actor::eAspectRatio:
327     case SMESH_Actor::eAspectRatio3D:
328     case SMESH_Actor::eMinimumAngle:
329     case SMESH_Actor::eWarping:
330     case SMESH_Actor::eSkew:
331       result = true;
332       break;
333     default:
334       break;
335     }
336   }
337   return result;
338 }
339
340 //=======================================================================
341 //function : facesOrientationMode
342 //purpose  : 
343 //=======================================================================
344
345 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
346 {
347   SMESH_Actor* actor = getActor( ind );
348   if ( actor ) {
349     if ( actor->GetFacesOriented() )
350       return "IsOriented";
351     return "IsNotOriented";
352   }
353   return "Unknown";
354 }
355
356 //=======================================================================
357 //function : isAutoColor
358 //purpose  : 
359 //=======================================================================
360
361 bool SMESHGUI_Selection::isAutoColor( int ind ) const
362 {
363   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
364   {
365     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
366     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
367
368     if ( ! CORBA::is_nil( obj )) {
369       SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
370       if ( ! mesh->_is_nil() )
371         return mesh->GetAutoColor();
372     }
373   }
374   return false;
375 }
376
377 //=======================================================================
378 //function : numberOfNodes
379 //purpose  : 
380 //=======================================================================
381
382 int SMESHGUI_Selection::numberOfNodes( int ind ) const
383 {
384   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
385   {
386     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
387     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
388
389     if ( ! CORBA::is_nil( obj )) {
390       SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
391       if ( ! mesh->_is_nil() )
392         return mesh->NbNodes();
393       SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
394       if ( !aSubMeshObj->_is_nil() )
395         return aSubMeshObj->GetNumberOfNodes(true);
396       SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
397       if ( !aGroupObj->_is_nil() )
398         return aGroupObj->Size();
399     }
400   }
401   return 0;
402 }
403
404 //================================================================================
405 /*!
406  * \brief return dimension of elements of the selected object
407  *
408  *  \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
409  */
410 //================================================================================
411
412 int SMESHGUI_Selection::dim( int ind ) const
413 {
414   int dim = -1;
415   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
416   {
417     _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
418     CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
419
420     if ( ! CORBA::is_nil( obj )) {
421       SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
422       if ( ! idSrc->_is_nil() )
423       {
424         SMESH::array_of_ElementType_var types = idSrc->GetTypes();
425         for ( int i = 0; i < types->length(); ++ i)
426           switch ( types[i] ) {
427           case SMESH::EDGE  : dim = std::max( dim, 1 ); break;
428           case SMESH::FACE  : dim = std::max( dim, 2 ); break;
429           case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
430           case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
431           default:;
432           }
433       }
434     }
435   }
436   return dim;
437 }
438
439 //=======================================================================
440 //function : isComputable
441 //purpose  : 
442 //=======================================================================
443
444 QVariant SMESHGUI_Selection::isComputable( int ind ) const
445 {
446   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
447   {
448 /*    Handle(SALOME_InteractiveObject) io =
449       static_cast<LightApp_DataOwner*>( myDataOwners[ ind ].get() )->IO();
450     if ( !io.IsNull() ) {
451       SMESH::SMESH_Mesh_var mesh = SMESH::GetMeshByIO(io); // m,sm,gr->m
452       if ( !mesh->_is_nil() ) {*/
453         _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
454         //FindSObject( mesh );
455         if ( so ) {
456           CORBA::Object_var obj = SMESH::SObjectToObject(so, SMESH::GetActiveStudyDocument());
457           if(!CORBA::is_nil(obj)){
458             SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
459             if (!mesh->_is_nil()){
460               if(mesh->HasShapeToMesh()) {
461                 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
462                 return QVariant( !shape->_is_nil() );
463               }
464               else
465               {
466                 return QVariant(!mesh->NbFaces()==0);
467               }
468             }
469             else
470             {
471               GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
472               return QVariant( !shape->_is_nil() );
473             }
474           }
475         }
476 //      }
477 //    }
478   }
479   return QVariant( false );
480 }
481
482 //=======================================================================
483 //function : isPreComputable
484 //purpose  : 
485 //=======================================================================
486
487 QVariant SMESHGUI_Selection::isPreComputable( int ind ) const
488 {
489   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
490   {
491     QMap<int,int> modeMap;
492     _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
493     SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
494     return QVariant( modeMap.size() > 1 );
495   }
496   return QVariant( false );
497 }
498
499 //=======================================================================
500 //function : hasReference
501 //purpose  : 
502 //=======================================================================
503
504 QVariant SMESHGUI_Selection::hasReference( int ind ) const
505 {
506   return QVariant( isReference( ind ) );
507 }
508
509 //=======================================================================
510 //function : isVisible
511 //purpose  : 
512 //=======================================================================
513
514 QVariant SMESHGUI_Selection::isVisible( int ind ) const
515 {
516   if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
517   {
518     QString ent = entry( ind );
519     SMESH_Actor* actor = SMESH::FindActorByEntry( ent.toLatin1().data() );
520     if ( actor && actor->hasIO() ) {
521       if(SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView())
522         return QVariant( aViewWindow->isVisible( actor->getIO() ) );
523     }
524   }
525   return QVariant( false );
526 }
527
528 //=======================================================================
529 //function : type
530 //purpose  : 
531 //=======================================================================
532
533 int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
534 {
535   _PTR(SObject) obj (study->FindObjectID(entry.toLatin1().data()));
536   if( !obj )
537     return -1;
538
539   _PTR(SObject) ref;
540   if( obj->ReferencedObject( ref ) )
541     obj = ref;
542
543   _PTR(SObject) objFather = obj->GetFather();
544   _PTR(SComponent) objComponent = obj->GetFatherComponent();
545
546   if( objComponent->ComponentDataType()!="SMESH" )
547     return -1;
548
549   if( objComponent->GetIOR()==obj->GetIOR() )
550     return COMPONENT;
551
552   int aLevel = obj->Depth() - objComponent->Depth(),
553       aFTag = objFather->Tag(),
554       anOTag = obj->Tag(),
555       res = -1;
556
557   switch (aLevel)
558   {
559   case 1:
560     if (anOTag >= SMESH::Tag_FirstMeshRoot)
561       res = MESH;
562     break;
563   case 2:
564     switch (aFTag)
565     {
566     case SMESH::Tag_HypothesisRoot:
567       res = HYPOTHESIS;
568       break;
569     case SMESH::Tag_AlgorithmsRoot:
570       res = ALGORITHM;
571       break;
572     }
573     break;
574   case 3:
575     switch (aFTag)
576     {
577     case SMESH::Tag_SubMeshOnVertex:
578       res = SUBMESH_VERTEX;
579       break;
580     case SMESH::Tag_SubMeshOnEdge:
581       res = SUBMESH_EDGE;
582       break;
583     case SMESH::Tag_SubMeshOnFace:
584       res = SUBMESH_FACE;
585       break;
586     case SMESH::Tag_SubMeshOnSolid:
587       res = SUBMESH_SOLID;
588       break;
589     case SMESH::Tag_SubMeshOnCompound:
590       res = SUBMESH_COMPOUND;
591       break;
592     default:
593       if (aFTag >= SMESH::Tag_FirstGroup)
594         res = GROUP;
595       else
596         res = SUBMESH;
597     }
598     break;
599   }
600
601   return res;
602 }
603
604 //=======================================================================
605 //function : typeName
606 //purpose  : 
607 //=======================================================================
608
609 QString SMESHGUI_Selection::typeName( const int t )
610 {
611   switch( t )
612   {
613   case HYPOTHESIS:
614     return "Hypothesis";
615   case ALGORITHM:
616     return "Algorithm";
617   case MESH:
618     return "Mesh";
619   case SUBMESH:
620     return "SubMesh";
621   case MESHorSUBMESH:
622     return "Mesh or submesh";
623   case SUBMESH_VERTEX:
624     return "Mesh vertex";
625   case SUBMESH_EDGE:
626     return "Mesh edge";
627   case SUBMESH_FACE:
628     return "Mesh face";
629   case SUBMESH_SOLID:
630     return "Mesh solid";
631   case SUBMESH_COMPOUND:
632     return "Mesh compound";
633   case GROUP:
634     return "Group";
635   case COMPONENT:
636     return "Component";
637   default:
638     return "Unknown";
639   }
640 }
641
642 bool SMESHGUI_Selection::isImported( const int ind ) const
643 {
644   QString e = entry( ind );
645   _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
646   bool res = false;
647   if( SO )
648   {
649     SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( SO ) );
650     if( !aMesh->_is_nil() )
651     {
652       SALOME_MED::MedFileInfo* inf = aMesh->GetMEDFileInfo();
653       res = strlen( (char*)inf->fileName ) > 0;
654     }
655   }
656   return res;
657 }
658
659 //=======================================================================
660 //function : groupType
661 //purpose  : 
662 //=======================================================================
663
664 QString SMESHGUI_Selection::groupType( int ind ) const
665 {
666   QString e = entry( ind );
667   _PTR(SObject) SO = SMESH::GetActiveStudyDocument()->FindObjectID( e.toLatin1().constData() );
668   if( SO )
669   {
670     SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( SO );
671     if( !g->_is_nil() )
672       return "Group";
673
674     SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( SO );
675     if( !gog->_is_nil() )
676       return "GroupOnGeom";
677
678     SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>(SO);
679     if ( !gof->_is_nil() )
680       return "GroupOnFilter";
681   }
682   return "";
683 }