0021306: Visualization, AIS_InteractiveContext - revise DisplayedModes() semantics
authorisk <isk@opencascade.com>
Tue, 2 Aug 2016 11:46:13 +0000 (14:46 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 11 Aug 2016 08:39:53 +0000 (11:39 +0300)
Remove the AIS_InteractiveContext::DisplayedModes() method.
Remove list of active display modes from AIS_GlobalStatus.

src/AIS/AIS_GlobalStatus.cxx
src/AIS/AIS_GlobalStatus.hxx
src/AIS/AIS_GlobalStatus.lxx
src/AIS/AIS_InteractiveContext.cxx
src/AIS/AIS_InteractiveContext.hxx
src/AIS/AIS_InteractiveContext_2.cxx

index ee999f7..04bc386 100644 (file)
@@ -15,6 +15,7 @@
 // commercial license or contractual agreement.
 
 
+#include <AIS_DisplayMode.hxx>
 #include <AIS_GlobalStatus.hxx>
 #include <Standard_Type.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
@@ -23,6 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus,MMgt_TShared)
 
 AIS_GlobalStatus::AIS_GlobalStatus():
 myStatus(AIS_DS_None),
+myDispMode(AIS_WireFrame),
 myLayerIndex(0),
 myIsHilit(Standard_False),
 myHiCol(Quantity_NOC_WHITE),
@@ -37,28 +39,15 @@ AIS_GlobalStatus::AIS_GlobalStatus(const AIS_DisplayStatus DS,
                                   const Quantity_NameOfColor TheHiCol,
                                   const Standard_Integer Layer):
 myStatus(DS),
+myDispMode(DMode),
 myLayerIndex(Layer),
 myIsHilit(Standard_False),
 myHiCol(TheHiCol),
 mySubInt(Standard_False)
 {
-  myDispModes.Append(DMode);
   mySelModes.Append(SMode);
 }
 
-void AIS_GlobalStatus::RemoveDisplayMode(const Standard_Integer aMode)
-{
-  TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
-  for (; anIt.More(); anIt.Next())
-  {
-    if (anIt.Value() == aMode)
-    {
-      myDispModes.Remove (anIt);
-      return;
-    }
-  }
-}
-
 void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode)
 {
   TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
@@ -77,19 +66,6 @@ void AIS_GlobalStatus::ClearSelectionModes()
   mySelModes.Clear();
 }
 
-Standard_Boolean AIS_GlobalStatus::IsDModeIn(const Standard_Integer aMode) const 
-{
-  TColStd_ListIteratorOfListOfInteger anIt (myDispModes);
-  for (; anIt.More(); anIt.Next())
-  {
-    if (anIt.Value() == aMode)
-    {
-      return Standard_True;
-    }
-  }
-  return Standard_False;
-}
-
 Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const 
 {
   TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
index 9c5f8e5..18e44a2 100644 (file)
@@ -50,9 +50,13 @@ public:
   
     void SetGraphicStatus (const AIS_DisplayStatus aStat);
   
-    void AddDisplayMode (const Standard_Integer aMode);
-  
     void AddSelectionMode (const Standard_Integer aMode);
+
+    //! Sets display mode.
+    void SetDisplayMode (const Standard_Integer theMode);
+
+    //! Returns the display mode.
+    Standard_Integer DisplayMode() const;
   
     void SetLayerIndex (const Standard_Integer AnIndex);
   
@@ -66,18 +70,12 @@ public:
   
     void SubIntensityOff();
   
-  Standard_EXPORT void RemoveDisplayMode (const Standard_Integer aMode);
-  
   Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode);
   
   Standard_EXPORT void ClearSelectionModes();
   
     AIS_DisplayStatus GraphicStatus() const;
   
-  //! keeps the information of displayed modes in the
-  //! main viewer.
-    const TColStd_ListOfInteger& DisplayedModes() const;
-  
   //! keeps the active selection modes of the object
   //! in the main viewer.
     const TColStd_ListOfInteger& SelectionModes() const;
@@ -86,8 +84,6 @@ public:
   
     Quantity_NameOfColor HilightColor() const;
   
-  Standard_EXPORT Standard_Boolean IsDModeIn (const Standard_Integer aMode) const;
-  
   Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const;
 
   //! Returns layer index.
@@ -109,7 +105,7 @@ private:
 
 
   AIS_DisplayStatus myStatus;
-  TColStd_ListOfInteger myDispModes;
+  Standard_Integer myDispMode;
   TColStd_ListOfInteger mySelModes;
   Standard_Integer myLayerIndex;
   Standard_Boolean myIsHilit;
