From 8ad28c51934b26b2bca1470bf22e184e4ff7f779 Mon Sep 17 00:00:00 2001 From: Krasilnikov Sergey Date: Wed, 9 Oct 2024 11:09:52 +0300 Subject: [PATCH] fix unneeded setPen --- qucs/diagrams/tabdiagram.cpp | 2 +- qucs/misc.cpp | 5 +++-- qucs/paintings/ellipse.cpp | 2 -- qucs/paintings/ellipsearc.cpp | 2 -- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/qucs/diagrams/tabdiagram.cpp b/qucs/diagrams/tabdiagram.cpp index 333149bf8..5c59e9281 100644 --- a/qucs/diagrams/tabdiagram.cpp +++ b/qucs/diagrams/tabdiagram.cpp @@ -116,7 +116,7 @@ void TabDiagram::paintDiagram(QPainter *painter) { if (isSelected) { painter->setPen(QPen(Qt::darkGray,3)); painter->drawRect(-5, -y2-5, x2+10, y2+10); - painter->setPen(QPen(Qt::darkRed,2)); + misc::draw_resize_handle(painter, QPoint{0, -y2}); misc::draw_resize_handle(painter, QPoint{0, 0}); misc::draw_resize_handle(painter, QPoint{x2, -y2}); diff --git a/qucs/misc.cpp b/qucs/misc.cpp index be9f2278a..69223a657 100644 --- a/qucs/misc.cpp +++ b/qucs/misc.cpp @@ -846,11 +846,12 @@ void misc::draw_resize_handle(QPainter* painter, const QPointF& center) { // 1. Find out where on canvas lies the central point and remember these // coordinates // 2. Remove all transformations and draw the handle in its natural size - QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size + static QRectF resize_handle{0, 0, 10, 10}; // nothing special, just a size resize_handle.moveCenter(painter->transform().map(center)); + static QTransform transform{}; // reset transformation painter->save(); - painter->setTransform(QTransform{}); + painter->setTransform(transform); painter->setPen(QPen{Qt::darkRed, 2}); painter->drawRect(resize_handle); painter->restore(); diff --git a/qucs/paintings/ellipse.cpp b/qucs/paintings/ellipse.cpp index 9a883aad3..b6f0a743f 100644 --- a/qucs/paintings/ellipse.cpp +++ b/qucs/paintings/ellipse.cpp @@ -57,8 +57,6 @@ void qucs::Ellipse::paint(QPainter *painter) { painter->setPen(QPen(Qt::white, Pen.width(), Pen.style())); painter->drawEllipse(cx, cy, x2, y2); - painter->setPen(QPen(Qt::darkRed,2)); - misc::draw_resize_handle(painter, QPoint{cx, cy}); misc::draw_resize_handle(painter, QPoint{cx, cy + y2}); misc::draw_resize_handle(painter, QPoint{cx + x2, cy}); diff --git a/qucs/paintings/ellipsearc.cpp b/qucs/paintings/ellipsearc.cpp index 6d22f2e63..a9a2a3130 100644 --- a/qucs/paintings/ellipsearc.cpp +++ b/qucs/paintings/ellipsearc.cpp @@ -52,8 +52,6 @@ void EllipseArc::paint(QPainter *painter) { painter->setPen(QPen(Qt::white, Pen.width(), Pen.style())); painter->drawArc(cx, cy, x2, y2, Angle, ArcLen); - painter->setPen(QPen(Qt::darkRed, 2)); - misc::draw_resize_handle(painter, QPoint{cx, cy}); misc::draw_resize_handle(painter, QPoint{cx, cy + y2}); misc::draw_resize_handle(painter, QPoint{cx + x2, cy});