]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Task 5.2.7 Distinguish the selection color of the presentation (default white)
authorvsv <vsv@opencascade.com>
Thu, 7 Nov 2019 08:38:29 +0000 (11:38 +0300)
committervsv <vsv@opencascade.com>
Thu, 7 Nov 2019 08:41:46 +0000 (11:41 +0300)
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index 5b69d3593ffb8e02830a296173cbdf0abf0185bb..7ba5bf25a0c084aab2f0ac16ad9e5bf61de414d2 100644 (file)
@@ -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<int> 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<int> aColor = Config_PropManager::color("Visualization", "selection_color");
+    myWorkshop->displayer()->setSelectionColor(aColor);
+  }
+
   myWorkshop->displayer()->redisplayObjects();
 }
 
index 32b5035cde8ac7006a3e06d8ced4d768411a8c77..4530fb9c34fd50b9d810b74158125a68c33d001a 100644 (file)
@@ -277,6 +277,8 @@ private slots:
   QMap<QString, QIntList> myToolbars;
   QMap<QString, QIntList> myDefaultToolbars;
   bool myIsToolbarsModified;
+
+  std::vector<int> myOldSelectionColor;
 };
 
 #endif
index dbc9cc53c04d86cb8d82db0021c25f650014fa2b..333774a030d70a5f28b9d18d83f4115aa7e3aded 100644 (file)
@@ -679,6 +679,21 @@ void XGUI_Displayer::setSelectionColor(const std::vector<int>& theColor)
 }
 
 
+//**************************************************************
+std::vector<int> XGUI_Displayer::selectionColor() const
+{
+  std::vector<int> 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()
 {
index 9f7ff8f799617028c85ba9290ff02b13b9d0aedd..eb976eb6ccff296df60f62c1bd3a923df45ee816 100644 (file)
@@ -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<int>& theColor);
 
+  /// Returns current selection color
+  std::vector<int> selectionColor() const;
+
 signals:
   /// Signal on object display
   /// \param theObject a data object