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