0025027: Visualization - 2D layer viewport is updated incorrectly on resize
[occt.git] / src / Visual3d / Visual3d_ViewManager.cxx
index 4a9a3a1..e2a0dc7 100644 (file)
@@ -67,8 +67,6 @@
 #include <Graphic3d_MapOfStructure.hxx>
 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
 
-#include <Visual3d_PickPath.hxx>
-#include <Visual3d_SetIteratorOfSetOfView.hxx>
 
 #if defined (_WIN32) || defined(__WIN32__)
 # include <WNT_Window.hxx>
@@ -83,7 +81,7 @@
 //-Global data definitions
 
 //     -- les vues definies
-//     MyDefinedView           :       SetOfView;
+//     MyDefinedView           :       SequenceOfView;
 
 //     -- le generateur d'identificateurs de vues
 //     MyViewGenId             :       GenId;
@@ -103,6 +101,7 @@ MyTransparency (Standard_False)
   myLayerSeq.Append (0);
 
   MyGraphicDriver = theDriver;
+  myMapOfZLayerSettings.Bind (0, Graphic3d_ZLayerSettings());
 }
 
 //-Destructors
@@ -142,28 +141,23 @@ void Visual3d_ViewManager::Remove () {
   MyDefinedView.Clear();
 }
 
-void Visual3d_ViewManager::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority) {
+void Visual3d_ViewManager::ChangeDisplayPriority (const Handle(Graphic3d_Structure)& AStructure, const Standard_Integer OldPriority, const Standard_Integer NewPriority)
+{
 
 #ifdef TRACE
-       cout << "Visual3d_ViewManager::ChangeDisplayPriority ("
-            << AStructure->Identification ()
-            << ", " << OldPriority << ", " << NewPriority << ")\n";
-       cout << flush;
+  cout << "Visual3d_ViewManager::ChangeDisplayPriority ("
+    << AStructure->Identification ()
+    << ", " << OldPriority << ", " << NewPriority << ")\n";
+  cout << flush;
 #endif
 
-       //
-       // Change structure priority in all defined views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->ChangeDisplayPriority
-                       (AStructure, OldPriority, NewPriority);
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+  //
+  // Change structure priority in all defined views
+  //
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->ChangeDisplayPriority(AStructure, OldPriority, NewPriority);
+  }
 }
 
 void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure) {
@@ -180,15 +174,10 @@ void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStruct
   //
   // Recompute structure in all activated views
   //
-  Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-  while (MyIterator.More ()) {
-    (MyIterator.Value ())->ReCompute (AStructure);
-
-    // MyIterator.Next () is located on the next view
-    MyIterator.Next ();
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->ReCompute(AStructure);
   }
-
 }
 
 void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStructure,
@@ -213,106 +202,71 @@ void Visual3d_ViewManager::ReCompute (const Handle(Graphic3d_Structure)& AStruct
   //
   // Recompute structure in all activated views
   //
-  Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-  while (MyIterator.More ()) {
-    if ((MyIterator.Value ())->Identification () == ViewId)
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    if ((MyDefinedView.Value(i))->Identification () == ViewId)
+    {
       theView->ReCompute (AStructure);
-
-    // MyIterator.Next () is located on the next view
-    MyIterator.Next ();
+    }
   }
-
 }
 
-void Visual3d_ViewManager::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction) {
-
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Clear (AStructure, WithDestruction);
-
-               // MyIterator.Next ()  is located on the next view
-               MyIterator.Next ();
-       }
-
+void Visual3d_ViewManager::Clear (const Handle(Graphic3d_Structure)& AStructure, const Standard_Boolean WithDestruction)
+{
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Clear(AStructure, WithDestruction);
+  }
 }
 
-void Visual3d_ViewManager::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
-
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Connect (AMother, ADaughter);
-
-               // MyIterator.Next ()  is located on the next view
-               MyIterator.Next ();
-       }
-
+void Visual3d_ViewManager::Connect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter)
+{
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Connect (AMother, ADaughter);
+  }
 }
 
-void Visual3d_ViewManager::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter) {
-
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Disconnect (AMother, ADaughter);
-
-               // MyIterator.Next ()  is located on the next view
-               MyIterator.Next ();
-       }
-
+void Visual3d_ViewManager::Disconnect (const Handle(Graphic3d_Structure)& AMother, const Handle(Graphic3d_Structure)& ADaughter)
+{
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Disconnect (AMother, ADaughter);
+  }
 }
 
