Salome HOME
0021708: [CEA 586] Object browser sort only children:
[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 == "nbChildren" )
165     v = nbChildren(idx);
166   else if ( p == "hasConcealedChildren" )
167     v = hasConcealedChildren( idx );
168   else if ( p == "hasDisclosedChildren" )
169     v = hasDisclosedChildren( idx );
170   else if ( p == "compoundOfVertices" )
171     v = compoundOfVertices( idx );
172   else if ( p == "imported" )
173     v = isImported( idx );
174   else if ( p == "isPhysicalMaterial" )
175     v = isPhysicalMaterial(idx);
176   else if ( p == "isFolder" )
177     v = isFolder(idx);
178   else
179     v = LightApp_Selection::parameter( idx, p );
180
181   return v;
182 }
183
184 // the method to skip temporary objects from selection (called from LightApp)
185 bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
186 {
187   return !theOwner->entry().contains("_");
188 }
189
190 QString GEOMGUI_Selection::typeName( const int index ) const
191 {
192   if ( isComponent( index ) )
193     return "Component";
194   if ( isFolder( index ) )
195     return "Folder";
196
197   static QString aGroup( "Group" );
198   static QString aShape( "Shape" );
199   static QString anUnknown( "Unknown" );
200
201   GEOM::GEOM_Object_var anObj = getObject( index );
202   if ( !CORBA::is_nil( anObj ) ) {
203     const int aGeomType = anObj->GetType();
204     if ( aGeomType == GEOM_GROUP )
205       return aGroup;
206     else
207       return aShape;
208   }
209   return anUnknown;
210 }
211
212 int GEOMGUI_Selection::typeId( const int index ) const
213 {
214   int aType = -1;
215   GEOM::GEOM_Object_var anObj = getObject( index );
216   if ( !CORBA::is_nil( anObj ) )
217     aType = (int)anObj->GetShapeType();
218   return aType;
219 }
220
221 bool GEOMGUI_Selection::isVisible( const int index ) const
222 {
223 #ifdef USE_VISUAL_PROP_MAP
224   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Visibility ) );
225   if ( v.canConvert( QVariant::Bool ) )
226     return v.toBool();
227 #endif
228
229   bool res = false;
230
231   GEOM::GEOM_Object_var obj = getObject( index );
232   SALOME_View* view = GEOM_Displayer::GetActiveView();
233   if ( !CORBA::is_nil( obj ) && view ) {
234     Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" );
235     res = view->isVisible( io );
236   }
237
238   return res;
239 }
240
241 bool GEOMGUI_Selection::isAutoColor( const int index ) const
242 {
243   GEOM::GEOM_Object_var obj = getObject( index );
244   if ( !CORBA::is_nil( obj ) )
245     return obj->GetAutoColor();
246   return false;
247 }
248
249 bool GEOMGUI_Selection::isImported( const int index ) const
250 {
251   GEOM::GEOM_Object_var obj = getObject( index );
252   if ( !CORBA::is_nil( obj ) )
253     return obj->GetType() == GEOM_IMPORT;
254   return false;
255 }
256
257 bool GEOMGUI_Selection::hasImported() const
258 {
259   bool res = false;
260   for ( int i = 0; i < count() && !res; i++ )
261     res = isImported( i );
262   return res;
263 }
264
265 bool GEOMGUI_Selection::allImported() const
266 {
267   bool res = true;
268   for ( int i = 0; i < count() && res; i++ )
269     res = isImported( i );
270   return res;
271 }
272
273 QVariant GEOMGUI_Selection::visibleProperty( const QString& entry, const QString& propName ) const
274 {
275   QVariant v;
276   LightApp_Study* aStudy = study();
277   if ( aStudy ) {
278     LightApp_Application* anApp = ::qobject_cast<LightApp_Application*>( aStudy->application() );
279     if ( anApp && anApp->activeViewManager() ) {
280       int id = anApp->activeViewManager()->getGlobalId();
281       v = aStudy->getObjectProperty( id, entry, propName, QVariant() );
282     }
283   }
284   return v;
285 }
286
287 QString GEOMGUI_Selection::displayMode( const int index ) const
288 {
289   QString res;
290   QString viewType = activeViewType();
291   
292 #ifdef USE_VISUAL_PROP_MAP
293   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::DisplayMode ) );
294   if ( v.canConvert( QVariant::Int ) ) {
295     int dm = v.toInt();
296     if ( viewType == OCCViewer_Viewer::Type() ) {
297       OCC_DISPLAY_MODE_TO_STRING( res, dm );
298     } else if ( viewType == SVTK_Viewer::Type() ) {
299       VTK_DISPLAY_MODE_TO_STRING( res, dm );
300     }
301     return res;
302   }
303 #endif
304
305   SALOME_View* view = GEOM_Displayer::GetActiveView();
306   if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
307     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
308     if ( prs ) {
309       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
310         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
311         AIS_ListOfInteractive lst;
312         occPrs->GetObjects( lst );
313         if ( lst.Extent() ) {
314           Handle(AIS_InteractiveObject) io = lst.First();
315           if ( !io.IsNull() ) {
316             int dm;
317             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
318             if(!aSh.IsNull()) {
319               dm = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
320             } else {
321               dm = io->DisplayMode();
322             }
323             OCC_DISPLAY_MODE_TO_STRING( res, dm );
324             if ( res.isEmpty() ) { // return default display mode of AIS_InteractiveContext
325               OCCViewer_Viewer* occViewer = (OCCViewer_Viewer*)SUIT_Session::session()->activeApplication()->
326                 desktop()->activeWindow()->getViewManager()->getViewModel();
327               Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
328               dm = ic->DisplayMode();
329               OCC_DISPLAY_MODE_TO_STRING( res, dm );
330             }
331           }
332         }
333       }
334       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
335         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
336         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
337         if ( lst ) {
338           lst->InitTraversal();
339           vtkActor* actor = lst->GetNextActor();
340           if ( actor ) {
341             SALOME_Actor* salActor = dynamic_cast<SALOME_Actor*>( actor );
342             if ( salActor ) {
343               int dm = salActor->getDisplayMode();
344               VTK_DISPLAY_MODE_TO_STRING( res, dm );
345             } // if ( salome actor )
346           } // if ( actor )
347         } // if ( lst == vtkPrs->GetObjects() )
348       } // if VTK
349     }
350   }
351
352   return res;
353 }
354
355 bool GEOMGUI_Selection::isVectorsMode( const int index ) const
356 {
357 #ifdef USE_VISUAL_PROP_MAP
358   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::EdgesDirection ) );
359   if ( v.canConvert( QVariant::Bool ) )
360     return v.toBool();
361 #endif
362
363   bool res = false;
364   
365   SALOME_View* view = GEOM_Displayer::GetActiveView();
366   QString viewType = activeViewType();
367   if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
368     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
369     if ( prs ) {
370       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
371         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
372         AIS_ListOfInteractive lst;
373         occPrs->GetObjects( lst );
374         if ( lst.Extent() ) {
375           Handle(AIS_InteractiveObject) io = lst.First();
376           if ( !io.IsNull() ) {
377             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
378             if ( !aSh.IsNull() )
379               res = aSh->isShowVectors();
380           }
381         }
382       }
383       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
384         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
385         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
386         if ( lst ) {
387           lst->InitTraversal();
388           vtkActor* actor = lst->GetNextActor();
389           if ( actor ) {
390             GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
391             if ( aGeomActor )
392               res = aGeomActor->GetVectorMode();
393             }
394         }
395       }
396     }
397   }
398
399   return res;
400 }
401
402 bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
403 {
404   // as soon as Use Case browser data tree was added
405   return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
406 }
407
408 bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
409 {
410   bool exp = true;
411   _PTR(GenericAttribute) anAttr;
412   if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) {
413     _PTR(AttributeExpandable) aAttrExp = anAttr;
414     exp = aAttrExp->IsExpandable();
415   }
416   return exp;
417 }
418
419 bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
420 {
421   bool ret = false;
422   /*
423   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
424   (SUIT_Session::session()->activeApplication()->activeStudy());*/
425   if ( /*appStudy && */!CORBA::is_nil( obj ) )
426     ret = obj->GetShapeType() == GEOM::COMPOUND && obj->GetMaxShapeType() == GEOM::VERTEX;
427   return ret;
428 }
429
430 bool GEOMGUI_Selection::isFolder( const _PTR(SObject)& obj )
431 {
432   bool ret = false;
433   _PTR(GenericAttribute) anAttr;
434   if ( obj->FindAttribute(anAttr, "AttributeLocalID") ) {
435     _PTR(AttributeLocalID) aLocalID( anAttr );
436     ret = aLocalID->Value() == 999;
437   }
438   return ret;
439 }
440
441 bool GEOMGUI_Selection::hasChildren( const int index ) const
442 {
443   bool ok = false;
444   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
445
446   if ( appStudy ) {
447     QString anEntry = entry( index );
448     _PTR(Study) study = appStudy->studyDS();
449     if ( study && !anEntry.isEmpty() ) {
450       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
451       ok = hasChildren( aSO );
452     }
453   }
454   return ok;
455 }
456
457 int GEOMGUI_Selection::nbChildren( const int index ) const
458 {
459   int nb = 0;
460   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
461
462   if ( appStudy ) {
463     QString anEntry = entry( index );
464     _PTR(Study) study = appStudy->studyDS();
465     if ( study && !anEntry.isEmpty() ) {
466       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
467       if ( aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
468         _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO ); 
469         for (it->Init(false); it->More(); it->Next()) nb++;
470       }
471     }
472   }
473   return nb;
474 }
475
476 bool GEOMGUI_Selection::hasConcealedChildren( const int index ) const
477 {
478   bool OK = false;
479   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
480
481   if ( appStudy ) {
482     QString anEntry = entry( index );
483     _PTR(Study) study = appStudy->studyDS();
484     if ( study && !anEntry.isEmpty() ) {
485       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
486       OK = !expandable( aSO ) && hasChildren( aSO );
487     }
488   }
489   return OK;
490 }
491
492 bool GEOMGUI_Selection::hasDisclosedChildren( const int index ) const
493 {
494   bool OK = false;
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.isEmpty() ) {
501       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
502       OK = expandable( aSO ) && hasChildren( aSO );
503     }
504   }
505   return OK;
506 }
507
508 bool GEOMGUI_Selection::compoundOfVertices( const int index ) const
509 {
510   GEOM::GEOM_Object_var obj = getObject( index );
511   return isCompoundOfVertices( obj );
512 }
513
514 bool GEOMGUI_Selection::isComponent( const int index ) const
515 {
516   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
517
518   if ( appStudy ) {
519     QString anEntry = entry( index );
520     _PTR(Study) study = appStudy->studyDS();
521     if ( study && !anEntry.isNull() ) {
522       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
523       if ( aSO && aSO->GetFatherComponent() )
524         return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
525     }
526   }
527   return false;
528 }
529
530 GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const
531 {
532   GEOM::GEOM_Object_var o;
533   if ( 0 <= index && index < myObjects.size() )
534     o = GEOM::GEOM_Object::_duplicate( myObjects[index] );
535   return o._retn();
536 }
537
538 QString GEOMGUI_Selection::selectionMode() const
539 {
540   SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study()->application() );
541   if ( app ) {
542     GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
543     if ( aGeomGUI ) {
544       switch ( aGeomGUI->getLocalSelectionMode() )
545       {
546         case GEOM_POINT      : return "VERTEX";
547         case GEOM_EDGE       : return "EDGE";
548         case GEOM_WIRE       : return "WIRE";
549         case GEOM_FACE       : return "FACE";
550         case GEOM_SHELL      : return "SHELL";
551         case GEOM_SOLID      : return "SOLID";
552         case GEOM_COMPOUND   : return "COMPOUND";
553         case GEOM_ALLOBJECTS : return "ALL";
554         default: return "";
555       }
556     }
557   }
558   return "";
559 }
560
561 bool GEOMGUI_Selection::topLevel( const int index ) const
562 {
563 #ifdef USE_VISUAL_PROP_MAP
564   QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::TopLevel ) );
565   if ( v.canConvert<bool>() )
566     return v.toBool();
567 #endif
568
569   bool res = false;
570
571   SALOME_View* view = GEOM_Displayer::GetActiveView();
572   QString viewType = activeViewType();
573   if ( view && viewType == OCCViewer_Viewer::Type() ) {
574     SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
575     if ( prs ) {
576       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
577         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
578         AIS_ListOfInteractive lst;
579         occPrs->GetObjects( lst );
580         if ( lst.Extent() ) {
581           Handle(AIS_InteractiveObject) io = lst.First();
582           if ( !io.IsNull() ) {
583             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
584             if ( !aSh.IsNull() )
585               res = (bool)aSh->isTopLevel();
586           }
587         }
588       }
589     }
590   }
591   return res;
592 }
593
594 bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
595 {
596 #ifdef USE_VISUAL_PROP_MAP
597   QVariant v = visibleProperty( entry( idx ), GEOM::propertyName( GEOM::Material ) );
598   if ( v.canConvert<QString>() ) {
599     Material_Model material;
600     material.fromProperties( v.toString() );
601     return material.isPhysical();
602   }
603 #endif
604
605   bool res = false;
606   
607   SALOME_View* view = GEOM_Displayer::GetActiveView();
608   QString viewType = activeViewType();
609   if ( view ) {
610     SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() );
611     if ( prs ) {
612       if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
613         SOCC_Prs* occPrs = (SOCC_Prs*) prs;
614         AIS_ListOfInteractive lst;
615         occPrs->GetObjects( lst );
616         if ( lst.Extent() ) {
617           Handle(AIS_InteractiveObject) io = lst.First();
618           if ( !io.IsNull() ) {
619             Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
620             if ( !aSh.IsNull() )
621               res = (bool) aSh->Attributes()->ShadingAspect()->
622                 Material(Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC );
623           }
624         }
625       }
626       else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
627         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
628         vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
629         if ( lst ) {
630           lst->InitTraversal();
631           vtkActor* actor = lst->GetNextActor();
632           if ( actor ) {
633             GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
634             if ( aGeomGActor ) {
635               GEOM_VTKPropertyMaterial* mat  = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
636               res = mat->GetPhysical();
637             } // if ( salome actor )
638           } // if ( actor )
639         } // if ( lst == vtkPrs->GetObjects() )
640       }
641     }
642   }
643
644   return res;
645 }
646
647 bool GEOMGUI_Selection::isFolder( const int index ) const
648 {
649   bool res = false;
650   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
651
652   if ( appStudy ) {
653     QString anEntry = entry( index );
654     _PTR(Study) study = appStudy->studyDS();
655     if ( study && !anEntry.isNull() ) {
656       _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
657       if ( aSO ) res = isFolder( aSO );
658     }
659   }
660   return res;
661 }
662