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

@@ -281,7 +281,7 @@ private:
try {
Py::Sequence list(object);
std::vector<App::DocumentObject*> objs;
std::map<Part::Feature*, std::vector<App::Color>> partColor;
std::map<Part::Feature*, std::vector<Base::Color>> partColor;
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
@@ -310,7 +310,7 @@ private:
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
auto getShapeColors = [partColor](App::DocumentObject* obj, const char* subname) {
std::map<std::string, App::Color> cols;
std::map<std::string, Base::Color> cols;
auto it = partColor.find(dynamic_cast<Part::Feature*>(obj));
if (it != partColor.end() && boost::starts_with(subname, "Face")) {
const auto& colors = it->second;

View File

@@ -133,7 +133,7 @@ void ExportOCAF::exportObjects(std::vector<App::DocumentObject*>& objs)
std::vector<int> part_id;
getFreeLabels(hierarchical_label, FreeLabels, part_id);
std::vector<std::vector<App::Color>> Colors;
std::vector<std::vector<Base::Color>> Colors;
getPartColors(hierarchical_part, FreeLabels, part_id, Colors);
reallocateFreeShape(hierarchical_part, FreeLabels, part_id, Colors);
@@ -179,7 +179,7 @@ int ExportOCAF::exportObject(App::DocumentObject* obj,
if (obj->isDerivedFrom<Part::Feature>()) {
Part::Feature* part = static_cast<Part::Feature*>(obj);
std::vector<App::Color> colors;
std::vector<Base::Color> colors;
findColors(part, colors);
return_label =
@@ -221,7 +221,7 @@ void ExportOCAF::createNode(App::Part* part,
}
int ExportOCAF::saveShape(Part::Feature* part,
const std::vector<App::Color>& colors,
const std::vector<Base::Color>& colors,
std::vector<TDF_Label>& hierarchical_label,
std::vector<TopLoc_Location>& hierarchical_loc,
std::vector<App::DocumentObject*>& hierarchical_part)
@@ -301,7 +301,7 @@ int ExportOCAF::saveShape(Part::Feature* part,
}
if (!faceLabel.IsNull()) {
const App::Color& color = colors[index - 1];
const Base::Color& color = colors[index - 1];
col = Tools::convertColor(color);
aColorTool->SetColor(faceLabel, col, XCAFDoc_ColorSurf);
}
@@ -310,7 +310,7 @@ int ExportOCAF::saveShape(Part::Feature* part,
}
}
else if (!colors.empty()) {
App::Color color = colors.front();
Base::Color color = colors.front();
col = Tools::convertColor(color);
aColorTool->SetColor(shapeLabel, col, XCAFDoc_ColorGen);
}
@@ -347,12 +347,12 @@ void ExportOCAF::getFreeLabels(std::vector<TDF_Label>& hierarchical_label,
void ExportOCAF::getPartColors(std::vector<App::DocumentObject*> hierarchical_part,
std::vector<TDF_Label> FreeLabels,
std::vector<int> part_id,
std::vector<std::vector<App::Color>>& Colors) const
std::vector<std::vector<Base::Color>>& Colors) const
{
// I am seeking for the colors of each parts
std::size_t n = FreeLabels.size();
for (std::size_t i = 0; i < n; i++) {
std::vector<App::Color> colors;
std::vector<Base::Color> colors;
Part::Feature* part = static_cast<Part::Feature*>(hierarchical_part.at(part_id.at(i)));
findColors(part, colors);
Colors.push_back(colors);
@@ -362,7 +362,7 @@ void ExportOCAF::getPartColors(std::vector<App::DocumentObject*> hierarchical_pa
void ExportOCAF::reallocateFreeShape(std::vector<App::DocumentObject*> hierarchical_part,
std::vector<TDF_Label> FreeLabels,
std::vector<int> part_id,
std::vector<std::vector<App::Color>>& Colors)
std::vector<std::vector<Base::Color>>& Colors)
{
std::size_t n = FreeLabels.size();
for (std::size_t i = 0; i < n; i++) {
@@ -372,7 +372,7 @@ void ExportOCAF::reallocateFreeShape(std::vector<App::DocumentObject*> hierarchi
Part::Feature* part = static_cast<Part::Feature*>(hierarchical_part.at(part_id.at(i)));
aShapeTool->SetShape(label, part->Shape.getValue());
// Add color information
std::vector<App::Color> colors;
std::vector<Base::Color> colors;
colors = Colors.at(i);
TopoDS_Shape baseShape = part->Shape.getValue();
@@ -409,7 +409,7 @@ void ExportOCAF::reallocateFreeShape(std::vector<App::DocumentObject*> hierarchi
}
if (!faceLabel.IsNull()) {
const App::Color& color = colors[index - 1];
const Base::Color& color = colors[index - 1];
col = Tools::convertColor(color);
aColorTool->SetColor(faceLabel, col, XCAFDoc_ColorSurf);
}
@@ -419,7 +419,7 @@ void ExportOCAF::reallocateFreeShape(std::vector<App::DocumentObject*> hierarchi
}
}
else if (!colors.empty()) {
App::Color color = colors.front();
Base::Color color = colors.front();
col = Tools::convertColor(color);
aColorTool->SetColor(label, col, XCAFDoc_ColorGen);
}
@@ -463,9 +463,9 @@ ExportOCAFCmd::ExportOCAFCmd(Handle(TDocStd_Document) h, bool explicitPlacement)
: ExportOCAF(h, explicitPlacement)
{}
void ExportOCAFCmd::findColors(Part::Feature* part, std::vector<App::Color>& colors) const
void ExportOCAFCmd::findColors(Part::Feature* part, std::vector<Base::Color>& colors) const
{
std::map<Part::Feature*, std::vector<App::Color>>::const_iterator it = partColors.find(part);
std::map<Part::Feature*, std::vector<Base::Color>>::const_iterator it = partColors.find(part);
if (it != partColors.end()) {
colors = it->second;
}

View File

@@ -65,18 +65,18 @@ public:
std::vector<TopLoc_Location>& hierarchical_loc,
std::vector<App::DocumentObject*>& hierarchical_part);
int saveShape(Part::Feature* part,
const std::vector<App::Color>&,
const std::vector<Base::Color>&,
std::vector<TDF_Label>& hierarchical_label,
std::vector<TopLoc_Location>& hierarchical_loc,
std::vector<App::DocumentObject*>& hierarchical_part);
void getPartColors(std::vector<App::DocumentObject*> hierarchical_part,
std::vector<TDF_Label> FreeLabels,
std::vector<int> part_id,
std::vector<std::vector<App::Color>>& Colors) const;
std::vector<std::vector<Base::Color>>& Colors) const;
void reallocateFreeShape(std::vector<App::DocumentObject*> hierarchical_part,
std::vector<TDF_Label> FreeLabels,
std::vector<int> part_id,
std::vector<std::vector<App::Color>>& Colors);
std::vector<std::vector<Base::Color>>& Colors);
void getFreeLabels(std::vector<TDF_Label>& hierarchical_label,
std::vector<TDF_Label>& labels,
std::vector<int>& label_part_id);
@@ -91,7 +91,7 @@ public:
std::vector<TopLoc_Location>& hierarchical_loc);
private:
virtual void findColors(Part::Feature*, std::vector<App::Color>&) const
virtual void findColors(Part::Feature*, std::vector<Base::Color>&) const
{}
std::vector<App::DocumentObject*> filterPart(App::Part* part) const;
@@ -108,16 +108,16 @@ class ImportExport ExportOCAFCmd: public ExportOCAF
{
public:
ExportOCAFCmd(Handle(TDocStd_Document) h, bool explicitPlacement);
void setPartColorsMap(const std::map<Part::Feature*, std::vector<App::Color>>& colors)
void setPartColorsMap(const std::map<Part::Feature*, std::vector<Base::Color>>& colors)
{
partColors = colors;
}
private:
void findColors(Part::Feature*, std::vector<App::Color>&) const override;
void findColors(Part::Feature*, std::vector<Base::Color>&) const override;
private:
std::map<Part::Feature*, std::vector<App::Color>> partColors;
std::map<Part::Feature*, std::vector<Base::Color>> partColors;
};

View File

@@ -232,7 +232,7 @@ void ExportOCAF2::setupObject(TDF_Label label,
return;
}
std::map<std::string, std::map<std::string, App::Color>> colors;
std::map<std::string, std::map<std::string, Base::Color>> colors;
static std::string marker(App::DocumentObject::hiddenMarker() + "*");
static std::array<const char*, 3> keys = {"Face*", "Edge*", marker.c_str()};
std::string childName;
@@ -280,7 +280,7 @@ void ExportOCAF2::setupObject(TDF_Label label,
aColorTool->SetVisibility(nodeLabel, Standard_False);
continue;
}
const App::Color& c = vv.second;
const Base::Color& c = vv.second;
Quantity_ColorRGBA color = Tools::convertColor(c);
auto colorType = vv.first[0] == 'F' ? XCAFDoc_ColorSurf : XCAFDoc_ColorCurv;
if (vv.first == "Face" || vv.first == "Edge") {

View File

@@ -51,7 +51,7 @@ namespace Import
struct ImportExport ExportOCAFOptions
{
ExportOCAFOptions();
App::Color defaultColor;
Base::Color defaultColor;
bool exportHidden = true;
bool keepPlacement = false;
};
@@ -60,7 +60,7 @@ class ImportExport ExportOCAF2
{
public:
using GetShapeColorsFunc =
std::function<std::map<std::string, App::Color>(App::DocumentObject*, const char*)>;
std::function<std::map<std::string, Base::Color>(App::DocumentObject*, const char*)>;
explicit ExportOCAF2(Handle(TDocStd_Document) hDoc,
GetShapeColorsFunc func = GetShapeColorsFunc());

View File

@@ -394,12 +394,12 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape,
void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
{
Quantity_ColorRGBA aColor;
App::Color color(0.8f, 0.8f, 0.8f);
Base::Color color(0.8f, 0.8f, 0.8f);
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor)
|| aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor)
|| aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
color = Tools::convertColor(aColor);
std::vector<App::Color> colors;
std::vector<Base::Color> colors;
colors.push_back(color);
applyColors(part, colors);
}
@@ -412,7 +412,7 @@ void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
}
bool found_face_color = false;
std::vector<App::Color> faceColors;
std::vector<Base::Color> faceColors;
faceColors.resize(faces.Extent(), color);
xp.Init(aShape, TopAbs_FACE);
while (xp.More()) {
@@ -438,7 +438,7 @@ ImportOCAFCmd::ImportOCAFCmd(Handle(TDocStd_Document) h, App::Document* d, const
: ImportOCAF(h, d, name)
{}
void ImportOCAFCmd::applyColors(Part::Feature* part, const std::vector<App::Color>& colors)
void ImportOCAFCmd::applyColors(Part::Feature* part, const std::vector<Base::Color>& colors)
{
partColors[part] = colors;
}
@@ -503,7 +503,7 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
std::map<Standard_Integer, Quantity_ColorRGBA>::const_iterator jt;
jt = myColorMap.find(Part::ShapeMapHasher {}(shape));
App::Color partColor(0.8f, 0.8f, 0.8f);
Base::Color partColor(0.8f, 0.8f, 0.8f);
// set label name if defined
@@ -524,7 +524,7 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
xp.Next();
}
std::vector<App::Color> faceColors;
std::vector<Base::Color> faceColors;
faceColors.resize(faces.Extent(), partColor);
xp.Init(shape, TopAbs_FACE);
while (xp.More()) {

View File

@@ -81,7 +81,7 @@ private:
const std::string&,
std::vector<App::DocumentObject*>&);
void loadColors(Part::Feature* part, const TopoDS_Shape& aShape);
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
virtual void applyColors(Part::Feature*, const std::vector<Base::Color>&)
{}
static void tryPlacementFromLoc(App::GeoFeature*, const TopLoc_Location&);
static void tryPlacementFromMatrix(App::GeoFeature*, const Base::Matrix4D&);
@@ -100,16 +100,16 @@ class ImportExport ImportOCAFCmd: public ImportOCAF
{
public:
ImportOCAFCmd(Handle(TDocStd_Document) h, App::Document* d, const std::string& name);
std::map<Part::Feature*, std::vector<App::Color>> getPartColorsMap() const
std::map<Part::Feature*, std::vector<Base::Color>> getPartColorsMap() const
{
return partColors;
}
private:
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors) override;
void applyColors(Part::Feature* part, const std::vector<Base::Color>& colors) override;
private:
std::map<Part::Feature*, std::vector<App::Color>> partColors;
std::map<Part::Feature*, std::vector<Base::Color>> partColors;
};
class ImportXCAF
@@ -122,7 +122,7 @@ public:
private:
void createShape(const TopoDS_Shape& shape, bool perface = false, bool setname = false) const;
void loadShapes(const TDF_Label& label);
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
virtual void applyColors(Part::Feature*, const std::vector<Base::Color>&)
{}
private:

View File

@@ -204,7 +204,7 @@ bool ImportOCAF2::getColor(const TopoDS_Shape& shape, Info& info, bool check, bo
bool ret = false;
Quantity_ColorRGBA aColor;
if (aColorTool->GetColor(shape, XCAFDoc_ColorSurf, aColor)) {
App::Color c = Tools::convertColor(aColor);
Base::Color c = Tools::convertColor(aColor);
if (!check || info.faceColor != c) {
info.faceColor = c;
info.hasFaceColor = true;
@@ -212,7 +212,7 @@ bool ImportOCAF2::getColor(const TopoDS_Shape& shape, Info& info, bool check, bo
}
}
if (!noDefault && !info.hasFaceColor && aColorTool->GetColor(shape, XCAFDoc_ColorGen, aColor)) {
App::Color c = Tools::convertColor(aColor);
Base::Color c = Tools::convertColor(aColor);
if (!check || info.faceColor != c) {
info.faceColor = c;
info.hasFaceColor = true;
@@ -220,7 +220,7 @@ bool ImportOCAF2::getColor(const TopoDS_Shape& shape, Info& info, bool check, bo
}
}
if (aColorTool->GetColor(shape, XCAFDoc_ColorCurv, aColor)) {
App::Color c = Tools::convertColor(aColor);
Base::Color c = Tools::convertColor(aColor);
// Some STEP include a curve color with the same value of the face
// color. And this will look weird in FC. So for shape with face
// we'll ignore the curve color, if it is the same as the face color.
@@ -296,8 +296,8 @@ bool ImportOCAF2::createObject(App::Document* doc,
bool hasEdgeColors = false;
Part::TopoShape tshape(shape);
std::vector<App::Color> faceColors;
std::vector<App::Color> edgeColors;
std::vector<Base::Color> faceColors;
std::vector<Base::Color> edgeColors;
TDF_LabelSequence seq;
if (!label.IsNull() && aShapeTool->GetSubShapes(label, seq)) {
@@ -328,7 +328,7 @@ bool ImportOCAF2::createObject(App::Document* doc,
}
bool foundFaceColor = false, foundEdgeColor = false;
App::Color faceColor, edgeColor;
Base::Color faceColor, edgeColor;
Quantity_ColorRGBA aColor;
if (aColorTool->GetColor(l, XCAFDoc_ColorSurf, aColor)
|| aColorTool->GetColor(l, XCAFDoc_ColorGen, aColor)) {
@@ -585,7 +585,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
}
void ImportOCAF2::getSHUOColors(TDF_Label label,
std::map<std::string, App::Color>& colors,
std::map<std::string, Base::Color>& colors,
bool appendFirst)
{
TDF_AttributeSequence seq;
@@ -638,7 +638,7 @@ void ImportOCAF2::getSHUOColors(TDF_Label label,
}
if (!aColorTool->IsVisible(slabel)) {
subname += App::DocumentObject::hiddenMarker();
colors.emplace(subname, App::Color());
colors.emplace(subname, Base::Color());
}
else {
Quantity_ColorRGBA aColor;
@@ -685,7 +685,7 @@ App::DocumentObject* ImportOCAF2::loadShape(App::Document* doc,
return it->second.obj;
}
std::map<std::string, App::Color> shuoColors;
std::map<std::string, Base::Color> shuoColors;
if (!options.useLinkGroup) {
getSHUOColors(label, shuoColors, false);
}
@@ -735,7 +735,7 @@ struct ChildInfo
{
std::vector<Base::Placement> plas;
boost::dynamic_bitset<> vis;
std::map<size_t, App::Color> colors;
std::map<size_t, Base::Color> colors;
std::vector<TDF_Label> labels;
TopoDS_Shape shape;
};
@@ -751,7 +751,7 @@ bool ImportOCAF2::createAssembly(App::Document* _doc,
std::vector<App::DocumentObject*> children;
std::map<App::DocumentObject*, ChildInfo> childrenMap;
boost::dynamic_bitset<> visibilities;
std::map<std::string, App::Color> shuoColors;
std::map<std::string, Base::Color> shuoColors;
auto doc = _doc;
if (newDoc) {
@@ -877,7 +877,7 @@ ImportOCAFExt::ImportOCAFExt(Handle(TDocStd_Document) hStdDoc,
: ImportOCAF2(hStdDoc, doc, name)
{}
void ImportOCAFExt::applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors)
void ImportOCAFExt::applyFaceColors(Part::Feature* part, const std::vector<Base::Color>& colors)
{
partColors[part] = colors;
}

View File

@@ -62,8 +62,8 @@ namespace Import
struct ImportExport ImportOCAFOptions
{
ImportOCAFOptions();
App::Color defaultFaceColor;
App::Color defaultEdgeColor;
Base::Color defaultFaceColor;
Base::Color defaultEdgeColor;
bool merge = false;
bool useLinkGroup = false;
bool useBaseName = true;
@@ -130,8 +130,8 @@ private:
std::string baseName;
App::DocumentObject* obj = nullptr;
App::PropertyPlacement* propPlacement = nullptr;
App::Color faceColor;
App::Color edgeColor;
Base::Color faceColor;
Base::Color edgeColor;
bool hasFaceColor = false;
bool hasEdgeColor = false;
int free = true;
@@ -162,19 +162,19 @@ private:
bool
getColor(const TopoDS_Shape& shape, Info& info, bool check = false, bool noDefault = false);
void
getSHUOColors(TDF_Label label, std::map<std::string, App::Color>& colors, bool appendFirst);
getSHUOColors(TDF_Label label, std::map<std::string, Base::Color>& colors, bool appendFirst);
void setObjectName(Info& info, TDF_Label label);
std::string getLabelName(TDF_Label label);
App::DocumentObject*
expandShape(App::Document* doc, TDF_Label label, const TopoDS_Shape& shape);
virtual void applyEdgeColors(Part::Feature*, const std::vector<App::Color>&)
virtual void applyEdgeColors(Part::Feature*, const std::vector<Base::Color>&)
{}
virtual void applyFaceColors(Part::Feature*, const std::vector<App::Color>&)
virtual void applyFaceColors(Part::Feature*, const std::vector<Base::Color>&)
{}
virtual void applyElementColors(App::DocumentObject*, const std::map<std::string, App::Color>&)
virtual void applyElementColors(App::DocumentObject*, const std::map<std::string, Base::Color>&)
{}
virtual void applyLinkColor(App::DocumentObject*, int /*index*/, App::Color)
virtual void applyLinkColor(App::DocumentObject*, int /*index*/, Base::Color)
{}
private:
@@ -187,7 +187,7 @@ private:
{}
private:
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors) override
void applyColors(Part::Feature* part, const std::vector<Base::Color>& colors) override
{
myParent.applyFaceColors(part, colors);
}
@@ -217,16 +217,16 @@ class ImportExport ImportOCAFExt: public ImportOCAF2
public:
ImportOCAFExt(Handle(TDocStd_Document) hStdDoc, App::Document* doc, const std::string& name);
std::map<Part::Feature*, std::vector<App::Color>> partColors;
std::map<Part::Feature*, std::vector<Base::Color>> partColors;
private:
void applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors) override;
void applyFaceColors(Part::Feature* part, const std::vector<Base::Color>& colors) override;
};
struct ImportExport ExportOCAFOptions
{
ExportOCAFOptions();
App::Color defaultColor;
Base::Color defaultColor;
bool exportHidden = true;
bool keepPlacement = false;
};
@@ -235,7 +235,7 @@ class ImportExport ExportOCAF2
{
public:
using GetShapeColorsFunc =
std::function<std::map<std::string, App::Color>(App::DocumentObject*, const char*)>;
std::function<std::map<std::string, Base::Color>(App::DocumentObject*, const char*)>;
explicit ExportOCAF2(Handle(TDocStd_Document) h,
GetShapeColorsFunc func = GetShapeColorsFunc());

View File

@@ -251,14 +251,14 @@ void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape,
part->Label.setValue(name);
Quantity_Color aColor;
App::Color color(0.8f, 0.8f, 0.8f);
Base::Color color(0.8f, 0.8f, 0.8f);
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor)
|| aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor)
|| aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
color.r = (float)aColor.Red();
color.g = (float)aColor.Green();
color.b = (float)aColor.Blue();
std::vector<App::Color> colors;
std::vector<Base::Color> colors;
colors.push_back(color);
applyColors(part, colors);
}
@@ -270,7 +270,7 @@ void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape,
xp.Next();
}
bool found_face_color = false;
std::vector<App::Color> faceColors;
std::vector<Base::Color> faceColors;
faceColors.resize(faces.Extent(), color);
xp.Init(aShape, TopAbs_FACE);
while (xp.More()) {

View File

@@ -76,7 +76,7 @@ private:
int dep);
void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&);
void createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&);
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
virtual void applyColors(Part::Feature*, const std::vector<Base::Color>&)
{}
private:

View File

@@ -46,24 +46,24 @@ FC_LOG_LEVEL_INIT("Import", true, true)
using namespace Import;
App::Color Tools::convertColor(const Quantity_ColorRGBA& rgba)
Base::Color Tools::convertColor(const Quantity_ColorRGBA& rgba)
{
Standard_Real red, green, blue;
rgba.GetRGB().Values(red, green, blue, OCC_COLOR_SPACE);
return App::Color(static_cast<float>(red),
static_cast<float>(green),
static_cast<float>(blue),
static_cast<float>(rgba.Alpha()));
return Base::Color(static_cast<float>(red),
static_cast<float>(green),
static_cast<float>(blue),
static_cast<float>(rgba.Alpha()));
}
Quantity_ColorRGBA Tools::convertColor(const App::Color& col)
Quantity_ColorRGBA Tools::convertColor(const Base::Color& col)
{
return Quantity_ColorRGBA(Quantity_Color(col.r, col.g, col.b, OCC_COLOR_SPACE), col.a);
}
static inline std::ostream& operator<<(std::ostream& os, const Quantity_ColorRGBA& rgba)
{
App::Color color = Tools::convertColor(rgba);
Base::Color color = Tools::convertColor(rgba);
auto toHex = [](float v) {
return boost::format("%02X") % static_cast<int>(v * 255);
};

View File

@@ -27,7 +27,7 @@
#include <TopoDS_Shape.hxx>
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <App/Color.h>
#include <Base/Color.h>
#include <Standard_Version.hxx>
@@ -60,8 +60,8 @@ struct LabelHasher
struct Tools
{
static App::Color convertColor(const Quantity_ColorRGBA& rgba);
static Quantity_ColorRGBA convertColor(const App::Color& col);
static Base::Color convertColor(const Quantity_ColorRGBA& rgba);
static Quantity_ColorRGBA convertColor(const Base::Color& col);
static std::string labelName(TDF_Label label);
static void printLabel(TDF_Label label,
Handle(XCAFDoc_ShapeTool) aShapeTool,

View File

@@ -644,7 +644,7 @@ ImpExpDxfRead::MakeLayer(const std::string& name, ColorIndex_t color, std::strin
{
if (m_preserveLayers) {
// Hidden layers are implemented in the wrapup code after the entire file has been read.
App::Color appColor = ObjectColor(color);
Base::Color appColor = ObjectColor(color);
PyObject* draftModule = nullptr;
PyObject* layer = nullptr;
draftModule = getDraftModule();

View File

@@ -15,7 +15,7 @@
#include "dxf.h"
#include <App/Application.h>
#include <App/Color.h>
#include <Base/Color.h>
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <Base/Interpreter.h>
@@ -3027,13 +3027,13 @@ inline static double level(int distance, double blackLevel)
// 8 and beyond yield the black level
return blackLevel;
}
inline static App::Color wheel(int hue, double blackLevel, double multiplier = 1.0)
inline static Base::Color wheel(int hue, double blackLevel, double multiplier = 1.0)
{
return App::Color((float)(level(hue - 0, blackLevel) * multiplier),
(float)(level(hue - 8, blackLevel) * multiplier),
(float)(level(hue - 16, blackLevel) * multiplier));
return Base::Color((float)(level(hue - 0, blackLevel) * multiplier),
(float)(level(hue - 8, blackLevel) * multiplier),
(float)(level(hue - 16, blackLevel) * multiplier));
}
App::Color CDxfRead::ObjectColor(ColorIndex_t index)
Base::Color CDxfRead::ObjectColor(ColorIndex_t index)
{
// TODO: If it is ColorByBlock we need to use the color of the INSERT entity.
// This is tricky because a block can itself contain INSERT entities and we don't currently
@@ -3050,28 +3050,28 @@ App::Color CDxfRead::ObjectColor(ColorIndex_t index)
// The AA fades as AA 7E 56 45 35 which is almost the exact same percentages.
// For hue, (index-10)/10 : 0 is ff0000, and each step linearly adds green until 4 is pure
// yellow ffff00, then red starts to fade... until but not including 24 which is back to ff0000.
App::Color result = App::Color();
Base::Color result = Base::Color();
if (index == 0) {
// Technically, 0 is BYBLOCK and not a real color, but all that means is that an object in a
// block cannot specifically ask to be black. These colors are all contrasted to the
// background so there is no objective black colour, through 255 is an objective white.
result = App::Color();
result = Base::Color();
}
else if (index < 7) {
result = wheel((index - 1) * 4, 0x00);
}
else if (index == 7) {
result = App::Color(1, 1, 1);
result = Base::Color(1, 1, 1);
}
else if (index == 8) {
result = App::Color(0.5, 0.5, 0.5);
result = Base::Color(0.5, 0.5, 0.5);
}
else if (index == 9) {
result = App::Color(0.75, 0.75, 0.75);
result = Base::Color(0.75, 0.75, 0.75);
}
else if (index >= 250) {
auto brightness = (float)((index - 250 + (255 - index) * 0.2) / 5);
result = App::Color(brightness, brightness, brightness);
result = Base::Color(brightness, brightness, brightness);
}
else {
static const std::array<float, 5> fades = {1.00F, 0.74F, 0.50F, 0.40F, 0.30F};

View File

@@ -25,7 +25,7 @@
#include <Base/Matrix.h>
#include <Base/Vector3D.h>
#include <Base/Console.h>
#include <App/Color.h>
#include <Base/Color.h>
#include <Mod/Import/ImportGlobal.h>
// For some reason Cpplint complains about some of the categories used by Clang-tidy
@@ -923,7 +923,7 @@ public:
{
return m_entityAttributes.m_LineType[0] == 'h' || m_entityAttributes.m_LineType[0] == 'H';
}
static App::Color ObjectColor(ColorIndex_t colorIndex); // as rgba value
static Base::Color ObjectColor(ColorIndex_t colorIndex); // as rgba value
#ifdef DEBUG
protected: