0025180: Visualization - Homogeneous transformation API in TKV3d
[occt.git] / src / AIS / AIS_InteractiveContext_2.cxx
index 0b58c79..442b39d 100644 (file)
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <AIS_InteractiveContext.jxx>
 
-#include <AIS_LocalContext.hxx>
-
-#include <AIS_GlobalStatus.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
 #include <AIS_DataMapIteratorOfDataMapOfILC.hxx>
-#include <Graphic3d_StructureManager.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_MapOfStructure.hxx>
-#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
+#include <AIS_GlobalStatus.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LocalContext.hxx>
 #include <AIS_Selection.hxx>
-
+#include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
+#include <Graphic3d_MapOfStructure.hxx>
+#include <Graphic3d_Structure.hxx>
+#include <Graphic3d_StructureManager.hxx>
+#include <Prs3d_BasicAspect.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Quantity_Color.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_OrFilter.hxx>
+#include <SelectMgr_SelectionManager.hxx>
+#include <Standard_Transient.hxx>
 #include <StdSelect_ViewerSelector3d.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Viewer.hxx>
 
 //=======================================================================
 //function : OpenLocalContext
 //purpose  : 
 //=======================================================================
-
 Standard_Integer AIS_InteractiveContext::
 OpenLocalContext(const Standard_Boolean UseDisplayedObjects, 
                  const Standard_Boolean AllowShapeDecomposition, 
@@ -44,10 +55,12 @@ OpenLocalContext(const Standard_Boolean UseDisplayedObjects,
 {
 
   // the entities eventually detected just before the context was opened are unhighlighted...
-  if(!IsCurrent(myLastPicked)){
+  if(!IsSelected(myLastPicked)){
     if(!myLastPicked.IsNull()){
-      Standard_Integer HiMod = myLastPicked->HasHilightMode()?myLastPicked->HilightMode():0;
-      myMainPM->Unhighlight(myLastPicked,HiMod);
+      const Handle(AIS_InteractiveObject) aLastPickedAIS =
+        Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
+      Standard_Integer HiMod = aLastPickedAIS->HasHilightMode()?aLastPickedAIS->HilightMode():0;
+      myMainPM->Unhighlight (aLastPickedAIS, HiMod);
     }}
   
   if(!mylastmoveview.IsNull()){
@@ -135,7 +148,10 @@ void AIS_InteractiveContext::CloseLocalContext(const Standard_Integer Index,
    }
    else if(debugmode)
      cout<<"a No Current Local Context WasClosed"<<endl;
-   
+
+   // restore activated selections of current local context
+   myLocalContexts (myCurLocalIndex)->RestoreActivatedModes();
+
    if(debugmode) cout<<"Index Of CurrentLocalContext:"<<myCurLocalIndex<<endl;
    
  }
@@ -349,12 +365,10 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
     GB->SubIntensityOn();
     Standard_Boolean UpdMain(Standard_False);
     
-    for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
-      if (GB->GraphicStatus()==AIS_DS_Displayed)
-      {
-        myMainPM->Color(anIObj,mySubIntensity,It.Value());
-        UpdMain = Standard_True;
-      }
+    if (GB->GraphicStatus() == AIS_DS_Displayed)
+    {
+      myMainPM->Color (anIObj, mySubIntensity, GB->DisplayMode());
+      UpdMain = Standard_True;
     }
     if(updateviewer){
       if(UpdMain)
@@ -365,9 +379,7 @@ SubIntensityOn(const Handle(AIS_InteractiveObject)& anIObj,
     if(myObjects.IsBound(anIObj)){
       const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
       STAT->SubIntensityOn();
-      TColStd_ListIteratorOfListOfInteger ItL;
-      for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
-        myMainPM->Color(anIObj,mySubIntensity,ItL.Value());
+      myMainPM->Color (anIObj, mySubIntensity, STAT->DisplayMode());
     }
     else
       myLocalContexts(myCurLocalIndex)->SubIntensityOn(anIObj);
@@ -393,17 +405,15 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
     GB->SubIntensityOff();
     Standard_Boolean UpdMain(Standard_False);
     
-    for(TColStd_ListIteratorOfListOfInteger It(GB->DisplayedModes());It.More();It.Next()){
-      if(GB->GraphicStatus()==AIS_DS_Displayed)
-      {
-        myMainPM->Unhighlight(anIObj,It.Value());
-        UpdMain = Standard_True;
-      }
+    if(GB->GraphicStatus() == AIS_DS_Displayed)
+    {
+      myMainPM->Unhighlight (anIObj, GB->DisplayMode());
+      UpdMain = Standard_True;
     }
     
     Standard_Integer DM,HM,SM;
     GetDefModes(anIObj,DM,HM,SM);
-    if(AIS_Selection::IsSelected(anIObj))
+    if(IsSelected(anIObj))
       myMainPM->Highlight(anIObj,HM);
     
     if(updateviewer){
@@ -415,9 +425,7 @@ SubIntensityOff(const Handle(AIS_InteractiveObject)& anIObj,
     if(myObjects.IsBound(anIObj)){
       const Handle(AIS_GlobalStatus)& STAT = myObjects(anIObj);
       STAT->SubIntensityOff();
-      TColStd_ListIteratorOfListOfInteger ItL;
-      for (ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
-        myMainPM->Unhighlight(anIObj,ItL.Value());
+      myMainPM->Unhighlight (anIObj, STAT->DisplayMode());
       if(STAT->IsHilighted())
         Hilight(anIObj);
     }
@@ -440,14 +448,12 @@ void AIS_InteractiveContext::SubIntensityOn(const Standard_Boolean updateviewer)
   if(!HasOpenedContext()) return;
   
   AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
-  TColStd_ListIteratorOfListOfInteger ItM;
   for(;It.More();It.Next()){
     const Handle(AIS_GlobalStatus)& STAT = It.Value();
     if(STAT->GraphicStatus()==AIS_DS_Displayed)
       {
         STAT->SubIntensityOn();
-        for(ItM.Initialize(STAT->DisplayedModes());ItM.More();ItM.Next())
-          {myMainPM->Color(It.Key(),mySubIntensity,ItM.Value());}
+        myMainPM->Color (It.Key(), mySubIntensity, STAT->DisplayMode());
       }
   }
   if(updateviewer) myMainVwr->Update();
@@ -462,13 +468,11 @@ void AIS_InteractiveContext::SubIntensityOff(const Standard_Boolean updateviewer
   if(!HasOpenedContext()) return;
 
   AIS_DataMapIteratorOfDataMapOfIOStatus It (myObjects);
-  TColStd_ListIteratorOfListOfInteger ItL;
   for(;It.More();It.Next()){
     const Handle(AIS_GlobalStatus)& STAT = It.Value();
     if(STAT->IsSubIntensityOn())
       STAT->SubIntensityOff();
-    for(ItL.Initialize(STAT->DisplayedModes());ItL.More();ItL.Next())
-      myMainPM->Unhighlight(It.Key());
+    myMainPM->Unhighlight (It.Key());
   }
 
   if(updateviewer) myMainVwr->Update();
@@ -674,7 +678,7 @@ Standard_Integer AIS_InteractiveContext::PurgeDisplay()
 //=======================================================================
 Standard_Integer AIS_InteractiveContext::PurgeViewer(const Handle(V3d_Viewer)& Vwr)
 {
-  Handle(Graphic3d_StructureManager) GSM = Vwr->Viewer();
+  Handle(Graphic3d_StructureManager) GSM = Vwr->StructureManager();
   Standard_Integer NbCleared(0);
   Graphic3d_MapOfStructure SOS;
   GSM->DisplayedStructures(SOS);
@@ -739,7 +743,7 @@ Standard_Boolean AIS_InteractiveContext::ImmediateAdd (const Handle(AIS_Interact
 Standard_Boolean AIS_InteractiveContext::EndImmediateDraw (const Handle(V3d_View)& theView)
 {
   return HasOpenedContext()
-      && myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView);
+      && myLocalContexts (myCurLocalIndex)->EndImmediateDraw (theView->Viewer());
 }
 
 //=======================================================================
@@ -761,7 +765,7 @@ Standard_Boolean AIS_InteractiveContext::EndImmediateDraw()
   }
 
   Handle(V3d_View) aView = myMainVwr->ActiveView();
-  return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (aView);
+  return myLocalContexts (myCurLocalIndex)->EndImmediateDraw (aView->Viewer());
 }
 
 
@@ -784,8 +788,7 @@ void AIS_InteractiveContext::ResetOriginalState(const Standard_Boolean updatevie
       upd_main = Standard_True;
       
       // part display...
-      for(itl.Initialize(STAT->DisplayedModes());itl.More();itl.Next())
-        myMainPM->Display(iobj,itl.Value());
+      myMainPM->Display (iobj, STAT->DisplayMode());
       if(STAT->IsHilighted()){
         if(STAT->HilightColor()!=Quantity_NOC_WHITE)
           HilightWithColor(iobj,STAT->HilightColor(),Standard_False);