From 6cb67579084fad4da7bc84092fa929af3afcadbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Sun, 23 Feb 2025 00:07:20 +0100 Subject: [PATCH] TechDraw: remove unneeded state from QGIDecoration --- src/Mod/TechDraw/Gui/QGIDecoration.cpp | 16 +++++---------- src/Mod/TechDraw/Gui/QGIDecoration.h | 7 +------ src/Mod/TechDraw/Gui/QGISectionLine.cpp | 18 +++++++---------- src/Mod/TechDraw/Gui/QGITile.cpp | 27 +++++++++---------------- 4 files changed, 23 insertions(+), 45 deletions(-) diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.cpp b/src/Mod/TechDraw/Gui/QGIDecoration.cpp index 1922a500a7..98717bb881 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.cpp +++ b/src/Mod/TechDraw/Gui/QGIDecoration.cpp @@ -38,9 +38,7 @@ using namespace TechDrawGui; using namespace TechDraw; QGIDecoration::QGIDecoration() : - m_colCurrent(Qt::black), - m_styleCurrent(Qt::SolidLine), - m_brushCurrent(Qt::SolidPattern), + m_pen(Qt::SolidLine), m_dragState(DragState::NoDrag) { setCacheMode(QGraphicsItem::NoCache); @@ -68,22 +66,18 @@ void QGIDecoration::paint ( QPainter * painter, const QStyleOptionGraphicsItem * void QGIDecoration::setWidth(double w) { - m_width = w; - m_pen.setWidthF(m_width); + m_pen.setWidthF(w); } void QGIDecoration::setStyle(Qt::PenStyle s) { - m_styleCurrent = s; - m_pen.setStyle(m_styleCurrent); + m_pen.setStyle(s); } void QGIDecoration::setColor(QColor c) { - m_colNormal = c; - m_colCurrent = c; - m_pen.setColor(m_colCurrent); - m_brush.setColor(m_colCurrent); + m_pen.setColor(c); + m_brush.setColor(c); } QColor QGIDecoration::prefNormalColor() diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.h b/src/Mod/TechDraw/Gui/QGIDecoration.h index 1f033e48d7..fe3de1391a 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.h +++ b/src/Mod/TechDraw/Gui/QGIDecoration.h @@ -67,11 +67,10 @@ public: virtual void onDragFinished(); void setWidth(double w); - double getWidth() { return m_width; } + double getWidth() { return m_pen.widthF(); } void setStyle(Qt::PenStyle s); void setColor(QColor c); QColor getColor() { return m_colNormal; } - void setFill(Qt::BrushStyle bs) { m_brushCurrent = bs; } void makeMark(double x, double y); void makeMark(Base::Vector3d v); @@ -84,11 +83,7 @@ protected: virtual QColor prefSelectColor(); QPen m_pen; QBrush m_brush; - QColor m_colCurrent; QColor m_colNormal; - double m_width; - Qt::PenStyle m_styleCurrent; - Qt::BrushStyle m_brushCurrent; DragState m_dragState; diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp index cff66044de..37415d4df5 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp +++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp @@ -483,22 +483,18 @@ void QGISectionLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem void QGISectionLine::setTools() { - m_pen.setWidthF(m_width); - m_pen.setColor(m_colCurrent); - m_brush.setStyle(m_brushCurrent); - m_brush.setColor(m_colCurrent); - m_line->setPen(m_pen); + QColor currentColor = m_pen.color(); - m_arrow1->setNormalColor(m_colCurrent); - m_arrow1->setFillColor(m_colCurrent); + m_arrow1->setNormalColor(currentColor); + m_arrow1->setFillColor(currentColor); m_arrow1->setPrettyNormal(); - m_arrow2->setNormalColor(m_colCurrent); - m_arrow2->setFillColor(m_colCurrent); + m_arrow2->setNormalColor(currentColor); + m_arrow2->setFillColor(currentColor); m_arrow2->setPrettyNormal(); - m_symbol1->setDefaultTextColor(m_colCurrent); - m_symbol2->setDefaultTextColor(m_colCurrent); + m_symbol1->setDefaultTextColor(currentColor); + m_symbol2->setDefaultTextColor(currentColor); } diff --git a/src/Mod/TechDraw/Gui/QGITile.cpp b/src/Mod/TechDraw/Gui/QGITile.cpp index bc3d6580bc..a2a02d1684 100644 --- a/src/Mod/TechDraw/Gui/QGITile.cpp +++ b/src/Mod/TechDraw/Gui/QGITile.cpp @@ -84,7 +84,6 @@ QGITile::QGITile(TechDraw::DrawTileWeld* dtw) : setFlag(QGraphicsItem::ItemStacksBehindParent, true); m_colNormal = prefNormalColor(); - m_colCurrent = m_colNormal; } @@ -100,7 +99,6 @@ void QGITile::draw() void QGITile::makeSymbol() { -// m_effect->setColor(m_colCurrent); // m_qgSvg->setGraphicsEffect(m_effect); std::string symbolString = getStringFromFile(m_tileFeat->SymbolFile.getValue()); @@ -123,7 +121,6 @@ void QGITile::makeText() m_qgTextL->setFont(m_font); m_qgTextL->setPlainText(m_textL); - m_qgTextL->setColor(m_colCurrent); double textWidth = m_qgTextL->boundingRect().width(); double charWidth = textWidth / m_textL.size(); //not good for non-ASCII chars double hMargin = 1; @@ -148,7 +145,6 @@ void QGITile::makeText() m_qgTextR->setFont(m_font); m_qgTextR->setPlainText(m_textR); - m_qgTextR->setColor(m_colCurrent); textWidth = m_qgTextR->boundingRect().width(); charWidth = textWidth / m_textR.size(); hMargin = 1; @@ -165,7 +161,6 @@ void QGITile::makeText() m_qgTextC->setFont(m_font); m_qgTextC->setPlainText(m_textC); - m_qgTextC->setColor(m_colCurrent); double textHeightC = m_qgTextC->boundingRect().height(); if (m_row < 0) { // below line vOffset = m_high * (1 + verticalFudge); @@ -235,8 +230,6 @@ void QGITile::setSymbolFile(const std::string &fileSpec) } void QGITile::setPrettyNormal() { - m_colCurrent = m_colNormal; - // m_effect->setColor(m_colNormal); m_qgTextL->setColor(m_colNormal); m_qgTextR->setColor(m_colNormal); @@ -246,23 +239,23 @@ void QGITile::setPrettyNormal() { } void QGITile::setPrettyPre() { - m_colCurrent = prefPreColor(); + QColor color = prefPreColor(); -// m_effect->setColor(m_colCurrent); - m_qgTextL->setColor(m_colCurrent); - m_qgTextR->setColor(m_colCurrent); - m_qgTextC->setColor(m_colCurrent); +// m_effect->setColor(color); + m_qgTextL->setColor(color); + m_qgTextR->setColor(color); + m_qgTextC->setColor(color); draw(); } void QGITile::setPrettySel() { - m_colCurrent = prefSelectColor(); + QColor color = prefSelectColor(); -// m_effect->setColor(m_colCurrent); - m_qgTextL->setColor(m_colCurrent); - m_qgTextR->setColor(m_colCurrent); - m_qgTextC->setColor(m_colCurrent); +// m_effect->setColor(color); + m_qgTextL->setColor(color); + m_qgTextR->setColor(color); + m_qgTextC->setColor(color); draw(); }