-// 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
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_ResultBody.h>
-
+#include <ModelAPI_Tools.h>
#include <GeomAPI_Pnt.h>
//--------------------------------------------------------------------------------------
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;
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<int> 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)