Material: Appearance Updates 2

Improves the use of the ShapeAppearance property for the Part workbench.

    removes DiffuseColor property
        adds Python compatibility using custom attributes
        transitions DiffuseColor to ShapeAppearance on open
    Improved UI elements for setting object appearance, and appearance per face
    Lays the foundation for future texture support
This commit is contained in:
David Carter
2024-06-01 18:26:38 -04:00
committed by Chris Hennes
parent 958d83ed06
commit 8b5a3b1124
55 changed files with 1540 additions and 714 deletions

View File

@@ -210,6 +210,17 @@ void ReferenceHighlighter::getFaceColor(const std::string& element, std::vector<
colors[pos] = elementColor;
}
void ReferenceHighlighter::getFaceColor(const std::string& element,
std::vector<App::Material>& materials) const
{
int idx = std::stoi(element.substr(4)) - 1;
assert(idx >= 0);
std::size_t pos = std::size_t(idx);
if (pos < materials.size()) {
materials[pos].diffuseColor = elementColor;
}
}
void ReferenceHighlighter::getFaceColors(const std::vector<std::string>& elements,
std::vector<App::Color>& colors) const
{
@@ -226,3 +237,24 @@ void ReferenceHighlighter::getFaceColors(const std::vector<std::string>& element
std::fill(colors.begin(), colors.end(), objectColor);
}
}
void ReferenceHighlighter::getFaceMaterials(const std::vector<std::string>& elements,
std::vector<App::Material>& materials) const
{
App::Material defaultMaterial;
materials.resize(fMap.Extent(), defaultMaterial);
if (!elements.empty()) {
for (const std::string& e : elements) {
if (boost::starts_with(e, "Face")) {
getFaceColor(e, materials);
}
}
}
else {
for (auto& material : materials) {
material.diffuseColor = objectColor;
}
// std::fill(materials.begin(), materials.end(), objectColor);
}
}