]> OCCT Git - occt.git/commitdiff
0032184: Visualization - remove ambiguous AIS_GlobalStatus constructor
authorkgv <kgv@opencascade.com>
Mon, 1 Mar 2021 10:20:58 +0000 (13:20 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 4 Mar 2021 16:39:20 +0000 (19:39 +0300)
Auxiliary AIS_GlobalStatus constructor has been removed.
AIS_InteractiveContext::setObjectStatus() no more adds
an invalid -1 mode to AIS_GlobalStatus.

Never updated property AIS_GlobalStatus::GetLayerIndex() has been removed;
AIS_InteractiveContext::SetTransformPersistence() has been corrected to use
ZLayer defined within object itself.

src/AIS/AIS_GlobalStatus.cxx
src/AIS/AIS_GlobalStatus.hxx
src/AIS/AIS_InteractiveContext.cxx
src/QABugs/QABugs_11.cxx
tests/bugs/vis/bug166 [deleted file]

index 012ed5e5b1b36334de9541bd581811fece0f565e..63245c50e89f385851bbc4ffaa45218068df7b0f 100644 (file)
 
 #include <AIS_GlobalStatus.hxx>
 
-#include <AIS_DisplayMode.hxx>
-#include <Standard_Type.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
 IMPLEMENT_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
 
-AIS_GlobalStatus::AIS_GlobalStatus():
-myDispMode(AIS_WireFrame),
-myLayerIndex(0),
-myIsHilit(Standard_False),
-mySubInt(Standard_False)
+// =======================================================================
+// function : AIS_GlobalStatus
+// purpose  :
+// =======================================================================
+AIS_GlobalStatus::AIS_GlobalStatus()
+: myDispMode (0),
+  myIsHilit(Standard_False),
+  mySubInt (Standard_False)
 {  
 }
-
-AIS_GlobalStatus::AIS_GlobalStatus (const Standard_Integer theDMode,
-                                    const Standard_Integer theSMode,
-                                    const Standard_Integer theLayer):
-myDispMode (theDMode),
-myLayerIndex (theLayer),
-myIsHilit (Standard_False),
-mySubInt (Standard_False)
-{
-  mySelModes.Append (theSMode);
-}
-
-void AIS_GlobalStatus::RemoveSelectionMode(const Standard_Integer aMode)
-{
-  TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
-  for (; anIt.More(); anIt.Next())
-  {
-    if (anIt.Value() == aMode)
-    {
-      mySelModes.Remove (anIt);
-      return;
-    }
-  }
-}
-
-void AIS_GlobalStatus::ClearSelectionModes()
-{
-  mySelModes.Clear();
-}
-
-Standard_Boolean AIS_GlobalStatus::IsSModeIn(const Standard_Integer aMode) const 
-{
-  TColStd_ListIteratorOfListOfInteger anIt (mySelModes);
-  for (; anIt.More(); anIt.Next())
-  {
-    if (anIt.Value() == aMode)
-    {
-      return Standard_True;
-    }
-  }
-  return Standard_False;
-}
index df7cf8847c0b428a003f21ded180d5524810ff41..9a1585a015fb8a2779690b1a05354250724b85d5 100644 (file)
 
 DEFINE_STANDARD_HANDLE(AIS_GlobalStatus, Standard_Transient)
 
-//! Stores  information  about objects in graphic context:
-//! - Status Of Display : in the main viewer
-//! hidden in the main viewer
-//! - Displayed Modes
-//! - Active Selection Modes
-//! - is the Interactive Object Current ?
-//! - Layer Index
+//! Stores information about objects in graphic context:
 class AIS_GlobalStatus : public Standard_Transient
 {
   DEFINE_STANDARD_RTTIEXT(AIS_GlobalStatus, Standard_Transient)
 public:
 
+  //! Default constructor.
   Standard_EXPORT AIS_GlobalStatus();
-  
-  Standard_EXPORT AIS_GlobalStatus (const Standard_Integer theDispMode,
-                                    const Standard_Integer theSelMode,
-                                    const Standard_Integer theLayerIndex = 0);
 
-  void AddSelectionMode (const Standard_Integer theMode) { if (!IsSModeIn (theMode)) mySelModes.Append (theMode); }
+  //! Returns the display mode.
+  Standard_Integer DisplayMode() const { return myDispMode; }
 
   //! Sets display mode.
   void SetDisplayMode (const Standard_Integer theMode) { myDispMode = theMode; }
 
-  //! Returns the display mode.
-  Standard_Integer DisplayMode() const { return myDispMode; }
-
-  void SetLayerIndex (const Standard_Integer theIndex) { myLayerIndex = theIndex; }
+  //! Returns TRUE if object is highlighted
+  Standard_Boolean IsHilighted() const { return myIsHilit; }
 
+  //! Sets highlighted state.
   void SetHilightStatus (const Standard_Boolean theStatus) { myIsHilit = theStatus; }
 
   //! Changes applied highlight style for a particular object
@@ -65,36 +56,47 @@ public:
   //! Returns applied highlight style for a particular object
   const Handle(Prs3d_Drawer)& HilightStyle() const { return myHiStyle; }
 
-  Standard_Boolean IsSubIntensityOn() const { return mySubInt; }
-
-  void SubIntensityOn() { mySubInt = Standard_True; }
+  //! Returns active selection modes of the object.
+  const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; }
 
-  void SubIntensityOff() { mySubInt = Standard_False; }
-  
-  Standard_EXPORT void RemoveSelectionMode (const Standard_Integer aMode);
-  
-  Standard_EXPORT void ClearSelectionModes();
+  //! Return TRUE if selection mode was registered.
+  Standard_Boolean IsSModeIn (Standard_Integer theMode) const
+  {
+    return mySelModes.Contains (theMode);
+  }
 
-  //! keeps the active selection modes of the object
-  //! in the main viewer.
-  const TColStd_ListOfInteger& SelectionModes() const { return mySelModes; }
-  
-  Standard_Boolean IsHilighted() const { return myIsHilit; }
+  //! Add selection mode.
+  Standard_Boolean AddSelectionMode (const Standard_Integer theMode)
+  {
+    if (!mySelModes.Contains (theMode))
+    {
+      mySelModes.Append (theMode);
+      return Standard_True;
+    }
+    return Standard_False;
+  }
 
-  Standard_EXPORT Standard_Boolean IsSModeIn (const Standard_Integer aMode) const;
+  //! Remove selection mode.
+  Standard_Boolean RemoveSelectionMode (const Standard_Integer theMode)
+  {
+    return mySelModes.Remove (theMode);
+  }
 
-  //! Returns layer index.
-  Standard_Integer GetLayerIndex() const
+  //! Remove all selection modes.
+  void ClearSelectionModes()
   {
-    return myLayerIndex;
+    mySelModes.Clear();
   }
 
+  Standard_Boolean IsSubIntensityOn() const { return mySubInt; }
+
+  void SetSubIntensity (Standard_Boolean theIsOn) { mySubInt = theIsOn; }
+
 private:
 
   TColStd_ListOfInteger mySelModes;
   Handle(Prs3d_Drawer) myHiStyle;
   Standard_Integer myDispMode;
-  Standard_Integer myLayerIndex;
   Standard_Boolean myIsHilit;
   Standard_Boolean mySubInt;
 
index ad09da4d5df51de16f045aa0a64cfde5c37bc0d5..ba42fb6f8a37cb3f12d6f8a98bd914437556cb67 100644 (file)
@@ -495,8 +495,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO
       }
       if (!mgrSelector->IsActivated (theIObj, theSelectionMode))
       {
-        if (!aStatus->IsSModeIn (theSelectionMode))
-          aStatus->AddSelectionMode (theSelectionMode);
+        aStatus->AddSelectionMode (theSelectionMode);
         mgrSelector->Activate (theIObj, theSelectionMode);
       }
     }
