0000630: User-defined defaults for shape colors

The default colors for new geometry (light grey + 2px black line)
are now a user preference (In Display->Colors properties)
This commit is contained in:
Yorik van Havre
2012-08-12 22:55:17 -03:00
parent 33ad622209
commit 5c20d6bbdc
4 changed files with 132 additions and 19 deletions

View File

@@ -63,14 +63,17 @@
using namespace Gui;
PROPERTY_SOURCE(Gui::ViewProviderGeometryObject, Gui::ViewProviderDocumentObject)
const App::PropertyIntegerConstraint::Constraints intPercent = {0,100,1};
ViewProviderGeometryObject::ViewProviderGeometryObject() : pcBoundSwitch(0)
{
ADD_PROPERTY(ShapeColor,(0.8f,0.8f,0.8f));
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
unsigned long shcol = hGrp->GetUnsigned("DefaultShapeColor",3435973887UL); // light gray (204,204,204)
float r,g,b;
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);
App::Material mat(App::Material::DEFAULT);
@@ -86,7 +89,8 @@ ViewProviderGeometryObject::ViewProviderGeometryObject() : pcBoundSwitch(0)
pcShapeMaterial = new SoMaterial;
pcShapeMaterial->ref();
ShapeMaterial.touch();
//ShapeMaterial.touch(); materials are rarely used, so better to initialize with default shape color
ShapeColor.touch();
pcBoundingBox = new Gui::SoFCBoundingBox;
pcBoundingBox->ref();