X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_SelectionMgr.cpp;h=8304179726f246d4106c5cef7f06256dd71a53b5;hb=d77e6639d89abdcbf327cc73d13bf955064b8524;hp=bafdeda30423f348fe2e8ca03a30d978d22df891;hpb=7bf19255421b34594c7b0a76d0ce28166d0ce895;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index bafdeda30..830417972 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -18,6 +18,8 @@ #include #include +#include + XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent) : QObject(theParent), myWorkshop(theParent) @@ -40,6 +42,47 @@ void XGUI_SelectionMgr::connectViewers() connect(myWorkshop->viewer(), SIGNAL(selectionChanged()), this, SLOT(onViewerSelection())); } +//************************************************************** +void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners, + bool isUpdateViewer) +{ + SelectMgr_IndexedMapOfOwner aSelectedOwners; + selection()->selectedOwners(aSelectedOwners); + + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + for (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++) { + Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i); + if (aSelectedOwners.FindIndex(anOwner) > 0) + continue; + + aContext->AddOrRemoveSelected(anOwner, isUpdateViewer); + } +} + +//************************************************************** +void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer) +{ + Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); + const SelectMgr_ListOfFilter& aFilters = aContext->Filters(); + + SelectMgr_IndexedMapOfOwner anOwnersToDeselect; + + SelectMgr_ListIteratorOfListOfFilter anIt(aFilters); + for (; anIt.More(); anIt.Next()) { + Handle(SelectMgr_Filter) aFilter = anIt.Value(); + for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { + Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner(); + if (!aFilter->IsOk(anOwner)) + anOwnersToDeselect.Add(aContext->SelectedOwner()); + } + } + + setSelectedOwners(anOwnersToDeselect, false); + + if (isUpdateViewer) + aContext->UpdateCurrentViewer(); +} + //************************************************************** void XGUI_SelectionMgr::onObjectBrowserSelection() {