]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #2963: Show Color Bar on commands Show and Show only
authorvsv <vsv@opencascade.com>
Fri, 26 Jul 2019 12:15:47 +0000 (15:15 +0300)
committervsv <vsv@opencascade.com>
Fri, 26 Jul 2019 12:15:47 +0000 (15:15 +0300)
src/XGUI/XGUI_SelectionMgr.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index b486fcd5ef53e7ba3a374237da117a15dcd522c9..17d4f6d59b5f59f3289c0e3fd004a29de77fa5ae 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>
 
@@ -132,38 +131,7 @@ 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();
 }
 
index c632de145af13a6297b581279299c9e77bfafa68..c3378cb70e33aaa41d6f91d3bf3735e7f0f15c16 100644 (file)
@@ -79,6 +79,7 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
 
 //#include <PartSetPlugin_Part.h>
 
 #include <ModuleBase_ModelWidget.h>
 #include <ModuleBase_ResultPrs.h>
 #include <ModuleBase_ActionIntParameter.h>
+#include <ModuleBase_IStepPrs.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
@@ -2499,6 +2501,8 @@ void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
   }
   Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   myObjectBrowser->updateAllIndexes();
+
+  updateColorScaleVisibility();
 }
 
 //**************************************************************
@@ -2538,8 +2542,46 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 
   // Necessary for update icons in ObjectBrowser on Linux
   myObjectBrowser->updateAllIndexes();
+  updateColorScaleVisibility();
 }
 
+
+//**************************************************************
+void XGUI_Workshop::updateColorScaleVisibility()
+{
+  QObjectPtrList aObjects = mySelector->selection()->selectedObjects();
+  viewer()->setColorScaleShown(false);
+  if (aObjects.size() == 1) {
+    FieldStepPtr aStep =
+      std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aObjects.first());
+    if (aStep.get() && myDisplayer->isVisible(aStep)) {
+      AISObjectPtr aAisPtr = myDisplayer->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)) {
+          myViewerProxy->setupColorScale();
+          if (aType == ModelAPI_AttributeTables::BOOLEAN) {
+            myViewerProxy->setColorScaleIntervals(2);
+            myViewerProxy->setColorScaleRange(0., 1.);
+          }
+          else {
+            double aMin, aMax;
+            aPrs->dataRange(aMin, aMax);
+            myViewerProxy->setColorScaleRange(aMin, aMax);
+          }
+          myViewerProxy->setColorScaleTitle(aStep->name().c_str());
+          myViewerProxy->setColorScaleShown(true);
+        }
+      }
+    }
+  }
+}
+
+
 //**************************************************************
 void XGUI_Workshop::setNormalView(bool toInvert)
 {
index e4cdd5358d24cccf18f45d6d697e20776cf66679..e24c7d59900b09271717f7e26347f2a83f091d0b 100644 (file)
@@ -327,6 +327,9 @@ Q_OBJECT
 
   void deactivateCurrentSelector();
 
+  /// The method updates a Color Scale object in the viewer
+  void updateColorScaleVisibility();
+
 signals:
   /// Emitted when selection happens in Salome viewer
   void salomeViewerSelection();