]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #590 Setting random colors to bodies V_1.4.0_demo1
authornds <nds@opencascade.com>
Fri, 2 Oct 2015 13:14:01 +0000 (16:14 +0300)
committernds <nds@opencascade.com>
Fri, 2 Oct 2015 13:14:01 +0000 (16:14 +0300)
src/XGUI/XGUI_ColorDialog.cpp
src/XGUI/XGUI_ColorDialog.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_Workshop.cpp

index e91d3cceb8e5073c7bc87727ee3f9d42db279ffc..9170958f29b3589b392edbf0ab1b13054a0218b3 100644 (file)
@@ -63,16 +63,22 @@ void XGUI_ColorDialog::setColor(const std::vector<int>& theValue)
 }
 
 std::vector<int> XGUI_ColorDialog::getColor() const
+{
+  QColor aColorResult = myColorButton->color();
+
+  std::vector<int> aValues;
+  aValues.push_back(aColorResult.red());
+  aValues.push_back(aColorResult.green());
+  aValues.push_back(aColorResult.blue());
+
+  return aValues;
+}
+
+std::vector<int> XGUI_ColorDialog::getRandomColor() const
 {
   std::vector<int> aValues;
   if (isRandomColor()) {
     ModelAPI_Tools::findRandomColor(aValues);
   }
-  else {
-    QColor aColorResult = myColorButton->color();
-    aValues.push_back(aColorResult.red());
-    aValues.push_back(aColorResult.green());
-    aValues.push_back(aColorResult.blue());
-  }
   return aValues;
 }
index e5bc381d5ba331ec1252e57c099a4fdaea0d4db7..1b41916a4763a4268ac00fc1865f3479f219ea47 100644 (file)
@@ -43,6 +43,11 @@ public:
   /// \return a vector of values
   std::vector<int> getColor() const;
 
+  /// Returns a container with the current color value. These are tree int values for RGB definition.
+  /// It returns the next random color.
+  /// \return a vector of values
+  std::vector<int> getRandomColor() const;
+
 private:
   QButtonGroup* myButtonGroup; /// a group, contained random and certain color radio button choice
   QtxColorButton* myColorButton; /// a control to select a color
index ad3ce3ea8e4b537be2190ecc55ed9e7c06654b3b..494d80002450f719c987419c3b6d4a81ca2d32b5 100644 (file)
@@ -410,6 +410,7 @@ void XGUI_ContextMenuMgr::addObjBrowserMenu(QMenu* theMenu) const
       aActions.append(mySeparator);
       aActions.append(action("DELETE_CMD"));
       //aActions.append(action("MOVE_CMD"));
+      aActions.append(action("COLOR_CMD"));
   }
   theMenu->addActions(aActions);
 
index 4f20df5efaf10df960ce3c8f3aff81b554f9a083..6e98038dc437b8874881baa183009ac5377b04c2 100644 (file)
@@ -1550,10 +1550,11 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
     if (aResult.get() != NULL) {
       ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResult);
       if (aCompsolidResult.get() != NULL) { // change colors for all sub-solids
-        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++)
-          setColor(aCompsolidResult->subResult(i), aColorResult);
+        for(int i = 0; i < aCompsolidResult->numberOfSubs(); i++) {
+          setColor(aCompsolidResult->subResult(i), !isRandomColor ? aColorResult : aDlg->getRandomColor());
+        }
       }
-      setColor(aResult, aColorResult);
+      setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
     }
   }
   if (!aWasOperation)