From 18a83fe9a77ee80f6d06c36a492012ffd10195fb Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 17 Apr 2015 18:45:40 +0300 Subject: [PATCH] Issue #388: Synchronize list of displayed objects on activation of module --- src/NewGeom/NewGeom_Module.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 50279350e..a569af015 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -33,6 +33,9 @@ #include #include +#include +#include + #include #include #include @@ -178,6 +181,33 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) // switch off in this module aResMgr->setValue("Study", "store_positions", false); + // Synchronize displayed objects + if (mySelector && mySelector->viewer()) { + Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext(); + XGUI_Displayer* aDisp = myWorkshop->displayer(); + QObjectPtrList aObjList = aDisp->displayedObjects(); + + AIS_ListOfInteractive aList; + aContext->DisplayedObjects(aList); + AIS_ListIteratorOfListOfInteractive aLIt; + Handle(AIS_InteractiveObject) anAISIO; + foreach (ObjectPtr aObj, aObjList) { + AISObjectPtr aPrs = aDisp->getAISObject(aObj); + Handle(AIS_InteractiveObject) aAIS = aPrs->impl(); + bool aFound = false; + for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) { + anAISIO = aLIt.Value(); + if (anAISIO.Access() == aAIS.Access()) { + aFound = true; + break; + } + } + if (!aFound) { + aDisp->erase(aObj, false); + } + } + } + return isDone; } -- 2.39.2