-void Visual3d_ViewManager::Display (const Handle(Graphic3d_Structure)& AStructure) {
-
-
- // Even if physically the structure cannot
+void Visual3d_ViewManager::Display (const Handle(Graphic3d_Structure)& AStructure)
+{
+  // Even if physically the structure cannot
   // be displayed (pb of visualisation type)
   // it has status Displayed.
 
   MyDisplayedStructure.Add(AStructure);
-
-       //
-       // Display structure in all activated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Display (AStructure);
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+  
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Display(AStructure);
+  }
 }
 
-void Visual3d_ViewManager::Erase (const Handle(Graphic3d_Structure)& AStructure) {
-
-
-// Even if physically the structure cannot
+void Visual3d_ViewManager::Erase (const Handle(Graphic3d_Structure)& AStructure)
+{
+  // Even if physically the structure cannot
   // be displayed (pb of visualisation type)
   // it has status Displayed.
 
- MyDisplayedStructure.Remove(AStructure);
-
-
-
-       //
-       // Erase structure in all defined views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Erase (AStructure);
+  MyDisplayedStructure.Remove(AStructure);
 
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
-       MyHighlightedStructure.Remove (AStructure);
-       MyPickStructure.Remove (AStructure);
+  //
+  // Erase structure in all defined views
+  //
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Erase (AStructure);
+  }
 
+  MyHighlightedStructure.Remove (AStructure);
+  MyPickStructure.Remove (AStructure);
 }
 
 void Visual3d_ViewManager::Erase () {
@@ -326,35 +280,26 @@ void Visual3d_ViewManager::Erase () {
 
 }
 
-void Visual3d_ViewManager::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod) {
-
+void Visual3d_ViewManager::Highlight (const Handle(Graphic3d_Structure)& AStructure, const Aspect_TypeOfHighlightMethod AMethod)
+{
   MyHighlightedStructure.Add(AStructure);
-
-       //
-       // Highlight in all activated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Highlight (AStructure, AMethod);
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+  
+  //
+  // Highlight in all activated views
+  //
+  
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->Highlight (AStructure, AMethod);
+  }
 }
 
-void Visual3d_ViewManager::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf) {
-
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->SetTransform (AStructure, ATrsf);
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+void Visual3d_ViewManager::SetTransform (const Handle(Graphic3d_Structure)& AStructure, const TColStd_Array2OfReal& ATrsf)
+{
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->SetTransform (AStructure, ATrsf);
+  }
 }
 
 void Visual3d_ViewManager::UnHighlight () {
@@ -369,149 +314,144 @@ void Visual3d_ViewManager::UnHighlight () {
 
 }
 
-void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStructure) {
-
+void Visual3d_ViewManager::UnHighlight (const Handle(Graphic3d_Structure)& AStructure)
+{
   MyHighlightedStructure.Remove(AStructure);
 
+  //
+  // UnHighlight in all activated views
+  //
 
-       //
-       // UnHighlight in all activated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->UnHighlight (AStructure);
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->UnHighlight (AStructure);
+  }
 }
 
-void Visual3d_ViewManager::Redraw () const {
-
-Standard_Integer MaxDx, MaxDy;
-Standard_Integer Dx, Dy;
-       MaxDx = MaxDy = IntegerFirst ();
+void Visual3d_ViewManager::Redraw() const
+{
+  // redraw all activated views
+  if (MyDefinedView.Length() == 0)
+  {
+    return;
+  }
 
-       //
-       // Redraw all activated views
-       //
-       Standard_Integer j = MyDefinedView.Extent ();
-       if (j == 0) return;
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ()) {
-           while (MyIterator.More ()) {
-               (MyIterator.Value ())->Window ()->Size (Dx, Dy);
-               if (Dx > MaxDx) MaxDx = Dx;
-               if (Dy > MaxDy) MaxDy = Dy;
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-           }
-           if (! MyUnderLayer.IsNull ())
-               MyUnderLayer->SetViewport (MaxDx, MaxDy);
-           if (! MyOverLayer.IsNull ())
-               MyOverLayer->SetViewport (MaxDx, MaxDy);
-       }
+  if (!MyUnderLayer.IsNull() || !MyOverLayer.IsNull())
+  {
+    Standard_Integer aWidth = 0, aHeight = 0;
+    Standard_Integer aWidthMax  = 0;
+    Standard_Integer aHeightMax = 0;
 
-       if (! MyUnderLayer.IsNull () || ! MyOverLayer.IsNull ())
-           MyIterator.Initialize (MyDefinedView);
-       while (MyIterator.More ()) {
-           (MyIterator.Value ())->Redraw (MyUnderLayer, MyOverLayer);
+    for(int i=1; i<=MyDefinedView.Length(); i++)
+    {
+      MyDefinedView.Value(i)->Window()->Size (aWidth, aHeight);
+      aWidthMax  = Max (aWidthMax,  aWidth);
+      aHeightMax = Max (aHeightMax, aHeight);
+    }
 
-           // MyIterator.Next () is located on the next view
-           MyIterator.Next ();
-       }
+    if (!MyUnderLayer.IsNull())
+    {
+      MyUnderLayer->SetViewport (aWidthMax, aHeightMax);
+    }
+    if (!MyOverLayer.IsNull())
+    {
+      MyOverLayer->SetViewport (aWidthMax, aHeightMax);
+    }
+  }
 
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    MyDefinedView.Value(i)->Redraw (MyUnderLayer, MyOverLayer);
+  }
 }
 
