]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue # 1929: Fix for stayed selection of point after middle constraint creating...
authornds <nds@opencascade.com>
Wed, 28 Dec 2016 14:50:16 +0000 (17:50 +0300)
committernds <nds@opencascade.com>
Wed, 28 Dec 2016 14:50:41 +0000 (17:50 +0300)
src/XGUI/XGUI_Displayer.cpp

index eeeb8d2e76e7c208d30263853707e9466ca08d01..4984664e8e031200b715c19c1e5795366d6b4c1a 100644 (file)
@@ -91,8 +91,6 @@ const int MOUSE_SENSITIVITY_IN_PIXEL = 10;
 
 //#define DEBUG_OCCT_SHAPE_SELECTION
 
-//#define DEBUG_OCCT_26172
-
 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList)
 {
   // Get from null point
@@ -109,6 +107,29 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS
   return anInfo.join(theSeparator);
 }
 
+void deselectPresentation(const Handle(AIS_InteractiveObject) theObject,
+                          const Handle(AIS_InteractiveContext)& theContext)
+{
+  NCollection_List<Handle(SelectBasics_EntityOwner)> aResultOwners;
+
+  for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) {
+    Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+    if (anOwner.IsNull()) // TODO: check why it is possible
+      continue;
+    if (anOwner->Selectable() == theObject && anOwner->IsSelected())
+      aResultOwners.Append(anOwner);
+
+    aResultOwners.Append(anOwner);
+  }
+  NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
+  Handle(SelectMgr_EntityOwner) anOwner;
+  for (; anOwnersIt.More(); anOwnersIt.Next()) {
+    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+    if (!anOwner.IsNull())
+      theContext->AddOrRemoveSelected(anOwner, false);
+  }
+}
+
 XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
   : myWorkshop(theWorkshop), myNeedUpdate(false),
   myIsTrihedronActive(true), myViewerBlockedRecursiveCount(0),
@@ -356,6 +377,7 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer)
       if (aNeedToRestoreSelection)
         myWorkshop->module()->storeSelection();
 
+      deselectPresentation(aAISIO, aContext);
       aContext->Redisplay(aAISIO, false);
 
       #ifdef VINSPECTOR
@@ -1295,13 +1317,6 @@ bool XGUI_Displayer::activate(const Handle(AIS_InteractiveObject)& theIO,
     }
   }
   if (isDeactivated) {
-#ifdef DEBUG_OCCT_26172
-    // the selection from the previous activation modes should be cleared manually (#26172)
-    theIO->ClearSelected();
-    #ifdef VINSPECTOR
-    if (getCallBack()) getCallBack()->ClearSelected(theIO);
-    #endif
-#endif
     // For performance issues
     //if (theUpdateViewer)
     //  updateViewer();