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

@@ -95,8 +95,8 @@ void ViewProviderCompound::updateData(const App::Property* prop)
TopTools_IndexedMapOfShape compMap;
TopExp::MapShapes(compShape, TopAbs_FACE, compMap);
std::vector<App::Color> compCol;
compCol.resize(compMap.Extent(), this->ShapeAppearance.getDiffuseColor());
std::vector<App::Material> compCol;
compCol.resize(compMap.Extent(), this->ShapeAppearance[0]);
int index=0;
for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it, ++index) {
@@ -111,14 +111,14 @@ void ViewProviderCompound::updateData(const App::Property* prop)
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
if (vpBase) {
std::vector<App::Color> baseCol = vpBase->DiffuseColor.getValues();
applyTransparency(vpBase->Transparency.getValue(),baseCol);
if (static_cast<int>(baseCol.size()) == baseMap.Extent()) {
applyColor(hist[index], baseCol, compCol);
vpBase->ShapeAppearance.setTransparency(vpBase->Transparency.getValue());
if (static_cast<int>(vpBase->ShapeAppearance.getSize()) == baseMap.Extent()) {
applyMaterial(hist[index], vpBase->ShapeAppearance, compCol);
}
else if (!baseCol.empty() && baseCol[0] != this->ShapeAppearance.getDiffuseColor()) {
baseCol.resize(baseMap.Extent(), baseCol[0]);
applyColor(hist[index], baseCol, compCol);
else if (vpBase->ShapeAppearance.getSize() > 0
&& vpBase->ShapeAppearance[0] != this->ShapeAppearance[0]) {
vpBase->ShapeAppearance.setSize(baseMap.Extent(), vpBase->ShapeAppearance[0]);
applyMaterial(hist[index], vpBase->ShapeAppearance, compCol);
}
}
}
@@ -129,7 +129,7 @@ void ViewProviderCompound::updateData(const App::Property* prop)
applyTransparency(Transparency.getValue(), compCol);
}
this->DiffuseColor.setValues(compCol);
this->ShapeAppearance.setValues(compCol);
}
else if (prop->isDerivedFrom<App::PropertyLinkList>()) {
const std::vector<App::DocumentObject *>& pBases = static_cast<const App::PropertyLinkList*>(prop)->getValues();