1 // Copyright (C) 2007-2013 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.
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 #include <HYDROGUI_ZLayers.h>
24 #include <PrsMgr_PresentableObject.hxx>
25 #include <PrsMgr_ModedPresentation.hxx>
26 #include <TColStd_SequenceOfInteger.hxx>
28 class PrsMgr_PresentationManager
31 static void SetZLayer( const Handle_PrsMgr_PresentableObject& thePresentableObject,
32 const Standard_Integer theMode,
33 const Standard_Integer theLayerId )
35 PrsMgr_Presentations& aPresentations = thePresentableObject->Presentations();
36 for (Standard_Integer aIdx = 1; aIdx <= aPresentations.Length (); aIdx++)
38 Handle(PrsMgr_Presentation) aPrs = aPresentations (aIdx).Presentation ();
39 if ( aPresentations (aIdx).Mode() == theMode )
40 aPrs->SetZLayer (theLayerId);
45 void SetPrsZLayer( const Handle_PrsMgr_PresentableObject& thePresentableObject,
46 const int theMode, const int theLayerId )
48 PrsMgr_PresentationManager::SetZLayer( thePresentableObject, theMode, theLayerId );
51 HYDROGUI_ZLayersIterator::HYDROGUI_ZLayersIterator( const Handle_V3d_Viewer& theViewer )
52 : myIndex( 0 ), myNewZLayer( -1 ), myViewer( theViewer )
57 HYDROGUI_ZLayersIterator::~HYDROGUI_ZLayersIterator()
61 void HYDROGUI_ZLayersIterator::Init( const Handle_V3d_Viewer& theViewer )
63 TColStd_SequenceOfInteger anExistingZLayers;
64 theViewer->GetAllZLayers( anExistingZLayers );
66 int n = anExistingZLayers.Length();
67 myZLayers.resize( n );
68 for( int i=1; i<=n; i++ )
69 myZLayers[i-1] = anExistingZLayers( i );
74 bool HYDROGUI_ZLayersIterator::More() const
76 return myIndex <= (int)myZLayers.size() || myNewZLayer >= 0;
79 void HYDROGUI_ZLayersIterator::Next()
81 if( myIndex < (int)myZLayers.size() )
83 else if( !myViewer.IsNull() )
85 bool isOK = myViewer->AddZLayer( myNewZLayer )==Standard_True;
91 int HYDROGUI_ZLayersIterator::MaxLayer() const
94 for( int i=0, n=myZLayers.size(); i<n; i++ )
95 if( myZLayers[i] > aMaxLayer )
96 aMaxLayer = myZLayers[i];
101 int HYDROGUI_ZLayersIterator::LayerId() const
104 return myZLayers[myIndex];