From 6d566c2715c3d37dc84a1976fa955964b777f38b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 4 Dec 2015 10:04:43 +0200 Subject: [PATCH] Make fictive scene bigger in all cases. --HG-- branch : develop --- src/libs/vwidgets/vmaingraphicsview.cpp | 27 +++++++++++-------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index d97d9e9de..0bac5bdd3 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -194,25 +194,22 @@ void GraphicsViewZoom::FictiveSceneRect(QGraphicsScene *sc, QGraphicsView *view) const QPointF b = view->mapToScene(view->viewport()->width(), view->viewport()->height()); QRectF viewRect = QRectF( a, b ); + //Scale view + QLineF topLeftRay(viewRect.center(), viewRect.topLeft()); + topLeftRay.setLength(topLeftRay.length()*2); + + QLineF bottomRightRay(viewRect.center(), viewRect.bottomRight()); + bottomRightRay.setLength(bottomRightRay.length()*2); + + viewRect = QRectF(topLeftRay.p2(), bottomRightRay.p2()); + //Calculate scene rect const QRectF sceneRect = sc->sceneRect(); - if (not sceneRect.contains(viewRect)) - {//Scene less than view - //Scale view - QLineF topLeftRay(viewRect.center(), viewRect.topLeft()); - topLeftRay.setLength(topLeftRay.length()*2); + //Unite two rects + const QRectF newRect = sceneRect.united(viewRect); - QLineF bottomRightRay(viewRect.center(), viewRect.bottomRight()); - bottomRightRay.setLength(bottomRightRay.length()*2); - - viewRect = QRectF(topLeftRay.p2(), bottomRightRay.p2()); - - //Unite two rects - const QRectF newRect = sceneRect.united(viewRect); - - sc->setSceneRect(newRect); - } + sc->setSceneRect(newRect); } //---------------------------------------------------------------------------------------------------------------------