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

scene.
(grafted from a080e8c10e0817579d802539e4ef30b4b51f43a8)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-15 14:57:23 +02:00
parent 5517b96613
commit 3026f9dfc6
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

@ -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));
}