From aec154e43cdc8fe86efd728b9e471880b879d7c8 Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 17 Aug 2014 22:34:01 +0300 Subject: [PATCH] If point intersects with rect the line to the label wrong. --HG-- branch : develop --- src/app/tools/drawTools/vtoolpoint.cpp | 40 ++++++++++++++++---------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index f4b7226c4..032ab2a98 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -241,27 +241,37 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point) */ void VToolPoint::RefreshLine() { - QRectF nameRec = namePoint->sceneBoundingRect(); - QPointF p1, p2; - LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); - QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); - lineName->setLine(QLineF(p1, pRec - scenePos())); - if (currentColor == Qt::gray) + QRectF nRec = namePoint->sceneBoundingRect(); + nRec.translate(- scenePos()); + if (this->rect().intersects(nRec) == false) { - lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + QRectF nameRec = namePoint->sceneBoundingRect(); + QPointF p1, p2; + LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2); + QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); + lineName->setLine(QLineF(p1, pRec - scenePos())); + if (currentColor == Qt::gray) + { + lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + } + else + { + lineName->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); + } + + if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm)) + { + lineName->setVisible(false); + } + else + { + lineName->setVisible(true); + } } else - { - lineName->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); - } - if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm)) { lineName->setVisible(false); } - else - { - lineName->setVisible(true); - } } //---------------------------------------------------------------------------------------------------------------------