+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::SetSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+
+ std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+ boost::shared_ptr<ModelAPI_Feature> aFeature;
+
+ Handle(AIS_Shape) anAIS;
+ // we need to unhighligth objects manually in the current local context
+ // in couple with the selection clear (TODO)
+ Handle(AIS_LocalContext) aLocalContext = aContext->LocalContext();
+ if (!aLocalContext.IsNull())
+ aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
+ aContext->ClearSelected(false);
+
+ for (; anIt != aLast; anIt++) {
+ aFeature = (*anIt).feature();
+ if (IsVisible(aFeature))
+ anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
+ if (anAIS.IsNull())
+ continue;
+ aContext->AddOrRemoveSelected(anAIS, false);
+ }
+
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::EraseAll(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+
+ AIS_ListOfInteractive aList;
+ ic->DisplayedObjects(aList);
+ AIS_ListIteratorOfListOfInteractive anIter(aList);
+ for (; anIter.More(); anIter.Next()) {
+ if ((anIter.Value()->DynamicType() == STANDARD_TYPE(AIS_Trihedron)))
+ continue;
+
+ // erase an object
+ Handle(AIS_InteractiveObject) anIO = anIter.Value();
+ ic->Erase(anIO, false);
+ }
+ myFeature2AISObjectMap.clear();
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::EraseDeletedFeatures(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+
+ FeatureToAISMap::const_iterator aFIt = myFeature2AISObjectMap.begin(),
+ aFLast = myFeature2AISObjectMap.end();
+ std::list<boost::shared_ptr<ModelAPI_Feature>> aRemoved;
+ for (; aFIt != aFLast; aFIt++)
+ {
+ boost::shared_ptr<ModelAPI_Feature> aFeature = (*aFIt).first;
+ if (!aFeature || !aFeature->data() || !aFeature->data()->isValid()) {
+ Handle(AIS_InteractiveObject) anAIS = (*aFIt).second;
+ if (!anAIS.IsNull()) {
+ aContext->Erase(anAIS, false);
+ aRemoved.push_back(aFeature);
+ }
+ }
+ }
+ std::list<boost::shared_ptr<ModelAPI_Feature>>::const_iterator anIt = aRemoved.begin(),
+ aLast = aRemoved.end();
+ for (; anIt != aLast; anIt++) {
+ myFeature2AISObjectMap.erase(myFeature2AISObjectMap.find(*anIt));
+ }