diff --git a/src/Gui/ViewProviderGeometryObject.cpp b/src/Gui/ViewProviderGeometryObject.cpp index 96ae294826..40dfc06831 100644 --- a/src/Gui/ViewProviderGeometryObject.cpp +++ b/src/Gui/ViewProviderGeometryObject.cpp @@ -77,9 +77,22 @@ 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", false); float r,g,b; - r = ((shcol >> 24) & 0xff) / 255.0; g = ((shcol >> 16) & 0xff) / 255.0; b = ((shcol >> 8) & 0xff) / 255.0; + + if(randomColor){ + 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); diff --git a/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp b/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp index 31092d00b0..5fa55e98ab 100644 --- a/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp +++ b/src/Mod/Part/Gui/DlgSettingsObjectColor.cpp @@ -41,6 +41,7 @@ DlgSettingsObjectColor::DlgSettingsObjectColor(QWidget* parent) : PreferencePage(parent) { this->setupUi(this); + this->DefaultShapeColor->setDisabled(this->checkRandomColor->isChecked()); } /** @@ -55,6 +56,7 @@ void DlgSettingsObjectColor::saveSettings() { // Part DefaultShapeColor->onSave(); + checkRandomColor->onSave(); DefaultShapeLineColor->onSave(); DefaultShapeLineWidth->onSave(); DefaultShapeVertexColor->onSave(); @@ -68,6 +70,7 @@ void DlgSettingsObjectColor::loadSettings() { // Part DefaultShapeColor->onRestore(); + checkRandomColor->onRestore(); DefaultShapeLineColor->onRestore(); DefaultShapeLineWidth->onRestore(); DefaultShapeVertexColor->onRestore(); diff --git a/src/Mod/Part/Gui/DlgSettingsObjectColor.ui b/src/Mod/Part/Gui/DlgSettingsObjectColor.ui index 3bbf5d1030..43b8269e15 100644 --- a/src/Mod/Part/Gui/DlgSettingsObjectColor.ui +++ b/src/Mod/Part/Gui/DlgSettingsObjectColor.ui @@ -6,8 +6,8 @@ 0 0 - 332 - 331 + 476 + 395 @@ -22,6 +22,32 @@ + + + + + 182 + 0 + + + + Default vertex color + + + + + + + + 182 + 0 + + + + Bounding box color + + + @@ -35,45 +61,12 @@ - - - - The default color for new shapes - - - - 204 - 204 - 204 - - - - DefaultShapeColor - - - View - - - - - - - - 182 - 0 - - - - Default line color - - - The default line color for new shapes - + 25 25 @@ -88,16 +81,23 @@ - - - - - 182 - 0 - + + + + The default color for new shapes - - Default line width + + + 204 + 204 + 204 + + + + DefaultShapeColor + + + View @@ -123,52 +123,6 @@ - - - - - 182 - 0 - - - - Default vertex color - - - - - - - The default line color for new shapes - - - - 25 - 25 - 25 - - - - DefaultShapeVertexColor - - - View - - - - - - - - 182 - 0 - - - - Default vertex size - - - @@ -191,25 +145,12 @@ - - - - - 182 - 0 - - - - Bounding box color - - - The color of bounding boxes in the 3D view - + 255 255 @@ -224,6 +165,81 @@ + + + + + 182 + 0 + + + + Default vertex size + + + + + + + + 182 + 0 + + + + Default line width + + + + + + + + 182 + 0 + + + + Default line color + + + + + + + The default line color for new shapes + + + + 25 + 25 + 25 + + + + DefaultShapeVertexColor + + + View + + + + + + + random shapecolor + + + true + + + RandomColor + + + View + + + @@ -322,6 +338,11 @@ Gui::ColorButton
Gui/PrefWidgets.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
DefaultShapeColor @@ -330,5 +351,22 @@ BoundingBoxColor - + + + checkRandomColor + toggled(bool) + DefaultShapeColor + setDisabled(bool) + + + 20 + 20 + + + 20 + 20 + + + +