index 5b04ef3..dc0561e 100644 (file)
@@ -19,11 +19,10 @@ inline void AIS_GlobalStatus::SetGraphicStatus(const AIS_DisplayStatus aStat)
  myStatus = aStat;
 }
 
-inline void AIS_GlobalStatus::AddDisplayMode(const Standard_Integer aMode)
+inline void AIS_GlobalStatus::SetDisplayMode (const Standard_Integer theMode)
 {
-  if(!IsDModeIn(aMode)) myDispModes.Append(aMode);
+  myDispMode = theMode;
 }
-
 inline void AIS_GlobalStatus::AddSelectionMode(const Standard_Integer aMode)
 {
   if(!IsSModeIn(aMode)) mySelModes.Append(aMode);
@@ -61,9 +60,9 @@ inline AIS_DisplayStatus AIS_GlobalStatus::GraphicStatus() const
   return myStatus;
 }
 
-inline const TColStd_ListOfInteger& AIS_GlobalStatus::DisplayedModes() const 
+inline Standard_Integer AIS_GlobalStatus::DisplayMode() const
 {
-  return myDispModes;
+  return myDispMode;
 }
 
 inline const TColStd_ListOfInteger& AIS_GlobalStatus::SelectionModes() const 
index d77c18d..0d4f39e 100644 (file)
@@ -452,30 +452,17 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
     // Mark the presentation modes hidden of interactive object different from aDispMode.
     // Then make sure aDispMode is displayed and maybe highlighted.
     // Finally, activate selection mode <SelMode> if not yet activated.
-    TColStd_ListOfInteger aModesToRemove;
-    for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+    const Standard_Integer anOldMode = aStatus->DisplayMode();
+    if (anOldMode != theDispMode)
     {
-      const Standard_Integer anOldMode = aDispModeIter.Value();
-      if (anOldMode != theDispMode)
+      if(myMainPM->IsHighlighted (theIObj, anOldMode))
       {
-        aModesToRemove.Append (anOldMode);
-        if(myMainPM->IsHighlighted (theIObj, anOldMode))
-        {
-          myMainPM->Unhighlight (theIObj, anOldMode);
-        }
-        myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
+        myMainPM->Unhighlight (theIObj, anOldMode);
       }
+      myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
     }
 
-    for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
-    {
-      aStatus->RemoveDisplayMode (aRemModeIter.Value());
-    }
-
-    if (!aStatus->IsDModeIn (theDispMode))
-    {
-      aStatus->AddDisplayMode (theDispMode);
-    }
+    aStatus->SetDisplayMode (theDispMode);
 
     myMainPM->Display (theIObj, theDispMode);
     aStatus->SetGraphicStatus (AIS_DS_Displayed);
@@ -788,15 +775,6 @@ AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_Intera
   return AIS_DS_None;
 }
 
-//=======================================================================
-//function : DisplayedModes
-//purpose  :
-//=======================================================================
-const TColStd_ListOfInteger& AIS_InteractiveContext::DisplayedModes (const Handle(AIS_InteractiveObject)& theIObj) const
-{
-  return myObjects (theIObj)->DisplayedModes();
-}
-
 //=======================================================================
 //function : Remove
 //purpose  :
@@ -1115,7 +1093,7 @@ Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_Interacti
   {
     Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj);
     if (aStatus->GraphicStatus() == AIS_DS_Displayed
-     && aStatus->IsDModeIn (theMode))
+     && theIObj->DisplayMode() == theMode)
     {
       return Standard_True;
     }
@@ -1546,12 +1524,8 @@ void AIS_InteractiveContext::SetDisplayMode (const AIS_DisplayMode  theMode,
     }
 
     Handle(AIS_GlobalStatus) aStatus = anObjIter.Value();
-    if (aStatus->IsDModeIn (myDisplayMode))
-    {
-      aStatus->RemoveDisplayMode (myDisplayMode);
-    }
+    aStatus->SetDisplayMode (theMode);
 
-    aStatus->AddDisplayMode (theMode);
     if (aStatus->GraphicStatus() == AIS_DS_Displayed)
     {
       myMainPM->Display (anObj, theMode);
@@ -1607,30 +1581,17 @@ void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)
   }
 
   // erase presentations for all display modes different from <aMode>
-  TColStd_ListOfInteger aModesToRemove;
-  for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+  const Standard_Integer anOldMode = aStatus->DisplayMode();
+  if (anOldMode != theMode)
   {
-    const Standard_Integer anOldMode = aDispModeIter.Value();
-    if (anOldMode != theMode)
+    if (myMainPM->IsHighlighted (theIObj, anOldMode))
     {
-      aModesToRemove.Append (anOldMode);
-      if (myMainPM->IsHighlighted (theIObj, anOldMode))
-      {
-        myMainPM->Unhighlight (theIObj, anOldMode);
-      }
-      myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
+      myMainPM->Unhighlight (theIObj, anOldMode);
     }
+    myMainPM->SetVisibility (theIObj, anOldMode, Standard_False);
   }
 
