Salome HOME
updated copyright message
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
index 78b20ee7d68cdf9a6d0dd07c4e0d2ccd9d076614..21abed372525679975ae07e3847d79b1a10ee3a3 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -40,6 +40,7 @@
 #include <ModelAPI_Object.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
 
 #include <GeomAPI_Shape.h>
 
 #include <inspector/VInspectorAPI_CallBack.hxx>
 #endif
 
+#ifdef WIN32
+#pragma warning(disable : 4456) // for nested foreach
+#endif
+
 #define OPTIMIZATION_LEVEL 50
 
 
@@ -105,6 +110,7 @@ void XGUI_SelectionMgr::setSelectedOwners(const SelectMgr_IndexedMapOfOwner& the
 //**************************************************************
 void XGUI_SelectionMgr::onObjectBrowserSelection()
 {
+  myLastSelectionPlace = ModuleBase_ISelection::Browser;
   QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
     myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser);
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
@@ -130,17 +136,24 @@ void XGUI_SelectionMgr::onObjectBrowserSelection()
     }
   }
   aDisplayer->setSelected(aSelectedPrs);
+  myWorkshop->updateColorScaleVisibility();
   emit selectionChanged();
 }
 
 //**************************************************************
 void XGUI_SelectionMgr::onViewerSelection()
 {
+  myLastSelectionPlace = ModuleBase_ISelection::Viewer;
   QList<ModuleBase_ViewerPrsPtr> aValues;
   Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
-  if (!aContext.IsNull())
+  if (!aContext.IsNull()) {
     aValues = selection()->getSelected(ModuleBase_ISelection::Viewer);
-
+    // Update is necessary for OCCT 7.4.0: when it is clears selection it doesn't updates viewer
+#if OCC_VERSION_HEX == 0x070400
+    if (aValues.isEmpty())
+      aContext->UpdateCurrentViewer();
+#endif
+  }
   QObjectPtrList anObjects;
   convertToObjectBrowserSelection(aValues, anObjects);
   myWorkshop->objectBrowser()->setObjectsSelected(anObjects);
@@ -164,7 +177,7 @@ void XGUI_SelectionMgr::deselectPresentation(const Handle(AIS_InteractiveObject)
   NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (aResultOwners);
   Handle(SelectMgr_EntityOwner) anOwner;
   for (; anOwnersIt.More(); anOwnersIt.Next()) {
-    anOwner = Handle(SelectMgr_EntityOwner)::DownCast(anOwnersIt.Value());
+    anOwner = anOwnersIt.Value();
     if (!anOwner.IsNull())
       aContext->AddOrRemoveSelected(anOwner, false);
   }
@@ -240,9 +253,9 @@ void XGUI_SelectionMgr::convertToObjectBrowserSelection(
               aFeature = anActiveDocument->producedByFeature(aResult, aShape);
               if (aFeature.get()) {
                 QList<TopoDS_Shape> aResList = findAllShapes(aResult);
-                foreach(TopoDS_Shape aShape, aResList) {
-                  if (!aShapeMap.Contains(aShape))
-                    aShapeMap.Add(aShape);
+                foreach(TopoDS_Shape aResShape, aResList) {
+                  if (!aShapeMap.Contains(aResShape))
+                    aShapeMap.Add(aResShape);
                 }
               }
             }