Salome HOME
Task 5.2.7 Distinguish the selection color of the presentation (default white)
authorvsv <vsv@opencascade.com>
Wed, 6 Nov 2019 15:34:56 +0000 (18:34 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 15:34:56 +0000 (18:34 +0300)
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index ccad93e0e2325f4d0a776c4c8a9044ebb5b3af85..dbc9cc53c04d86cb8d82db0021c25f650014fa2b 100644 (file)
@@ -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<int>& 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()
 {
index 45ea2eecbc7ba1f6dcafc3a6055b9537f84bca61..9f7ff8f799617028c85ba9290ff02b13b9d0aedd 100644 (file)
@@ -378,6 +378,8 @@ public:
   /// Returns scale of active view
   double getViewScale() const;
 
+  void setSelectionColor(const std::vector<int>& theColor);
+
 signals:
   /// Signal on object display
   /// \param theObject a data object
index 8198f5f1131d2dd80e5f329d87c23deb907ccf9c..0d2424dfa1292092342145236d39399fc2199142 100644 (file)
@@ -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<int> 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<int> aColor;
+    try {
+      aColor = Config_PropManager::color("Visualization", "selection_color");
+    }
+    catch (...) {
+    }
+    if (aColor.size() == 3)
+      displayer()->setSelectionColor(aColor);
+
     displayer()->redisplayObjects();
   }
 }