@@ -2402,7 +2401,7 @@ void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_Interacti
 
   mgrSelector->UpdateSelection (theObject);
 
-  const Standard_Integer    aLayerId   = myObjects.Find (theObject)->GetLayerIndex();
+  const Graphic3d_ZLayerId  aLayerId   = theObject->ZLayer();
   const Handle(V3d_Viewer)& aCurViewer = CurrentViewer();
   for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
   {
@@ -2432,7 +2431,12 @@ void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject
   theIObj->SetDisplayStatus (theStatus);
   if (theStatus != PrsMgr_DisplayStatus_None)
   {
-    Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (theDispMode, theSelectionMode);
+    Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus();
+    aStatus->SetDisplayMode (theDispMode);
+    if (theSelectionMode != -1)
+    {
+      aStatus->AddSelectionMode (theSelectionMode);
+    }
     myObjects.Bind (theIObj, aStatus);
   }
   else
@@ -2647,7 +2651,7 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj
         continue;
       }
 
-      aStatus->SubIntensityOn();
+      aStatus->SetSubIntensity (true);
       myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
     }
   }
@@ -2664,7 +2668,7 @@ void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObj
       return;
     }
 
-    aStatus->SubIntensityOn();
+    aStatus->SetSubIntensity (true);
     myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
   }
 }