-void Visual3d_ViewManager::Update () const {
-
-       //
-       // Update all activated views
-       //
-       Standard_Integer j = MyDefinedView.Extent ();
-       if (j == 0) return;
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->Update (MyUnderLayer, MyOverLayer);
+void Visual3d_ViewManager::Update() const
+{
+  Redraw();
+}
 
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+void Visual3d_ViewManager::RedrawImmediate() const
+{
+  if (MyDefinedView.Length() == 0)
+  {
+    return;
+  }
 
+  // update all activated views
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    MyDefinedView.Value(i)->RedrawImmediate (MyUnderLayer, MyOverLayer);
+  }
 }
 
-Handle(Visual3d_HSetOfView) Visual3d_ViewManager::ActivatedView () const {
-
-Handle (Visual3d_HSetOfView) SG = new Visual3d_HSetOfView ();
+void Visual3d_ViewManager::Invalidate() const
+{
+  if (MyDefinedView.Length() == 0)
+  {
+    return;
+  }
 
-Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
+  // update all activated views
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    MyDefinedView.Value(i)->Invalidate();
+  }
+}
 
-       while (MyIterator.More ()) {
-               if ((MyIterator.Value ())->IsActive ())
-                       SG->Add (MyIterator.Value ());
+Handle(Visual3d_HSequenceOfView) Visual3d_ViewManager::ActivatedView () const
+{
 
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+  Handle(Visual3d_HSequenceOfView) SG = new Visual3d_HSequenceOfView();
 
-       return (SG);
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    if ((MyDefinedView.Value(i))->IsActive ())
+    {
+      SG->Append(MyDefinedView.Value(i));
+    }
+  }
 
+  return (SG);
 }
 
 #ifdef IMPLEMENTED
