From 3026f9dfc6af4d320b6f15ab16d7df032221ee46 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 15 Jan 2016 14:57:23 +0200 Subject: [PATCH] Call ensureVisible() only in mouseMoveEvent() method. Alwayse update size of scene. (grafted from a080e8c10e0817579d802539e4ef30b4b51f43a8) --HG-- branch : develop --- .../tools/drawTools/toolcurve/vtoolspline.cpp | 43 +++++++++---------- .../drawTools/toolcurve/vtoolsplinepath.cpp | 43 +++++++++---------- src/libs/vwidgets/vmaingraphicsview.cpp | 7 +-- 3 files changed, 43 insertions(+), 50 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index e7e0f0170..6af2977e2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -426,6 +426,27 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event) MoveSpline *moveSpl = new MoveSpline(doc, spline.data(), spl, id, this->scene()); connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSpl); + + // Each time we move something we call recalculation scene rect. In some cases this can cause moving + // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move. + static bool changeFinished = true; + if (changeFinished) + { + changeFinished = false; + + const QList viewList = scene()->views(); + if (not viewList.isEmpty()) + { + if (QGraphicsView *view = viewList.at(0)) + { + VMainGraphicsScene *currentScene = qobject_cast(scene()); + SCASSERT(currentScene); + const QPointF cursorPosition = currentScene->getScenePos(); + view->ensureVisible(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10)); + } + } + changeFinished = true; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -513,28 +534,6 @@ void VToolSpline::RefreshGeometry() SetVisualization(); - // Each time we move something we call recalculation scene rect. In some cases this can cause moving - // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move. - static bool changeFinished = true; - if (changeFinished) - { - changeFinished = false; - - const QList viewList = scene()->views(); - if (not viewList.isEmpty()) - { - if (QGraphicsView *view = viewList.at(0)) - { - VMainGraphicsScene *currentScene = qobject_cast(scene()); - SCASSERT(currentScene); - const QPointF cursorPosition = currentScene->getScenePos(); - view->ensureVisible(QRectF(cursorPosition.x()-50, cursorPosition.y()-50, 100, 100)); - } - } - - changeFinished = true; - } - foreach (VControlPointSpline *point, controlPoints) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index dc67d767f..235fe3472 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -503,6 +503,27 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event) MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id, this->scene()); connect(moveSplPath, &VUndoCommand::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveSplPath); + + // Each time we move something we call recalculation scene rect. In some cases this can cause moving + // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move. + static bool changeFinished = true; + if (changeFinished) + { + changeFinished = false; + + const QList viewList = scene()->views(); + if (not viewList.isEmpty()) + { + if (QGraphicsView *view = viewList.at(0)) + { + VMainGraphicsScene *currentScene = qobject_cast(scene()); + SCASSERT(currentScene); + const QPointF cursorPosition = currentScene->getScenePos(); + view->ensureVisible(QRectF(cursorPosition.x()-5, cursorPosition.y()-5, 10, 10)); + } + } + changeFinished = true; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -590,28 +611,6 @@ void VToolSplinePath::RefreshGeometry() SetVisualization(); - // Each time we move something we call recalculation scene rect. In some cases this can cause moving - // objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move. - static bool changeFinished = true; - if (changeFinished) - { - changeFinished = false; - - const QList viewList = scene()->views(); - if (not viewList.isEmpty()) - { - if (QGraphicsView *view = viewList.at(0)) - { - VMainGraphicsScene *currentScene = qobject_cast(scene()); - SCASSERT(currentScene); - const QPointF cursorPosition = currentScene->getScenePos(); - view->ensureVisible(QRectF(cursorPosition.x()-50, cursorPosition.y()-50, 100, 100)); - } - } - - changeFinished = true; - } - foreach (VControlPointSpline *point, controlPoints) { point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 910c46e45..46afb9a5e 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -371,10 +371,5 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view) const QRectF itemsRect = currentScene->VisibleItemsBoundingRect(); //Unite two rects - const QRectF newRect = itemsRect.united(viewRect); - - if (newRect != itemsRect) - {//Update if only need - sc->setSceneRect(newRect); - } + sc->setSceneRect(itemsRect.united(viewRect)); }