@@ -3992,7 +3996,7 @@ void AIS_InteractiveContext::SubIntensityOff (const Handle(AIS_InteractiveObject
     return;
   }
 
-  (*aStatus)->SubIntensityOff();
+  (*aStatus)->SetSubIntensity (false);
   Standard_Boolean toUpdateMain = Standard_False;
   if (theObj->DisplayStatus() == PrsMgr_DisplayStatus_Displayed)
   {
index 57681786d857ab2661400cbe3bc3af28d7d42d67..4001d71067a46b08c7dd0c29624dffe18ef4eb14 100644 (file)
@@ -671,28 +671,6 @@ for(;wex.More();wex.Next())
 
 }
 
-static Standard_Integer OCC166 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
-{
-
-  Handle(AIS_InteractiveContext) myAISContext = ViewerTest::GetAISContext();
-  if(myAISContext.IsNull()) {
-    di << "use 'vinit' command before " << argv[0];
-    return 1;
-  }
-
-  BRepPrimAPI_MakeBox aBox(gp_Pnt(0, 0, 0), 100, 100, 100);
-  Handle(AIS_Shape) anAISBox = new AIS_Shape(aBox.Shape());
-  myAISContext->SetAutoActivateSelection (Standard_False);
-  myAISContext->Display(anAISBox, 1);
-
-  TColStd_ListOfInteger anActivatedModes;
-  myAISContext->ActivatedModes (anAISBox, anActivatedModes);
-  if(anActivatedModes.Extent() != 1 || anActivatedModes.First() != -1 )
-    return 1;
-
-  return 0;
-}
-
 #include <TDocStd_Document.hxx>
 #include <DDocStd.hxx>
 #include <PCDM_StoreStatus.hxx>
@@ -4992,7 +4970,6 @@ void QABugs::Commands_11(Draw_Interpretor& theCommands) {
   theCommands.Add("OCC305","OCC305 file",__FILE__,OCC305,group);
 
   // New commands:
-  theCommands.Add("OCC166", "OCC166", __FILE__, OCC166, group);
   theCommands.Add("OCC381_Save", "OCC381_Save Doc", __FILE__, OCC381_Save, group);
   theCommands.Add("OCC381_SaveAs", "OCC381_SaveAs Doc Path", __FILE__, OCC381_SaveAs, group);
 
diff --git a/tests/bugs/vis/bug166 b/tests/bugs/vis/bug166
deleted file mode 100644 (file)
index ddba098..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-puts "================="
-puts "OCC166"
-puts "================="
-puts ""
-
-vinit
-
-if [ catch { OCC166 } res ] then {
-   puts "OCC166: Error"
-} else {
-   puts "OCC166: OK"
-}
-
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png