Ensure cursor visibility when move curve.

(grafted from e7cbd25ec5f67ef9b413244b32a543b2a2a0603f)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-01-15 14:57:09 +02:00
parent 6a28f464b9
commit 5517b96613
2 changed files with 66 additions and 0 deletions

View File

@ -477,6 +477,12 @@ void VToolSpline::SetVisualization()
*/
void VToolSpline::RefreshGeometry()
{
// Very important to disable control points. Without it the pogram can't move the curve.
foreach (VControlPointSpline *point, controlPoints)
{
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
}
this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
if (isHovered || detailsMode)
@ -506,4 +512,31 @@ void VToolSpline::RefreshGeometry()
controlPoints[1]->blockSignals(false);
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

@ -549,6 +549,12 @@ void VToolSplinePath::SetVisualization()
*/
void VToolSplinePath::RefreshGeometry()
{
// Very important to disable control points. Without it the pogram can't move the curve.
foreach (VControlPointSpline *point, controlPoints)
{
point->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
}
if (isHovered || detailsMode)
{
this->setPath(ToolPath(PathDirection::Show));
@ -583,4 +589,31 @@ 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);
}
}