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:
committed by
Chris Hennes
parent
c4d0f3ed97
commit
5feb963f9d
@@ -161,22 +161,23 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&
|
||||
break;
|
||||
case ViewProviderFilling::Face:
|
||||
if (on) {
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<App::Material> materials;
|
||||
TopTools_IndexedMapOfShape fMap;
|
||||
TopExp::MapShapes(base->Shape.getValue(), TopAbs_FACE, fMap);
|
||||
colors.resize(fMap.Extent(), svp->ShapeAppearance.getDiffuseColor());
|
||||
materials.resize(fMap.Extent(), svp->ShapeAppearance[0]);
|
||||
|
||||
for (const auto& jt : it.second) {
|
||||
std::size_t idx =
|
||||
static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
// check again that the index is in range because it's possible that
|
||||
// the sub-names are invalid
|
||||
if (idx < colors.size()) {
|
||||
colors[idx] = App::Color(1.0, 0.0, 1.0); // magenta
|
||||
if (idx < materials.size()) {
|
||||
materials[idx].diffuseColor =
|
||||
App::Color(1.0, 0.0, 1.0); // magenta
|
||||
}
|
||||
}
|
||||
|
||||
svp->setHighlightedFaces(colors);
|
||||
svp->setHighlightedFaces(materials);
|
||||
}
|
||||
else {
|
||||
svp->unsetHighlightedFaces();
|
||||
|
||||
@@ -161,22 +161,23 @@ void ViewProviderSections::highlightReferences(ShapeType type, const References&
|
||||
break;
|
||||
case ViewProviderSections::Face:
|
||||
if (on) {
|
||||
std::vector<App::Color> colors;
|
||||
std::vector<App::Material> materials;
|
||||
TopTools_IndexedMapOfShape fMap;
|
||||
TopExp::MapShapes(base->Shape.getValue(), TopAbs_FACE, fMap);
|
||||
colors.resize(fMap.Extent(), svp->ShapeAppearance.getDiffuseColor());
|
||||
materials.resize(fMap.Extent(), svp->ShapeAppearance[0]);
|
||||
|
||||
for (const auto& jt : it.second) {
|
||||
std::size_t idx =
|
||||
static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
// check again that the index is in range because it's possible that
|
||||
// the sub-names are invalid
|
||||
if (idx < colors.size()) {
|
||||
colors[idx] = App::Color(1.0, 0.0, 1.0); // magenta
|
||||
if (idx < materials.size()) {
|
||||
materials[idx].diffuseColor =
|
||||
App::Color(1.0, 0.0, 1.0); // magenta
|
||||
}
|
||||
}
|
||||
|
||||
svp->setHighlightedFaces(colors);
|
||||
svp->setHighlightedFaces(materials);
|
||||
}
|
||||
else {
|
||||
svp->unsetHighlightedFaces();
|
||||
|
||||
Reference in New Issue
Block a user