0026628: Button Erase (Delete where erase algorythm is used) works incorrect
authorisk <isk@opencascade.com>
Thu, 10 Sep 2015 14:26:45 +0000 (17:26 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 10 Sep 2015 14:27:55 +0000 (17:27 +0300)
Update AIS_InteractiveContext::EraseSelected() method.

Fix HLR sample

Fix samples.

samples/CSharp/OCCTProxy/OCCTProxy.cpp
samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp
samples/mfc/standard/08_HLR/src/HLRDoc.cpp
samples/mfc/standard/Common/OCC_3dBaseDoc.cpp
samples/qt/Common/src/DocumentCommon.cxx
src/AIS/AIS_InteractiveContext.cxx

index 9f0d074..222ffbd 100644 (file)
@@ -579,10 +579,8 @@ public:
     {
       return;
     }
-    for(myAISContext()->InitCurrent();myAISContext()->MoreCurrent();myAISContext()->NextCurrent())
-    {
-        myAISContext()->Erase(myAISContext()->Current(),Standard_True);
-    }
+
+    myAISContext()->EraseSelected (Standard_True);
     myAISContext()->ClearCurrents();
   }
 
index 6ca5c9e..44a637a 100644 (file)
@@ -581,10 +581,8 @@ public:
     {
       return;
     }
-    for(myAISContext()->InitCurrent(); myAISContext()->MoreCurrent(); myAISContext()->NextCurrent())
-    {
-      myAISContext()->Erase (myAISContext()->Current(), Standard_True);
-    }
+
+    myAISContext()->EraseSelected (Standard_True);
     myAISContext()->ClearCurrents();
   }
 
index eaddf0a..3544bee 100755 (executable)
@@ -188,14 +188,17 @@ void CHLRDoc::Fit()
 void CHLRDoc::OnObjectErase()
 {
   Standard_Boolean toUpdateDisplayable = Standard_False;
-  for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
+  myAISContext->InitCurrent();
+  while (myAISContext->MoreCurrent())
   {
-    myAISContext->Erase (myAISContext->Current(), Standard_True);
     if (myAISContext->Current()->Type() == AIS_KOI_Shape && myCSelectionDialogIsCreated)
     {
       myCSelectionDialog->DiplayableShape()->Remove (Handle(AIS_Shape)::DownCast (myAISContext->Current())->Shape());
       toUpdateDisplayable = Standard_True;
     }
+
+    myAISContext->Erase (myAISContext->Current(), Standard_True);
+    myAISContext->InitCurrent();
   }
 
   myAISContext->ClearCurrents();
index 6e225fd..0655c57 100755 (executable)
@@ -293,10 +293,7 @@ void OCC_3dBaseDoc::OnUpdateObjectColor(CCmdUI* pCmdUI)
 
 void OCC_3dBaseDoc::OnObjectErase() 
 {
-  for (myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
-  {
-    myAISContext->Erase (myAISContext->Current(), Standard_True);
-  }
+  myAISContext->EraseSelected();
   myAISContext->ClearCurrents();
 }
 void OCC_3dBaseDoc::OnUpdateObjectErase(CCmdUI* pCmdUI) 
index 343c21d..1c56761 100755 (executable)
@@ -234,8 +234,7 @@ void DocumentCommon::onTransparency()
 
 void DocumentCommon::onDelete()
 {
-    for ( myContext->InitCurrent(); myContext->MoreCurrent(); myContext->NextCurrent() )
-        myContext->Erase( myContext->Current(), false);
+    myContext->EraseSelected (Standard_False);
     myContext->ClearSelected();
     getApplication()->onSelectionChanged();
 }
index e267211..158f897 100644 (file)
@@ -724,11 +724,17 @@ void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateVi
 
   Standard_Boolean      isFound  = Standard_False;
   Handle(AIS_Selection) aSelIter = AIS_Selection::Selection(myCurrentName.ToCString());
-  for (aSelIter->Init(); aSelIter->More(); aSelIter->Next())
+
+  aSelIter->Init();
+  while (aSelIter->More())
   {
-    Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter->Value());
+    Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelIter->Value());
+    Handle(AIS_InteractiveObject) anObj   = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+
     Erase (anObj, Standard_False);
     isFound = Standard_True;
+
+    aSelIter->Init();
   }
 
   if (isFound && theToUpdateViewer)