-Standard_Boolean Visual3d_ViewManager::ContainsComputedStructure () const {
-
-Standard_Boolean Result = Standard_False;
-
-       //
-       // Check all activated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       Standard_Integer i      = MyDefinedView.Extent ();
-
-       while ((! Result) && (MyIterator.More ())) {
-               if ((MyIterator.Value ())->IsActive ())
-                       Result  =
-                       (MyIterator.Value ())->ContainsComputedStructure ();
+Standard_Boolean Visual3d_ViewManager::ContainsComputedStructure () const
+{
+  Standard_Boolean Result = Standard_False;
 
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+  //
+  // Check all activated views
+  //
+  for(int i=1; (!Result) && i<=MyDefinedView.Length(); i++)
+  {
+    if ((MyDefinedView.Value(i))->IsActive())
+    {
+      Result = (MyDefinedView.Value(i))->ContainsComputedStructure();
+    }
+  }
 
-       return Result;
+  return Result;
 }
 #endif
 
-Handle(Visual3d_HSetOfView) Visual3d_ViewManager::DefinedView () const {
-
-Handle (Visual3d_HSetOfView) SG = new Visual3d_HSetOfView ();
-
-Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               SG->Add (MyIterator.Value ());
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+Handle(Visual3d_HSequenceOfView) Visual3d_ViewManager::DefinedView () const
+{
+  Handle (Visual3d_HSequenceOfView) SG = new Visual3d_HSequenceOfView();
 
-       return (SG);
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    SG->Append(MyDefinedView.Value(i));
+  }
 
+  return (SG);
 }
 
-Standard_Boolean Visual3d_ViewManager::ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const {
-
-Standard_Boolean Exist = Standard_False;
+Standard_Boolean Visual3d_ViewManager::ViewExists (const Handle(Aspect_Window)& AWindow, Graphic3d_CView& TheCView) const
+{
+  Standard_Boolean Exist = Standard_False;
 
-       // Parse the list of views to find
-       // a view with the specified window
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
+  // Parse the list of views to find
+  // a view with the specified window
 
 #if defined(_WIN32) || defined(__WIN32__)
   const Handle(WNT_Window) THEWindow = Handle(WNT_Window)::DownCast (AWindow);
@@ -524,68 +464,60 @@ Standard_Boolean Exist = Standard_False;
   int TheSpecifiedWindowId = int (THEWindow->XWindow ());
 #endif
 
-       while ((! Exist) && (MyIterator.More ())) {
-
-          if ( ((MyIterator.Value ())->IsDefined ()) &&
-               ((MyIterator.Value ())->IsActive ()) ) {
+  for(int i=1; (!Exist) && i<=MyDefinedView.Length(); i++)
+  {
+    if ( ((MyDefinedView.Value(i))->IsDefined ()) && ((MyDefinedView.Value(i))->IsActive ()) )
+    {
+      const Handle(Aspect_Window) AspectWindow = (MyDefinedView.Value(i))->Window();
 
-const Handle(Aspect_Window) AspectWindow = (MyIterator.Value ())->Window ();
 #if defined(_WIN32) || defined(__WIN32__)
-   const Handle(WNT_Window) theWindow = Handle(WNT_Window)::DownCast (AspectWindow);
-   Aspect_Handle TheWindowIdOfView = theWindow->HWindow ();
+      const Handle(WNT_Window) theWindow = Handle(WNT_Window)::DownCast (AspectWindow);
+      Aspect_Handle TheWindowIdOfView = theWindow->HWindow ();
 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
-   const Handle(Cocoa_Window) theWindow = Handle(Cocoa_Window)::DownCast (AspectWindow);
-   NSView* TheWindowIdOfView = theWindow->HView();
+      const Handle(Cocoa_Window) theWindow = Handle(Cocoa_Window)::DownCast (AspectWindow);
+      NSView* TheWindowIdOfView = theWindow->HView();
 #else
-   const Handle(Xw_Window) theWindow = Handle(Xw_Window)::DownCast (AspectWindow);
-   int TheWindowIdOfView = int (theWindow->XWindow ());
+      const Handle(Xw_Window) theWindow = Handle(Xw_Window)::DownCast (AspectWindow);
+      int TheWindowIdOfView = int (theWindow->XWindow ());
 #endif  // WNT
-               // Comparaison on window IDs
-               if (TheWindowIdOfView == TheSpecifiedWindowId) {
-                       Exist   = Standard_True;
-                       TheCView        = *(Graphic3d_CView* )(MyIterator.Value())->CView();
-               }
-          } /* if ((MyIterator.Value ())->IsDefined ()) */
-
-          // MyIterator.Next () is located on the next view
-          MyIterator.Next ();
-       }
-
-       return (Exist);
+      // Comparaison on window IDs
+      if (TheWindowIdOfView == TheSpecifiedWindowId)
+      {
+        Exist = Standard_True;
+        TheCView = *(Graphic3d_CView* )(MyDefinedView.Value(i))->CView();
+      }
+    }
+  }
 
+  return (Exist);
 }
 
-void Visual3d_ViewManager::Activate () {
-
-       //
-       // Activates all deactivated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               if (! (MyIterator.Value ())->IsActive ())
-                       (MyIterator.Value ())->Activate ();
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
-
+void Visual3d_ViewManager::Activate ()
+{
+  //
+  // Activates all deactivated views
+  //
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    if (! (MyDefinedView.Value(i))->IsActive())
+    {
+      (MyDefinedView.Value(i))->Activate();
+    }
+  }
 }
 
-void Visual3d_ViewManager::Deactivate () {
-
-       //
-       // Deactivates all activated views
-       //
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-
-       while (MyIterator.More ()) {
-               if ((MyIterator.Value ())->IsActive ())
-                       (MyIterator.Value ())->Deactivate ();
-
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+void Visual3d_ViewManager::Deactivate ()
+{
+  //
+  // Deactivates all activated views
+  //
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    if ((MyDefinedView.Value(i))->IsActive())
+    {
+      (MyDefinedView.Value(i))->Deactivate();
+    }
+  }
 
 }
 
@@ -610,82 +542,71 @@ Standard_Integer Visual3d_ViewManager::Identification () const {
 
 }
 
-Standard_Integer Visual3d_ViewManager::Identification (const Handle(Visual3d_View)& AView) {
-
-       MyDefinedView.Add (AView);
-       return (MyViewGenId.Next ());
-
+Standard_Integer Visual3d_ViewManager::Identification (const Handle(Visual3d_View)& AView)
+{
+  MyDefinedView.Append(AView);
+  return (MyViewGenId.Next ());
 }
 
 void Visual3d_ViewManager::UnIdentification (const Standard_Integer aViewId)
 {
-  Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-  while (MyIterator.More()) 
+  for(int i=1; i<=MyDefinedView.Length(); i++)
   {
-    if ((MyIterator.Value())->Identification () == aViewId)
+    if ((MyDefinedView.Value(i))->Identification() == aViewId)
     {
-      const Handle(Visual3d_View)& theView = MyIterator.Value();
       //remove the view from the list
-      MyDefinedView.Remove(theView);
+      MyDefinedView.Remove(i);
       break;
     }
-    // go to next
-    MyIterator.Next ();
   }
+
   MyViewGenId.Free(aViewId);
 }
 
-void Visual3d_ViewManager::SetTransparency (const Standard_Boolean AFlag) {
-
-       if (MyTransparency && AFlag) return;
-       if (! MyTransparency && ! AFlag) return;
-
-       Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-       while (MyIterator.More ()) {
-               (MyIterator.Value ())->SetTransparency (AFlag);
-               // MyIterator.Next () is located on the next view
-               MyIterator.Next ();
-       }
+void Visual3d_ViewManager::SetTransparency (const Standard_Boolean AFlag)
+{
+  if (MyTransparency && AFlag) return;
+  if (! MyTransparency && ! AFlag) return;
 
-       MyTransparency  = AFlag;
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->SetTransparency(AFlag);
+  }
 
+  MyTransparency = AFlag;
 }
 
-Standard_Boolean Visual3d_ViewManager::Transparency () const {
-
-       return (MyTransparency);
-
+Standard_Boolean Visual3d_ViewManager::Transparency () const
+{
+  return (MyTransparency);
 }
 
-void Visual3d_ViewManager::SetZBufferAuto (const Standard_Boolean AFlag) {
-
-       if (MyZBufferAuto && AFlag) return;
-       if (! MyZBufferAuto && ! AFlag) return;
-
-       // if pass from False to True :
-       // no problem, at the next view update, it
-       // will properly ask questions to answer (SetVisualisation)
-       // if pass from True to False :
-       // it is necessary to modify ZBufferActivity at each view so that
-       // zbuffer could be active only if required by context.
-       // In this case -1 is passed so that the view ask itself the question
-       // Note : 0 forces the desactivation, 1 forces the activation
-       if (! AFlag) {
-               Visual3d_SetIteratorOfSetOfView MyIterator(MyDefinedView);
-               while (MyIterator.More ()) {
-                       (MyIterator.Value ())->SetZBufferActivity (-1);
-                       // MyIterator.Next () is located on the next view
-                       MyIterator.Next ();
-               }
-       }
-       MyZBufferAuto   = AFlag;
-
+void Visual3d_ViewManager::SetZBufferAuto (const Standard_Boolean AFlag)
+{
+  if (MyZBufferAuto && AFlag) return;
+  if (! MyZBufferAuto && ! AFlag) return;
+
+  // if pass from False to True :
+  // no problem, at the next view update, it
+  // will properly ask questions to answer (SetVisualisation)
+  // if pass from True to False :
+  // it is necessary to modify ZBufferActivity at each view so that
+  // zbuffer could be active only if required by context.
+  // In this case -1 is passed so that the view ask itself the question
+  // Note : 0 forces the desactivation, 1 forces the activation
+  if (! AFlag)
+  {
+    for(int i=1; i<=MyDefinedView.Length(); i++)
+    {
+      (MyDefinedView.Value(i))->SetZBufferActivity(-1);
+    }
+  }
+  MyZBufferAuto = AFlag;
 }
 
-Standard_Boolean Visual3d_ViewManager::ZBufferAuto () const {
-
-       return (MyZBufferAuto);
-
+Standard_Boolean Visual3d_ViewManager::ZBufferAuto () const
+{
+  return (MyZBufferAuto);
 }
 
 void Visual3d_ViewManager::SetLayer (const Handle(Visual3d_Layer)& ALayer) {
@@ -741,9 +662,10 @@ void Visual3d_ViewManager::ChangeZLayer (const Handle(Graphic3d_Structure)& theS
   // change display layer for structure in all views
   if (MyDisplayedStructure.Contains (theStructure))
   {
-    Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
-    for ( ; aViewIt.More (); aViewIt.Next ())
-      (aViewIt.Value ())->ChangeZLayer (theStructure, theLayerId);
+    for(int i=1; i<=MyDefinedView.Length(); i++)
+    {
+      (MyDefinedView.Value(i))->ChangeZLayer(theStructure, theLayerId);
+    }
   }
 
   // tell graphic driver to update the structure's display layer
@@ -760,6 +682,44 @@ Standard_Integer Visual3d_ViewManager::GetZLayer (const Handle(Graphic3d_Structu
   return MyGraphicDriver->GetZLayer (*theStructure->CStructure ());
 }
 
+//=======================================================================
+//function : SetZLayerSettings
+//purpose  :
+//=======================================================================
+void Visual3d_ViewManager::SetZLayerSettings (const Standard_Integer theLayerId,
+                                              const Graphic3d_ZLayerSettings& theSettings)
+{
+  // tell all managed views to set zlayer settings
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->SetZLayerSettings (theLayerId, theSettings);
+  }
+
+  if (myMapOfZLayerSettings.IsBound (theLayerId))
+  {
+    myMapOfZLayerSettings.ChangeFind (theLayerId) = theSettings;
+  }
+  else
+  {
+    myMapOfZLayerSettings.Bind (theLayerId, theSettings);
+  }
+  
+}
+
+//=======================================================================
+//function : ZLayerSettings
+//purpose  :
+//=======================================================================
+Graphic3d_ZLayerSettings Visual3d_ViewManager::ZLayerSettings (const Standard_Integer theLayerId)
+{
+  if (!myLayerIds.Contains (theLayerId))
+  {
+    return Graphic3d_ZLayerSettings();
+  }
+
+  return myMapOfZLayerSettings.Find (theLayerId);
+}
+
 //=======================================================================
 //function : AddZLayer
 //purpose  :
@@ -780,10 +740,14 @@ Standard_Boolean Visual3d_ViewManager::AddZLayer (Standard_Integer& theLayerId)
     return Standard_False;
   }
 
+  // default z-layer settings
+  myMapOfZLayerSettings.Bind (theLayerId, Graphic3d_ZLayerSettings());
+
   // tell all managed views to remove display layers
-  Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
-  for ( ; aViewIt.More (); aViewIt.Next ())
-    (aViewIt.Value ())->AddZLayer (theLayerId);
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->AddZLayer(theLayerId);
+  }
 
   return Standard_True;
 }
@@ -799,19 +763,24 @@ Standard_Boolean Visual3d_ViewManager::RemoveZLayer (const Standard_Integer theL
     return Standard_False;
 
   // tell all managed views to remove display layers
-  Visual3d_SetIteratorOfSetOfView aViewIt(MyDefinedView);
-  for ( ; aViewIt.More (); aViewIt.Next ())
-    (aViewIt.Value ())->RemoveZLayer (theLayerId);
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    (MyDefinedView.Value(i))->RemoveZLayer (theLayerId);
+  }
 
   MyGraphicDriver->UnsetZLayer (theLayerId);
 
   // remove index
   for (int aIdx = 1; aIdx <= myLayerSeq.Length (); aIdx++)
-    if (myLayerSeq(aIdx) == theLayerId)
+  {
+    if (myLayerSeq (aIdx) == theLayerId)
     {
       myLayerSeq.Remove (aIdx);
       break;
     }
+  }
+
+  myMapOfZLayerSettings.UnBind (theLayerId);
 
   myLayerIds.Remove (theLayerId);
   getZLayerGenId ().Free (theLayerId);
@@ -847,7 +816,16 @@ Aspect_GenId& Visual3d_ViewManager::getZLayerGenId ()
 
 void Visual3d_ViewManager::InstallZLayers(const Handle(Visual3d_View)& theView) const
 {
-  if (!MyDefinedView.Contains (theView))
+  Standard_Boolean isContainsView = Standard_False;
+  for(int i=1; i<=MyDefinedView.Length(); i++)
+  {
+    if(MyDefinedView.Value(i) == theView)
+    {
+      isContainsView = Standard_True;
+      break;
+    }
+  }
+  if (!isContainsView)
     return;
 
   // erase and insert layers iteratively to provide the same layer order as