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

@@ -83,7 +83,7 @@ ViewProviderDatum::ViewProviderDatum()
"User parameter:BaseApp/Preferences/Mod/PartDesign");
unsigned long shcol = hGrp->GetUnsigned ( "DefaultDatumColor", 0xFFD70099 );
App::Color col ( (uint32_t) shcol );
Base::Color col ( (uint32_t) shcol );
ShapeAppearance.setDiffuseColor(col);
Transparency.setValue (col.a * 100);

View File

@@ -108,7 +108,7 @@ void ViewProviderDressUp::highlightReferences(const bool on)
vp->setHighlightedFaces(materials);
}
if (!edges.empty()) {
std::vector<App::Color> colors = vp->LineColorArray.getValues();
std::vector<Base::Color> colors = vp->LineColorArray.getValues();
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), LineColor.getValue());
highlighter.getEdgeColors(edges, colors);

View File

@@ -153,11 +153,11 @@ void ViewProviderLoft::highlightReferences(Part::Feature* base, const std::vecto
if (!svp)
return;
std::vector<App::Color>& edgeColors = originalLineColors[base->getID()];
std::vector<Base::Color>& edgeColors = originalLineColors[base->getID()];
if (on) {
edgeColors = svp->LineColorArray.getValues();
std::vector<App::Color> colors = edgeColors;
std::vector<Base::Color> colors = edgeColors;
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), svp->LineColor.getValue());
highlighter.getEdgeColors(elements, colors);

View File

@@ -63,7 +63,7 @@ private:
void highlightReferences(Part::Feature*, const std::vector<std::string>&, bool);
private:
std::map<long, std::vector<App::Color>> originalLineColors;
std::map<long, std::vector<Base::Color>> originalLineColors;
};

View File

@@ -151,12 +151,12 @@ void ViewProviderPipe::highlightReferences(Part::Feature* base, const std::vecto
if (!svp)
return;
std::vector<App::Color>& edgeColors = originalLineColors[base->getID()];
std::vector<Base::Color>& edgeColors = originalLineColors[base->getID()];
if (on) {
if (edgeColors.empty()) {
edgeColors = svp->LineColorArray.getValues();
std::vector<App::Color> colors = edgeColors;
std::vector<Base::Color> colors = edgeColors;
PartGui::ReferenceHighlighter highlighter(base->Shape.getValue(), svp->LineColor.getValue());
highlighter.getEdgeColors(edges, colors);

View File

@@ -64,7 +64,7 @@ private:
void highlightReferences(Part::Feature*, const std::vector<std::string>&, bool);
private:
std::map<long, std::vector<App::Color>> originalLineColors;
std::map<long, std::vector<Base::Color>> originalLineColors;
};

View File

@@ -70,7 +70,7 @@ ViewProviderShapeBinder::ViewProviderShapeBinder()
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/PartDesign");
unsigned long shcol = hGrp->GetUnsigned("DefaultDatumColor", 0xFFD70099);
App::Color col((uint32_t)shcol);
Base::Color col((uint32_t)shcol);
ShapeAppearance.setDiffuseColor(col);
LineColor.setValue(col);
@@ -157,7 +157,7 @@ void ViewProviderShapeBinder::highlightReferences(bool on)
TopTools_IndexedMapOfShape eMap;
TopExp::MapShapes(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_EDGE, eMap);
originalLineColors = svp->LineColorArray.getValues();
std::vector<App::Color> lcolors = originalLineColors;
std::vector<Base::Color> lcolors = originalLineColors;
lcolors.resize(eMap.Extent(), svp->LineColor.getValue());
TopExp::MapShapes(static_cast<Part::Feature*>(obj)->Shape.getValue(), TopAbs_FACE, eMap);
@@ -171,13 +171,13 @@ void ViewProviderShapeBinder::highlightReferences(bool on)
int idx = std::stoi(e.substr(4)) - 1;
assert(idx >= 0);
if (idx < static_cast<int>(lcolors.size()))
lcolors[idx] = App::Color(1.0, 0.0, 1.0); // magenta
lcolors[idx] = Base::Color(1.0, 0.0, 1.0); // magenta
}
else if (e.compare(0, 4, "Face") == 0) {
int idx = std::stoi(e.substr(4)) - 1;
assert(idx >= 0);
if (idx < static_cast<int>(fcolors.size()))
fcolors[idx].diffuseColor = App::Color(1.0, 0.0, 1.0); // magenta
fcolors[idx].diffuseColor = Base::Color(1.0, 0.0, 1.0); // magenta
}
}
svp->LineColorArray.setValues(lcolors);
@@ -239,7 +239,7 @@ void ViewProviderSubShapeBinder::onChanged(const App::Property* prop) {
if (prop == &UseBinderStyle
&& (!getObject() || !getObject()->isRestoring()))
{
App::Color shapeColor, lineColor, pointColor;
Base::Color shapeColor, lineColor, pointColor;
int transparency, linewidth;
if (UseBinderStyle.getValue()) {
//get the datum coloring scheme

View File

@@ -47,7 +47,7 @@ protected:
void attach(App::DocumentObject *obj) override;
private:
std::vector<App::Color> originalLineColors;
std::vector<Base::Color> originalLineColors;
std::vector<App::Material> originalFaceAppearance;
};