From 09d10e66ba0fac5353c8d1f138055fc6fe86fb65 Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 8 Apr 2014 04:43:42 +0000 Subject: [PATCH] another z layer for hilight presentation --- src/HYDROGUI/CMakeLists.txt | 3 + src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx | 5 ++ src/HYDROGUI/HYDROGUI_ZLayers.cxx | 107 +++++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_ZLayers.h | 55 +++++++++++++ src/HYDROGUI/HYDROGUI_ZLayers2.cxx | 48 +++++++++++ 5 files changed, 218 insertions(+) create mode 100644 src/HYDROGUI/HYDROGUI_ZLayers.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ZLayers.h create mode 100644 src/HYDROGUI/HYDROGUI_ZLayers2.cxx diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index f31a04a8..79549b29 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -91,6 +91,7 @@ set(PROJECT_HEADERS HYDROGUI_ZLevelsOp.h HYDROGUI_OrderedListWidget.h HYDROGUI_ListSelector.h + HYDROGUI_ZLayers.h ) QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -183,6 +184,8 @@ set(PROJECT_SOURCES HYDROGUI_ZLevelsOp.cxx HYDROGUI_OrderedListWidget.cxx HYDROGUI_ListSelector.cxx + HYDROGUI_ZLayers.cxx + HYDROGUI_ZLayers2.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index 719b6e46..8fed86b5 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -28,6 +28,7 @@ #include "HYDROGUI_Shape.h" #include "HYDROGUI_Operation.h" #include "HYDROGUI_DataObject.h" +#include "HYDROGUI_ZLayers.h" #include #include @@ -248,6 +249,10 @@ void HYDROGUI_OCCDisplayer::Display( const HYDROData_SequenceOfObjects& theObjs, aHOp->updatePreviewZLayer( aLayerId ); } + HYDROGUI_ZLayersIterator anIt( aViewer->getViewer3d() ); + int aMaxLayer = anIt.MaxLayer(); + UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, aMaxLayer ); + if ( theDoFitAll ) { OCCViewer_ViewManager* aViewManager diff --git a/src/HYDROGUI/HYDROGUI_ZLayers.cxx b/src/HYDROGUI/HYDROGUI_ZLayers.cxx new file mode 100644 index 00000000..2e9fad62 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZLayers.cxx @@ -0,0 +1,107 @@ +// Copyright (C) 2007-2013 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 +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include + +class PrsMgr_PresentationManager +{ +public: + static void SetZLayer( const Handle_PrsMgr_PresentableObject& thePresentableObject, + const Standard_Integer theMode, + const Standard_Integer theLayerId ) + { + PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations(); + for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++) + { + Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation (); + if ( aPresentations (aIdx).Mode() == theMode ) + aPrs->SetZLayer (theLayerId); + } + } +}; + +void SetPrsZLayer( const Handle_PrsMgr_PresentableObject& thePresentableObject, + const int theMode, const int theLayerId ) +{ + PrsMgr_PresentationManager::SetZLayer( thePresentableObject, theMode, theLayerId ); +} + +HYDROGUI_ZLayersIterator::HYDROGUI_ZLayersIterator( const Handle_V3d_Viewer& theViewer ) + : myIndex( 0 ), myNewZLayer( -1 ), myViewer( theViewer ) +{ + Init( theViewer ); +} + +HYDROGUI_ZLayersIterator::~HYDROGUI_ZLayersIterator() +{ +} + +void HYDROGUI_ZLayersIterator::Init( const Handle_V3d_Viewer& theViewer ) +{ + TColStd_SequenceOfInteger anExistingZLayers; + theViewer->GetAllZLayers( anExistingZLayers ); + + int n = anExistingZLayers.Length(); + myZLayers.resize( n ); + for( int i=1; i<=n; i++ ) + myZLayers[i-1] = anExistingZLayers( i ); + + myIndex = 0; +} + +bool HYDROGUI_ZLayersIterator::More() const +{ + return myIndex <= (int)myZLayers.size() || myNewZLayer >= 0; +} + +void HYDROGUI_ZLayersIterator::Next() +{ + if( myIndex < (int)myZLayers.size() ) + myIndex++; + else if( !myViewer.IsNull() ) + { + bool isOK = myViewer->AddZLayer( myNewZLayer )==Standard_True; + if( !isOK ) + myNewZLayer = -1; + } +} + +int HYDROGUI_ZLayersIterator::MaxLayer() const +{ + int aMaxLayer = -1; + for( int i=0, n=myZLayers.size(); i aMaxLayer ) + aMaxLayer = myZLayers[i]; + return aMaxLayer; +} + + +int HYDROGUI_ZLayersIterator::LayerId() const +{ + if( More() ) + return myZLayers[myIndex]; + else + return myNewZLayer; +} diff --git a/src/HYDROGUI/HYDROGUI_ZLayers.h b/src/HYDROGUI/HYDROGUI_ZLayers.h new file mode 100644 index 00000000..c8b6cbf1 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZLayers.h @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2013 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 +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_ZLAYERS_H +#define HYDROGUI_ZLAYERS_H + +#include +#include + +class Handle_PrsMgr_PresentableObject; +class Handle_AIS_InteractiveContext; + +class HYDROGUI_ZLayersIterator +{ +public: + HYDROGUI_ZLayersIterator( const Handle_V3d_Viewer& ); + ~HYDROGUI_ZLayersIterator(); + + void Init( const Handle_V3d_Viewer& ); + bool More() const; + void Next(); + int LayerId() const; + int MaxLayer() const; + +private: + std::vector myZLayers; + int myIndex; + int myNewZLayer; + Handle_V3d_Viewer myViewer; +}; + +void SetPrsZLayer( const Handle_PrsMgr_PresentableObject& thePresentableObject, + const int theMode, const int theLayerId ); +void UpdateZLayersOfHilightPresentationsOfDisplayedObjects( const Handle_AIS_InteractiveContext&, int theLayer ); + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ZLayers2.cxx b/src/HYDROGUI/HYDROGUI_ZLayers2.cxx new file mode 100644 index 00000000..0115def5 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZLayers2.cxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2013 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 +// +// 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. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include +#include +#include + +void UpdateZLayersOfHilightPresentationsOfDisplayedObjects( const Handle_AIS_InteractiveContext& theContext, + int theLayer ) +{ + AIS_ListOfInteractive aDisplayedObjects; + theContext->DisplayedObjects( aDisplayedObjects ); + + AIS_ListIteratorOfListOfInteractive aListIter( aDisplayedObjects ); + for ( ; aListIter.More(); aListIter.Next() ) + { + Handle(AIS_InteractiveObject) aPrsObj = aListIter.Value(); + if( !aPrsObj.IsNull() ) + { + theContext->MainPrsMgr()->Color( aPrsObj ); + int aMode = 0;//aPrsObj->HilightMode(); + SetPrsZLayer( aPrsObj, aMode, theLayer ); + theContext->MainPrsMgr()->Unhighlight( aPrsObj, aMode ); + } + } +} -- 2.39.2