]> OCCT Git - occt-copy.git/commitdiff
0027523: Visualization - selection owner contains obsolete shape
authorvpa <vpa@opencascade.com>
Fri, 10 Jun 2016 10:24:42 +0000 (13:24 +0300)
committernds <nds@opencascade.com>
Fri, 17 Jun 2016 09:22:16 +0000 (12:22 +0300)
- remove check for selection activation in SelectMgr_SelectionManager::RecomputeSelection;
- given selection mode is now handled properly and single selection mode can be recomputed;
- test case for issue #27523.

src/QABugs/QABugs_19.cxx
src/SelectMgr/SelectMgr_SelectionManager.cdl
src/SelectMgr/SelectMgr_SelectionManager.cxx
tests/bugs/vis/bug27523 [new file with mode: 0644]

index b767c260f9655f3e159de24e5b31c1816c773a73..602b44378371b50bd6bce571372dfd5a9d8d10e1 100755 (executable)
@@ -55,6 +55,7 @@
 #include <Standard_Atomic.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 
+#include <StdSelect_BRepOwner.hxx>
 #include <Standard_Version.hxx>
 
 #define QCOMPARE(val1, val2) \
@@ -4396,6 +4397,78 @@ static Standard_Integer OCC27065(Draw_Interpretor& di,
   return 0;
 }
 
+//========================================================================
+//function : OCC27523
+//purpose  : Checks recomputation of deactivated selection mode after object's redisplaying
+//========================================================================
+static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+  if (theArgNb != 1)
+  {
+    std::cerr << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp (theArgVec[0]);
+    return 1;
+  }
+
+  Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+  if(anAISContext.IsNull())
+  {
+    std::cerr << "Error: no active view. Please call vinit.\n";
+    return 1;
+  }
+
+  gp_Pnt aStart (100, 100, 100);
+  gp_Pnt anEnd (300, 400, 600);
+  BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
+  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
+  anAISContext->Display (aTestAISShape);
+
+  // activate it in selection modes
+  TColStd_SequenceOfInteger aModes;
+  aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
+
+  anAISContext->OpenLocalContext();
+  anAISContext->Deactivate (aTestAISShape);
+  anAISContext->Load (aTestAISShape, -1, true);
+  anAISContext->Activate (aTestAISShape, 0);
+  anAISContext->Deactivate (aTestAISShape, 0);
+
+  // activate in vertices mode
+  for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
+  {
+    anAISContext->Activate (aTestAISShape, aModes (anIt));
+  }
+
+  TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
+  TopAbs_ShapeEnum aVertexShapeType = aVertexShape.ShapeType();
+  Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
+  aTestAISShape->Redisplay();
+
+  anAISContext->AddOrRemoveSelected (aTestAISShape);
+
+  bool aValidShapeType = false;
+  for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
+  {
+    Handle(SelectMgr_EntityOwner) anOwner = anAISContext->SelectedOwner();
+    Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+    if (!aBRO.IsNull() && aBRO->HasShape())
+    {
+      TopoDS_Shape aShape = aBRO->Shape();
+
+      aValidShapeType = aShape.ShapeType() == aVertexShapeType;
+    }
+  }
+
+  if (!aValidShapeType)
+  {
+    std::cerr << "Error: shape type is invalid.\n";
+    return 1;
+  }
+
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -4491,5 +4564,9 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
                    "OCC27065 spine profile",
                    __FILE__, OCC27065, group);
 
+  theCommands.Add ("OCC27523",
+                   "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
+                   __FILE__, OCC27523, group);
+
   return;
 }
index 27ba83700f5a18ce49fb319eeb91ace7b434dd24..fae5ebc8ce4913042093d7bbf4b034e85cb67073 100644 (file)
@@ -32,6 +32,7 @@ uses
     AsciiString              from TCollection,
     ViewerSelector           from SelectMgr,
     SelectableObject         from SelectMgr,
+    Selection                from SelectMgr,
     CString                  from Standard,
     MapOfTransient           from TColStd,
     TypeOfUpdate             from SelectMgr,
