random shapecolor with toggle in settings dialog

This commit is contained in:
Arne Schmidt
2018-03-01 01:26:51 +01:00
committed by Arne
parent 85f926be97
commit 767d23b987
3 changed files with 47 additions and 3 deletions

View File

@@ -77,9 +77,21 @@ const App::PropertyIntegerConstraint::Constraints intPercent = {0,100,1};
ViewProviderGeometryObject::ViewProviderGeometryObject() : pcBoundSwitch(0),pcBoundColor(0)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
unsigned long shcol = hGrp->GetUnsigned("DefaultShapeColor",3435973887UL); // light gray (204,204,204)
bool randomColor = hGrp->GetBool("randomColor", true);
float r,g,b;
r = ((shcol >> 24) & 0xff) / 255.0; g = ((shcol >> 16) & 0xff) / 255.0; b = ((shcol >> 8) & 0xff) / 255.0;
if(randomColor){ // random box checked
float fMax = (float)RAND_MAX;
r = (float)rand()/fMax;
g = (float)rand()/fMax;
b = (float)rand()/fMax;
}
else {
unsigned long shcol = hGrp->GetUnsigned("DefaultShapeColor",3435973887UL); // light gray (204,204,204)
r = ((shcol >> 24) & 0xff) / 255.0;
g = ((shcol >> 16) & 0xff) / 255.0;
b = ((shcol >> 8) & 0xff) / 255.0;
}
ADD_PROPERTY(ShapeColor,(r, g, b));
ADD_PROPERTY(Transparency,(0));
Transparency.setConstraints(&intPercent);