+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
+ // Preserve selected objects
+ //AIS_ListOfInteractive aAisList;
+ //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ // aAisList.Append(aContext->SelectedInteractive());
+
+ // get the filters from the local context and append them to the global context
+ // a list of filters in the local context is cleared
+ SelectMgr_ListOfFilter aFilters;
+ aFilters.Assign(aContext->Filters());
+
+ //aContext->ClearSelected();
+ aContext->CloseAllContexts(false);
+ qDebug("### Close context");
+
+ // Redisplay all object if they were displayed in localContext
+ Handle(AIS_InteractiveObject) aAISIO;
+ foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
+ aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
+ if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
+ aContext->Display(aAISIO, false);
+ aContext->SetDisplayMode(aAISIO, Shading, false);
+ }
+ }
+
+ // Append the filters from the local selection in the global selection context
+ SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+ for (;aIt.More(); aIt.Next()) {
+ Handle(SelectMgr_Filter) aFilter = aIt.Value();
+ aContext->AddFilter(aFilter);
+ }
+
+ if (isUpdateViewer)
+ updateViewer();
+ //myUseExternalObjects = false;
+ myActiveSelectionModes.clear();
+
+ // Restore selection
+ //AIS_ListIteratorOfListOfInteractive aIt2(aAisList);
+ //for(; aIt2.More(); aIt2.Next()) {
+ // if (aContext->IsDisplayed(aIt2.Value()))
+ // aContext->SetCurrentObject(aIt2.Value(), false);
+ //}
+ }