From 695fc55c6e5402dcd3473f3f59910b80dc7ef356 Mon Sep 17 00:00:00 2001 From: David Carter Date: Fri, 26 Jul 2024 08:43:12 -0400 Subject: [PATCH] Materials: Reset per face when using property editor In v0.21 changin the color using the propert editor reset the per face colors. This recreates that behavior when settin the appearance. fixes #15170 --- src/Gui/propertyeditor/PropertyItem.cpp | 74 ++++++++++++------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 6167dd4c17..ef9851a67d 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -4261,48 +4261,48 @@ void PropertyMaterialListItem::setValue(const QVariant& value) return; } + // Setting an appearance using the property editor resets the + // per-face appearance + list = list.mid(0, 1); + QString data; QTextStream str(&data); str << "("; - for (const auto & it : list) { - auto mat = it.value(); - App::Color dc; dc.setValue(mat.diffuseColor); - App::Color ac; ac.setValue(mat.ambientColor); - App::Color sc; sc.setValue(mat.specularColor); - App::Color ec; ec.setValue(mat.emissiveColor); - float s = mat.shininess; - float t = mat.transparency; + auto mat = list[0].value(); + App::Color dc; dc.setValue(mat.diffuseColor); + App::Color ac; ac.setValue(mat.ambientColor); + App::Color sc; sc.setValue(mat.specularColor); + App::Color ec; ec.setValue(mat.emissiveColor); + float s = mat.shininess; + float t = mat.transparency; - QString item = QString::fromLatin1( - "App.Material(" - "DiffuseColor=(%1,%2,%3)," - "AmbientColor=(%4,%5,%6)," - "SpecularColor=(%7,%8,%9)," - "EmissiveColor=(%10,%11,%12)," - "Shininess=(%13)," - "Transparency=(%14)," - ")" - ) - .arg(dc.r, 0, 'f', decimals()) - .arg(dc.g, 0, 'f', decimals()) - .arg(dc.b, 0, 'f', decimals()) - .arg(ac.r, 0, 'f', decimals()) - .arg(ac.g, 0, 'f', decimals()) - .arg(ac.b, 0, 'f', decimals()) - .arg(sc.r, 0, 'f', decimals()) - .arg(sc.g, 0, 'f', decimals()) - .arg(sc.b, 0, 'f', decimals()) - .arg(ec.r, 0, 'f', decimals()) - .arg(ec.g, 0, 'f', decimals()) - .arg(ec.b, 0, 'f', decimals()) - .arg(s, 0, 'f', decimals()) - .arg(t, 0, 'f', decimals()) - ; - str << item << ", "; - } - - str << ")"; + QString item = QString::fromLatin1( + "App.Material(" + "DiffuseColor=(%1,%2,%3)," + "AmbientColor=(%4,%5,%6)," + "SpecularColor=(%7,%8,%9)," + "EmissiveColor=(%10,%11,%12)," + "Shininess=(%13)," + "Transparency=(%14)," + ")" + ) + .arg(dc.r, 0, 'f', decimals()) + .arg(dc.g, 0, 'f', decimals()) + .arg(dc.b, 0, 'f', decimals()) + .arg(ac.r, 0, 'f', decimals()) + .arg(ac.g, 0, 'f', decimals()) + .arg(ac.b, 0, 'f', decimals()) + .arg(sc.r, 0, 'f', decimals()) + .arg(sc.g, 0, 'f', decimals()) + .arg(sc.b, 0, 'f', decimals()) + .arg(ec.r, 0, 'f', decimals()) + .arg(ec.g, 0, 'f', decimals()) + .arg(ec.b, 0, 'f', decimals()) + .arg(s, 0, 'f', decimals()) + .arg(t, 0, 'f', decimals()) + ; + str << item << ")"; setPropertyValue(data); }