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:
@@ -992,7 +992,7 @@ void CenterLine::Restore(Base::XMLReader &reader)
|
||||
m_format.setWidth(reader.getAttributeAsFloat("value"));
|
||||
reader.readElement("Color");
|
||||
std::string tempHex = reader.getAttribute("value");
|
||||
App::Color tempColor;
|
||||
Base::Color tempColor;
|
||||
tempColor.fromHexString(tempHex);
|
||||
m_format.setColor(tempColor);
|
||||
reader.readElement("Visible");
|
||||
|
||||
@@ -248,7 +248,7 @@ void CosmeticEdge::Restore(Base::XMLReader &reader)
|
||||
m_format.setWidth(reader.getAttributeAsFloat("value"));
|
||||
reader.readElement("Color");
|
||||
std::string tempHex = reader.getAttribute("value");
|
||||
App::Color tempColor;
|
||||
Base::Color tempColor;
|
||||
tempColor.fromHexString(tempHex);
|
||||
m_format.setColor(tempColor);
|
||||
reader.readElement("Visible");
|
||||
@@ -451,7 +451,7 @@ void GeomFormat::Restore(Base::XMLReader &reader)
|
||||
m_format.setWidth(reader.getAttributeAsFloat("value"));
|
||||
reader.readElement("Color");
|
||||
std::string tempHex = reader.getAttribute("value");
|
||||
App::Color tempColor;
|
||||
Base::Color tempColor;
|
||||
tempColor.fromHexString(tempHex);
|
||||
m_format.setColor(tempColor);
|
||||
reader.readElement("Visible");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QColor>
|
||||
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
#include <Base/Persistence.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
Base::Vector3d permaPoint{Base::Vector3d()}; //permanent, unscaled value
|
||||
int linkGeom{-1}; //connection to corresponding "geom" Vertex (fragile - index based!)
|
||||
//better to do reverse search for CosmeticTag in vertex geometry
|
||||
App::Color color{App::Color()};
|
||||
Base::Color color{Base::Color()};
|
||||
double size{1.0};
|
||||
int style{1};
|
||||
bool visible{true}; //base class vertex also has visible property
|
||||
|
||||
@@ -169,7 +169,7 @@ void CosmeticVertexPy::setShow(Py::Boolean arg)
|
||||
|
||||
Py::Object CosmeticVertexPy::getColor() const
|
||||
{
|
||||
App::Color color = getCosmeticVertexPtr()->color;
|
||||
Base::Color color = getCosmeticVertexPtr()->color;
|
||||
PyObject* pyColor = DrawUtil::colorToPyTuple(color);
|
||||
return Py::asObject(pyColor);
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void CosmeticVertexPy::setColor(Py::Object arg)
|
||||
{
|
||||
PyObject* pTuple = arg.ptr();
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
App::Color c(red, green, blue, alpha);
|
||||
Base::Color c(red, green, blue, alpha);
|
||||
if (PyTuple_Check(pTuple)) {
|
||||
c = DrawUtil::pyTupleToColor(pTuple);
|
||||
CosmeticVertex* cv = getCosmeticVertexPtr();
|
||||
|
||||
@@ -612,9 +612,9 @@ std::string DrawGeomHatch::prefGeomHatchName()
|
||||
return result;
|
||||
}
|
||||
|
||||
App::Color DrawGeomHatch::prefGeomHatchColor()
|
||||
Base::Color DrawGeomHatch::prefGeomHatchColor()
|
||||
{
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(Preferences::getPreferenceGroup("Colors")->GetUnsigned("GeomHatch", 0x00FF0000));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
static TopoDS_Face extractFace(DrawViewPart* source, int iface );
|
||||
static std::string prefGeomHatchFile();
|
||||
static std::string prefGeomHatchName();
|
||||
static App::Color prefGeomHatchColor();
|
||||
static Base::Color prefGeomHatchColor();
|
||||
static std::vector<LineSet> makeLineSets(std::string fileSpec, std::string myPattern);
|
||||
|
||||
void translateLabel(std::string context, std::string baseName, std::string uniqueName);
|
||||
|
||||
@@ -215,9 +215,9 @@ std::string DrawHatch::prefSvgHatch(void)
|
||||
return Preferences::svgFile();
|
||||
}
|
||||
|
||||
App::Color DrawHatch::prefSvgHatchColor(void)
|
||||
Base::Color DrawHatch::prefSvgHatchColor(void)
|
||||
{
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(Preferences::getPreferenceGroup("Colors")->GetUnsigned("Hatch", 0x00FF0000));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
bool empty();
|
||||
static bool faceIsHatched(int i, std::vector<TechDraw::DrawHatch*> hatchObjs);
|
||||
static std::string prefSvgHatch();
|
||||
static App::Color prefSvgHatchColor();
|
||||
static Base::Color prefSvgHatchColor();
|
||||
|
||||
bool isSvgHatch() const;
|
||||
bool isBitmapHatch() const;
|
||||
|
||||
@@ -1097,12 +1097,12 @@ std::vector<std::string> DrawUtil::tokenize(std::string csvLine, std::string del
|
||||
return tokens;
|
||||
}
|
||||
|
||||
App::Color DrawUtil::pyTupleToColor(PyObject* pColor)
|
||||
Base::Color DrawUtil::pyTupleToColor(PyObject* pColor)
|
||||
{
|
||||
// Base::Console().Message("DU::pyTupleToColor()\n");
|
||||
double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
|
||||
if (!PyTuple_Check(pColor)) {
|
||||
return App::Color(red, green, blue, alpha);
|
||||
return Base::Color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
int tSize = (int)PyTuple_Size(pColor);
|
||||
@@ -1118,10 +1118,10 @@ App::Color DrawUtil::pyTupleToColor(PyObject* pColor)
|
||||
PyObject* pAlpha = PyTuple_GetItem(pColor, 3);
|
||||
alpha = PyFloat_AsDouble(pAlpha);
|
||||
}
|
||||
return App::Color(red, green, blue, alpha);
|
||||
return Base::Color(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
PyObject* DrawUtil::colorToPyTuple(App::Color color)
|
||||
PyObject* DrawUtil::colorToPyTuple(Base::Color color)
|
||||
{
|
||||
// Base::Console().Message("DU::pyTupleToColor()\n");
|
||||
PyObject* pTuple = PyTuple_New(4);
|
||||
|
||||
@@ -202,8 +202,8 @@ public:
|
||||
static std::vector<std::string> split(std::string csvLine);
|
||||
static std::vector<std::string> tokenize(std::string csvLine,
|
||||
std::string delimiter = ", $$$, ");
|
||||
static App::Color pyTupleToColor(PyObject* pColor);
|
||||
static PyObject* colorToPyTuple(App::Color color);
|
||||
static Base::Color pyTupleToColor(PyObject* pColor);
|
||||
static PyObject* colorToPyTuple(Base::Color color);
|
||||
static bool isCrazy(TopoDS_Edge e);
|
||||
static Base::Vector3d getFaceCenter(TopoDS_Face f);
|
||||
static bool circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C);
|
||||
|
||||
@@ -94,7 +94,7 @@ App::DocumentObjectExecReturn *DrawViewDraft::execute()
|
||||
// Draft.get_svg(obj, scale=1, linewidth=0.35, fontsize=12, fillstyle="shape color", direction=None, linestyle=None, color=None, linespacing=None, techdraw=False)
|
||||
|
||||
std::stringstream paramStr;
|
||||
App::Color col = Color.getValue();
|
||||
Base::Color col = Color.getValue();
|
||||
paramStr << ", scale=" << getScale()
|
||||
<< ", linewidth=" << LineWidth.getValue()
|
||||
<< ", fontsize=" << FontSize.getValue()
|
||||
|
||||
@@ -351,7 +351,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
|
||||
PyObject* pPnt2 = nullptr;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O!|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -389,7 +389,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args)
|
||||
PyObject* pPnt2 = nullptr;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!O!|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -434,7 +434,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
|
||||
double radius = 5.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!d|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -474,7 +474,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
|
||||
double angle2 = 360.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -516,7 +516,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle3d(PyObject *args)
|
||||
double radius = 5.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!d|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -559,7 +559,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc3d(PyObject *args)
|
||||
double angle2 = 360.0;
|
||||
int style = LineFormat::getDefEdgeStyle();
|
||||
double weight = LineFormat::getDefEdgeWidth();
|
||||
App::Color defCol = LineFormat::getDefEdgeColor();
|
||||
Base::Color defCol = LineFormat::getDefEdgeColor();
|
||||
PyObject* pColor = nullptr;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!ddd|idO!", &(Base::VectorPy::Type), &pPnt1,
|
||||
@@ -757,7 +757,7 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args)
|
||||
// Base::Console().Message("DVPPI::formatGeometricEdge()\n");
|
||||
int idx = -1;
|
||||
int style = Qt::SolidLine;
|
||||
App::Color color = LineFormat::getDefEdgeColor();
|
||||
Base::Color color = LineFormat::getDefEdgeColor();
|
||||
double weight = 0.5;
|
||||
int visible = 1;
|
||||
PyObject* pColor;
|
||||
|
||||
@@ -243,7 +243,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
|
||||
result << getSVGHead();
|
||||
|
||||
std::string ViewName = Label.getValue();
|
||||
App::Color c = TextColor.getValue();
|
||||
Base::Color c = TextColor.getValue();
|
||||
result << "<g id=\"" << ViewName << "\">" << std::endl;
|
||||
|
||||
// fill the cells
|
||||
@@ -296,7 +296,7 @@ std::string DrawViewSpreadsheet::getSheetImage()
|
||||
std::string fcolor = c.asHexString();
|
||||
std::string textstyle;
|
||||
if (cell) {
|
||||
App::Color f, b;
|
||||
Base::Color f, b;
|
||||
std::set<std::string> st;
|
||||
int colspan, rowspan;
|
||||
if (cell->getBackground(b)) {
|
||||
|
||||
@@ -72,7 +72,7 @@ void LineFormat::setCurrentLineFormat(LineFormat& newFormat)
|
||||
|
||||
LineFormat::LineFormat(const int style,
|
||||
const double weight,
|
||||
const App::Color& color,
|
||||
const Base::Color& color,
|
||||
const bool visible) :
|
||||
m_style(style),
|
||||
m_weight(weight),
|
||||
@@ -104,7 +104,7 @@ double LineFormat::getDefEdgeWidth()
|
||||
return TechDraw::LineGroup::getDefaultWidth("Graphic");
|
||||
}
|
||||
|
||||
App::Color LineFormat::getDefEdgeColor()
|
||||
Base::Color LineFormat::getDefEdgeColor()
|
||||
{
|
||||
return Preferences::normalColor();
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include <App/Color.h>
|
||||
#include <Base/Color.h>
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
@@ -43,13 +43,13 @@ public:
|
||||
LineFormat();
|
||||
LineFormat(const int style,
|
||||
const double weight,
|
||||
const App::Color& color,
|
||||
const Base::Color& color,
|
||||
const bool visible,
|
||||
const int lineNumber);
|
||||
// TODO: phase out the old 4 parameter constructor
|
||||
LineFormat(const int style,
|
||||
const double weight,
|
||||
const App::Color& color,
|
||||
const Base::Color& color,
|
||||
const bool visible);
|
||||
~LineFormat() = default;
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
double getWidth() const { return m_weight; }
|
||||
void setWidth(double width) {m_weight = width; }
|
||||
|
||||
App::Color getColor() const { return m_color; }
|
||||
void setColor(App::Color color) { m_color = color; }
|
||||
Base::Color getColor() const { return m_color; }
|
||||
void setColor(Base::Color color) { m_color = color; }
|
||||
QColor getQColor() const { return m_color.asValue<QColor>(); }
|
||||
void setQColor(QColor qColor) { m_color.set(qColor.redF(), qColor.greenF(), qColor.blueF(), 1.0 - qColor.alphaF()); }
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
void setLineNumber(int number) { m_lineNumber = number; }
|
||||
|
||||
static double getDefEdgeWidth();
|
||||
static App::Color getDefEdgeColor();
|
||||
static Base::Color getDefEdgeColor();
|
||||
static int getDefEdgeStyle();
|
||||
|
||||
void dump(const char* title);
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
private:
|
||||
int m_style;
|
||||
double m_weight;
|
||||
App::Color m_color;
|
||||
Base::Color m_color;
|
||||
bool m_visible;
|
||||
int m_lineNumber {1};
|
||||
};
|
||||
|
||||
@@ -77,14 +77,14 @@ double Preferences::dimArrowSize()
|
||||
return getPreferenceGroup("Dimensions")->GetFloat("ArrowSize", DefaultArrowSize);
|
||||
}
|
||||
|
||||
App::Color Preferences::normalColor()
|
||||
Base::Color Preferences::normalColor()
|
||||
{
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(getPreferenceGroup("Colors")->GetUnsigned("NormalColor", 0x000000FF));//#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::selectColor()
|
||||
Base::Color Preferences::selectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
@@ -93,12 +93,12 @@ App::Color Preferences::selectColor()
|
||||
->GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("SelectionColor", 0x00FF00FF);//#00FF00 lime
|
||||
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(getPreferenceGroup("Colors")->GetUnsigned("SelectColor", defColor));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::preselectColor()
|
||||
Base::Color Preferences::preselectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
@@ -107,14 +107,14 @@ App::Color Preferences::preselectColor()
|
||||
->GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("HighlightColor", 0xFFFF00FF);//#FFFF00 yellow
|
||||
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(getPreferenceGroup("Colors")->GetUnsigned("PreSelectColor", defColor));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::vertexColor()
|
||||
Base::Color Preferences::vertexColor()
|
||||
{
|
||||
App::Color fcColor;
|
||||
Base::Color fcColor;
|
||||
fcColor.setPackedValue(getPreferenceGroup("Decorations")->GetUnsigned("VertexColor", 0x000000FF));//#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
@@ -376,16 +376,16 @@ void Preferences::monochrome(bool state)
|
||||
getPreferenceGroup("Colors")->SetBool("Monochrome", state);
|
||||
}
|
||||
|
||||
App::Color Preferences::lightTextColor()
|
||||
Base::Color Preferences::lightTextColor()
|
||||
{
|
||||
App::Color result;
|
||||
Base::Color result;
|
||||
result.setPackedValue(getPreferenceGroup("Colors")->GetUnsigned("LightTextColor", 0xFFFFFFFF));//#FFFFFFFF white
|
||||
return result;
|
||||
}
|
||||
|
||||
//! attempt to lighten the give color
|
||||
// not currently used
|
||||
App::Color Preferences::lightenColor(App::Color orig)
|
||||
Base::Color Preferences::lightenColor(Base::Color orig)
|
||||
{
|
||||
// get component colours on [0, 255]
|
||||
uchar red = orig.r * 255;
|
||||
@@ -412,11 +412,11 @@ App::Color Preferences::lightenColor(App::Color orig)
|
||||
double greenF = (double)green / 255.0;
|
||||
double blueF = (double)blue / 255.0;
|
||||
|
||||
return App::Color(redF, greenF, blueF, orig.a);
|
||||
return Base::Color(redF, greenF, blueF, orig.a);
|
||||
}
|
||||
|
||||
//! color to use for monochrome display
|
||||
App::Color Preferences::getAccessibleColor(App::Color orig)
|
||||
Base::Color Preferences::getAccessibleColor(Base::Color orig)
|
||||
{
|
||||
if (Preferences::lightOnDark() && Preferences::monochrome()) {
|
||||
return lightTextColor();
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
class QColor;
|
||||
class QString;
|
||||
|
||||
namespace App
|
||||
namespace Base
|
||||
{
|
||||
class Color;
|
||||
}
|
||||
@@ -55,10 +55,10 @@ public:
|
||||
static double dimFontSizeMM();
|
||||
static double dimArrowSize();
|
||||
|
||||
static App::Color normalColor();
|
||||
static App::Color selectColor();
|
||||
static App::Color preselectColor();
|
||||
static App::Color vertexColor();
|
||||
static Base::Color normalColor();
|
||||
static Base::Color selectColor();
|
||||
static Base::Color preselectColor();
|
||||
static Base::Color vertexColor();
|
||||
static double vertexScale();
|
||||
static int scaleType();
|
||||
static double scale();
|
||||
@@ -103,9 +103,9 @@ public:
|
||||
static void lightOnDark(bool state);
|
||||
static bool monochrome();
|
||||
static void monochrome(bool state);
|
||||
static App::Color lightTextColor();
|
||||
static App::Color lightenColor(App::Color orig);
|
||||
static App::Color getAccessibleColor(App::Color orig);
|
||||
static Base::Color lightTextColor();
|
||||
static Base::Color lightenColor(Base::Color orig);
|
||||
static Base::Color getAccessibleColor(Base::Color orig);
|
||||
|
||||
static bool autoCorrectDimRefs();
|
||||
static int scrubCount();
|
||||
|
||||
Reference in New Issue
Block a user