// Object removes from Detected sequence
Standard_DISABLE_DEPRECATION_WARNINGS
- for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper(); ++aDetIter)
+ for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();)
{
- Handle(AIS_InteractiveObject) anObj = DetectedCurrentObject();
+ Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter));
+ Handle(AIS_InteractiveObject) anObj;
+ if (!aPicked.IsNull())
+ {
+ anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable());
+ }
+
if (!anObj.IsNull()
- && anObj != theIObj)
+ && anObj == theIObj)
{
myDetectedSeq.Remove (aDetIter);
+ if (myCurDetected == aDetIter)
+ {
+ myCurDetected = Min (myDetectedSeq.Upper(), aDetIter);
+ }
+ if (myCurHighlighted == aDetIter)
+ {
+ myCurHighlighted = 0;
+ }
+ }
+ else
+ {
+ aDetIter++;
}
}
Standard_ENABLE_DEPRECATION_WARNINGS
{
clearDynamicHighlight();
myLastinMain.Nullify();
+ myLastPicked.Nullify();
}
}
return 0;
}
+//========================================================================
+//function : OCC28310
+//purpose : Tests validness of iterator in AIS_InteractiveContext after
+// an removing object from it
+//========================================================================
+static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
+{
+ const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
+ {
+ std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
+ return 1;
+ }
+
+ TopoDS_Shape aBox = BRepPrimAPI_MakeBox (10.0, 10.0, 10.0).Shape();
+ Handle(AIS_InteractiveObject) aBoxObj = new AIS_Shape (aBox);
+ aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False);
+ ViewerTest::CurrentView()->FitAll();
+ aCtx->MoveTo (200, 200, ViewerTest::CurrentView());
+ aCtx->Select();
+
+ aCtx->Remove (aBoxObj, Standard_True);
+ // nullify the object explicitly to simulate situation in project,
+ // when ::Remove is called from another method and the object is destroyed
+ // before ::DetectedInteractive is called
+ aBoxObj.Nullify();
+
+ for (aCtx->InitDetected(); aCtx->MoreDetected(); aCtx->NextDetected())
+ {
+ Handle(AIS_InteractiveObject) anObj = aCtx->DetectedInteractive();
+ }
+
+ return 0;
+}
+
//========================================================================
//function : Commands_19
//purpose :
theCommands.Add ("OCC27893",
"OCC27893: Creates a box and selects it via AIS_InteractiveContext API",
__FILE__, OCC27893, group);
+ theCommands.Add("OCC28310",
+ "OCC28310: Tests validness of iterator in AIS_InteractiveContext after an removing object from it",
+ __FILE__, OCC28310, group);
return;
}