From: vsv Date: Thu, 7 Nov 2019 08:38:29 +0000 (+0300) Subject: Task 5.2.7 Distinguish the selection color of the presentation (default white) X-Git-Tag: V9_5_0a1~166^2~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=28db4c39ee08fe65d011f2ce62e6f71035e973b7;p=modules%2Fshaper.git Task 5.2.7 Distinguish the selection color of the presentation (default white) --- diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 5b69d3593..7ba5bf25a 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -322,6 +322,9 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) XGUI_Displayer* aDisp = myWorkshop->displayer(); QObjectPtrList aObjList = aDisp->displayedObjects(); + if (myOldSelectionColor.size() == 0) + myOldSelectionColor = aDisp->selectionColor(); + AIS_ListOfInteractive aList; aContext->DisplayedObjects(aList); AIS_ListIteratorOfListOfInteractive aLIt; @@ -400,6 +403,7 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) } // Delete selector because it has to be redefined on next activation if (mySelector) { + myWorkshop->displayer()->setSelectionColor(myOldSelectionColor); myProxyViewer->setSelector(0); delete mySelector; mySelector = 0; @@ -412,6 +416,8 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) aResMgr->setValue("Study", "store_positions", myIsStorePositions); getApp()->setEditEnabled(myIsEditEnabled); + myOldSelectionColor.clear(); + // Post-processing for LoadScriptId to remove created(if it was created) SALOME Object Browser disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)), this, SLOT(onScriptLoaded())); @@ -544,6 +550,12 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) aSel->setEnabled(aSel == aSelector); } myProxyViewer->setSelector(aSelector); + + if (myOldSelectionColor.size() == 0) + myOldSelectionColor = myWorkshop->displayer()->selectionColor(); + + std::vector aColor = Config_PropManager::color("Visualization", "selection_color"); + myWorkshop->displayer()->setSelectionColor(aColor); return aSelector; } return 0; @@ -856,6 +868,11 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the } aProp->setValue(aValue); + if ((theSection == "Visualization") && (theParam == "selection_color")) { + std::vector aColor = Config_PropManager::color("Visualization", "selection_color"); + myWorkshop->displayer()->setSelectionColor(aColor); + } + myWorkshop->displayer()->redisplayObjects(); } diff --git a/src/SHAPERGUI/SHAPERGUI.h b/src/SHAPERGUI/SHAPERGUI.h index 32b5035cd..4530fb9c3 100644 --- a/src/SHAPERGUI/SHAPERGUI.h +++ b/src/SHAPERGUI/SHAPERGUI.h @@ -277,6 +277,8 @@ private slots: QMap myToolbars; QMap myDefaultToolbars; bool myIsToolbarsModified; + + std::vector myOldSelectionColor; }; #endif diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index dbc9cc53c..333774a03 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -679,6 +679,21 @@ void XGUI_Displayer::setSelectionColor(const std::vector& theColor) } +//************************************************************** +std::vector XGUI_Displayer::selectionColor() const +{ + std::vector aColor; + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!aContext.IsNull()) { + Quantity_Color aQColor = aContext->SelectionStyle()->Color(); + aColor.push_back((int)(aQColor.Red() * 255)); + aColor.push_back((int)(aQColor.Green() * 255)); + aColor.push_back((int)(aQColor.Blue() * 255)); + } + return aColor; +} + + //************************************************************** Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter() { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 9f7ff8f79..eb976eb6c 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -378,8 +378,13 @@ public: /// Returns scale of active view double getViewScale() const; + /// Set color of selection + /// \param theColor R,G,B values of color void setSelectionColor(const std::vector& theColor); + /// Returns current selection color + std::vector selectionColor() const; + signals: /// Signal on object display /// \param theObject a data object