X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_Selection.cpp;h=3b45898cdc9cbef594502ea371f7e3193bff3abd;hb=276427c6a2ee41062c1dbe16926322e241233c85;hp=83fab90dea5adff036f24f0e1a8d6e042fd342d6;hpb=380f01e1fce1a012267d604a1190d04bf4659447;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_Selection.cpp b/src/ModelHighAPI/ModelHighAPI_Selection.cpp index 83fab90de..3b45898cd 100644 --- a/src/ModelHighAPI/ModelHighAPI_Selection.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Selection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,7 @@ #include #include #include - +#include #include //-------------------------------------------------------------------------------------- @@ -209,7 +209,7 @@ std::wstring ModelHighAPI_Selection::name() const return std::wstring(); } -void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) +void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue, bool random) { if (myVariantType != VT_ResultSubShapePair || !myResultSubShapePair.first.get()) return; @@ -217,9 +217,20 @@ void ModelHighAPI_Selection::setColor(int theRed, int theGreen, int theBlue) AttributeIntArrayPtr aColor = myResultSubShapePair.first->data()->intArray(ModelAPI_Result::COLOR_ID()); aColor->setSize(3); - aColor->setValue(0, theRed); - aColor->setValue(1, theGreen); - aColor->setValue(2, theBlue); + + if (random) + { + std::vector aValues; + ModelAPI_Tools::findRandomColor(aValues); + for (int anIndex = 0; anIndex < 3; ++anIndex) + aColor->setValue(anIndex, aValues[anIndex]); + } + else + { + aColor->setValue(0, theRed); + aColor->setValue(1, theGreen); + aColor->setValue(2, theBlue); + } } void ModelHighAPI_Selection::setDeflection(double theValue)