Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / XGUI / XGUI_Displayer.cpp
index 7fcc298946e8bd924de520fd175663c1fe95f8a1..2613adae6bbc9ab20b77f31e8b3f5e49b7bb6e75 100644 (file)
@@ -64,6 +64,25 @@ boost::shared_ptr<ModelAPI_Feature> XGUI_Displayer::GetFeature(const TopoDS_Shap
   return aFeature;
 }
 
+std::list<XGUI_ViewerPrs> XGUI_Displayer::GetViewerPrs
+                                                (const NCollection_List<TopoDS_Shape>& theShapes)
+{
+  std::list<XGUI_ViewerPrs> aPresentations;
+  if (theShapes.IsEmpty())
+    return aPresentations;
+
+  NCollection_List<TopoDS_Shape>::Iterator anIt(theShapes);
+  for (; anIt.More(); anIt.Next()) {
+    const TopoDS_Shape& aShape = anIt.Value();
+    if (aShape.IsNull())
+      continue;
+    boost::shared_ptr<ModelAPI_Feature> aFeature = GetFeature(aShape);
+    aPresentations.push_back(XGUI_ViewerPrs(aFeature, aShape));
+  }
+
+  return aPresentations;
+}
+
 void XGUI_Displayer::Erase(boost::shared_ptr<ModelAPI_Feature> theFeature,
                            const bool isUpdateViewer)
 {
@@ -122,6 +141,26 @@ void XGUI_Displayer::RedisplayInLocalContext(boost::shared_ptr<ModelAPI_Feature>
     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::CloseLocalContexts(const bool isUpdateViewer)
 {
   closeAllContexts(true);
@@ -137,6 +176,13 @@ void XGUI_Displayer::closeAllContexts(const bool isUpdateViewer)
   }
 }
 
+void XGUI_Displayer::UpdateViewer()
+{
+  Handle(AIS_InteractiveContext) ic = AISContext();
+  if (!ic.IsNull())
+    ic->UpdateCurrentViewer();
+}
+
 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const 
 { 
   return myWorkshop->viewer()->AISContext();