From 4b12d7cfb33b7be07effda4200e9b63f7d4d41be Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 26 Jul 2019 15:15:47 +0300 Subject: [PATCH] Issue #2963: Show Color Bar on commands Show and Show only --- src/XGUI/XGUI_SelectionMgr.cpp | 34 +-------------------------- src/XGUI/XGUI_Workshop.cpp | 42 ++++++++++++++++++++++++++++++++++ src/XGUI/XGUI_Workshop.h | 3 +++ 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index b486fcd5e..17d4f6d59 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include @@ -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 - (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(); - ModuleBase_IStepPrs* aPrs = dynamic_cast(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(); } diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index c632de145..c3378cb70 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -79,6 +79,7 @@ #include #include #include +#include //#include @@ -104,6 +105,7 @@ #include #include #include +#include #include #include @@ -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(aObjects.first()); + if (aStep.get() && myDisplayer->isVisible(aStep)) { + AISObjectPtr aAisPtr = myDisplayer->getAISObject(aStep); + Handle(AIS_InteractiveObject) aIO = aAisPtr->impl(); + ModuleBase_IStepPrs* aPrs = dynamic_cast(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) { diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index e4cdd5358..e24c7d599 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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(); -- 2.39.2