Salome HOME
Issue #1897 Selection of edges in Group feature with SHIFT Key
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
index 0d9b701f69cc71de1a2377c56eadfd91c1d533f5..df975ca9578ec657acc5aff23c8213248225ff67 100755 (executable)
 
 #include <SelectMgr_ListIteratorOfListOfFilter.hxx>
 
+#ifdef VINSPECTOR
+#include <VInspectorAPI_CallBack.hxx>
+#endif
+
 XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)
     : QObject(theParent),
       myWorkshop(theParent)
@@ -52,47 +56,22 @@ void XGUI_SelectionMgr::connectViewers()
 void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& theSelectedOwners,
                                           bool isUpdateViewer)
 {
-  SelectMgr_IndexedMapOfOwner aSelectedOwners;
-  selection()->selectedOwners(aSelectedOwners);
-
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull()) {
+    /// previous selection should be cleared, else there will be decomposition of selections:
+    /// as AddOrRemoveSelected inverts current selection
+    aContext->ClearSelected(false);
+
     for  (Standard_Integer i = 1, n = theSelectedOwners.Extent(); i <= n; i++)  {
       Handle(SelectMgr_EntityOwner) anOwner = theSelectedOwners(i);
-      if (aSelectedOwners.FindIndex(anOwner) > 0)
-        continue;
 
       aContext->AddOrRemoveSelected(anOwner, isUpdateViewer);
+      #ifdef VINSPECTOR
+      if (myWorkshop->displayer()->getCallBack())
+        myWorkshop->displayer()->getCallBack()->AddOrRemoveSelected(anOwner);
+      #endif
     }
   }
-  ModuleBase_Tools::selectionInfo(aContext, "XGUI_SelectionMgr::setSelectedOwners -- AddOrRemoveSelected");
-}
-
-//**************************************************************
-void XGUI_SelectionMgr::updateSelectedOwners(bool isUpdateViewer)
-{
-  Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (aContext.IsNull())
-    return;
-
-  const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
-
-  SelectMgr_IndexedMapOfOwner anOwnersToDeselect;
-
-  SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
-  for (; anIt.More(); anIt.Next()) {
-    Handle(SelectMgr_Filter) aFilter = anIt.Value();
-    for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
-      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
-      if (!aFilter->IsOk(anOwner))
-        anOwnersToDeselect.Add(aContext->SelectedOwner());
-    }
-  }
-
-  setSelectedOwners(anOwnersToDeselect, false);
-
-  if (isUpdateViewer)
-    aContext->UpdateCurrentViewer();
 }
 
 //**************************************************************
@@ -144,7 +123,8 @@ void XGUI_SelectionMgr::onViewerSelection()
   FeaturePtr aFeature;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
   if (!aContext.IsNull()) {
-    QList<ModuleBase_ViewerPrsPtr> aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer);
+    QList<ModuleBase_ViewerPrsPtr> aPresentations =
+      selection()->getSelected(ModuleBase_ISelection::Viewer);
     foreach(ModuleBase_ViewerPrsPtr aPrs, aPresentations) {
       if (aPrs->object().get()) {
         if (!aFeatures.contains(aPrs->object()))
@@ -185,7 +165,7 @@ void XGUI_SelectionMgr::clearSelection()
   bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true);
   myWorkshop->objectBrowser()->setObjectsSelected(aFeatures);
   myWorkshop->objectBrowser()->blockSignals(aBlocked);
-  
+
   QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
              myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser);