From 60531f384ea6c3357c012b83504e2f6f534017fd Mon Sep 17 00:00:00 2001 From: wandererfan Date: Wed, 21 Jun 2023 20:10:02 -0400 Subject: [PATCH] [TD]resolve variable name confusion QPen and QBrush variable names were too similar and easily confused. --- src/Mod/TechDraw/Gui/QGIFace.cpp | 29 ++++++++++++++++------------ src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 19 ++++++++---------- src/Mod/TechDraw/Gui/QGIPrimPath.h | 7 ++++--- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index b09af8cf34..f3008fc0ed 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -62,10 +62,12 @@ QGIFace::QGIFace(int index) : isHatched(false); setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); - //setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging - setStyle(Qt::DashLine); + setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging + //setStyle(Qt::DashLine); m_geomColor = PreferencesGui::getAccessibleQColor(QColor(Qt::black)); - setLineWeight(0.5); //0 = cosmetic + m_styleCurrent = Qt::NoPen; + m_pen.setStyle(m_styleCurrent); + setLineWeight(0.0); //0 = cosmetic setPrettyNormal(); m_texture = QPixmap(); //empty texture @@ -82,19 +84,20 @@ QGIFace::QGIFace(int index) : getParameters(); // set up style & colour defaults - m_styleDef = Qt::SolidPattern; - m_styleSelect = Qt::SolidPattern; App::Color temp {static_cast(Preferences::getPreferenceGroup("Colors")->GetUnsigned("FaceColor",0xffffffff))}; setFillColor(temp.asValue()); m_colDefFill = temp.asValue(); + m_fillDef = Qt::SolidPattern; + m_fillSelect = Qt::SolidPattern; if (m_defClearFace) { setFillMode(NoFill); m_colDefFill = Qt::transparent; - setFill(Qt::transparent, m_styleDef); + setFill(Qt::transparent, m_fillDef); } else { setFillMode(PlainFill); - setFill(m_colDefFill, m_styleDef); + m_colDefFill = Qt::white; + setFill(m_colDefFill, m_fillDef); } m_sharedRender = new QSvgRenderer(); @@ -108,6 +111,7 @@ QGIFace::~QGIFace() /// redraw this face void QGIFace::draw() { +// Base::Console().Message("QGIF::draw - pen style: %d\n", m_pen.style()); setPath(m_outline); //Face boundary if (isHatched()) { @@ -116,8 +120,8 @@ void QGIFace::draw() setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); if (!m_lineSets.empty()) { m_brush.setTexture(QPixmap()); - m_fillStyleCurrent = m_styleDef; - m_styleNormal = m_fillStyleCurrent; + m_fillStyleCurrent = m_fillDef; + m_fillNormal = m_fillStyleCurrent; for (auto& ls: m_lineSets) { lineSetToFillItems(ls); } @@ -126,8 +130,8 @@ void QGIFace::draw() m_svgHatchArea->hide(); } else if (m_mode == SvgFill) { m_brush.setTexture(QPixmap()); - m_styleNormal = m_styleDef; - m_fillStyleCurrent = m_styleNormal; + m_fillNormal = m_fillDef; + m_fillStyleCurrent = m_fillNormal; loadSvgHatch(m_fileSpec); if (m_hideSvgTiles) { //bitmap hatch doesn't need clipping @@ -147,7 +151,7 @@ void QGIFace::draw() m_texture = textureFromBitmap(m_fileSpec); m_brush.setTexture(m_texture); } else if (m_mode == PlainFill) { - setFill(m_colNormalFill, m_styleNormal); + setFill(m_colNormalFill, m_fillNormal); m_imageHatchArea->hide(); m_svgHatchArea->hide(); } @@ -189,6 +193,7 @@ void QGIFace::setPrettySel() { /// show or hide the edges of this face. Usually just for debugging void QGIFace::setDrawEdges(bool b) { +// Base::Console().Message("QGIF::setDrawEdges(%d)\n", b); if (b) { setStyle(Qt::DashLine); } else { diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index f33d441a83..1e9845269a 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -65,10 +65,10 @@ QGIPrimPath::QGIPrimPath(): m_pen.setCapStyle(m_capStyle); m_pen.setWidthF(m_width); - m_styleDef = Qt::NoBrush; - m_styleSelect = Qt::SolidPattern; - m_styleNormal = m_styleDef; - m_fillStyleCurrent = m_styleNormal; + m_fillDef = Qt::NoBrush; + m_fillSelect = Qt::SolidPattern; + m_fillNormal = m_fillDef; + m_fillStyleCurrent = m_fillNormal; m_colDefFill = Qt::white; // m_colDefFill = Qt::transparent; @@ -216,7 +216,6 @@ void QGIPrimPath::setStyle(int s) m_styleCurrent = static_cast(s); } - void QGIPrimPath::setNormalColor(QColor c) { m_colNormal = c; @@ -279,20 +278,20 @@ void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event) void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) { setFillColor(c); - m_styleNormal = s; + m_fillNormal = s; m_fillStyleCurrent = s; } void QGIPrimPath::setFill(QBrush b) { setFillColor(b.color()); - m_styleNormal = b.style(); + m_fillNormal = b.style(); m_fillStyleCurrent = b.style(); } void QGIPrimPath::resetFill() { m_colNormalFill = m_colDefFill; - m_styleNormal = m_styleDef; - m_fillStyleCurrent = m_styleDef; + m_fillNormal = m_fillDef; + m_fillStyleCurrent = m_fillDef; } //set PlainFill @@ -303,14 +302,12 @@ void QGIPrimPath::setFillColor(QColor c) // m_colDefFill = c; } - void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; m_pen.setWidthF(m_width); m_pen.setColor(m_colCurrent); - m_pen.setStyle(m_styleCurrent); setPen(m_pen); m_brush.setColor(m_fillColorCurrent); diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h index 36128243d0..fad67c44a5 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.h +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h @@ -93,6 +93,7 @@ protected: QColor m_colNormal; bool m_colOverride; Qt::PenStyle m_styleCurrent; + Qt::PenStyle m_styleNormal; double m_width; Qt::PenCapStyle m_capStyle; @@ -102,9 +103,9 @@ protected: QColor m_colDefFill; //"no color" default normal fill color QColor m_colNormalFill; //current Normal fill color def or plain fill - Qt::BrushStyle m_styleDef; //default Normal fill style - Qt::BrushStyle m_styleNormal; //current Normal fill style - Qt::BrushStyle m_styleSelect; //Select/preSelect fill style + Qt::BrushStyle m_fillDef; //default Normal fill style + Qt::BrushStyle m_fillNormal; //current Normal fill style + Qt::BrushStyle m_fillSelect; //Select/preSelect fill style bool m_fillOverride;