From: nds Date: Fri, 2 Oct 2015 13:14:01 +0000 (+0300) Subject: Issue #590 Setting random colors to bodies X-Git-Tag: V_1.4.0_demo1^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1ae83e2782aca0380a9a7ee664cac0ea8dc2e358;p=modules%2Fshaper.git Issue #590 Setting random colors to bodies --- diff --git a/src/XGUI/XGUI_ColorDialog.cpp b/src/XGUI/XGUI_ColorDialog.cpp index e91d3cceb..9170958f2 100644 --- a/src/XGUI/XGUI_ColorDialog.cpp +++ b/src/XGUI/XGUI_ColorDialog.cpp @@ -63,16 +63,22 @@ void XGUI_ColorDialog::setColor(const std::vector& theValue) } std::vector XGUI_ColorDialog::getColor() const +{ + QColor aColorResult = myColorButton->color(); + + std::vector aValues; + aValues.push_back(aColorResult.red()); + aValues.push_back(aColorResult.green()); + aValues.push_back(aColorResult.blue()); + + return aValues; +} + +std::vector XGUI_ColorDialog::getRandomColor() const { std::vector 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; } diff --git a/src/XGUI/XGUI_ColorDialog.h b/src/XGUI/XGUI_ColorDialog.h index e5bc381d5..1b41916a4 100644 --- a/src/XGUI/XGUI_ColorDialog.h +++ b/src/XGUI/XGUI_ColorDialog.h @@ -43,6 +43,11 @@ public: /// \return a vector of values std::vector 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 getRandomColor() const; + private: QButtonGroup* myButtonGroup; /// a group, contained random and certain color radio button choice QtxColorButton* myColorButton; /// a control to select a color diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index ad3ce3ea8..494d80002 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -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); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 4f20df5ef..6e98038dc 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1550,10 +1550,11 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) if (aResult.get() != NULL) { ResultCompSolidPtr aCompsolidResult = std::dynamic_pointer_cast(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)