Ensure cursor visibility when move curve.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2016-01-14 17:04:36 +02:00
parent 68b723148c
commit f5c85a73a1
2 changed files with 66 additions and 0 deletions

View File

@ -477,6 +477,12 @@ void VToolSpline::SetVisualization()
*/ */
void VToolSpline::RefreshGeometry() 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), this->setPen(QPen(CorrectColor(lineColor),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
if (isHovered || detailsMode) if (isHovered || detailsMode)
@ -506,4 +512,31 @@ void VToolSpline::RefreshGeometry()
controlPoints[1]->blockSignals(false); controlPoints[1]->blockSignals(false);
SetVisualization(); 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() 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) if (isHovered || detailsMode)
{ {
this->setPath(ToolPath(PathDirection::Show)); this->setPath(ToolPath(PathDirection::Show));
@ -583,4 +589,31 @@ void VToolSplinePath::RefreshGeometry()
} }
SetVisualization(); 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);
}
} }