0024624: Lost word in license statement in source files
[occt.git] / src / AIS / AIS_InteractiveContext.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 58515a6..56c56bd
@@ -1,19 +1,24 @@
-// File:        AIS_InteractiveContext.cxx
-// Created:     Fri Jan 17 13:36:48 1997
-// Author:      Robert COUBLANC
+// Created on: 1997-01-17
+// Created by: Robert COUBLANC
+// Copyright (c) 1997-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
 // Modified by  XAB & Serguei Dec 97 (angle &deviation coeffts)
-//              <rob@robox.paris1.matra-dtv.fr>
 
 #define BUC60577        //GG_101099     Enable to compute correctly
 //                      transparency with more than one object in the view.
 
-#define GER61351        //GG_171199     Enable to set an object RGB color
-//                              instead a restricted object NameOfColor. 
-
-#define G003            //EUG_26/01/00 Degenerate support (G003)
-
-#define IMP140200       //GG Add SetSelectedAspect() method.
-
 #define BUC60632        //GG 15/03/00 Add protection on SetDisplayMode()
 //                      method, compute only authorized presentation.
 
 #define OCC172          //SAV clear static map before destroying context.
 
 #define OCC204          //SAV 26/02/02 : pass <updateviewer> flag to 
-                        // AddOrRemoveCurrentObject method from ClearGlobal.
+// AddOrRemoveCurrentObject method from ClearGlobal.
 
 #define OCC4373         //SAN 10/11/03 : improve display mode management in
-                        // Display( IO, updateviewer ) and 
-                        // SetDisplayMode( IO, mode, updateviewer ) methods
+// Display( IO, updateviewer ) and 
+// SetDisplayMode( IO, mode, updateviewer ) methods
 
 #include <AIS_InteractiveContext.ixx>
 
 // in spite of the selection mode of the interactive object in Natural Point.
 #define OCC166
 
-// An interactive Object being erased in the main viewer and put into collector should have the same selection mode.
-// It impacts the performance!
-#define OCC328
-
 static Standard_Boolean AISDebugModeOn()
 {
 //  static OSD_Environment aisdb("AISDEBUGMODE");
@@ -120,7 +121,6 @@ mgrSelector(new SelectMgr_SelectionManager()),
 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
 myMainVwr(MainViewer),
 myMainSel(new StdSelect_ViewerSelector3d()),
-myIsCollClosed(Standard_True),
 myToHilightSelected( Standard_False ),
 myFilters(new SelectMgr_OrFilter()),
 myDefaultDrawer(new Prs3d_Drawer()),
@@ -139,49 +139,11 @@ myIsAutoActivateSelMode( Standard_True )
   InitAttributes();
 }
 
-
-//=======================================================================
-//function : AIS_InteractiveContext
-//purpose  : 
-//=======================================================================
-
-AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer,
-                                             const Handle(V3d_Viewer)& Collector):
-mgrSelector(new SelectMgr_SelectionManager()),
-myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
-myMainVwr(MainViewer),
-myMainSel(new StdSelect_ViewerSelector3d()),
-myCollectorPM(new PrsMgr_PresentationManager3d(Collector->Viewer())),
-myCollectorVwr(Collector),
-myCollectorSel(new StdSelect_ViewerSelector3d()),
-myIsCollClosed(Standard_False),
-myToHilightSelected( Standard_False ),
-myFilters(new SelectMgr_OrFilter()),
-myDefaultDrawer(new Prs3d_Drawer()),
-myDefaultColor(Quantity_NOC_GOLDENROD),
-myHilightColor(Quantity_NOC_CYAN1),
-mySelectionColor(Quantity_NOC_GRAY80),
-myPreselectionColor(Quantity_NOC_GREEN),
-mySubIntensity(Quantity_NOC_GRAY40),
-myDisplayMode(0),
-myCurLocalIndex(0),
-#ifdef IMP051001
-myZDetectionFlag(0),
-#endif
-myIsAutoActivateSelMode( Standard_True )
-{
-  InitAttributes();
-  mgrSelector->Add(myCollectorSel);
-#ifdef BUC60688
-  SetSensitivity();
-#else
-  myCollectorSel->Set(4);
-#endif
-
-}
-
 void AIS_InteractiveContext::Delete() const
 {
+  //Clear the static current selection. Else the memory
+  //is not release
+  AIS_Selection::ClearCurrentSelection();
 #ifdef OCC172
   // to avoid an exception
   if ( AIS_Selection::Find( mySelectionName.ToCString() ) )
@@ -195,6 +157,16 @@ void AIS_InteractiveContext::Delete() const
   // be performed when mgrSelector will be destroyed but anyway...
   mgrSelector->Remove( myMainSel );
 #endif
+  AIS_ListOfInteractive aList;
+  
+  AIS_DataMapIteratorOfDataMapOfIOStatus anIt(myObjects);
+  Handle(AIS_InteractiveContext) aNullContext;
+  for(; anIt.More() ; anIt.Next())
+  {
+    Handle(AIS_InteractiveObject) anObj = anIt.Key();
+    anObj->SetContext(aNullContext);
+    
+  }
   MMgt_TShared::Delete();
 }
 
@@ -223,13 +195,6 @@ void AIS_InteractiveContext::UpdateCurrentViewer()
     myMainVwr->Update();
 }
 
-void AIS_InteractiveContext::OpenCollector()
-{
-  myIsCollClosed =Standard_True;
-  // to be completed....
-}
-
-
 
 //=======================================================================
 //function : DomainOfMainViewer
