1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : GEOMGUI_Selection.cxx
24 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
26 #include "GEOMGUI_Selection.h"
27 #include <GEOMGUI_DimensionProperty.h>
29 #include "GeometryGUI.h"
30 #include "GEOM_Displayer.h"
32 #include "Material_Model.h"
34 #include <GEOM_Constants.h>
36 #include <SalomeApp_Application.h>
37 #include <SalomeApp_Study.h>
39 #include "LightApp_DataOwner.h"
41 #include <SUIT_Session.h>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_ViewWindow.h>
44 #include <SUIT_ViewManager.h>
45 #include <SUIT_ResourceMgr.h>
47 #include <SALOME_Prs.h>
48 #include <SALOME_InteractiveObject.hxx>
52 #include <SALOME_Actor.h>
53 #include <GEOM_Actor.h>
55 #include <OCCViewer_ViewModel.h>
56 #include <SVTK_ViewModel.h>
58 #include <GEOMImpl_Types.hxx>
60 #include <GEOM_AISShape.hxx>
61 #include <GEOM_VTKPropertyMaterial.hxx>
65 #include <AIS_InteractiveObject.hxx>
66 #include <AIS_ListOfInteractive.hxx>
67 #include <AIS_GraphicTool.hxx>
68 #include <Aspect_TypeOfFacingModel.hxx>
69 #include <Prs3d_ShadingAspect.hxx>
70 #include<Graphic3d_MaterialAspect.hxx>
73 #include <vtkActorCollection.h>
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" ); \
87 #define USE_VISUAL_PROP_MAP
89 #ifdef USE_VISUAL_PROP_MAP
90 #define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \
92 str = QString( "Wireframe" ); \
94 str = QString( "Shading" ); \
96 str = QString( "ShadingWithEdges" ); \
100 #define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \
102 str = QString( "Wireframe" ); \
103 else if ( dm == 1 ) \
104 str = QString( "Shading" ); \
105 else if ( dm == 3 ) \
106 str = QString( "ShadingWithEdges" ); \
111 GEOMGUI_Selection::GEOMGUI_Selection()
112 : LightApp_Selection()
116 GEOMGUI_Selection::~GEOMGUI_Selection()
120 void GEOMGUI_Selection::init( const QString& context, LightApp_SelectionMgr* selMgr )
122 LightApp_Selection::init( context, selMgr );
124 myObjects.resize( count() );
126 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
128 _PTR(Study) study = appStudy->studyDS();
129 for ( int idx = 0; idx < count(); idx++ ) {
130 QString anEntry = entry( idx );
131 if ( study && !anEntry.isEmpty() ) {
132 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
134 CORBA::Object_var varObj = GeometryGUI::ClientSObjectToObject( aSO );
135 myObjects[idx] = GEOM::GEOM_BaseObject::_narrow( varObj );
142 //QVariant GEOMGUI_Selection::contextParameter( const QString& p ) const
143 QVariant GEOMGUI_Selection::parameter( const QString& p ) const
147 v = activeViewType() == OCCViewer_Viewer::Type();
148 else if ( p == "selectionmode" )
150 else if ( p == "hasImported" )
152 else if ( p == "allImported" )
155 v = LightApp_Selection::parameter( p );
159 //QVariant GEOMGUI_Selection::objectParameter( const int idx, const QString& p ) const
160 QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
165 else if ( p == "typeid" )
167 else if ( p == "displaymode" )
168 v = displayMode( idx );
169 else if ( p == "isAutoColor" )
170 v = isAutoColor( idx );
171 else if ( p == "isVectorsMode" )
172 v = isVectorsMode( idx );
173 else if ( p == "isVerticesMode" )
174 v = isVerticesMode( idx );
175 else if ( p == "isNameMode" )
176 v = isNameMode( idx );
177 else if ( p == "topLevel" )
179 else if ( p == "autoBringToFront" )
180 v = autoBringToFront( idx );
181 else if ( p == "hasChildren" )
182 v = hasChildren( idx );
183 else if ( p == "nbChildren" )
185 else if ( p == "hasConcealedChildren" )
186 v = hasConcealedChildren( idx );
187 else if ( p == "hasDisclosedChildren" )
188 v = hasDisclosedChildren( idx );
189 else if ( p == "compoundOfVertices" )
190 v = compoundOfVertices( idx );
191 else if ( p == "imported" )
192 v = isImported( idx );
193 else if ( p == "isPhysicalMaterial" )
194 v = isPhysicalMaterial(idx);
195 else if ( p == "isFolder" )
197 else if ( p == "hasHiddenDimensions" )
198 v = hasHiddenDimensions(idx);
199 else if ( p == "hasVisibleDimensions" )
200 v = hasVisibleDimensions(idx);
202 v = LightApp_Selection::parameter( idx, p );
207 // the method to skip temporary objects from selection (called from LightApp)
208 bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
210 return !theOwner->entry().contains("_");
213 QString GEOMGUI_Selection::typeName( const int index ) const
215 if ( isComponent( index ) )
217 if ( isFolder( index ) )
220 static QString aGroup( "Group" );
221 static QString aShape( "Shape" );
222 static QString aField( "Field" );
223 static QString aFieldStep( "FieldStep" );
224 static QString anUnknown( "Unknown" );
226 GEOM::GEOM_BaseObject_var anObj = getBaseObject( index );
227 if ( !CORBA::is_nil( anObj ) ) {
228 const int aGeomType = anObj->GetType();
229 switch ( aGeomType ) {
230 case GEOM_GROUP : return aGroup;
231 case GEOM_FIELD : return aField;
232 case GEOM_FIELD_STEP: return aFieldStep;
233 default : return aShape;
239 int GEOMGUI_Selection::typeId( const int index ) const
242 GEOM::GEOM_Object_var anObj = getObject( index );
243 if ( !CORBA::is_nil( anObj ) )
244 aType = (int)anObj->GetShapeType();
248 bool GEOMGUI_Selection::isVisible( const int index ) const
250 #ifdef USE_VISUAL_PROP_MAP
251 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Visibility ) );
252 if ( v.canConvert( QVariant::Bool ) )
258 GEOM::GEOM_Object_var obj = getObject( index );
259 SALOME_View* view = GEOM_Displayer::GetActiveView();
260 if ( !CORBA::is_nil( obj ) && view ) {
261 Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( entry( index ).toLatin1().constData(), "GEOM", "TEMP_IO" );
262 res = view->isVisible( io );
268 bool GEOMGUI_Selection::isAutoColor( const int index ) const
270 GEOM::GEOM_Object_var obj = getObject( index );
271 if ( !CORBA::is_nil( obj ) )
272 return obj->GetAutoColor();
276 bool GEOMGUI_Selection::isImported( const int index ) const
278 GEOM::GEOM_Object_var obj = getObject( index );
279 if ( !CORBA::is_nil( obj ) )
280 return obj->GetType() == GEOM_IMPORT;
284 bool GEOMGUI_Selection::hasImported() const
287 for ( int i = 0; i < count() && !res; i++ )
288 res = isImported( i );
292 bool GEOMGUI_Selection::allImported() const
295 for ( int i = 0; i < count() && res; i++ )
296 res = isImported( i );
300 QVariant GEOMGUI_Selection::visibleProperty( const QString& entry, const QString& propName ) const
303 LightApp_Study* aStudy = study();
305 LightApp_Application* anApp = ::qobject_cast<LightApp_Application*>( aStudy->application() );
306 if ( anApp && anApp->activeViewManager() ) {
307 int id = anApp->activeViewManager()->getGlobalId();
308 v = aStudy->getObjectProperty( id, entry, propName, QVariant() );
314 QString GEOMGUI_Selection::displayMode( const int index ) const
317 QString viewType = activeViewType();
319 #ifdef USE_VISUAL_PROP_MAP
320 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::DisplayMode ) );
321 if ( v.canConvert( QVariant::Int ) ) {
323 if ( viewType == OCCViewer_Viewer::Type() ) {
324 OCC_DISPLAY_MODE_TO_STRING( res, dm );
325 } else if ( viewType == SVTK_Viewer::Type() ) {
326 VTK_DISPLAY_MODE_TO_STRING( res, dm );
332 SALOME_View* view = GEOM_Displayer::GetActiveView();
333 if ( view /*fix for 9320==>*/&& ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
334 SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
336 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
337 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
338 AIS_ListOfInteractive lst;
339 occPrs->GetObjects( lst );
340 if ( lst.Extent() ) {
341 Handle(AIS_InteractiveObject) io = lst.First();
342 if ( !io.IsNull() ) {
344 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
346 dm = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
348 dm = io->DisplayMode();
350 OCC_DISPLAY_MODE_TO_STRING( res, dm );
351 if ( res.isEmpty() ) { // return default display mode of AIS_InteractiveContext
352 OCCViewer_Viewer* occViewer = (OCCViewer_Viewer*)SUIT_Session::session()->activeApplication()->
353 desktop()->activeWindow()->getViewManager()->getViewModel();
354 Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
355 dm = ic->DisplayMode();
356 OCC_DISPLAY_MODE_TO_STRING( res, dm );
361 else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
362 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
363 vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
365 lst->InitTraversal();
366 vtkActor* actor = lst->GetNextActor();
368 SALOME_Actor* salActor = dynamic_cast<SALOME_Actor*>( actor );
370 int dm = salActor->getDisplayMode();
371 VTK_DISPLAY_MODE_TO_STRING( res, dm );
372 } // if ( salome actor )
374 } // if ( lst == vtkPrs->GetObjects() )
382 bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const
384 return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" );
387 bool GEOMGUI_Selection::isVectorsMode( const int index ) const
389 #ifdef USE_VISUAL_PROP_MAP
390 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::EdgesDirection ) );
391 if ( v.canConvert( QVariant::Bool ) )
397 SALOME_View* view = GEOM_Displayer::GetActiveView();
398 QString viewType = activeViewType();
399 if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
400 SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
402 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
403 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
404 AIS_ListOfInteractive lst;
405 occPrs->GetObjects( lst );
406 if ( lst.Extent() ) {
407 Handle(AIS_InteractiveObject) io = lst.First();
408 if ( !io.IsNull() ) {
409 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
411 res = aSh->isShowVectors();
415 else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
416 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
417 vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
419 lst->InitTraversal();
420 vtkActor* actor = lst->GetNextActor();
422 GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
424 res = aGeomActor->GetVectorMode();
434 bool GEOMGUI_Selection::isVerticesMode( const int index ) const
436 #ifdef USE_VISUAL_PROP_MAP
437 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Vertices ) );
438 if ( v.canConvert( QVariant::Bool ) )
444 SALOME_View* view = GEOM_Displayer::GetActiveView();
445 QString viewType = activeViewType();
446 if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
447 SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
449 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
450 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
451 AIS_ListOfInteractive lst;
452 occPrs->GetObjects( lst );
453 if ( lst.Extent() ) {
454 Handle(AIS_InteractiveObject) io = lst.First();
455 if ( !io.IsNull() ) {
456 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
458 res = aSh->isShowVertices();
462 else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
463 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
464 vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
466 lst->InitTraversal();
467 vtkActor* actor = lst->GetNextActor();
469 GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
471 res = aGeomActor->GetVerticesMode();
481 bool GEOMGUI_Selection::isNameMode( const int index ) const
483 #ifdef USE_VISUAL_PROP_MAP
484 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::ShowName ) );
485 if ( v.canConvert( QVariant::Bool ) )
491 SALOME_View* view = GEOM_Displayer::GetActiveView();
492 QString viewType = activeViewType();
493 if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) {
494 SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
496 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
497 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
498 AIS_ListOfInteractive lst;
499 occPrs->GetObjects( lst );
500 if ( lst.Extent() ) {
501 Handle(AIS_InteractiveObject) io = lst.First();
502 if ( !io.IsNull() ) {
503 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
505 res = aSh->isShowName();
509 else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
510 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
511 vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
513 lst->InitTraversal();
514 vtkActor* actor = lst->GetNextActor();
516 GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor);
518 res = aGeomActor->GetNameMode();
528 bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
531 // as soon as Use Case browser data tree was added
532 return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
536 bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
539 _PTR(GenericAttribute) anAttr;
540 if ( obj && obj->FindAttribute( anAttr, "AttributeExpandable" ) ) {
541 _PTR(AttributeExpandable) aAttrExp = anAttr;
542 exp = aAttrExp->IsExpandable();
547 bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj )
551 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>
552 (SUIT_Session::session()->activeApplication()->activeStudy());*/
553 if ( /*appStudy && */!CORBA::is_nil( obj ) )
554 ret = obj->GetShapeType() == GEOM::COMPOUND && obj->GetMaxShapeType() == GEOM::VERTEX;
558 bool GEOMGUI_Selection::isFolder( const _PTR(SObject)& obj )
561 _PTR(GenericAttribute) anAttr;
562 if ( obj && obj->FindAttribute(anAttr, "AttributeLocalID") ) {
563 _PTR(AttributeLocalID) aLocalID( anAttr );
564 ret = aLocalID->Value() == 999;
569 bool GEOMGUI_Selection::hasChildren( const int index ) const
572 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
575 QString anEntry = entry( index );
576 _PTR(Study) study = appStudy->studyDS();
577 if ( study && !anEntry.isEmpty() ) {
578 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
579 ok = hasChildren( aSO );
585 int GEOMGUI_Selection::nbChildren( const int index ) const
588 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
591 QString anEntry = entry( index );
592 _PTR(Study) study = appStudy->studyDS();
593 if ( study && !anEntry.isEmpty() ) {
594 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
595 if ( aSO && aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) {
596 _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO );
597 for (it->Init(false); it->More(); it->Next()) nb++;
604 bool GEOMGUI_Selection::hasConcealedChildren( const int index ) const
607 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
610 QString anEntry = entry( index );
611 _PTR(Study) study = appStudy->studyDS();
612 if ( study && !anEntry.isEmpty() ) {
613 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
614 OK = !expandable( aSO ) && hasChildren( aSO );
620 bool GEOMGUI_Selection::hasDisclosedChildren( const int index ) const
623 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
626 QString anEntry = entry( index );
627 _PTR(Study) study = appStudy->studyDS();
628 if ( study && !anEntry.isEmpty() ) {
629 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
630 OK = expandable( aSO ) && hasChildren( aSO );
636 bool GEOMGUI_Selection::compoundOfVertices( const int index ) const
638 GEOM::GEOM_Object_var obj = getObject( index );
639 return isCompoundOfVertices( obj );
642 bool GEOMGUI_Selection::isComponent( const int index ) const
644 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
647 QString anEntry = entry( index );
648 _PTR(Study) study = appStudy->studyDS();
649 if ( study && !anEntry.isNull() ) {
650 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
651 if ( aSO && aSO->GetFatherComponent() )
652 return aSO->GetFatherComponent()->GetIOR() == aSO->GetIOR();
658 GEOM::GEOM_Object_ptr GEOMGUI_Selection::getObject( const int index ) const
660 GEOM::GEOM_Object_var o;
661 if ( 0 <= index && index < myObjects.size() )
662 o = GEOM::GEOM_Object::_narrow( myObjects[index] );
666 GEOM::GEOM_BaseObject_ptr GEOMGUI_Selection::getBaseObject( const int index ) const
668 GEOM::GEOM_BaseObject_var o;
669 if ( 0 <= index && index < myObjects.size() )
670 o = GEOM::GEOM_BaseObject::_duplicate( myObjects[index] );
674 QString GEOMGUI_Selection::selectionMode() const
676 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( study()->application() );
678 GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
680 switch ( aGeomGUI->getLocalSelectionMode() )
682 case GEOM_POINT : return "VERTEX";
683 case GEOM_EDGE : return "EDGE";
684 case GEOM_WIRE : return "WIRE";
685 case GEOM_FACE : return "FACE";
686 case GEOM_SHELL : return "SHELL";
687 case GEOM_SOLID : return "SOLID";
688 case GEOM_COMPOUND : return "COMPOUND";
689 case GEOM_ALLOBJECTS : return "ALL";
697 bool GEOMGUI_Selection::topLevel( const int index ) const
699 #ifdef USE_VISUAL_PROP_MAP
700 QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::TopLevel ) );
701 if ( v.canConvert<bool>() )
707 SALOME_View* view = GEOM_Displayer::GetActiveView();
708 QString viewType = activeViewType();
709 if ( view && viewType == OCCViewer_Viewer::Type() ) {
710 SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() );
712 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
713 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
714 AIS_ListOfInteractive lst;
715 occPrs->GetObjects( lst );
716 if ( lst.Extent() ) {
717 Handle(AIS_InteractiveObject) io = lst.First();
718 if ( !io.IsNull() ) {
719 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
721 res = (bool)aSh->isTopLevel();
730 bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
732 #ifdef USE_VISUAL_PROP_MAP
733 QVariant v = visibleProperty( entry( idx ), GEOM::propertyName( GEOM::Material ) );
734 if ( v.canConvert<QString>() ) {
735 Material_Model material;
736 material.fromProperties( v.toString() );
737 return material.isPhysical();
743 SALOME_View* view = GEOM_Displayer::GetActiveView();
744 QString viewType = activeViewType();
746 SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() );
748 if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
749 SOCC_Prs* occPrs = (SOCC_Prs*) prs;
750 AIS_ListOfInteractive lst;
751 occPrs->GetObjects( lst );
752 if ( lst.Extent() ) {
753 Handle(AIS_InteractiveObject) io = lst.First();
754 if ( !io.IsNull() ) {
755 Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
757 res = (bool) aSh->Attributes()->ShadingAspect()->
758 Material(Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC );
762 else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
763 SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
764 vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
766 lst->InitTraversal();
767 vtkActor* actor = lst->GetNextActor();
769 GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
771 GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
773 res = mat->GetPhysical();
774 } // if ( salome actor )
776 } // if ( lst == vtkPrs->GetObjects() )
784 bool GEOMGUI_Selection::isFolder( const int index ) const
787 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
790 QString anEntry = entry( index );
791 _PTR(Study) study = appStudy->studyDS();
792 if ( study && !anEntry.isNull() ) {
793 _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) );
794 if ( aSO ) res = isFolder( aSO );
800 bool GEOMGUI_Selection::hasDimensions( const int theIndex, bool& theHidden, bool& theVisible ) const
802 SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
809 QString anEntry = entry( theIndex );
810 _PTR(Study) aStudy = appStudy->studyDS();
811 if ( !aStudy || anEntry.isNull() )
816 GEOMGUI_DimensionProperty aDimensions( appStudy, anEntry.toStdString() );
821 for ( int it = 0; it < aDimensions.GetNumber(); ++it )
823 if ( aDimensions.IsVisible( it ) )
829 return aDimensions.GetNumber() > 0;
832 bool GEOMGUI_Selection::hasHiddenDimensions( const int theIndex ) const
834 bool isAnyVisible = false;
835 bool isAnyHidden = false;
836 if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) )
844 bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const
846 bool isAnyVisible = false;
847 bool isAnyHidden = false;
848 if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) )