From a25fe5dc2b163e29800d09dd354a0e82daf59b2d Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 30 Nov 2014 13:34:27 +0200 Subject: [PATCH] Fix for method VGObject::BuildRay. Correct way make rect bigger. --HG-- branch : develop --- src/app/geometry/vgobject.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/geometry/vgobject.cpp b/src/app/geometry/vgobject.cpp index dcf3280cc..0c17fc860 100644 --- a/src/app/geometry/vgobject.cpp +++ b/src/app/geometry/vgobject.cpp @@ -193,10 +193,14 @@ QLineF VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal & QPointF VGObject::BuildRay(const QPointF &firstPoint, const qreal &angle, const QRectF &scRect) { QRectF rect = scRect; + if (rect.isValid() == false) + { + rect = QRectF(0, 0, 1200, 700); + } if (rect.contains(firstPoint) == false) { - // If point outside of scene rect use the biggest rect that can be. - QRectF rectangle(INT_MIN, INT_MIN, INT_MAX, INT_MAX); + // If point outside of scene rect create one around point and unite two rects. + QRectF rectangle(firstPoint.x()-rect.width()/2, firstPoint.y()-rect.height()/2, rect.width(), rect.height()); rect = rect.united(rectangle); } const qreal diagonal = qSqrt(pow(rect.height(), 2) + pow(rect.width(), 2));