Gui: Refactor DressUp VP to use setHighlighted*

This refactors DressUp VP a bit so it does no longer store original copy
of original faces colors to properly support selection, but uses
highlight methods provided by the base class. It simplfies code a bit
and ensures coherent behavior.
This commit is contained in:
Kacper Donat
2024-05-31 11:48:56 +02:00
parent d09fb588f4
commit 83cf2a17cd
2 changed files with 11 additions and 23 deletions

View File

@@ -63,7 +63,7 @@ std::string ViewProviderDressUp::featureIcon() const
bool ViewProviderDressUp::setEdit(int ModNum) {
if (ModNum == ViewProvider::Default ) {
if (ModNum == ViewProvider::Default) {
// Here we should prevent edit of a Feature with missing base
// Otherwise it could call unhandled exception.
PartDesign::DressUp* dressUp = static_cast<PartDesign::DressUp*>(getObject());
@@ -84,7 +84,6 @@ bool ViewProviderDressUp::setEdit(int ModNum) {
}
}
void ViewProviderDressUp::highlightReferences(const bool on)
{
PartDesign::DressUp* pcDressUp = static_cast<PartDesign::DressUp*>(getObject());
@@ -100,31 +99,25 @@ void ViewProviderDressUp::highlightReferences(const bool on)
std::vector<std::string> edges = pcDressUp->Base.getSubValuesStartsWith("Edge");
if (on) {
if (!faces.empty() && originalFaceMaterials.empty()) {
originalFaceMaterials = vp->ShapeAppearance.getValues();
std::vector<App::Material> materials = originalFaceMaterials;
if (!faces.empty()) {
std::vector<App::Material> materials = vp->ShapeAppearance.getValues();
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), ShapeAppearance.getDiffuseColor());
highlighter.getFaceMaterials(faces, materials);
vp->ShapeAppearance.setValues(materials);
vp->setHighlightedFaces(materials);
}
if (!edges.empty() && originalLineColors.empty()) {
originalLineColors = vp->LineColorArray.getValues();
std::vector<App::Color> colors = originalLineColors;
if (!edges.empty()) {
std::vector<App::Color> colors = vp->LineColorArray.getValues();
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), LineColor.getValue());
highlighter.getEdgeColors(edges, colors);
vp->LineColorArray.setValues(colors);
vp->setHighlightedEdges(colors);
}
} else {
if (!faces.empty() && !originalFaceMaterials.empty()) {
vp->ShapeAppearance.setValues(originalFaceMaterials);
originalFaceMaterials.clear();
}
if (!edges.empty() && !originalLineColors.empty()) {
vp->LineColorArray.setValues(originalLineColors);
originalLineColors.clear();
}
vp->unsetHighlightedFaces();
vp->unsetHighlightedEdges();
}
}

View File

@@ -58,11 +58,6 @@ public:
protected:
bool setEdit(int ModNum) override;
private:
std::vector<App::Material> originalFaceMaterials;
std::vector<App::Color> originalLineColors;
};