diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index db1591136353..102d9db36aa2 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -97,6 +97,8 @@ # include #endif +#include + /// Here the FreeCAD includes sorted by Base,App,Gui...... #include #include @@ -745,6 +747,91 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& } } +std::map ViewProviderPartExt::getElementColors(const char *element) const { + std::map ret; + + if(!element || !element[0]) { + auto color = ShapeColor.getValue(); + color.a = Transparency.getValue()/100.0f; + ret["Face"] = color; + ret["Edge"] = LineColor.getValue(); + ret["Vertex"] = PointColor.getValue(); + return ret; + } + + if(boost::starts_with(element,"Face")) { + auto size = DiffuseColor.getSize(); + if(element[4]=='*') { + auto color = ShapeColor.getValue(); + color.a = Transparency.getValue()/100.0f; + bool singleColor = true; + for(int i=0;i0 && idx<=size) + ret[element] = DiffuseColor[idx-1]; + else + ret[element] = ShapeColor.getValue(); + if(size==1) + ret[element].a = Transparency.getValue()/100.0f; + } + } else if (boost::starts_with(element,"Edge")) { + auto size = LineColorArray.getSize(); + if(element[4]=='*') { + auto color = LineColor.getValue(); + bool singleColor = true; + for(int i=0;i0 && idx<=size) + ret[element] = LineColorArray[idx-1]; + else + ret[element] = LineColor.getValue(); + } + } else if (boost::starts_with(element,"Vertex")) { + auto size = PointColorArray.getSize(); + if(element[5]=='*') { + auto color = PointColor.getValue(); + bool singleColor = true; + for(int i=0;i0 && idx<=size) + ret[element] = PointColorArray[idx-1]; + else + ret[element] = PointColor.getValue(); + } + } + return ret; +} + void ViewProviderPartExt::unsetHighlightedFaces() { DiffuseColor.touch(); diff --git a/src/Mod/Part/Gui/ViewProviderExt.h b/src/Mod/Part/Gui/ViewProviderExt.h index 9bd8a89e748d..f763b9bd4c2b 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.h +++ b/src/Mod/Part/Gui/ViewProviderExt.h @@ -129,6 +129,12 @@ class PartGuiExport ViewProviderPartExt : public Gui::ViewProviderGeometryObject void unsetHighlightedPoints(); //@} + /** @name Color mangement methods + */ + //@{ + virtual std::map getElementColors(const char *element=0) const override; + //@} + virtual bool isUpdateForced() const override { return forceUpdateCount>0; }