0023649: Visualization, AIS_LocalContext - make highlighting of already selected...
[occt.git] / src / AIS / AIS_InteractiveContext.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 85547fd..46a3262
@@ -1,22 +1,18 @@
 // Created on: 1997-01-17
 // Created by: Robert COUBLANC
 // Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// 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)
 
 // 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");
@@ -129,7 +121,7 @@ mgrSelector(new SelectMgr_SelectionManager()),
 myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())),
 myMainVwr(MainViewer),
 myMainSel(new StdSelect_ViewerSelector3d()),
-myToHilightSelected( Standard_False ),
+myToHilightSelected( Standard_True ),
 myFilters(new SelectMgr_OrFilter()),
 myDefaultDrawer(new Prs3d_Drawer()),
 myDefaultColor(Quantity_NOC_GOLDENROD),
@@ -149,6 +141,9 @@ myIsAutoActivateSelMode( Standard_True )
 
 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() ) )
@@ -243,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()){
@@ -821,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)
@@ -1276,42 +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;
-    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  : 
@@ -2584,7 +2580,7 @@ Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject&, const Standard_Integer )
+void AIS_InteractiveContext::SetSelectionMode(const Handle(AIS_InteractiveObject)&, const Standard_Integer )
 {
 }
 
@@ -2593,7 +2589,7 @@ void AIS_InteractiveContext::SetSelectionMode(const Handle_AIS_InteractiveObject
 //purpose  : 
 //=======================================================================
 
-void AIS_InteractiveContext::UnsetSelectionMode(const Handle_AIS_InteractiveObject&)
+void AIS_InteractiveContext::UnsetSelectionMode(const Handle(AIS_InteractiveObject)&)
 {
 }
 
@@ -2680,7 +2676,7 @@ Standard_Integer AIS_InteractiveContext::PixelTolerance() const {
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle_AIS_InteractiveObject& anIObj,
+Standard_Boolean AIS_InteractiveContext::IsInLocal(const Handle(AIS_InteractiveObject)& anIObj,
                                                    Standard_Integer& TheIndex) const 
 {
   if(anIObj.IsNull()) return Standard_False;