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

@@ -2301,7 +2301,7 @@ PropertyColor::~PropertyColor() = default;
//**************************************************************************
// Base class implementer
void PropertyColor::setValue(const Color& col)
void PropertyColor::setValue(const Base::Color& col)
{
aboutToSetValue();
_cCol = col;
@@ -2322,7 +2322,7 @@ void PropertyColor::setValue(float r, float g, float b, float a)
hasSetValue();
}
const Color& PropertyColor::getValue() const
const Base::Color& PropertyColor::getValue() const
{
return _cCol;
}
@@ -2345,7 +2345,7 @@ PyObject* PropertyColor::getPyObject()
void PropertyColor::setPyObject(PyObject* value)
{
App::Color cCol;
Base::Color cCol;
if (PyTuple_Check(value) && (PyTuple_Size(value) == 3 || PyTuple_Size(value) == 4)) {
PyObject* item;
item = PyTuple_GetItem(value, 0);
@@ -2485,7 +2485,7 @@ PyObject* PropertyColorList::getPyObject()
return list;
}
Color PropertyColorList::getPyValue(PyObject* item) const
Base::Color PropertyColorList::getPyValue(PyObject* item) const
{
PropertyColor col;
col.setPyObject(item);
@@ -2529,7 +2529,7 @@ void PropertyColorList::RestoreDocFile(Base::Reader& reader)
Base::InputStream str(reader);
uint32_t uCt = 0;
str >> uCt;
std::vector<Color> values(uCt);
std::vector<Base::Color> values(uCt);
uint32_t value; // must be 32 bit long
for (auto& it : values) {
str >> value;
@@ -2552,7 +2552,7 @@ void PropertyColorList::Paste(const Property& from)
unsigned int PropertyColorList::getMemSize() const
{
return static_cast<unsigned int>(_lValueList.size() * sizeof(Color));
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Color));
}
//**************************************************************************
@@ -2573,7 +2573,7 @@ void PropertyMaterial::setValue(const Material& mat)
hasSetValue();
}
void PropertyMaterial::setValue(const Color& col)
void PropertyMaterial::setValue(const Base::Color& col)
{
setDiffuseColor(col);
}
@@ -2593,7 +2593,7 @@ const Material& PropertyMaterial::getValue() const
return _cMat;
}
void PropertyMaterial::setAmbientColor(const Color& col)
void PropertyMaterial::setAmbientColor(const Base::Color& col)
{
aboutToSetValue();
_cMat.ambientColor = col;
@@ -2614,7 +2614,7 @@ void PropertyMaterial::setAmbientColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterial::setDiffuseColor(const Color& col)
void PropertyMaterial::setDiffuseColor(const Base::Color& col)
{
aboutToSetValue();
_cMat.diffuseColor = col;
@@ -2635,7 +2635,7 @@ void PropertyMaterial::setDiffuseColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterial::setSpecularColor(const Color& col)
void PropertyMaterial::setSpecularColor(const Base::Color& col)
{
aboutToSetValue();
_cMat.specularColor = col;
@@ -2656,7 +2656,7 @@ void PropertyMaterial::setSpecularColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterial::setEmissiveColor(const Color& col)
void PropertyMaterial::setEmissiveColor(const Base::Color& col)
{
aboutToSetValue();
_cMat.emissiveColor = col;
@@ -2691,22 +2691,22 @@ void PropertyMaterial::setTransparency(float val)
hasSetValue();
}
const Color& PropertyMaterial::getAmbientColor() const
const Base::Color& PropertyMaterial::getAmbientColor() const
{
return _cMat.ambientColor;
}
const Color& PropertyMaterial::getDiffuseColor() const
const Base::Color& PropertyMaterial::getDiffuseColor() const
{
return _cMat.diffuseColor;
}
const Color& PropertyMaterial::getSpecularColor() const
const Base::Color& PropertyMaterial::getSpecularColor() const
{
return _cMat.specularColor;
}
const Color& PropertyMaterial::getEmissiveColor() const
const Base::Color& PropertyMaterial::getEmissiveColor() const
{
return _cMat.emissiveColor;
}
@@ -2894,7 +2894,7 @@ void PropertyMaterialList::setValue(int index, const Material& mat)
hasSetValue();
}
void PropertyMaterialList::setAmbientColor(const Color& col)
void PropertyMaterialList::setAmbientColor(const Base::Color& col)
{
aboutToSetValue();
setMinimumSizeOne();
@@ -2924,7 +2924,7 @@ void PropertyMaterialList::setAmbientColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setAmbientColor(int index, const Color& col)
void PropertyMaterialList::setAmbientColor(int index, const Base::Color& col)
{
verifyIndex(index);
@@ -2954,7 +2954,7 @@ void PropertyMaterialList::setAmbientColor(int index, uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setDiffuseColor(const Color& col)
void PropertyMaterialList::setDiffuseColor(const Base::Color& col)
{
aboutToSetValue();
setMinimumSizeOne();
@@ -2984,7 +2984,7 @@ void PropertyMaterialList::setDiffuseColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setDiffuseColor(int index, const Color& col)
void PropertyMaterialList::setDiffuseColor(int index, const Base::Color& col)
{
verifyIndex(index);
@@ -3014,7 +3014,7 @@ void PropertyMaterialList::setDiffuseColor(int index, uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setDiffuseColors(const std::vector<App::Color>& colors)
void PropertyMaterialList::setDiffuseColors(const std::vector<Base::Color>& colors)
{
aboutToSetValue();
setSize(colors.size(), _lValueList[0]);
@@ -3025,7 +3025,7 @@ void PropertyMaterialList::setDiffuseColors(const std::vector<App::Color>& color
hasSetValue();
}
void PropertyMaterialList::setSpecularColor(const Color& col)
void PropertyMaterialList::setSpecularColor(const Base::Color& col)
{
aboutToSetValue();
setMinimumSizeOne();
@@ -3055,7 +3055,7 @@ void PropertyMaterialList::setSpecularColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setSpecularColor(int index, const Color& col)
void PropertyMaterialList::setSpecularColor(int index, const Base::Color& col)
{
verifyIndex(index);
@@ -3085,7 +3085,7 @@ void PropertyMaterialList::setSpecularColor(int index, uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setEmissiveColor(const Color& col)
void PropertyMaterialList::setEmissiveColor(const Base::Color& col)
{
aboutToSetValue();
setMinimumSizeOne();
@@ -3115,7 +3115,7 @@ void PropertyMaterialList::setEmissiveColor(uint32_t rgba)
hasSetValue();
}
void PropertyMaterialList::setEmissiveColor(int index, const Color& col)
void PropertyMaterialList::setEmissiveColor(int index, const Base::Color& col)
{
verifyIndex(index);
@@ -3196,29 +3196,29 @@ void PropertyMaterialList::setTransparencies(const std::vector<float>& transpare
hasSetValue();
}
const Color& PropertyMaterialList::getAmbientColor() const
const Base::Color& PropertyMaterialList::getAmbientColor() const
{
return _lValueList[0].ambientColor;
}
const Color& PropertyMaterialList::getAmbientColor(int index) const
const Base::Color& PropertyMaterialList::getAmbientColor(int index) const
{
return _lValueList[index].ambientColor;
}
const Color& PropertyMaterialList::getDiffuseColor() const
const Base::Color& PropertyMaterialList::getDiffuseColor() const
{
return _lValueList[0].diffuseColor;
}
const Color& PropertyMaterialList::getDiffuseColor(int index) const
const Base::Color& PropertyMaterialList::getDiffuseColor(int index) const
{
return _lValueList[index].diffuseColor;
}
std::vector<App::Color> PropertyMaterialList::getDiffuseColors() const
std::vector<Base::Color> PropertyMaterialList::getDiffuseColors() const
{
std::vector<App::Color> list;
std::vector<Base::Color> list;
for (auto& material : _lValueList) {
list.push_back(material.diffuseColor);
}
@@ -3226,22 +3226,22 @@ std::vector<App::Color> PropertyMaterialList::getDiffuseColors() const
return list;
}
const Color& PropertyMaterialList::getSpecularColor() const
const Base::Color& PropertyMaterialList::getSpecularColor() const
{
return _lValueList[0].specularColor;
}
const Color& PropertyMaterialList::getSpecularColor(int index) const
const Base::Color& PropertyMaterialList::getSpecularColor(int index) const
{
return _lValueList[index].specularColor;
}
const Color& PropertyMaterialList::getEmissiveColor() const
const Base::Color& PropertyMaterialList::getEmissiveColor() const
{
return _lValueList[0].emissiveColor;
}
const Color& PropertyMaterialList::getEmissiveColor(int index) const
const Base::Color& PropertyMaterialList::getEmissiveColor(int index) const
{
return _lValueList[index].emissiveColor;
}