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

@@ -510,7 +510,7 @@ private:
Py::Float r(t[0]);
Py::Float g(t[1]);
Py::Float b(t[2]);
App::Color c(static_cast<float>(r),
Base::Color c(static_cast<float>(r),
static_cast<float>(g),
static_cast<float>(b));
colors.push_back(c.getPackedValue());

View File

@@ -197,7 +197,7 @@ public:
std::stringstream str;
str << "patch" << index++;
segm.setName(str.str());
App::Color col;
Base::Color col;
col.setPackedValue(it.first);
segm.setColor(col.asHexString());
meshdata->addSegment(segm);

View File

@@ -377,7 +377,7 @@ void Tessellation::setFaceColors(int method, App::Document* doc, App::DocumentOb
auto svp = Base::freecad_dynamic_cast<PartGui::ViewProviderPartExt>(
Gui::Application::Instance->getViewProvider(obj));
if (vpmesh && svp) {
std::vector<App::Color> diff_col = svp->ShapeAppearance.getDiffuseColors();
std::vector<Base::Color> diff_col = svp->ShapeAppearance.getDiffuseColors();
if (ui->groupsFaceColors->isChecked()) {
diff_col = getUniqueColors(diff_col);
}
@@ -389,15 +389,15 @@ void Tessellation::setFaceColors(int method, App::Document* doc, App::DocumentOb
}
}
void Tessellation::addFaceColors(Mesh::Feature* mesh, const std::vector<App::Color>& colorPerSegm)
void Tessellation::addFaceColors(Mesh::Feature* mesh, const std::vector<Base::Color>& colorPerSegm)
{
const Mesh::MeshObject& kernel = mesh->Mesh.getValue();
unsigned long numSegm = kernel.countSegments();
if (numSegm > 0 && numSegm == colorPerSegm.size()) {
unsigned long uCtFacets = kernel.countFacets();
std::vector<App::Color> colorPerFace(uCtFacets);
std::vector<Base::Color> colorPerFace(uCtFacets);
for (unsigned long i = 0; i < numSegm; i++) {
App::Color segmColor = colorPerSegm[i];
Base::Color segmColor = colorPerSegm[i];
std::vector<Mesh::FacetIndex> segm = kernel.getSegment(i).getIndices();
for (Mesh::FacetIndex it : segm) {
colorPerFace[it] = segmColor;
@@ -412,7 +412,7 @@ void Tessellation::addFaceColors(Mesh::Feature* mesh, const std::vector<App::Col
}
}
std::vector<App::Color> Tessellation::getUniqueColors(const std::vector<App::Color>& colors) const
std::vector<Base::Color> Tessellation::getUniqueColors(const std::vector<Base::Color>& colors) const
{
// unique colors
std::set<uint32_t> col_set;
@@ -420,7 +420,7 @@ std::vector<App::Color> Tessellation::getUniqueColors(const std::vector<App::Col
col_set.insert(it.getPackedValue());
}
std::vector<App::Color> unique;
std::vector<Base::Color> unique;
unique.reserve(col_set.size());
for (const auto& it : col_set) {
unique.emplace_back(it);

View File

@@ -97,12 +97,12 @@ protected:
void process(int method, App::Document* doc, const std::list<App::SubObjectT>&);
void saveParameters(int method);
void setFaceColors(int method, App::Document* doc, App::DocumentObject* obj);
void addFaceColors(Mesh::Feature* mesh, const std::vector<App::Color>& colorPerSegm);
void addFaceColors(Mesh::Feature* mesh, const std::vector<Base::Color>& colorPerSegm);
QString getMeshingParameters(int method, App::DocumentObject* obj) const;
QString getStandardParameters(App::DocumentObject* obj) const;
QString getMefistoParameters() const;
QString getNetgenParameters() const;
std::vector<App::Color> getUniqueColors(const std::vector<App::Color>& colors) const;
std::vector<Base::Color> getUniqueColors(const std::vector<Base::Color>& colors) const;
private:
void setupConnections();