X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGEOMGUI_Selection.cxx;h=014c622c29797de5d7d80fc036c37bd0e0f9abd2;hb=b7989b4db56e9ddd30a8496d112f9a49163175e0;hp=c7b82dfd07e259e4152c1f0f23baf4f4b03daca2;hpb=6c2ee27d457fe387b43fc9a13739adf0e7282cce;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index c7b82dfd0..014c622c2 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -24,6 +24,7 @@ // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com) #include "GEOMGUI_Selection.h" +#include #include "GeometryGUI.h" #include "GEOM_Displayer.h" @@ -84,18 +85,30 @@ else \ str = QString(); } -#define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \ - if ( dm == 0 ) \ - str = QString( "Wireframe" ); \ - else if ( dm == 1 ) \ - str = QString( "Shading" ); \ - else if ( dm == 3 ) \ - str = QString( "ShadingWithEdges" ); \ - else \ - str = QString(); } - #define USE_VISUAL_PROP_MAP +#ifdef USE_VISUAL_PROP_MAP + #define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \ + if ( dm == 0 ) \ + str = QString( "Wireframe" ); \ + else if ( dm == 1 ) \ + str = QString( "Shading" ); \ + else if ( dm == 2 ) \ + str = QString( "ShadingWithEdges" ); \ + else \ + str = QString(); } +#else + #define VTK_DISPLAY_MODE_TO_STRING( str, dm ) { \ + if ( dm == 0 ) \ + str = QString( "Wireframe" ); \ + else if ( dm == 1 ) \ + str = QString( "Shading" ); \ + else if ( dm == 3 ) \ + str = QString( "ShadingWithEdges" ); \ + else \ + str = QString(); } +#endif + GEOMGUI_Selection::GEOMGUI_Selection() : LightApp_Selection() { @@ -158,6 +171,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const v = isAutoColor( idx ); else if ( p == "isVectorsMode" ) v = isVectorsMode( idx ); + else if ( p == "isVerticesMode" ) + v = isVerticesMode( idx ); else if ( p == "topLevel" ) v = topLevel( idx ); else if ( p == "autoBringToFront" ) @@ -178,6 +193,10 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const v = isPhysicalMaterial(idx); else if ( p == "isFolder" ) v = isFolder(idx); + else if ( p == "hasHiddenDimensions" ) + v = hasHiddenDimensions(idx); + else if ( p == "hasVisibleDimensions" ) + v = hasVisibleDimensions(idx); else v = LightApp_Selection::parameter( idx, p ); @@ -361,7 +380,7 @@ QString GEOMGUI_Selection::displayMode( const int index ) const bool GEOMGUI_Selection::autoBringToFront( const int /*index*/ ) const { - return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front" ); + return SUIT_Session::session()->resourceMgr()->booleanValue( "Geometry", "auto_bring_to_front", "false" ); } bool GEOMGUI_Selection::isVectorsMode( const int index ) const @@ -411,10 +430,59 @@ bool GEOMGUI_Selection::isVectorsMode( const int index ) const return res; } +bool GEOMGUI_Selection::isVerticesMode( const int index ) const +{ +#ifdef USE_VISUAL_PROP_MAP + QVariant v = visibleProperty( entry( index ), GEOM::propertyName( GEOM::Vertices ) ); + if ( v.canConvert( QVariant::Bool ) ) + return v.toBool(); +#endif + + bool res = false; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + QString viewType = activeViewType(); + if ( view && ( viewType == OCCViewer_Viewer::Type() || viewType == SVTK_Viewer::Type() ) ) { + SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1().constData() ); + if ( prs ) { + if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC + SOCC_Prs* occPrs = (SOCC_Prs*) prs; + AIS_ListOfInteractive lst; + occPrs->GetObjects( lst ); + if ( lst.Extent() ) { + Handle(AIS_InteractiveObject) io = lst.First(); + if ( !io.IsNull() ) { + Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io); + if ( !aSh.IsNull() ) + res = aSh->isShowVertices(); + } + } + } + else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK + SVTK_Prs* vtkPrs = dynamic_cast( prs ); + vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; + if ( lst ) { + lst->InitTraversal(); + vtkActor* actor = lst->GetNextActor(); + if ( actor ) { + GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(actor); + if ( aGeomActor ) + res = aGeomActor->GetVerticesMode(); + } + } + } + } + } + + return res; +} + bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj ) { - // as soon as Use Case browser data tree was added - return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ); + if ( obj ) { + // as soon as Use Case browser data tree was added + return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ); + } } bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj ) @@ -443,7 +511,7 @@ bool GEOMGUI_Selection::isFolder( const _PTR(SObject)& obj ) { bool ret = false; _PTR(GenericAttribute) anAttr; - if ( obj->FindAttribute(anAttr, "AttributeLocalID") ) { + if ( obj && obj->FindAttribute(anAttr, "AttributeLocalID") ) { _PTR(AttributeLocalID) aLocalID( anAttr ); ret = aLocalID->Value() == 999; } @@ -476,7 +544,7 @@ int GEOMGUI_Selection::nbChildren( const int index ) const _PTR(Study) study = appStudy->studyDS(); if ( study && !anEntry.isEmpty() ) { _PTR(SObject) aSO( study->FindObjectID( anEntry.toStdString() ) ); - if ( aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) { + if ( aSO && aSO->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode(aSO) ) { _PTR(UseCaseIterator) it = aSO->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( aSO ); for (it->Init(false); it->More(); it->Next()) nb++; } @@ -653,7 +721,8 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor ); if ( aGeomGActor ) { GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty()); - res = mat->GetPhysical(); + if ( mat ) + res = mat->GetPhysical(); } // if ( salome actor ) } // if ( actor ) } // if ( lst == vtkPrs->GetObjects() ) @@ -680,3 +749,59 @@ bool GEOMGUI_Selection::isFolder( const int index ) const return res; } +bool GEOMGUI_Selection::hasDimensions( const int theIndex, bool& theHidden, bool& theVisible ) const +{ + SalomeApp_Study* appStudy = dynamic_cast( study() ); + + if ( !appStudy ) + { + return false; + } + + QString anEntry = entry( theIndex ); + _PTR(Study) aStudy = appStudy->studyDS(); + if ( !aStudy || anEntry.isNull() ) + { + return false; + } + + GEOMGUI_DimensionProperty aDimensions( appStudy, anEntry.toStdString() ); + + theHidden = false; + theVisible = false; + + for ( int it = 0; it < aDimensions.GetNumber(); ++it ) + { + if ( aDimensions.IsVisible( it ) ) + theVisible = true; + else + theHidden = true; + } + + return aDimensions.GetNumber() > 0; +} + +bool GEOMGUI_Selection::hasHiddenDimensions( const int theIndex ) const +{ + bool isAnyVisible = false; + bool isAnyHidden = false; + if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) ) + { + return false; + } + + return isAnyHidden; +} + +bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const +{ + bool isAnyVisible = false; + bool isAnyHidden = false; + if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) ) + { + return false; + } + + return isAnyVisible; +} +