@@ -273,15 +238,14 @@ void AIS_InteractiveContext::DisplayedObjects(AIS_ListOfInteractive& aListOfIO,
 #endif
 
     //parse all local contexts...
+#ifdef DEBUG
     Standard_Integer NbDisp;
     for(AIS_DataMapIteratorOfDataMapOfILC it1(myLocalContexts);it1.More();it1.Next()){
       const Handle(AIS_LocalContext)& LC = it1.Value();
       NbDisp =  LC->DisplayedObjects(theMap);
-#ifdef DEBUG
       cout<<"\tIn Local Context "<<it1.Key()<<" : "<<NbDisp<<endl;
-#endif
-      
     }
+#endif
     Handle(AIS_InteractiveObject) curIO;
     Handle(Standard_Transient) Tr;
       for(TColStd_MapIteratorOfMapOfTransient it2(theMap);it2.More();it2.Next()){
@@ -304,50 +268,6 @@ void AIS_InteractiveContext::DisplayedObjects(const AIS_KindOfInteractive TheKin
   ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Displayed, aListOfIO );
 }
 
-//=======================================================================
-//function : UpdateCollector
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveContext::UpdateCollector()
-{
-  if (!myCollectorVwr.IsNull())
-    myCollectorVwr->Update();
-}
-
-//=======================================================================
-//function : DomainOfCollector
-//purpose  : 
-//=======================================================================
-
-Standard_CString AIS_InteractiveContext::DomainOfCollector() const 
-{
-  if(myCollectorVwr.IsNull()) return "";
-  return  myCollectorVwr->Domain();
-}
-
-//=======================================================================
-//function : ObjectsInCollector
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveContext::ObjectsInCollector(AIS_ListOfInteractive& aListOfIO) const 
-{
-  ObjectsByDisplayStatus( AIS_DS_Erased, aListOfIO );
-}
-
-//=======================================================================
-//function : ObjectsInCollector
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheKind,
-                                                const Standard_Integer TheSign,
-                                                AIS_ListOfInteractive& aListOfIO) const 
-{
-  ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, aListOfIO );
-}
-
 //=======================================================================
 //function : ErasedObjects
 //purpose  : 
@@ -355,7 +275,7 @@ void AIS_InteractiveContext::ObjectsInCollector(const AIS_KindOfInteractive TheK
 
 void AIS_InteractiveContext::ErasedObjects(AIS_ListOfInteractive& theListOfIO) const 
 {
-  ObjectsByDisplayStatus( AIS_DS_FullErased, theListOfIO );
+  ObjectsByDisplayStatus( AIS_DS_Erased, theListOfIO );
 }
 
 //=======================================================================
@@ -367,7 +287,7 @@ void AIS_InteractiveContext::ErasedObjects(const AIS_KindOfInteractive TheKind,
                                            const Standard_Integer TheSign,
                                            AIS_ListOfInteractive& theListOfIO) const 
 {
-  ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_FullErased, theListOfIO );
+  ObjectsByDisplayStatus( TheKind, TheSign, AIS_DS_Erased, theListOfIO );
 }
 
 //=======================================================================
@@ -463,8 +383,7 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
     // SAN : Do not return here. Perform advanced display mode analysis a bit later...
     if(IsDisplayed(anIObj)) return;
 #endif
-    Standard_Boolean updcol = Standard_False;
-    
+
     // it did not yet exist
     if(!myObjects.IsBound(anIObj)){
       
@@ -491,34 +410,11 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
       // ENDCLE
-      switch (STATUS->GraphicStatus()){
-      case AIS_DS_Erased:{
-        if(STATUS->IsHilighted())
-          myCollectorPM->Unhighlight(anIObj,HiMod);
-        myCollectorPM->Erase(anIObj,HiMod);
-        mgrSelector->Deactivate(anIObj,myCollectorSel);
-        updcol = updateviewer;
-                         }// attention the break is not set on purpose...
-      case AIS_DS_FullErased:{
-        TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
-        for (;ItL.More();ItL.Next()){
-          myMainPM->Display(anIObj,ItL.Value());
-          if(STATUS->IsSubIntensityOn())
-            myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
-        }
-        if( myIsAutoActivateSelMode )        
-            for (ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
-                mgrSelector->Activate(anIObj,ItL.Value(),myMainSel);
-        STATUS->SetGraphicStatus(AIS_DS_Displayed);
-        if(STATUS->IsHilighted())
-          myMainPM->Highlight(anIObj,HiMod);
-        break;
-                             }
-#ifdef OCC4373
-      // SAN : erase presentations for all display modes different from <DispMode>;
-      //       then make sure <DispMode> is displayed and maybe highlighted;
-      //       Finally, activate selection mode <SelMode> if not yet activated.
-      case AIS_DS_Displayed:{
+      if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
+      {
+        // SAN : erase presentations for all display modes different from <DispMode>;
+        //       then make sure <DispMode> is displayed and maybe highlighted;
+        //       Finally, activate selection mode <SelMode> if not yet activated.
         TColStd_ListOfInteger aModesToRemove;
         TColStd_ListIteratorOfListOfInteger ItL (STATUS->DisplayedModes());
         for(;ItL.More();ItL.Next()){
@@ -540,6 +436,10 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
           STATUS->AddDisplayMode(DispMode);
 
         myMainPM->Display(anIObj,DispMode);
+        if (STATUS->GraphicStatus() == AIS_DS_Erased)
+        {
+          STATUS->SetGraphicStatus(AIS_DS_Displayed);
+        }
         if(STATUS->IsHilighted()){
           myMainPM->Highlight(anIObj,HiMod);
         }
@@ -550,19 +450,12 @@ void AIS_InteractiveContext::Display(const Handle(AIS_InteractiveObject)& anIObj
            if(!mgrSelector->IsActivated(anIObj,SelMode))
               mgrSelector->Activate(anIObj,SelMode,myMainSel);
         }
-
-        break;
-                            }
-#endif
-      default:
-        break;
       }
     } 
     
     if(anIObj->IsTransparent() && !myMainVwr->Viewer()->Transparency())
       myMainVwr->Viewer()->SetTransparency(Standard_True);
     if(updateviewer) myMainVwr->Update();
-    if(updcol && !myCollectorVwr.IsNull()) myCollectorVwr->Update();
   }
   
   //  LOCAL CONTEXT OPEN
@@ -657,7 +550,7 @@ void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
       
       GetDefModes(anIObj,DispMode,HiMod,SelModeDef);
       Handle(AIS_GlobalStatus) STATUS= 
-        new AIS_GlobalStatus(AIS_DS_FullErased,DispMode,SelModeDef);
+        new AIS_GlobalStatus(AIS_DS_Erased,DispMode,SelModeDef);
       myObjects.Bind (anIObj,STATUS);      
       return;
     }
@@ -672,8 +565,7 @@ void AIS_InteractiveContext::Load(const Handle(AIS_InteractiveObject)& anIObj,
 //=======================================================================
 
 void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj, 
-                                   const Standard_Boolean updateviewer, 
-                                   const Standard_Boolean PutInCollector)
+                                   const Standard_Boolean updateviewer)
 {
   if(anIObj.IsNull()) return;
   
@@ -681,7 +573,7 @@ void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
     anIObj->ClearSelected();
   
   if(!HasOpenedContext()){
-    EraseGlobal(anIObj,updateviewer,PutInCollector);
+    EraseGlobal(anIObj,updateviewer);
   }
   else
     {
@@ -701,62 +593,31 @@ void AIS_InteractiveContext::Erase(const Handle(AIS_InteractiveObject)& anIObj,
       }
       
       if(!WasInCtx)
-        EraseGlobal(anIObj,updateviewer,PutInCollector);
+        EraseGlobal(anIObj,updateviewer);
       else
         if(updateviewer) myMainVwr->Update();
     }
 }
