From: vsv Date: Wed, 6 Nov 2019 15:34:56 +0000 (+0300) Subject: Task 5.2.7 Distinguish the selection color of the presentation (default white) X-Git-Tag: V9_5_0a1~166^2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90b89886d1dde512d38d47ffbb2b70c916acda3a;p=modules%2Fshaper.git Task 5.2.7 Distinguish the selection color of the presentation (default white) --- diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index ccad93e0e..dbc9cc53c 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -649,6 +649,8 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const aContext->DefaultDrawer()->UIsoAspect()->SetNumber(0); ModuleBase_IViewer::DefaultHighlightDrawer = aContext->HighlightStyle(); + + // Commented out according to discussion in bug #2825 //Handle(Prs3d_Drawer) aSelStyle = aContext->SelectionStyle(); //double aDeflection = @@ -663,6 +665,20 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const return aContext; } +//************************************************************** +void XGUI_Displayer::setSelectionColor(const std::vector& theColor) +{ + Handle(AIS_InteractiveContext) aContext = AISContext(); + if (!aContext.IsNull()) { + Quantity_Color aQColor(theColor[0] / 255., + theColor[1] / 255., + theColor[2] / 255., Quantity_TOC_RGB); + aContext->SelectionStyle()->SetColor(aQColor); + aContext->HighlightStyle(Prs3d_TypeOfHighlight_LocalSelected)->SetColor(aQColor); + } +} + + //************************************************************** Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter() { diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 45ea2eecb..9f7ff8f79 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -378,6 +378,8 @@ public: /// Returns scale of active view double getViewScale() const; + void setSelectionColor(const std::vector& theColor); + signals: /// Signal on object display /// \param theObject a data object diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 8198f5f11..0d2424dfa 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -296,6 +296,9 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) Config_PropManager::registerProp("Visualization", "result_field_color", "Field color", Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR()); + Config_PropManager::registerProp("Visualization", "selection_color", "Selection color", + Config_Prop::Color, "255,255,255"); + if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true)) myViewerSelMode.append(TopAbs_FACE); if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "edge-selection", true)) @@ -352,6 +355,15 @@ void XGUI_Workshop::startApplication() // Calling of loadCustomProps before activating module is required // by Config_PropManger to restore user-defined path to plugins ModuleBase_Preferences::loadCustomProps(); + std::vector aColor; + try { + aColor = Config_PropManager::color("Visualization", "selection_color"); + } + catch (...) { + } + if (aColor.size() == 3) + myDisplayer->setSelectionColor(aColor); + createModule(); #ifndef HAVE_SALOME @@ -1071,8 +1083,7 @@ void XGUI_Workshop::onPreferences() ModuleBase_Preferences::editPreferences(aModif); if (aModif.size() > 0) { QString aSection; - foreach (ModuleBase_Pref aPref, aModif) - { + foreach (ModuleBase_Pref aPref, aModif) { aSection = aPref.first; if (aSection == ModuleBase_Preferences::VIEWER_SECTION) { myMainWindow->viewer()->updateFromResources(); @@ -1080,6 +1091,15 @@ void XGUI_Workshop::onPreferences() myMainWindow->menuObject()->updateFromResources(); } } + std::vector aColor; + try { + aColor = Config_PropManager::color("Visualization", "selection_color"); + } + catch (...) { + } + if (aColor.size() == 3) + displayer()->setSelectionColor(aColor); + displayer()->redisplayObjects(); } }