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