From b0efdab52f468255e12a2add406e78fc5cd07f9f Mon Sep 17 00:00:00 2001 From: rnv Date: Tue, 13 Mar 2012 08:36:26 +0000 Subject: [PATCH] Implementation of the "0021239: EDF 1829 OCC: Bring to front selected objects" issue. --- src/OBJECT/SALOME_AISShape.hxx | 4 +++- src/OCCViewer/OCCViewer_ViewModel.cxx | 13 +++++++++++++ src/OCCViewer/OCCViewer_ViewModel.h | 6 +++++- src/SOCC/SOCC_ViewModel.cxx | 9 ++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/OBJECT/SALOME_AISShape.hxx b/src/OBJECT/SALOME_AISShape.hxx index cdc8afe2a..bcaf862bd 100755 --- a/src/OBJECT/SALOME_AISShape.hxx +++ b/src/OBJECT/SALOME_AISShape.hxx @@ -80,6 +80,8 @@ public: Standard_EXPORT SALOME_AISShape(const TopoDS_Shape& shape); Standard_EXPORT virtual Handle_SALOME_InteractiveObject getIO() = 0; Standard_EXPORT virtual Standard_Boolean hasIO() = 0; +Standard_EXPORT virtual Standard_Boolean isTopLevel() = 0; +Standard_EXPORT virtual void setTopLevel(Standard_Boolean) = 0; Standard_EXPORT virtual Standard_CString getName() = 0; Standard_EXPORT virtual void setName(const Standard_CString aName) = 0; Standard_EXPORT virtual void highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, const Standard_Boolean aHighlight ) = 0; @@ -111,7 +113,7 @@ private: // Fields PRIVATE // - + }; diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 9196394dc..8bd978269 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -61,6 +61,8 @@ #include +#include + /*! Get data for supported background modes: gradient types, identifiers and supported image formats */ @@ -85,6 +87,7 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron) : SUIT_ViewModel(), myBackgrounds(4, Qtx::BackgroundData( Qt::black )), myIsRelative(true), + myTopLayerId( 0 ), myTrihedronSize(100) { // init CasCade viewers @@ -359,6 +362,16 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven emit selectionChanged(); } +int OCCViewer_Viewer::getTopLayerId() +{ +#if OCC_VERSION_LARGE > 0x06050200 + if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() ) + myAISContext->CurrentViewer()->AddZLayer( myTopLayerId ); +#endif + + return myTopLayerId; +} + /*! \return interaction style */ diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index bda8ce782..b55e9d77f 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -121,6 +121,8 @@ public: Handle(AIS_InteractiveContext) getAISContext() const { return myAISContext; } Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; } + int getTopLayerId(); + int interactionStyle() const; void setInteractionStyle( const int ); @@ -170,7 +172,7 @@ protected: Handle(V3d_Viewer) myV3dCollector; Handle(AIS_Trihedron) myTrihedron; - Handle(AIS_InteractiveContext) myAISContext; + Handle(AIS_InteractiveContext) myAISContext; int myInteractionStyle; int myZoomingStyle; @@ -179,6 +181,8 @@ protected: bool myMultiSelectionEnabled; bool myIsRelative; + int myTopLayerId; + //QColor myBgColor; QPoint myStartPnt, myEndPnt; diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index aa23946ac..630e919de 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -57,6 +57,7 @@ //#include "SALOMEDSClient.hxx" //#include "SALOMEDS_StudyManager.hxx" +#include #include #include @@ -390,7 +391,13 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) } ic->Display( anAIS, false ); - + +#if OCC_VERSION_LARGE > 0x06050200 + Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(anAIS); + if ( !aSh.IsNull() ) { + ic->SetZLayer( aSh, aSh->isTopLevel() ? getTopLayerId() : 0 ); + } +#endif //Register anAIS (if it has an entry) in entry2aisobjects map Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); if ( !anObj.IsNull() && anObj->hasEntry()) -- 2.39.2