random shapecolor with toggle in settings dialog
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -292,6 +292,22 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="2">
|
||||
<widget class="Gui::PrefCheckBox" name="checkRandomColor">
|
||||
<property name="text">
|
||||
<string>random shapecolor</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>randomColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -322,13 +338,26 @@
|
||||
<extends>Gui::ColorButton</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefCheckBox</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>DefaultShapeColor</tabstop>
|
||||
<tabstop>checkRandomColor</tabstop>
|
||||
<tabstop>DefaultShapeLineWidth</tabstop>
|
||||
<tabstop>DefaultShapeLineColor</tabstop>
|
||||
<tabstop>BoundingBoxColor</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>checkRandomColor</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>DefaultShapeColor</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user