Base: Move App::Color to Base

Every basic data type is stored in Base module, color is standing out as
one that does not. Moving it to Base opens possibilities to integrate it
better with the rest of FreeCAD.
This commit is contained in:
Kacper Donat
2025-02-15 22:58:19 +01:00
parent 145af5cddc
commit a72a63232a
215 changed files with 1057 additions and 1054 deletions

View File

@@ -997,7 +997,7 @@ void LinkView::setMaterial(int index, const App::Material *material) {
pcLinkRoot->removeColorOverride();
return;
}
App::Color c = material->diffuseColor;
Base::Color c = material->diffuseColor;
c.setTransparency(material->transparency);
pcLinkRoot->setColorOverride(c);
for(int i=0;i<getSize();++i)
@@ -1010,7 +1010,7 @@ void LinkView::setMaterial(int index, const App::Material *material) {
info.pcRoot->removeColorOverride();
return;
}
App::Color c = material->diffuseColor;
Base::Color c = material->diffuseColor;
c.setTransparency(material->transparency);
info.pcRoot->setColorOverride(c);
}
@@ -2933,7 +2933,7 @@ PyObject *ViewProviderLink::getPyLinkView() {
return linkView->getPyObject();
}
std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char *subname) const {
std::map<std::string, Base::Color> ViewProviderLink::getElementColors(const char *subname) const {
bool isPrefix = true;
if(!subname)
subname = "";
@@ -2941,7 +2941,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
auto len = strlen(subname);
isPrefix = !len || subname[len-1]=='.';
}
std::map<std::string, App::Color> colors;
std::map<std::string, Base::Color> colors;
auto ext = getLinkExtension();
if(!ext || ! ext->getColoredElementsProperty())
return colors;
@@ -2951,7 +2951,7 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
std::string wildcard(subname);
if(wildcard == "Face" || wildcard == "Face*" || wildcard.empty()) {
if(wildcard.size()==4 || OverrideMaterial.getValue()) {
App::Color c = ShapeMaterial.getValue().diffuseColor;
Base::Color c = ShapeMaterial.getValue().diffuseColor;
c.setTransparency(ShapeMaterial.getValue().transparency);
colors["Face"] = c;
if(wildcard.size()==4)
@@ -3072,9 +3072,9 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
bool found = true;
if(colors.empty()) {
found = false;
colors.emplace(subname,App::Color());
colors.emplace(subname,Base::Color());
}
std::map<std::string, App::Color> ret;
std::map<std::string, Base::Color> ret;
for(const auto &v : colors) {
const char *pos = nullptr;
auto sobj = getObject()->resolve(v.first.c_str(),nullptr,nullptr,&pos);
@@ -3098,18 +3098,18 @@ std::map<std::string, App::Color> ViewProviderLink::getElementColors(const char
return ret;
}
void ViewProviderLink::setElementColors(const std::map<std::string, App::Color> &colorMap) {
void ViewProviderLink::setElementColors(const std::map<std::string, Base::Color> &colorMap) {
auto ext = getLinkExtension();
if(!ext || ! ext->getColoredElementsProperty())
return;
// For checking and collapsing array element color
std::map<std::string,std::map<int,App::Color> > subMap;
std::map<std::string,std::map<int,Base::Color> > subMap;
int element_count = ext->getElementCountValue();
std::vector<std::string> subs;
std::vector<App::Color> colors;
App::Color faceColor;
std::vector<Base::Color> colors;
Base::Color faceColor;
bool hasFaceColor = false;
for(const auto &v : colorMap) {
if(!hasFaceColor && v.first == "Face") {
@@ -3133,7 +3133,7 @@ void ViewProviderLink::setElementColors(const std::map<std::string, App::Color>
}
for(auto &v : subMap) {
if(element_count == (int)v.second.size()) {
App::Color firstColor = v.second.begin()->second;
Base::Color firstColor = v.second.begin()->second;
subs.push_back(v.first);
colors.push_back(firstColor);
for(auto it=v.second.begin();it!=v.second.end();) {
@@ -3179,7 +3179,7 @@ void ViewProviderLink::applyColors() {
// reset color and visibility first
action.apply(linkView->getLinkRoot());
std::map<std::string, std::map<std::string,App::Color> > colorMap;
std::map<std::string, std::map<std::string,Base::Color> > colorMap;
std::set<std::string> hideList;
auto colors = getElementColors();
colors.erase("Face");