+ if (myFeature2AISObjectMap.find(theFeature) == myFeature2AISObjectMap.end())
+ return;
+
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ Handle(AIS_InteractiveObject) anAIS = myFeature2AISObjectMap[theFeature];
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (!anAISShape.IsNull())
+ {
+ aContext->Erase(anAISShape);
+ }
+ myFeature2AISObjectMap.erase(theFeature);
+
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::RedisplayInLocalContext(boost::shared_ptr<ModelAPI_Feature> theFeature,
+ const TopoDS_Shape& theShape,
+ const std::list<int>& theModes, const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) aContext = AISContext();
+ // Open local context if there is no one
+ if (!aContext->HasOpenedContext()) {
+ aContext->ClearCurrents(false);
+ aContext->OpenLocalContext(false/*use displayed objects*/, /*true*/false/*use displayed objects*/,
+ true/*allow shape decomposition*/);
+ }
+ // display or redisplay presentation
+ Handle(AIS_Shape) anAIS;
+ if (IsVisible(theFeature)) {
+ anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]);
+ if (!anAIS.IsNull()) {
+ anAIS->Set(theShape);
+ anAIS->Redisplay();
+ }
+ }
+ else {
+ anAIS = new AIS_Shape(theShape);
+ myFeature2AISObjectMap[theFeature] = anAIS;
+ aContext->Display(anAIS, false);
+ }
+ // Activate selection of objects from prs
+ if (!anAIS.IsNull()) {
+ aContext->Load(anAIS, -1, true/*allow decomposition*/);
+ std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+ for (; anIt != aLast; anIt++)
+ {
+ aContext->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt));
+ }
+ }
+
+ if (isUpdateViewer)
+ aContext->UpdateCurrentViewer();
+}
+
+void XGUI_Displayer::CloseLocalContexts(const bool isUpdateViewer)
+{
+ closeAllContexts(true);
+}
+
+void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
+{
+ Handle(AIS_InteractiveContext) ic = AISContext();
+ if (!ic.IsNull()) {
+ ic->CloseAllContexts(false);
+ if (isUpdateViewer)
+ ic->UpdateCurrentViewer();
+ }
+}
+
+Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
+{
+ return myWorkshop->viewer()->AISContext();