From 7140edaf8e3650d8559c561135bcd2533f62226a Mon Sep 17 00:00:00 2001 From: isk Date: Thu, 10 Sep 2015 17:26:45 +0300 Subject: [PATCH] 0026628: Button Erase (Delete where erase algorythm is used) works incorrect Update AIS_InteractiveContext::EraseSelected() method. Fix HLR sample Fix samples. --- samples/CSharp/OCCTProxy/OCCTProxy.cpp | 6 ++---- samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp | 6 ++---- samples/mfc/standard/08_HLR/src/HLRDoc.cpp | 7 +++++-- samples/mfc/standard/Common/OCC_3dBaseDoc.cpp | 5 +---- samples/qt/Common/src/DocumentCommon.cxx | 3 +-- src/AIS/AIS_InteractiveContext.cxx | 10 ++++++++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.cpp b/samples/CSharp/OCCTProxy/OCCTProxy.cpp index 9f0d07484f..222ffbdd1f 100644 --- a/samples/CSharp/OCCTProxy/OCCTProxy.cpp +++ b/samples/CSharp/OCCTProxy/OCCTProxy.cpp @@ -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(); } diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp index 6ca5c9ef01..44a637ae4e 100644 --- a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp @@ -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(); } diff --git a/samples/mfc/standard/08_HLR/src/HLRDoc.cpp b/samples/mfc/standard/08_HLR/src/HLRDoc.cpp index eaddf0aea8..3544beeb61 100755 --- a/samples/mfc/standard/08_HLR/src/HLRDoc.cpp +++ b/samples/mfc/standard/08_HLR/src/HLRDoc.cpp @@ -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(); diff --git a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp index 6e225fd6e8..0655c57d37 100755 --- a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp +++ b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp @@ -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) diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 343c21db99..1c567615df 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -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(); } diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index e2672112b2..158f8971bd 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -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) -- 2.20.1