]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMGUI/GEOMGUI_Selection.cxx
Salome HOME
Implementation of 0021855: EDF 2321 GEOM : Add folders to group objects in the object...
[modules/geom.git] / src / GEOMGUI / GEOMGUI_Selection.cxx
1 // Copyright (C) 2007-2013  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 // File   : GEOMGUI_Selection.cxx
24 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
25
26 #include "GEOMGUI_Selection.h"
27
28 #include "GeometryGUI.h"
29 #include "GEOM_Displayer.h"
30
31 #include "Material_Model.h"
32
33 #include <GEOM_Constants.h>
34
35 #include <SalomeApp_Application.h>
36 #include <SalomeApp_Study.h>
37
38 #include "LightApp_DataOwner.h"
39
40 #include <SUIT_Session.h>
41 #include <SUIT_Desktop.h>
42 #include <SUIT_ViewWindow.h>
43 #include <SUIT_ViewManager.h>
44
45 #include <SALOME_Prs.h>
46 #include <SALOME_InteractiveObject.hxx>
47
48 #include <SOCC_Prs.h>
49 #include <SVTK_Prs.h>
50 #include <SALOME_Actor.h>
51 #include <GEOM_Actor.h>
52
53 #include <OCCViewer_ViewModel.h>
54 #include <SVTK_ViewModel.h>
55
56 #include <GEOMImpl_Types.hxx>
57
58 #include <GEOM_AISShape.hxx>
59 #include <GEOM_VTKPropertyMaterial.hxx>
60
61 // OCCT Includes
62 #include <AIS.hxx>
63 #include <AIS_InteractiveObject.hxx>
64 #include <AIS_ListOfInteractive.hxx>
65 #include <AIS_GraphicTool.hxx>
66 #include <AIS_Drawer.hxx>
67 #include <Aspect_TypeOfFacingModel.hxx>
68 #include <Prs3d_ShadingAspect.hxx>
69 #include<Graphic3d_MaterialAspect.hxx>
70
71 // VTK Includes
72 #include <vtkActorCollection.h>
73
74 #define OCC_DISPLAY_MODE_TO_STRING( str, dm ) { \
75     if ( dm == AIS_WireFrame ) \
76       str = QString( "Wireframe" ); \
77     else if ( dm == AIS_Shaded )    \
78       str = QString( "Shading" ); \
79     else if ( dm == GEOM_AISShape::ShadingWithEdges )    \
80       str = QString( "ShadingWithEdges" ); \
81     else if ( dm == GEOM_AISShape::TexturedShape )    \
82       str = QString( "Texture" ); \
83     else \
84       str = QString(); }
85
86 #define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \
87     if ( dm == 0 ) \
88       str = QString( "Wireframe" ); \
89     else if ( dm == 1 )    \
90       str = QString( "Shading" ); \
91     else if ( dm == 3 )    \
92       str = QString( "ShadingWithEdges" ); \
93     else \
94       str = QString(); }
95
96 #define USE_VISUAL_PROP_MAP
97
98 GEOMGUI_Selection::GEOMGUI_Selection()
99 : LightApp_Selection()
100 {
101 }
102
103 GEOMGUI_Selection::~GEOMGUI_Selection()
104 {
105 }
106
107 void GEOMGUI_Selection::init( const QString& context, LightApp_SelectionMgr* selMgr )
108 {
109   LightApp_Selection::init( context, selMgr );
110
111   myObjects.resize( count() );
112
113   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
114   if ( appStudy ) {
115     _PTR(Study) study = appStudy->studyDS();
116     for ( int idx = 0; idx < count(); idx++ ) {
117       QString anEntry = entry( idx );
118       if ( study && !anEntry.isEmpty() ) {
119         _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
120         if ( aSO ) {
121           CORBA::Object_var varObj = GeometryGUI::ClientSObjectToObject( aSO );
122           myObjects[idx] = GEOM::GEOM_Object::_narrow( varObj );
123         }
124       }
125     }
126   }
127 }
128
129 //QVariant GEOMGUI_Selection::contextParameter( const QString& p ) const
130 QVariant GEOMGUI_Selection::parameter( const QString& p ) const
131 {
132   QVariant v;
133   if ( p == "isOCC" )
134     v = activeViewType() == OCCViewer_Viewer::Type();
135   else if ( p == "selectionmode" )
136     v = selectionMode();
137   else if ( p == "hasImported" )
138     v = hasImported();
139   else if ( p == "allImported" )
140     v = allImported();
141   else
142     v = LightApp_Selection::parameter( p );
143   return v;
144 }
145
146 //QVariant GEOMGUI_Selection::objectParameter( const int idx, const QString& p ) const
147 QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
148 {
149   QVariant v;
150   if ( p == "type" )
151     v = typeName( idx );
152   else if ( p == "typeid" )
153     v = typeId( idx );
154   else if ( p == "displaymode" )
155     v = displayMode( idx );
156   else if ( p == "isAutoColor" )
157     v = isAutoColor( idx );
158   else if ( p == "isVectorsMode" )
159     v = isVectorsMode( idx );
160   else if ( p == "topLevel" )
161     v = topLevel( idx );
162   else if ( p == "hasChildren" )
163     v = hasChildren( idx );
164   else if ( p == "hasConcealedChildren" )
165     v = hasConcealedChildren( idx );
166   else if ( p == "hasDisclosedChildren" )
167     v = hasDisclosedChildren( idx );
168   else if ( p == "compoundOfVertices" )
169     v = compoundOfVertices( idx );
170   else if ( p == "imported" )
171     v = isImported( idx );
172   else if ( p == "isPhysicalMaterial" )
173     v = isPhysicalMaterial(idx);
174   else if ( p == "isFolder" )
175     v = isFolder(idx);
176   else
177     v = LightApp_Selection::parameter( idx, p );
178
179   return v;
180 }
181
182 // the method to skip temporary objects from selection (called from LightApp)
183 bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
184 {
185   return !theOwner->entry().contains("_");
186 }
187
188 QString GEOMGUI_Selection::typeName( const int index ) const
189 {
190   if ( isComponent( index ) )
191     return "Component";
192   if ( isFolder( index ) )
193     return "Folder";
194
195   static QString aGroup( "Group" );
196   static QString aShape( "Shape" );
197   static QString anUnknown( "Unknown" );
198
199   GEOM::GEOM_Object_var anObj = getObject( index );
200   if ( !CORBA::is_nil( anObj ) ) {
201     const int aGeomType = anObj->GetType();
202     if ( aGeomType == GEOM_GROUP )
203       return aGroup;
204     else
205       return aShape;
206   }
207   return anUnknown;
208 }
209
210 int GEOMGUI_Selection::typeId( const int index ) const
211 {
212   int aType = -1;
213   GEOM::GEOM_Object_var anObj = getObject( index );
214   if ( !CORBA::is_nil( anObj ) )
215     aType = (int)anObj->GetShapeType();
216   return aType;
217 }
218
219 bool GEOMGUI_Selection::isVisible( const int index ) const
220 {
221 #ifdef USE_VISUAL_PROP_MAP
222   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Visibility ) );
223   if ( v.canConvert( QVariant::Bool ) )
224     return v.toBool();
225 #endif
226
227   bool res = false;
228
229   GEOM::GEOM_Object_var obj = getObject( index );
230   SALOME_View* view = GEOM_Displayer::GetActiveView();
231   if ( !CORBA::is_nil( obj ) && view ) {
232     Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" );
233     res = view->isVisible( io );
234   }
235
236   return res;
237 }
238
239 bool GEOMGUI_Selection::isAutoColor( const int index ) const
240 {
241   GEOM::GEOM_Object_var obj = getObject( index );
242   if ( !CORBA::is_nil( obj ) )
243     return obj->GetAutoColor();
244   return false;
245 }
246
247 bool GEOMGUI_Selection::isImported( const int index ) const
248 {
249   GEOM::GEOM_Object_var obj = getObject( index );
250   if ( !CORBA::is_nil( obj ) )
251     return obj->GetType() == GEOM_IMPORT;
252   return false;
253 }
254
255 bool GEOMGUI_Selection::hasImported() const
256 {
257   bool res = false;
258   for ( int i = 0; i < count() && !res; i++ )
259     res = isImported( i );
260   return res;
261 }
262
263 bool GEOMGUI_Selection::allImported() const
264 {
265   bool res = true;
266   for ( int i = 0; i < count() && res; i++ )
267     res = isImported( i );
268   return res;
269 }
270
271 QVariant GEOMGUI_Selection::visibleProperty( const QString& entry, const QString& propName ) const
272 {
273   QVariant v;
274   LightApp_Study* aStudy = study();
275   if ( aStudy ) {
276     LightApp_Application* anApp = ::qobject_cast<LightApp_Application*>( aStudy->application() );
277     if ( anApp && anApp->activeViewManager() ) {
278       int id = anApp->activeViewManager()->getGlobalId();
279       v = aStudy->getObjectProperty( id, entry, propName, QVariant() );
280     }
281   }
282   return v;
283 }
284
285 QString GEOMGUI_Selection::displayMode( const int index ) const
286 {
287   QString res;
288   QString viewType = activeViewType();
289   
290 #ifdef USE_VISUAL_PROP_MAP
291   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::DisplayMode ) );
292   if ( v.canConvert( QVariant::Int ) ) {
293     int dm = v.toInt();
294     if ( viewType == OCCViewer_Viewer::Type() ) {
295       OCC_DISPLAY_MODE_TO_STRING( res, dm );
296     } else if ( viewType == SVTK_Viewer::Type() ) {
297       VTK_DISPLAY_MODE_TO_STRING( res, dm );
298     }
299     return res;
300   }
301 #endif
302
303   SALOME_View* view = GEOM_Displayer::GetActiveView();
304   if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
305     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
306     if ( prs ) {
307       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
308         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
309         AIS_ListOfInteractive lst;
310         occPrs->GetObjects( lst );
311         if ( lst.Extent() ) {
312           Handle(AIS_InteractiveObject) io = lst.First();
313           if ( !io.IsNull() ) {
314             int dm;
315             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
316             if(!aSh.IsNull()) {
317               dm = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
318             } else {
319               dm = io->DisplayMode();
320             }
321             OCC_DISPLAY_MODE_TO_STRING( res, dm );
322             if ( res.isEmpty() ) { // return default display mode of AIS_InteractiveContext
323               OCCViewer_Viewer* occViewer = (OCCViewer_Viewer*)SUIT_Session::session()->activeApplication()->
324                 desktop()->activeWindow()->getViewManager()->getViewModel();
325               Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
326               dm = ic->DisplayMode();
327               OCC_DISPLAY_MODE_TO_STRING( res, dm );
328             }
329           }
330         }
331       }
332       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
333         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
334         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
335         if ( lst ) {
336           lst->InitTraversal();
337           vtkActor* actor = lst->GetNextActor();
338           if ( actor ) {
339             SALOME_Actor* salActor = dynamic_cast<SALOME_Actor*>( actor );
340             if ( salActor ) {
341               int dm = salActor->getDisplayMode();
342               VTK_DISPLAY_MODE_TO_STRING( res, dm );
343             } // if ( salome actor )
344           } // if ( actor )
345         } // if ( lst == vtkPrs->GetObjects() )
346       } // if VTK
347     }
348   }
349
350   return res;
351 }
352
353 bool GEOMGUI_Selection::isVectorsMode( const int index ) const
354 {
355 #ifdef USE_VISUAL_PROP_MAP
356   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::EdgesDirection ) );
357   if ( v.canConvert( QVariant::Bool ) )
358     return v.toBool();
359 #endif
360
361   bool res = false;
362   
363   SALOME_View* view = GEOM_Displayer::GetActiveView();
364   QString viewType = activeViewType();
365   if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
366     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
367     if ( prs ) {
368       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
369         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
370         AIS_ListOfInteractive lst;
371         occPrs->GetObjects( lst );
372         if ( lst.Extent() ) {
373           Handle(AIS_InteractiveObject) io = lst.First();
374           if ( !io.IsNull() ) {
375             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
376             if ( !aSh.IsNull() )
377               res = aSh->isShowVectors();
378           }
379         }
380       }
381       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
382         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
383         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
384         if ( lst ) {
385           lst->InitTraversal();
386           vtkActor* actor = lst->GetNextActor();
387           if ( actor ) {
388             GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
389             if ( aGeomActor )
390               res = aGeomActor->GetVectorMode();
391             }
392         }
393       }
394     }
395   }
396
397   return res;
398 }
399
400 bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
401 {
402   bool ok = false;
403   if ( obj ) {
404     _PTR(ChildIterator) it ( obj->GetStudy()->NewChildIterator( obj ) );
405     for ( ; it->More() && !ok; it->Next() ) {
406       _PTR(SObject) child = it->Value();
407       if ( child ) {
408         _PTR(SObject) refObj;
409         if ( child->ReferencedObject( refObj ) ) continue; // omit references
410         if ( child->GetName() != "" ) ok = true;
411       }
412     }
413   }
414   return ok;
415 }
416
417 bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
418 {
419   bool exp = true;
420   _PTR(GenericAttribute) anAttr;
421   if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) {
422     _PTR(AttributeExpandable) aAttrExp = anAttr;
423     exp = aAttrExp->IsExpandable();
424   }
425   return exp;
426 }
427
428 bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
429 {
430   bool ret = false;
431   /*
432   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
433   (SUIT_Session::session()->activeApplication()->activeStudy());*/
434   if ( /*appStudy && */!CORBA::is_nil( obj ) )
435     ret = obj->GetShapeType() == GEOM::COMPOUND && obj->GetMaxShapeType() == GEOM::VERTEX;
436   return ret;
437 }
438
439 bool GEOMGUI_Selection::hasChildren( const int index ) const
440 {
441   bool ok = false;
442   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
443
444   if ( appStudy ) {
445     QString anEntry = entry( index );
446     _PTR(Study) study = appStudy->studyDS();
447     if ( study && !anEntry.isEmpty() ) {
448       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
449       ok = hasChildren( aSO );
450     }
451   }
452   return ok;
453 }
454
455 bool GEOMGUI_Selection::hasConcealedChildren( const int index ) const
456 {
457   bool OK = false;
458   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
459
460   if ( appStudy ) {
461     QString anEntry = entry( index );
462     _PTR(Study) study = appStudy->studyDS();
463     if ( study && !anEntry.isEmpty() ) {
464       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
465       OK = !expandable( aSO ) && hasChildren( aSO );
466     }
467   }
468   return OK;
469 }
470
471 bool GEOMGUI_Selection::hasDisclosedChildren( const int index ) const
472 {
473   bool OK = false;
474   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
475
476   if ( appStudy )  {
477     QString anEntry = entry( index );
478     _PTR(Study) study = appStudy->studyDS();
479     if ( study && !anEntry.isEmpty() ) {
480       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
481       OK = expandable( aSO ) && hasChildren( aSO );
482     }
483   }
484   return OK;
485 }
486
487 bool GEOMGUI_Selection::compoundOfVertices( const int index ) const
488 {
489   GEOM::GEOM_Object_var obj = getObject( index );
490   return isCompoundOfVertices( obj );
491 }
492
493 bool GEOMGUI_Selection::isComponent( const int index ) const
494 {
495   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
496
497   if ( appStudy ) {
498     QString anEntry = entry( index );
499     _PTR(Study) study = appStudy->studyDS();
500     if ( study && !anEntry.isNull() ) {
501       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
502       if ( aSO && aSO->GetFatherComponent() )
503         return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
504     }
505   }
506   return false;
507 }
508
509 GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const
510 {
511   GEOM::GEOM_Object_var o;
512   if ( 0 <= index && index < myObjects.size() )
513     o = GEOM::GEOM_Object::_duplicate( myObjects[index] );
514   return o._retn();
515 }
516
517 QString GEOMGUI_Selection::selectionMode() const
518 {
519   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study()->application() );
520   if ( app ) {
521     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
522     if ( aGeomGUI ) {
523       switch ( aGeomGUI->getLocalSelectionMode() )
524       {
525         case GEOM_POINT      : return "VERTEX";
526         case GEOM_EDGE       : return "EDGE";
527         case GEOM_WIRE       : return "WIRE";
528         case GEOM_FACE       : return "FACE";
529         case GEOM_SHELL      : return "SHELL";
530         case GEOM_SOLID      : return "SOLID";
531         case GEOM_COMPOUND   : return "COMPOUND";
532         case GEOM_ALLOBJECTS : return "ALL";
533         default: return "";
534       }
535     }
536   }
537   return "";
538 }
539
540 bool GEOMGUI_Selection::topLevel( const int index ) const
541 {
542 #ifdef USE_VISUAL_PROP_MAP
543   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::TopLevel ) );
544   if ( v.canConvert<bool>() )
545     return v.toBool();
546 #endif
547
548   bool res = false;
549
550   SALOME_View* view = GEOM_Displayer::GetActiveView();
551   QString viewType = activeViewType();
552   if ( view && viewType == OCCViewer_Viewer::Type() ) {
553     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
554     if ( prs ) {
555       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
556         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
557         AIS_ListOfInteractive lst;
558         occPrs->GetObjects( lst );
559         if ( lst.Extent() ) {
560           Handle(AIS_InteractiveObject) io = lst.First();
561           if ( !io.IsNull() ) {
562             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
563             if ( !aSh.IsNull() )
564               res = (bool)aSh->isTopLevel();
565           }
566         }
567       }
568     }
569   }
570   return res;
571 }
572
573 bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
574 {
575 #ifdef USE_VISUAL_PROP_MAP
576   QVariant v = visibleProperty( entry( idx ), GEOM::propertyName( GEOM::Material ) );
577   if ( v.canConvert<QString>() ) {
578     Material_Model material;
579     material.fromProperties( v.toString() );
580     return material.isPhysical();
581   }
582 #endif
583
584   bool res = false;
585   
586   SALOME_View* view = GEOM_Displayer::GetActiveView();
587   QString viewType = activeViewType();
588   if ( view ) {
589     SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() );
590     if ( prs ) {
591       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
592         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
593         AIS_ListOfInteractive lst;
594         occPrs->GetObjects( lst );
595         if ( lst.Extent() ) {
596           Handle(AIS_InteractiveObject) io = lst.First();
597           if ( !io.IsNull() ) {
598             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
599             if ( !aSh.IsNull() )
600               res = (bool) aSh->Attributes()->ShadingAspect()->
601                 Material(Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC );
602           }
603         }
604       }
605       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
606         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
607         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
608         if ( lst ) {
609           lst->InitTraversal();
610           vtkActor* actor = lst->GetNextActor();
611           if ( actor ) {
612             GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
613             if ( aGeomGActor ) {
614               GEOM_VTKPropertyMaterial* mat  = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
615               res = mat->GetPhysical();
616             } // if ( salome actor )
617           } // if ( actor )
618         } // if ( lst == vtkPrs->GetObjects() )
619       }
620     }
621   }
622
623   return res;
624 }
625
626 bool GEOMGUI_Selection::isFolder( const int index ) const
627 {
628   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
629
630   if ( appStudy ) {
631     QString anEntry = entry( index );
632     _PTR(Study) study = appStudy->studyDS();
633     if ( study && !anEntry.isNull() ) {
634       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
635       if ( aSO ) {
636         _PTR(GenericAttribute) anAttr;
637         if ( aSO->FindAttribute(anAttr, "AttributeLocalID") ) {
638           _PTR(AttributeLocalID) aLocalID( anAttr );
639           return aLocalID->Value() == 999;
640         }
641       }
642     }
643   }
644   return false;
645 }
646