Call ensureVisible() only in mouseMoveEvent() method. Alwayse update size of

scene.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2016-01-15 12:05:56 +02:00
parent 9578206ad6
commit b2d498b78c
3 changed files with 43 additions and 50 deletions

View file

@ -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<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty())
{
if (QGraphicsView *view = viewList.at(0))
{
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(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<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty())
{
if (QGraphicsView *view = viewList.at(0))
{
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(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);

View file

@ -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<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty())
{
if (QGraphicsView *view = viewList.at(0))
{
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(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<QGraphicsView *> viewList = scene()->views();
if (not viewList.isEmpty())
{
if (QGraphicsView *view = viewList.at(0))
{
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(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);

View file

@ -369,10 +369,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));
}