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:
@@ -71,6 +71,9 @@ void DlgSettingsViewColor::saveSettings()
|
||||
EditedVertexColor->onSave();
|
||||
ConstructionColor->onSave();
|
||||
FullyConstrainedColor->onSave();
|
||||
DefaultShapeColor->onSave();
|
||||
DefaultShapeLineColor->onSave();
|
||||
DefaultShapeLineWidth->onSave();
|
||||
}
|
||||
|
||||
void DlgSettingsViewColor::loadSettings()
|
||||
@@ -91,6 +94,9 @@ void DlgSettingsViewColor::loadSettings()
|
||||
EditedVertexColor->onRestore();
|
||||
ConstructionColor->onRestore();
|
||||
FullyConstrainedColor->onRestore();
|
||||
DefaultShapeColor->onRestore();
|
||||
DefaultShapeLineColor->onRestore();
|
||||
DefaultShapeLineWidth->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -361,7 +361,20 @@
|
||||
<string>Default colors</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="colgridLayout">
|
||||
<item row="0" column="0">
|
||||
<item row="2" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
@@ -509,18 +522,98 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="_1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>240</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default shape color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="DefaultShapeColor">
|
||||
<property name="toolTip">
|
||||
<string>The default color for new shapes</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>204</red>
|
||||
<green>204</green>
|
||||
<blue>204</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DefaultShapeColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>182</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default line width and color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::PrefColorButton" name="DefaultShapeLineColor">
|
||||
<property name="toolTip">
|
||||
<string>The default line color for new shapes</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>25</red>
|
||||
<green>25</green>
|
||||
<blue>25</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DefaultShapeLineColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefSpinBox" name="DefaultShapeLineWidth">
|
||||
<property name="toolTip">
|
||||
<string>The default line thickness for new shapes</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string>px</string>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>DefaultShapeLineWidth</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -533,6 +626,11 @@
|
||||
<extends>QPushButton</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefSpinBox</class>
|
||||
<extends>QSpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefColorButton</class>
|
||||
<extends>Gui::ColorButton</extends>
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -125,9 +125,14 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||
{
|
||||
VisualTouched = true;
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
|
||||
unsigned long lcol = hGrp->GetUnsigned("DefaultShapeLineColor",421075455UL); // dark grey (25,25,25)
|
||||
float r,g,b;
|
||||
r = ((lcol >> 24) & 0xff) / 255.0; g = ((lcol >> 16) & 0xff) / 255.0; b = ((lcol >> 8) & 0xff) / 255.0;
|
||||
int lwidth = hGrp->GetInt("DefaultShapeLineWidth",2);
|
||||
App::Material mat;
|
||||
mat.ambientColor.set(0.2f,0.2f,0.2f);
|
||||
mat.diffuseColor.set(0.1f,0.1f,0.1f);
|
||||
mat.diffuseColor.set(r,g,b);
|
||||
mat.specularColor.set(0.0f,0.0f,0.0f);
|
||||
mat.emissiveColor.set(0.0f,0.0f,0.0f);
|
||||
mat.shininess = 1.0f;
|
||||
@@ -137,10 +142,10 @@ ViewProviderPartExt::ViewProviderPartExt()
|
||||
ADD_PROPERTY(LineColor,(mat.diffuseColor));
|
||||
ADD_PROPERTY(PointColor,(mat.diffuseColor));
|
||||
ADD_PROPERTY(DiffuseColor,(ShapeColor.getValue()));
|
||||
ADD_PROPERTY(LineWidth,(2.0f));
|
||||
ADD_PROPERTY(LineWidth,(lwidth));
|
||||
LineWidth.setConstraints(&sizeRange);
|
||||
PointSize.setConstraints(&sizeRange);
|
||||
ADD_PROPERTY(PointSize,(2.0f));
|
||||
ADD_PROPERTY(PointSize,(lwidth));
|
||||
ADD_PROPERTY(Deviation,(0.5f));
|
||||
Deviation.setConstraints(&tessRange);
|
||||
ADD_PROPERTY(ControlPoints,(false));
|
||||
|
||||
Reference in New Issue
Block a user