]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
another z layer for hilight presentation
authorasl <asl@opencascade.com>
Tue, 8 Apr 2014 04:43:42 +0000 (04:43 +0000)
committerasl <asl@opencascade.com>
Tue, 8 Apr 2014 04:43:42 +0000 (04:43 +0000)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_ZLayers.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ZLayers.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ZLayers2.cxx [new file with mode: 0644]

index f31a04a8b1bfaf4adea438e47a52cd6655e9bd83..79549b29ce725798faf55ed8e3b491466c87e091 100644 (file)
@@ -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(
index 719b6e46c90d6bed23559704a5c1260806d8a257..8fed86b55ff52e550043e18fef898d698fbfd3f0 100644 (file)
@@ -28,6 +28,7 @@
 #include "HYDROGUI_Shape.h"
 #include "HYDROGUI_Operation.h"
 #include "HYDROGUI_DataObject.h"
+#include "HYDROGUI_ZLayers.h"
 
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
@@ -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 (file)
index 0000000..2e9fad6
--- /dev/null
@@ -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 <HYDROGUI_ZLayers.h>
+#include <PrsMgr_PresentableObject.hxx>
+#include <PrsMgr_ModedPresentation.hxx>
+#include <TColStd_SequenceOfInteger.hxx>
+
+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<n; i++ )
+    if( myZLayers[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 (file)
index 0000000..c8b6cbf
--- /dev/null
@@ -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 <vector>
+#include <V3d_Viewer.hxx>
+
+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<int>  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 (file)
index 0000000..0115def
--- /dev/null
@@ -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 <HYDROGUI_ZLayers.h>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+
+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 );
+    }
+  }
+}