@@ -163,7 +164,7 @@ is
                         theObject  : SelectableObject from SelectMgr;
                         theIsForce : Boolean from Standard  = Standard_False;
                         theMode    : Integer from Standard = -1);
-    ---Purpose: Recomputes activated selections of theObject for all known viewer selectors according to theMode specified.
+    ---Purpose: Recomputes all selections of theObject for all known viewer selectors according to theMode specified.
     -- If theMode is set to default (-1), then all activated selections will be recomputed. If theIsForce is set to true,
     -- then selection mode theMode for object theObject will be recomputed regardless of its activation status.
 
@@ -210,7 +211,11 @@ is
     --          changes previous sensitivity value of all sensitive entities in selection with theMode
     --          to the given theNewSensitivity.
 
-
+    recomputeSelectionMode (me           : mutable;
+                            theObject    : SelectableObject from SelectMgr;
+                            theSelection : Selection from SelectMgr;
+                            theMode      : Integer from Standard) is protected;
+    ---Purpose: Recomputes given selection mode and updates BVHs in all viewer selectors
 
     loadMode (me          : mutable;
               theObject   : SelectableObject from SelectMgr;
index 6aa89831c27df246fc48bd061899b30ac1cd9e5b..c621f7d285b61760bc145465090ff6e1376723f2 100644 (file)
@@ -646,6 +646,28 @@ void SelectMgr_SelectionManager::rebuildSelectionStructures (const Handle(Select
   }
 }
 
+//==================================================
+// Function: recomputeSelectionMode
+// Purpose :
+//==================================================
+void SelectMgr_SelectionManager::recomputeSelectionMode (const Handle(SelectMgr_SelectableObject)& theObject,
+                                                         const Handle(SelectMgr_Selection)& theSelection,
+                                                         const Standard_Integer theMode)
+{
+  theSelection->UpdateStatus (SelectMgr_TOU_Full);
+
+  for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+  {
+    Handle(SelectMgr_ViewerSelector) aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
+
+    ClearSelectionStructures (theObject, theMode, aCurSelector);
+    theObject->RecomputePrimitives (theMode);
+    RestoreSelectionStructures (theObject, theMode, aCurSelector);
+    theSelection->UpdateStatus (SelectMgr_TOU_None);
+    theSelection->UpdateBVHStatus (SelectMgr_TBU_None);
+  }
+}
+
 //==================================================
 // Function: Update
 // Purpose :
@@ -684,25 +706,23 @@ void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_Sele
   if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
     return;
 
-  for(theObject->Init(); theObject->More(); theObject->Next())
+  if (theMode == -1)
   {
-    const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
-    aSelection->UpdateStatus (SelectMgr_TOU_Full);
-    Standard_Integer aSelMode = aSelection->Mode();
-
-    for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+    for (theObject->Init(); theObject->More(); theObject->Next())
     {
-      const Handle(SelectMgr_ViewerSelector)& aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
-      if (aCurSelector->Status (aSelection) == SelectMgr_SOS_Activated)
-      {
-          ClearSelectionStructures (theObject, aSelMode, aCurSelector);
-          theObject->RecomputePrimitives(aSelMode);
-          RestoreSelectionStructures (theObject, aSelMode, aCurSelector);
-          aSelection->UpdateStatus (SelectMgr_TOU_None);
-          aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
-      }
+      const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
+      Standard_Integer aSelMode = aSelection->Mode();
+      recomputeSelectionMode (theObject, aSelection, aSelMode);
     }
   }
+  else
+  {
+    if (!theObject->HasSelection (theMode))
+      return;
+
+    const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
+    recomputeSelectionMode (theObject, aSelection, theMode);
+  }
 }
 
 //=======================================================================
diff --git a/tests/bugs/vis/bug27523 b/tests/bugs/vis/bug27523
new file mode 100644 (file)
index 0000000..571f2da
--- /dev/null
@@ -0,0 +1,15 @@
+puts "============"
+puts "OCC27523"
+puts "============"
+puts ""
+####################################################################################
+# Visualization - selection owner contains obsolete shape
+####################################################################################
+
+
+pload QAcommands VISUALIZATION
+
+vinit
+OCC27523
+
+set only_screen 1