-  for (TColStd_ListIteratorOfListOfInteger aRemModeIter (aModesToRemove); aRemModeIter.More(); aRemModeIter.Next())
-  {
-    aStatus->RemoveDisplayMode (aRemModeIter.Value());
-  }
-
-  if (!aStatus->IsDModeIn (theMode))
-  {
-    aStatus->AddDisplayMode (theMode);
-  }
+  aStatus->SetDisplayMode (theMode);
 
   myMainPM->Display (theIObj, theMode);
   Standard_Integer aDispMode, aHiMode, aSelMode;
@@ -1677,11 +1638,7 @@ void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObjec
   }
 
   const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
-  aStatus->RemoveDisplayMode (anOldMode);
-  if (!aStatus->IsDModeIn(myDisplayMode))
-  {
-    aStatus->AddDisplayMode (myDisplayMode);
-  }
+  aStatus->SetDisplayMode (myDisplayMode);
 
   if (aStatus->GraphicStatus() == AIS_DS_Displayed)
   {
@@ -2330,12 +2287,10 @@ void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIOb
   }
 
   theStatus += "\t| Active Display Modes in the MainViewer :\n";
-  for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
-  {
-    theStatus += "\t|\t Mode ";
-    theStatus += TCollection_AsciiString (aDispModeIter.Value());
-    theStatus += "\n";
-  }
+  theStatus += "\t|\t Mode ";
+  theStatus += TCollection_AsciiString (aStatus->DisplayMode());
+  theStatus += "\n";
+
   if (IsSelected(theIObj)) theStatus +="\t| Selected\n";
 
   theStatus += "\t| Active Selection Modes in the MainViewer :\n";
@@ -2393,23 +2348,20 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
     return;
   }
 
-  for (TColStd_ListIteratorOfListOfInteger aDispModeIter (aStatus->DisplayedModes()); aDispModeIter.More(); aDispModeIter.Next())
+  if (aStatus->IsHilighted())
   {
-    if (aStatus->IsHilighted())
+    if (IsCurrent (theIObj))
     {
-      if (IsCurrent (theIObj))
-      {
-        AddOrRemoveCurrentObject (theIObj, Standard_False);
-      }
-      else if (myMainPM->IsHighlighted (theIObj, aDispModeIter.Value()))
-      {
-        myMainPM->Unhighlight (theIObj, aDispModeIter.Value());
-      }
+      AddOrRemoveCurrentObject (theIObj, Standard_False);
+    }
+    else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode()))
+    {
+      myMainPM->Unhighlight (theIObj, aStatus->DisplayMode());
     }
-
-    myMainPM->SetVisibility (theIObj, aDispModeIter.Value(), Standard_False);
   }
 
+  myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False);
+
   if (aStatus->IsHilighted()
    && theIObj->HasHilightMode())
   {
@@ -2423,7 +2375,7 @@ void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& t
   }
 
   if (IsSelected (theIObj)
-  && !aStatus->IsDModeIn (aDispMode))
+   && aStatus->DisplayMode() != aDispMode)
   {
     myMainPM->SetVisibility (theIObj, aDispMode, Standard_False);
   }
@@ -2536,7 +2488,7 @@ void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)
   }
 
   const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj);
-  if (aStatus->IsDModeIn (theMode))
+  if (aStatus->DisplayMode() == theMode)
   {
     const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0;
     if (aDispMode == theMode
index 288b401..1aa68e1 100644 (file)
@@ -555,9 +555,6 @@ public:
   Standard_EXPORT AIS_DisplayStatus DisplayStatus (const Handle(AIS_InteractiveObject)& anIobj) const;
   
 
-  //! Returns the list of active display modes for the entity aniobj.
-  Standard_EXPORT const TColStd_ListOfInteger& DisplayedModes (const Handle(AIS_InteractiveObject)& aniobj) const;
-  
   //! Returns true if anIobj is displayed in the interactive context.
   Standard_EXPORT Standard_Boolean IsDisplayed (const Handle(AIS_InteractiveObject)& anIobj) const;
   
index d5f4bae..a993c16 100644 (file)
@@ -365,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)
@@ -381,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);
@@ -409,12 +405,10 @@ 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;
@@ -431,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);
     }
@@ -456,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();
@@ -478,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();
@@ -800,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);