Salome HOME
Merge remote-tracking branch 'remotes/origin/occ/compounds_processing'
[modules/shaper.git] / src / XGUI / XGUI_SelectionMgr.cpp
index b486fcd5ef53e7ba3a374237da117a15dcd522c9..49bcdcbd375174e0c6ad221b217250cf38c26ad8 100644 (file)
@@ -41,7 +41,6 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultField.h>
-#include <ModuleBase_IStepPrs.h>
 
 #include <GeomAPI_Shape.h>
 
@@ -107,6 +106,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();
@@ -132,49 +132,24 @@ void XGUI_SelectionMgr::onObjectBrowserSelection()
     }
   }
   aDisplayer->setSelected(aSelectedPrs);
-  myWorkshop->viewer()->setColorScaleShown(false);
-  if (aSelectedPrs.size() == 1) {
-    FieldStepPtr aStep =
-      std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>
-      (aSelectedPrs.first()->object());
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    if (aStep.get() && aDisplayer->isVisible(aStep)) {
-      XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
-      AISObjectPtr aAisPtr = aDisplayer->getAISObject(aStep);
-      Handle(AIS_InteractiveObject) aIO = aAisPtr->impl<Handle(AIS_InteractiveObject)>();
-      ModuleBase_IStepPrs* aPrs = dynamic_cast<ModuleBase_IStepPrs*>(aIO.get());
-      if (aPrs) {
-        ModelAPI_AttributeTables::ValueType aType = aPrs->dataType();
-        if ((aType == ModelAPI_AttributeTables::DOUBLE) ||
-          (aType == ModelAPI_AttributeTables::INTEGER) ||
-          (aType == ModelAPI_AttributeTables::BOOLEAN)) {
-          aViewer->setupColorScale();
-          if (aType == ModelAPI_AttributeTables::BOOLEAN) {
-            aViewer->setColorScaleIntervals(2);
-            aViewer->setColorScaleRange(0., 1.);
-          }
-          else {
-            double aMin, aMax;
-            aPrs->dataRange(aMin, aMax);
-            aViewer->setColorScaleRange(aMin, aMax);
-          }
-          aViewer->setColorScaleTitle(aStep->name().c_str());
-          aViewer->setColorScaleShown(true);
-        }
-      }
-    }
-  }
+  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);