Salome HOME
refs #30 - Sketch base GUI: create, draw lines
[modules/shaper.git] / src / XGUI / XGUI_Viewer.cpp
index 6d4c100681cd3677f60761ca556c521ef5172601..c78bd72d1bfa7fa6d065fb90bfe2d148682c6880 100644 (file)
@@ -19,6 +19,8 @@
 #include <V3d_View.hxx>
 #include <Visual3d_View.hxx>
 #include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
 
 #include <QMouseEvent>
 
@@ -188,6 +190,47 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
   return aWnd;
 }
 
+void XGUI_Viewer::setLocalSelection(const AIS_ListOfInteractive& theAISObjects, const int theMode,
+                                    const bool isUpdateViewer)
+{
+  Handle(AIS_InteractiveContext) ic = AISContext();
+
+  // Open local context if there is no one
+  bool allObjects = false; // calculate by AIS shape
+  if (!ic->HasOpenedContext()) {
+    ic->ClearCurrents(false);
+    ic->OpenLocalContext(allObjects, true, true);
+  }
+
+  // Activate selection of objects from prs
+  AIS_ListIteratorOfListOfInteractive aIter(theAISObjects);
+  for (; aIter.More(); aIter.Next()) {
+    Handle(AIS_InteractiveObject) anAIS = aIter.Value();
+    if (!anAIS.IsNull()) {
+      if (anAIS->IsKind(STANDARD_TYPE(AIS_Shape))) {
+        ic->Load(anAIS, -1, false);
+        ic->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)theMode));
+      }
+      else if (anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron)) {
+        ic->Load(anAIS, -1, false);
+        ic->Activate(anAIS, theMode);
+      }
+    }
+  }
+  if (isUpdateViewer)
+    ic->UpdateCurrentViewer();
+}
+
+void XGUI_Viewer::setGlobalSelection(const bool isUpdateViewer)
+{
+  Handle(AIS_InteractiveContext) ic = AISContext();
+  if (!ic.IsNull()) {
+    ic->CloseAllContexts(false);
+    if (isUpdateViewer)
+      ic->UpdateCurrentViewer();
+  }
+}
+
 /*! Sets hot button
  *\param theOper - hot operation
  *\param theState - adding state to state map operations.