- ResultToAISMap::const_iterator aFIt = myResult2AISObjectMap.begin(),
- aFLast = myResult2AISObjectMap.end();
- std::list<ObjectPtr> aRemoved;
- for (; aFIt != aFLast; aFIt++)
- {
- ObjectPtr aFeature = (*aFIt).first;
- if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
- boost::shared_ptr<GeomAPI_AISObject> anObj = (*aFIt).second;
- if (!anObj) continue;
- Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
- if (!anAIS.IsNull()) {
- aContext->Erase(anAIS, false);
- aRemoved.push_back(aFeature);
- }
+ foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
+ // erase an object
+ Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ if (!anIO.IsNull())
+ aContext->Remove(anIO, false);
+ }
+ myResult2AISObjectMap.clear();
+ if (isUpdateViewer)
+ updateViewer();
+ }
+
+//void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
+//{
+// Handle(AIS_InteractiveContext) aContext = AISContext();
+// if (aContext.IsNull())
+// return;
+//
+// QObjectPtrList aRemoved;
+// foreach (ObjectPtr aFeature, myResult2AISObjectMap.keys()) {
+// if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
+// AISObjectPtr anObj = myResult2AISObjectMap[aFeature];
+// if (!anObj)
+// continue;
+// Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+// if (!anAIS.IsNull()) {
+// aContext->Remove(anAIS, false);
+// aRemoved.append(aFeature);
+// }
+// }
+// }
+// foreach(ObjectPtr aObj, aRemoved) {
+// myResult2AISObjectMap.remove(aObj);
+// }
+//
+// if (isUpdateViewer)
+// updateViewer();
+//}
+
+void XGUI_Displayer::openLocalContext()
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ if (aContext.IsNull())
+ return;
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext()) {
+ // Preserve selected objects
+ //AIS_ListOfInteractive aAisList;
+ //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
+ // aAisList.Append(aContext->Current());
+
+ // get the filters from the global context and append them to the local context
+ // a list of filters in the global context is not cleared and should be cleared here
+ SelectMgr_ListOfFilter aFilters;
+ aFilters.Assign(aContext->Filters());
+ // it is important to remove the filters in the global context, because there is a code
+ // in the closeLocalContex, which restore the global context filters
+ aContext->RemoveFilters();
+
+ aContext->ClearCurrents();
+ aContext->OpenLocalContext();
+ //aContext->NotUseDisplayedObjects();
+
+ //myUseExternalObjects = false;
+ myActiveSelectionModes.clear();
+
+ SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+ for (;aIt.More(); aIt.Next()) {
+ aContext->AddFilter(aIt.Value());