-//=======================================================================
-//function : Erase
-//purpose  : 
-//=======================================================================
-
-void AIS_InteractiveContext::EraseMode(const Handle(AIS_InteractiveObject)& anIObj,
-                                  const Standard_Integer aMode,
-                                  const Standard_Boolean /*updateviewer*/)
-{
-  if(anIObj.IsNull()) return;
-
-  if(!myObjects.IsBound(anIObj)) return;
-  
-  if(anIObj->HasDisplayMode()){
-    if(anIObj->DisplayMode()==aMode) return;
-  }
-  else if(myDisplayMode==aMode) return;
-  // CLE
-  // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
-  Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
-  // ENDCLE
-  if(STATUS->GraphicStatus()!=AIS_DS_Displayed) return;
-  
-  
-//  if(STATUS->IsDModeIn(aMode)) {}
-}
-
-
 
 //=======================================================================
 //function : EraseAll
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector,
-                                      const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::EraseAll(const Standard_Boolean updateviewer)
 {
-  if(!HasOpenedContext()){
-    AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
-    
-    for(;ItM.More();ItM.Next()){
+  if(!HasOpenedContext())
+  {
+    for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects); ItM.More(); ItM.Next())
+    {
       if(ItM.Value()->GraphicStatus() == AIS_DS_Displayed)
-        Erase(ItM.Key(),Standard_False,PutInCollector);
+        Erase(ItM.Key(),Standard_False);
     }
-    if(updateviewer){
+    if(updateviewer)
+    {
       myMainVwr->Update();
-      if (PutInCollector && !myCollectorVwr.IsNull()) 
-        myCollectorVwr->Update();
     }
   }
-  
 }
 
 //=======================================================================
@@ -764,27 +625,23 @@ void AIS_InteractiveContext::EraseAll(const Standard_Boolean PutInCollector,
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector,
-                                      const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::DisplayAll(const Standard_Boolean updateviewer)
 {
   if(!HasOpenedContext()){
-    Standard_Boolean FoundInCollector(Standard_False);
-    AIS_DisplayStatus aDStatus = OnlyFromCollector ? AIS_DS_Erased : AIS_DS_FullErased,TheStatus;
 
-    if(!HasOpenedContext()){
-      AIS_DataMapIteratorOfDataMapOfIOStatus ItM(myObjects);
-      
-      for(;ItM.More();ItM.Next()){
-        TheStatus = ItM.Value()->GraphicStatus();
-        if(TheStatus == aDStatus)
+    AIS_DisplayStatus aStatus;
+
+    if (!HasOpenedContext())
+    {
+      for (AIS_DataMapIteratorOfDataMapOfIOStatus ItM (myObjects); ItM.More(); ItM.Next())
+      {
+        aStatus = ItM.Value()->GraphicStatus();
+        if (aStatus == AIS_DS_Erased)
           Display(ItM.Key(),Standard_False);
-        if(TheStatus == AIS_DS_Erased)
-          FoundInCollector = Standard_True;
       }
-      if(updateviewer){
+      if(updateviewer)
+      {
         myMainVwr->Update();
-        if(FoundInCollector && !myCollectorVwr.IsNull())
-          myCollectorVwr->Update();
       }
     }
   }
@@ -799,20 +656,20 @@ void AIS_InteractiveContext::DisplayAll(const Standard_Boolean OnlyFromCollector
 void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer)
 {
   
-  if(!HasOpenedContext()){
+  if (!HasOpenedContext())
+  {
     Standard_Boolean found = Standard_False;
     Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
     Handle(AIS_InteractiveObject) iObj;
-    for (sel->Init();sel->More();sel->Next()) {
+    for (sel->Init(); sel->More(); sel->Next())
+    {
       iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
       Display(iObj,Standard_False);
       found = Standard_True;
     }
-    if(found && updateviewer) {
+    if (found && updateviewer)
+    {
       myMainVwr->Update();
-      if(!(myIsCollClosed && myCollectorVwr.IsNull())) 
-       
-        myCollectorVwr->Update();
     }
   }
 }
@@ -823,23 +680,22 @@ void AIS_InteractiveContext::DisplaySelected(const Standard_Boolean updateviewer
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::EraseSelected(const Standard_Boolean PutInCollector,
-                                           const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::EraseSelected(const Standard_Boolean updateviewer)
 {
-  
-  if(!HasOpenedContext()){
+  if (!HasOpenedContext())
+  {
     Standard_Boolean found = Standard_False;
     Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString());
     Handle(AIS_InteractiveObject) iObj;
-    for(sel->Init();sel->More();sel->Next()) {
+    for (sel->Init();sel->More();sel->Next())
+    {
       iObj = Handle(AIS_InteractiveObject)::DownCast(sel->Value());
-      Erase(iObj,Standard_False,PutInCollector);
+      Erase(iObj,Standard_False);
       found = Standard_True;
     }
-    if(found && updateviewer) {
+    if(found && updateviewer)
+    {
       myMainVwr->Update();
-      if(PutInCollector && !myCollectorVwr.IsNull())
-        myCollectorVwr->Update();
     }
   }
 }
@@ -959,11 +815,11 @@ void AIS_InteractiveContext::Remove(const Handle(AIS_InteractiveObject)& anIObj,
   }
   else
     {
-      Standard_Boolean  WasInCtx = myLocalContexts(myCurLocalIndex)->Remove(anIObj);
+      myLocalContexts(myCurLocalIndex)->Remove(anIObj);
       AIS_DataMapIteratorOfDataMapOfILC It(myLocalContexts);
       for (;It.More() ;It.Next()){
         if(It.Value()->AcceptErase())
-          WasInCtx = It.Value()->Remove(anIObj);
+          It.Value()->Remove(anIObj);
         
       }
       //      if(!WasInCtx)
@@ -1065,42 +921,28 @@ void AIS_InteractiveContext::Hilight(const Handle(AIS_InteractiveObject)& anIObj
 
   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
   if (!HasOpenedContext())
-    {
-      if(!myObjects.IsBound(anIObj)) return;
+  {
+    if(!myObjects.IsBound(anIObj)) return;
 
-      // CLE
-      // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
-      // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
-      Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
+    // CLE
+    // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
+    // const TColStd_ListOfInteger& LL = STATUS->DisplayedModes();
+    Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
 
-      // ENDCLE
-      STATUS->SetHilightStatus (Standard_True);
-      
-      switch(STATUS->GraphicStatus()){
-      case AIS_DS_Displayed:
-        {
-          Standard_Integer DispMode,HiMode,SelMode;
-          GetDefModes(anIObj,DispMode,HiMode,SelMode);
-//        if(!STATUS->IsDModeIn(HiMode)){
-//          myMainPM->Display(anIObj,HiMode);
-//        }
-          myMainPM->Highlight(anIObj,HiMode);
-          if(updateviewer) myMainVwr->Update();
-          break;
-        }
-      case AIS_DS_Erased:
-        {
-          Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
-          myCollectorPM->Highlight(anIObj,HiMode);
-          if(updateviewer) myCollectorVwr->Update();
-          break;
-        }
-      default:
-        break;
-      }
+    // ENDCLE
+    STATUS->SetHilightStatus (Standard_True);
+
+    if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+    {
+      Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
+      myMainPM->Highlight (anIObj, aHilightMode);
     }
+  }
   else
+  {
     myLocalContexts(myCurLocalIndex)->Hilight(anIObj);
+  }
+
   if(updateviewer) myMainVwr->Update();
 }
 //=======================================================================
@@ -1117,38 +959,23 @@ void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject
   if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this);
 
   if (!HasOpenedContext())
-    {
-      if(!myObjects.IsBound(anIObj)) return;
+  {
+    if(!myObjects.IsBound(anIObj)) return;
 
-      const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
-      STATUS->SetHilightStatus (Standard_True);
-      
-      switch(STATUS->GraphicStatus()){
-      case AIS_DS_Displayed:
-        {
-          Standard_Integer DispMode,HiMode,SelMode;
-          GetDefModes(anIObj,DispMode,HiMode,SelMode);
-//        if(!STATUS->IsDModeIn(HiMode)){
-//          myMainPM->Display(anIObj,HiMode);
-//        }
-          myMainPM->Color(anIObj,aCol,HiMode);
-          STATUS->SetHilightColor(aCol);
-          if(updateviewer) myMainVwr->Update();
-          break;
-        }
-      case AIS_DS_Erased:
-        {
-          Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
-          myCollectorPM->Color(anIObj,aCol,HiMode);
-          if(updateviewer) myCollectorVwr->Update();
-          break;
-        }
-      default:
-        break;  
-      }
+    const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
+    STATUS->SetHilightStatus (Standard_True);
+
+    if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+    {
+      Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
+      myMainPM->Color (anIObj, aCol, aHilightMode);
+      STATUS->SetHilightColor (aCol);
     }
+  }
   else
+  {
     myLocalContexts(myCurLocalIndex)->Hilight(anIObj,aCol);
+  }
   if(updateviewer) myMainVwr->Update();
 }
 
@@ -1162,37 +989,23 @@ void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIO
   if(anIObj.IsNull()) return;
 
   if (!HasOpenedContext())
-    {
-      if(!myObjects.IsBound(anIObj)) return;
+  {
+    if(!myObjects.IsBound(anIObj)) return;
 
-      const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
-      STATUS->SetHilightStatus (Standard_False);
-      STATUS->SetHilightColor(Quantity_NOC_WHITE);
-      
-      switch(STATUS->GraphicStatus()){
-      case AIS_DS_Displayed:
-        {
-          Standard_Integer DispMode,HiMode,SelMode;
-          GetDefModes(anIObj,DispMode,HiMode,SelMode);
-          myMainPM->Unhighlight(anIObj,HiMode);
-//        if(!STATUS->IsDModeIn(HiMode))
-//          myMainPM->Erase(anIObj,HiMode);
-          if(updateviewer) myMainVwr->Update();
-          break;
-        }
-      case AIS_DS_Erased:
-        {
-          Standard_Integer HiMode = anIObj->HasHilightMode()? anIObj->HilightMode():0;
-          myCollectorPM->Unhighlight(anIObj,HiMode);
-          if(updateviewer) myCollectorVwr->Update();
-          break;
-        }
-      default:
-        break;  
-      }
+    const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
+    STATUS->SetHilightStatus (Standard_False);
+    STATUS->SetHilightColor(Quantity_NOC_WHITE);
+
+    if (STATUS->GraphicStatus() == AIS_DS_Displayed)
+    {
+      Standard_Integer aHilightMode = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0;
+      myMainPM->Unhighlight (anIObj, aHilightMode);
     }
+  }
   else
+  {
     myLocalContexts(myCurLocalIndex)->Unhilight(anIObj);
+  }
   if(updateviewer) myMainVwr->Update();
 }
 
@@ -1272,21 +1085,6 @@ Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_Interactiv
   return Standard_False;
   
 }
-//=======================================================================
-//function : IsDisplayed
-//purpose  : 
-//=======================================================================
-
-Standard_Boolean AIS_InteractiveContext::IsInCollector(const Handle(AIS_InteractiveObject)& anIObj) const 
-{
-  if(anIObj.IsNull()) return Standard_False;
-
-
-  if(myObjects.IsBound(anIObj)) 
-    return (myObjects(anIObj)->GraphicStatus()==AIS_DS_Erased);
-  return Standard_False;
-}
-
 
 //=======================================================================
 //function : IsDisplayed
@@ -1322,25 +1120,16 @@ Standard_Integer AIS_InteractiveContext::
 DisplayPriority(const Handle(AIS_InteractiveObject)& anIObj) const 
 {
   if(anIObj.IsNull()) return -1;
-  if(myObjects.IsBound(anIObj)){
-    // CLE
-    // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
+
+  if (myObjects.IsBound(anIObj))
+  {
     Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
-    // ENDCLE
-    Standard_Integer DM,HM,SM ;
-    GetDefModes(anIObj,DM,HM,SM);
-    switch(STATUS->GraphicStatus()){
-    case AIS_DS_Displayed:
-      {
-        return myMainPM->DisplayPriority(anIObj,DM);
-        break;
-      }
-    case AIS_DS_Erased:
-      return myCollectorPM->DisplayPriority(anIObj,HM);
-    default:
-      break;
+    if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
+    {
+      Standard_Integer aDispMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() : 
+                                   (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
+      return myMainPM->DisplayPriority (anIObj, aDispMode);
     }
-    return 0;
   }
   return 0;
 }
@@ -1356,30 +1145,21 @@ void AIS_InteractiveContext::SetDisplayPriority(const Handle(AIS_InteractiveObje
     return;
   if(!anIObj->HasInteractiveContext())
     anIObj->SetContext(this);
-  if(myObjects.IsBound(anIObj)){
-    // CLE
-    // const Handle(AIS_GlobalStatus) & STATUS = myObjects(anIObj);
+  if(myObjects.IsBound(anIObj))
+  {
     Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
-    // ENDCLE
-    Standard_Integer DM,HM,SM ;
-    GetDefModes(anIObj,DM,HM,SM);
-    switch(STATUS->GraphicStatus()){
-    case AIS_DS_Displayed:
-      {
-        myMainPM->SetDisplayPriority(anIObj,DM,aPriority);
-        break;
-      }
-    case AIS_DS_Erased:
-      {
-        myCollectorPM->SetDisplayPriority(anIObj,HM,aPriority);
-        break;
-      }
-    default:
-      break;
+
+    if (STATUS->GraphicStatus() == AIS_DS_Displayed || STATUS->GraphicStatus() == AIS_DS_Erased)
+    {
+      Standard_Integer aDisplayMode = anIObj->HasDisplayMode() ? anIObj->DisplayMode() : 
+                                      (anIObj->AcceptDisplayMode(myDisplayMode)? myDisplayMode : 0);
+      myMainPM->SetDisplayPriority (anIObj, aDisplayMode, aPriority);
     }
   }
   else if (HasOpenedContext())
-    {myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);}
+  {
+    myLocalContexts(myCurLocalIndex)->SetDisplayPriority(anIObj,aPriority);
+  }
 }
 
 //=======================================================================
@@ -1409,7 +1189,7 @@ void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
                                        const Standard_Integer /*Sign*/,
                                       const Standard_Boolean updateviewer)
 {
-  Standard_Boolean found_viewer(Standard_False),found_coll(Standard_False);
+  Standard_Boolean found_viewer(Standard_False);
   // update
   for(AIS_DataMapIteratorOfDataMapOfIOStatus It(myObjects);It.More();It.Next()){
     // CLE
@@ -1422,24 +1202,16 @@ void AIS_InteractiveContext::Redisplay(const AIS_KindOfInteractive KOI,
 //        ((IO->Signature()==Sign)? Standard_True:Standard_False);
 #endif
       Redisplay(IO,Standard_False);
-      switch(It.Value()->GraphicStatus()){
-      case AIS_DS_Displayed:
+      if (It.Value()->GraphicStatus() == AIS_DS_Displayed)
+      {
         found_viewer = Standard_True;
-        break;
-      case AIS_DS_Erased:
-        found_coll = Standard_True;
-        break;
-      default:
-        break;
       }
     }
   }
   // update viewer...
-  if(updateviewer){
-    if(found_viewer)
-      myMainVwr->Update();
-    if(found_coll)
-      myCollectorVwr->Update();
+  if(updateviewer && found_viewer)
+  {
+    myMainVwr->Update();
   }
 }
 
@@ -1455,26 +1227,16 @@ void AIS_InteractiveContext::RecomputePrsOnly(const Handle(AIS_InteractiveObject
 {
   if(anIObj.IsNull()) return;
   anIObj->Update(allmodes);
-  
-  if(updateviewer)  {
-    if(HasOpenedContext())
-      myMainVwr->Update();
-    else{
-      if(myObjects.IsBound(anIObj)){
-        switch(myObjects(anIObj)->GraphicStatus()){
-        case AIS_DS_Displayed:
-          myMainVwr->Update();
-          break;
-        case AIS_DS_Erased:
-          {
-            if(!myCollectorVwr.IsNull())
-              myCollectorVwr->Update();
-          }
-        default:
-          break;
-        }
-      }
-    }
+
+  if (!updateviewer)
+  {
+    return;
+  }
+
+  if (HasOpenedContext() ||
+     (myObjects.IsBound(anIObj) && myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed))
+  {
+    myMainVwr->Update();
   }
 }
 //=======================================================================
@@ -1493,24 +1255,14 @@ void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_Interactive
   ActivatedModes(anIObj,LI);
   if(!HasOpenedContext()){
     if(!myObjects.IsBound(anIObj)) return;
-    switch(myObjects(anIObj)->GraphicStatus())
+
+    if (myObjects(anIObj)->GraphicStatus() == AIS_DS_Displayed)
+    {
+      for(Lit.Initialize(LI);Lit.More();Lit.Next())
       {
-      case AIS_DS_Displayed:
-        {
-          for(Lit.Initialize(LI);Lit.More();Lit.Next())
-            mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
-          break;
-        }
-      case AIS_DS_Erased:
-        {
-          for(Lit.Initialize(LI);Lit.More();Lit.Next())
-            mgrSelector->Activate(anIObj,Lit.Value(),myCollectorSel);
-          
-          break;
-        }
-      default:
-        break;
+        mgrSelector->Activate(anIObj,Lit.Value(),myMainSel);
       }
+    }
   }
 }
 
@@ -1518,45 +1270,44 @@ void AIS_InteractiveContext::RecomputeSelectionOnly(const Handle(AIS_Interactive
 //function : Update
 //purpose  : 
 //=======================================================================
-
-void AIS_InteractiveContext::Update(const Handle(AIS_InteractiveObject)& anIObj,
-                                    const Standard_Boolean updateviewer)
+void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj,
+                                     const Standard_Boolean theUpdateViewer)
 {
-  if(anIObj.IsNull()) return;
+  if (theIObj.IsNull())
+  {
+    return;
+  }
 
-  
+  TColStd_ListOfInteger aListOfFlaggedPrsModes;
+  theIObj->ToBeUpdated (aListOfFlaggedPrsModes);
 
-  TColStd_ListOfInteger LL;
-  anIObj->ToBeUpdated(LL);
-  TColStd_ListIteratorOfListOfInteger ITI(LL);
-  Standard_Boolean wasupdated(Standard_False);
-  
-  for (;ITI.More();ITI.Next()){
-    anIObj->Update(ITI.Value(),Standard_False);
-    wasupdated = Standard_True;
+  TColStd_ListIteratorOfListOfInteger aPrsModesIt (aListOfFlaggedPrsModes);
+  for ( ; aPrsModesIt.More(); aPrsModesIt.Next())
+  {
+    theIObj->Update (aPrsModesIt.Value(), Standard_False);
   }
-  
-  if(wasupdated)
-    mgrSelector->Update(anIObj);
-  
-  if(updateviewer){
-    if(!myObjects.IsBound(anIObj)) return;
-    switch(myObjects(anIObj)->GraphicStatus()){
-    case AIS_DS_Displayed:
-    case AIS_DS_Temporary:
-      myMainVwr->Update();
-      break;
-    case AIS_DS_Erased:
-      myCollectorVwr->Update();
-      break;
-    default:
-      break;
+
+  mgrSelector->Update(theIObj);
+
+  if (theUpdateViewer)
+  {
+    if (!myObjects.IsBound (theIObj))
+    {
+      return;
+    }
+
+    switch (myObjects (theIObj)->GraphicStatus())
+    {
+      case AIS_DS_Displayed:
+      case AIS_DS_Temporary:
+        myMainVwr->Update();
+        break;
+      default:
+        break;
     }
   }
 }
 
-
-
 //=======================================================================
 //function : SetLocation
 //purpose  : 
@@ -1650,8 +1401,8 @@ void AIS_InteractiveContext::SetDeviationAngle(const Standard_Real anAngle)
 
 Standard_Real AIS_InteractiveContext::DeviationAngle() const
 {
-  return M_PI/180.0e0 ;
-  //  return myDefaultDrawer->DeviationAngle();
+  //return M_PI/180.0e0 ;
+    return myDefaultDrawer->DeviationAngle();
 }
 
 //=======================================================================
@@ -1754,7 +1505,7 @@ void AIS_InteractiveContext::SetDisplayMode(const AIS_DisplayMode aMode,
           STATUS->AddDisplayMode(aMode);
           
           if(STATUS->GraphicStatus()== AIS_DS_Displayed){
-            myMainPM->Erase(anObj, myDisplayMode);
+            myMainPM->SetVisibility (anObj, myDisplayMode, Standard_False);
             myMainPM->Display(anObj, aMode);
             if(STATUS->IsSubIntensityOn())
               myMainPM->Color(anObj,mySubIntensity,aMode);
@@ -1784,33 +1535,12 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
     
     if(!myObjects.IsBound(anIObj)) 
       anIObj->SetDisplayMode(aMode);
-#ifdef BUC60632
     else if( anIObj->AcceptDisplayMode(aMode) ) 
-#else
-    else
-#endif
     {
       // CLE
       // const Handle(AIS_GlobalStatus)& STATUS = myObjects(anIObj);
       Handle(AIS_GlobalStatus) STATUS = myObjects(anIObj);
       // ENDCLE
-#ifndef OCC4373      
-      // the interactive object has no mode : OldMode = Mode Session
-      //                    already has a mode : OldMode = old mode Propre
-
-      Standard_Integer OldMode = anIObj->HasDisplayMode() ?  anIObj->DisplayMode(): myDisplayMode;
-      
-      if(STATUS->IsDModeIn(OldMode))
-        STATUS->RemoveDisplayMode(OldMode);
-      STATUS->AddDisplayMode(aMode);
-      
-      if(STATUS->GraphicStatus()==AIS_DS_Displayed){
-        if(aMode!=OldMode ){
-          if(myMainPM->IsHighlighted(anIObj,OldMode))
-            myMainPM->Unhighlight(anIObj,OldMode);
-          
-          myMainPM->Erase(anIObj,OldMode);
-#else
       // SAN : erase presentations for all display modes different from <aMode>
       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
         TColStd_ListOfInteger aModesToRemove;
@@ -1823,7 +1553,7 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
             aModesToRemove.Append(OldMode);
             if(myMainPM->IsHighlighted(anIObj,OldMode))
               myMainPM->Unhighlight(anIObj,OldMode);
-            myMainPM->Erase(anIObj,OldMode);
+            myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
           }
         }
 
@@ -1832,8 +1562,7 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
 
         if(!STATUS->IsDModeIn(aMode))
           STATUS->AddDisplayMode(aMode);
-#endif
-        
+
         myMainPM->Display(anIObj,aMode);
         Standard_Integer DM,HM,SM;
         GetDefModes(anIObj,DM,HM,SM);
@@ -1847,9 +1576,6 @@ void AIS_InteractiveContext::SetDisplayMode(const Handle(AIS_InteractiveObject)&
           myMainVwr->Viewer()->SetTransparency(Standard_True);
         
         if(updateviewer) myMainVwr->Update();
-#ifndef OCC4373 
-        }
-#endif
       }
       anIObj->SetDisplayMode(aMode);
     }
@@ -1881,7 +1607,7 @@ UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
       if(STATUS->GraphicStatus()==AIS_DS_Displayed){
         if(myMainPM->IsHighlighted(anIObj,OldMode))
           myMainPM->Unhighlight(anIObj,OldMode);
-        myMainPM->Erase(anIObj,OldMode);
+        myMainPM->SetVisibility (anIObj, OldMode, Standard_False);
         myMainPM->Display(anIObj,myDisplayMode);
         Standard_Integer DM,HM,SM;
         GetDefModes(anIObj,DM,HM,SM);
@@ -1903,15 +1629,13 @@ UnsetDisplayMode(const Handle(AIS_InteractiveObject)& anIObj,
 //purpose  : 
 //=======================================================================
 
-#ifdef GER61351
 void AIS_InteractiveContext::SetCurrentFacingModel(
                         const Handle(AIS_InteractiveObject)& anIObj,
-                        const Aspect_TypeOfFacingModel aModel) { 
- if (  !anIObj.IsNull ()  ) {
-   anIObj->SetCurrentFacingModel(aModel);
- }
+                        const Aspect_TypeOfFacingModel aModel)
+{
+  if (  !anIObj.IsNull ()  )
+    anIObj->SetCurrentFacingModel(aModel);
 }
-#endif
 
 //=======================================================================
 //function : SetColor
@@ -1921,7 +1645,6 @@ void AIS_InteractiveContext::SetCurrentFacingModel(
 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, 
                                      const Quantity_NameOfColor aColor,
                                      const Standard_Boolean updateviewer)
-#ifdef GER61351
 {
   SetColor(anIObj,Quantity_Color(aColor),updateviewer);
 }
@@ -1929,7 +1652,6 @@ void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIOb
 void AIS_InteractiveContext::SetColor(const Handle(AIS_InteractiveObject)& anIObj, 
                                      const Quantity_Color &aColor,
                                      const Standard_Boolean updateviewer)
-#endif
 {
   if(anIObj.IsNull()) return ;
  
@@ -2281,13 +2003,11 @@ Quantity_NameOfColor AIS_InteractiveContext::Color(const Handle(AIS_InteractiveO
   return anIObj->Color();
 }
 
-#ifdef GER61351
 void AIS_InteractiveContext::Color(const Handle(AIS_InteractiveObject)& anIObj,
-                                             Quantity_Color &aColor) const 
+                                   Quantity_Color &aColor) const
 {
   anIObj->Color(aColor);
 }
-#endif
 
 //=======================================================================
 //function : Width
@@ -2491,46 +2211,6 @@ void AIS_InteractiveContext::UnsetTransparency(const Handle(AIS_InteractiveObjec
     UpdateCurrentViewer();
 }
 
-//=======================================================================
-//function : SetDegenerateModel
-//purpose  : 
-//=======================================================================
-
-#ifdef G003
-void AIS_InteractiveContext :: SetDegenerateModel (
-                          const Handle( AIS_InteractiveObject )& anObject,
-                          const Aspect_TypeOfDegenerateModel   aModel,
-                          const Quantity_Ratio                 aRatio
-                               ) {
- if (  !anObject.IsNull ()  ) {
-  if (  !anObject -> HasInteractiveContext ()  ) 
-                                anObject -> SetContext ( this );
-  anObject->SetDegenerateModel(aModel,aRatio);
-
- }  // end if
-}  // end AIS_InteractiveContext :: SetDegenerateModel
-
-void AIS_InteractiveContext :: SetDegenerateModel (
-                           const Aspect_TypeOfDegenerateModel aModel,
-                           const Quantity_Ratio            aRatio
-                               ) {
-
- AIS_DataMapIteratorOfDataMapOfIOStatus it ( myObjects );
-
- while (  it.More ()  ) {
-
-  Handle( AIS_InteractiveObject ) obj = it.Key ();
-
-  obj->SetDegenerateModel(aModel,aRatio);
-
-  it.Next ();
-
- }  // end while
-
-}  // end AIS_InteractiveContext :: SetDegenerateModel
-#endif
-
-#ifdef IMP140200
 //=======================================================================
 //function : SetSelectedAspect
 //purpose  : 
@@ -2538,7 +2218,8 @@ void AIS_InteractiveContext :: SetDegenerateModel (
 void AIS_InteractiveContext::SetSelectedAspect(
                                 const Handle(Prs3d_BasicAspect)& anAspect,
                                 const Standard_Boolean globalChange,
-                                const Standard_Boolean updateViewer) {
+                                const Standard_Boolean updateViewer)
+{
   if( !HasOpenedContext() ) {
     Standard_Boolean found = Standard_False;
     Handle(AIS_Selection) sel = 
@@ -2551,12 +2232,9 @@ void AIS_InteractiveContext::SetSelectedAspect(
     }
     if( found && updateViewer) {
       myMainVwr->Update();
-      if( !(myIsCollClosed && myCollectorVwr.IsNull()) ) 
-                                        myCollectorVwr->Update();
     }
   }
 }
-#endif
 
 //=======================================================================
 //function : SetLocalAttributes
@@ -2615,11 +2293,6 @@ void AIS_InteractiveContext::Status(const Handle(AIS_InteractiveObject)& anIObj,
         astatus +="\t| -->Erased\n";
         break;
       }
-    case AIS_DS_FullErased:
-      {
-        astatus +="\t| -->Full Erased\n";
-        break;
-      }
     default:
       break;
     }
@@ -2674,8 +2347,7 @@ void AIS_InteractiveContext::GetDefModes(const Handle(AIS_InteractiveObject)& an
 //=======================================================================
 
 void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& anIObj, 
-                                         const Standard_Boolean updateviewer, 
-                                         const Standard_Boolean PutInCollector)
+                                         const Standard_Boolean updateviewer)
 {
   if(anIObj.IsNull()) return ;
   if(!myObjects.IsBound(anIObj)) return;
@@ -2691,30 +2363,16 @@ void AIS_InteractiveContext::EraseGlobal(const Handle(AIS_InteractiveObject)& an
     for(;ItL.More();ItL.Next()){
       if(myMainPM->IsHighlighted(anIObj,ItL.Value()))
         myMainPM->Unhighlight(anIObj,ItL.Value());
-      myMainPM->Erase(anIObj,ItL.Value());
+      myMainPM->SetVisibility (anIObj, ItL.Value(), Standard_False);
     }
     if(IsCurrent(anIObj) && !STATUS->IsDModeIn(Dmode))
-      myMainPM->Erase(anIObj,Dmode);
+      myMainPM->SetVisibility (anIObj, Dmode, Standard_False);
     
     for(ItL.Initialize(STATUS->SelectionModes());ItL.More();ItL.Next())
       mgrSelector->Deactivate(anIObj,ItL.Value(),myMainSel);
     if(updateviewer) myMainVwr->Update();
   }
-  if(PutInCollector && !myCollectorPM.IsNull()){
-    myCollectorPM->Display(anIObj,Dmode);
-#ifdef OCC328
-    Standard_Integer SMode = anIObj->SelectionMode();
-    mgrSelector->Activate(anIObj,SMode,myCollectorSel);
-#else
-    mgrSelector->Activate(anIObj,0,myCollectorSel);
-#endif
-    if(STATUS->IsHilighted())
-      myCollectorPM->Highlight(anIObj,Dmode);
-    STATUS->SetGraphicStatus(AIS_DS_Erased);
-    if(updateviewer) myCollectorVwr->Update();
-  }
-  else
-    STATUS->SetGraphicStatus(AIS_DS_FullErased);
+  STATUS->SetGraphicStatus(AIS_DS_Erased);
   
 }
 
@@ -2765,8 +2423,6 @@ void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& an
 
   if(myLastinMain == anIObj)
     myLastinMain.Nullify();
-  if(myLastinColl == anIObj)
-    myLastinColl.Nullify();
 
   if(myLastPicked == anIObj)
     myLastPicked.Nullify();
@@ -2775,26 +2431,11 @@ void AIS_InteractiveContext::ClearGlobal(const Handle(AIS_InteractiveObject)& an
   // to avoid memory leaks
   mgrSelector->Remove(anIObj);
 
-  switch(STATUS->GraphicStatus()){
-  case AIS_DS_Erased:
-     { 
-       Standard_Integer DM = anIObj->HasHilightMode() ? anIObj->HilightMode() : 0; 
-       if(STATUS->IsHilighted()){
-         myCollectorPM->Unhighlight(anIObj,DM);
-       }
-       myCollectorPM->Erase(anIObj,DM);
-       myCollectorPM->Clear(anIObj,DM);
-       if(updateviewer) myCollectorVwr->Update();
-       break;
-     }
-   case AIS_DS_Displayed:
-     {
-       if(updateviewer) myMainVwr->Update();
-       break;
-     }
-   default:
-     break;
-   }
+  if (updateviewer && (STATUS->GraphicStatus() == AIS_DS_Displayed))
+  {
+    myMainVwr->Update();
+  }
+
   myObjects.UnBind(anIObj);
   
 }
@@ -2821,17 +2462,8 @@ void AIS_InteractiveContext::ClearGlobalPrs(const Handle(AIS_InteractiveObject)&
     myMainPM->Clear(anIObj,aMode);
   }
   
-  if(STATUS->GraphicStatus()== AIS_DS_Erased)
-    {
-      if(DM==aMode){
-        if(STATUS->IsHilighted())
-          myCollectorPM->Unhighlight(anIObj,aMode);
-        myCollectorPM->Erase(anIObj,DM);
-        myCollectorPM->Clear(anIObj,DM);
-      }
-      if(updateviewer) myCollectorVwr->Update();
-    }
-  else if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
+
+  if(STATUS->GraphicStatus()==AIS_DS_Displayed && updateviewer)
     myMainVwr->Update();
 }
 
@@ -2961,7 +2593,32 @@ void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObje
 {
 }
 
-#ifdef BUC60688
+//=======================================================================
+//function : SetSensitivityMode
+//purpose  : 
+//=======================================================================
+
+void AIS_InteractiveContext::SetSensitivityMode(const StdSelect_SensitivityMode aMode) {
+
+  if( HasOpenedContext() )
+        myLocalContexts(myCurLocalIndex)->SetSensitivityMode(aMode);
+  else {
+    myMainSel->SetSensitivityMode(aMode);
+  }
+}
+
+//=======================================================================
+//function : SensitivityMode
+//purpose  : 
+//=======================================================================
+
+StdSelect_SensitivityMode AIS_InteractiveContext::SensitivityMode() const {
+
+  if( HasOpenedContext() )
+        return myLocalContexts(myCurLocalIndex)->SensitivityMode();
+  return myMainSel->SensitivityMode();
+}
+
 //=======================================================================
 //function : SetSensitivity
 //purpose  : 
@@ -2973,25 +2630,46 @@ void AIS_InteractiveContext::SetSensitivity(const Standard_Real aPrecision) {
         myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
   else {
     myMainSel->SetSensitivity(aPrecision);
-    if( !myCollectorSel.IsNull() ) myCollectorSel->SetSensitivity(aPrecision);
   }
 }
 
 //=======================================================================
-//function : SetSensitivity
+//function : Sensitivity
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::SetSensitivity(const Standard_Integer aPrecision) {
+Standard_Real AIS_InteractiveContext::Sensitivity() const {
 
   if( HasOpenedContext() )
-        myLocalContexts(myCurLocalIndex)->SetSensitivity(aPrecision);
+        return myLocalContexts(myCurLocalIndex)->Sensitivity();
+  return myMainSel->Sensitivity();
+}
+
+//=======================================================================
+//function : SetPixelTolerance
+//purpose  : 
+//=======================================================================
+
+void AIS_InteractiveContext::SetPixelTolerance(const Standard_Integer aPrecision) {
+
+  if( HasOpenedContext() )
+        myLocalContexts(myCurLocalIndex)->SetPixelTolerance(aPrecision);
   else {
-    myMainSel->Set(aPrecision);
-    if( !myCollectorSel.IsNull() ) myCollectorSel->Set(aPrecision);
+    myMainSel->SetPixelTolerance(aPrecision);
   }
 }
-#endif
+
+//=======================================================================
+//function : PixelTolerance
+//purpose  : 
+//=======================================================================
+
+Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
+
+  if( HasOpenedContext() )
+        return myLocalContexts(myCurLocalIndex)->PixelTolerance();
+  return myMainSel->PixelTolerance();
+}
 
 //=======================================================================
 //function : IsInLocal
@@ -3047,11 +2725,7 @@ void AIS_InteractiveContext::InitAttributes()
   HLA->SetTypeOfLine(Aspect_TOL_DASH);
 
   // tolerance to 4 pixels...
-#ifdef BUC60688
-  SetSensitivity();
-#else
-  myMainSel->Set(4);
-#endif
+  SetPixelTolerance();
 
   // Customizing the drawer for trihedrons and planes...
 
@@ -3147,3 +2821,49 @@ Standard_Boolean AIS_InteractiveContext::GetAutoActivateSelection() const
 {
   return myIsAutoActivateSelMode;
 }
+
+//=======================================================================
+//function : SetZLayer
+//purpose  : 
+//=======================================================================
+
+void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj,
+                                        const Standard_Integer theLayerId)
+{
+  if (theIObj.IsNull ())
+    return;
+
+  if (myObjects.IsBound (theIObj))
+  {
+    if (myObjects (theIObj)->GraphicStatus() == AIS_DS_Displayed || myObjects (theIObj)->GraphicStatus() == AIS_DS_Erased)
+    {
+      theIObj->SetZLayer (myMainPM, theLayerId);
+    }
+  }
+  else if (HasOpenedContext ())
+  {
+    myLocalContexts (myCurLocalIndex)->SetZLayer (theIObj, theLayerId);
+  }
+}
+
+//=======================================================================
+//function : GetZLayer
+//purpose  : 
+//=======================================================================
+
+Standard_Integer AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const
+{
+  if (theIObj.IsNull ())
+    return -1;
+
+  if (myObjects.IsBound (theIObj))
+  {
+    return theIObj->GetZLayer (myMainPM);
+  }
+  else if (HasOpenedContext ())
+  {
+    return myLocalContexts (myCurLocalIndex)->GetZLayer (theIObj);
+  }
+
+  return -1;
+}