Optimization. No need to refresh a pattern when move a label.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-28 12:21:24 +03:00
parent 2e83967caf
commit 0c9b8453bf
5 changed files with 11 additions and 18 deletions

View File

@ -165,20 +165,16 @@ void VToolDoublePoint::UpdateNamePosition(quint32 id)
{
if (id == p1id)
{
VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
const VPointF *p1 = VAbstractTool::data.GeometricObject<VPointF>(p1id).data();
MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id,
this->scene());
connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
auto moveLabel = new MoveDoubleLabel(doc, p1->mx(), p1->my(), DoublePoint::FirstPoint, this->id, scene());
qApp->getUndoStack()->push(moveLabel);
}
else if (id == p2id)
{
VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
const VPointF *p2 = VAbstractTool::data.GeometricObject<VPointF>(p2id).data();
MoveDoubleLabel *moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id,
this->scene());
connect(moveLabel, &MoveDoubleLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
auto moveLabel = new MoveDoubleLabel(doc, p2->mx(), p2->my(), DoublePoint::SecondPoint, this->id, scene());
qApp->getUndoStack()->push(moveLabel);
}
}

View File

@ -128,8 +128,7 @@ void VToolSinglePoint::NameChangePosition(const QPointF &pos)
void VToolSinglePoint::UpdateNamePosition(quint32 id)
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
MoveLabel *moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, this->scene());
connect(moveLabel, &MoveLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
auto moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, scene());
qApp->getUndoStack()->push(moveLabel);
}
@ -249,7 +248,8 @@ void VToolSinglePoint::RefreshLine(quint32 id)
{
Q_UNUSED(id)
VAbstractTool::RefreshLine(this, namePoint, lineName, radius);
lineName->setPen(QPen(CorrectColor(Qt::black), qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
lineName->setPen(QPen(CorrectColor(Qt::black),
qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -323,8 +323,8 @@ void VAbstractTool::AddRecord(const quint32 id, const Tool &toolType, VAbstractP
/**
* @brief RefreshLine refresh line to label on scene.
*/
void VAbstractTool::RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleTextItem *namePoint, QGraphicsLineItem *lineName,
const qreal radius)
void VAbstractTool::RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleTextItem *namePoint,
QGraphicsLineItem *lineName, const qreal radius)
{
SCASSERT(point != nullptr);
SCASSERT(namePoint != nullptr);
@ -336,7 +336,8 @@ void VAbstractTool::RefreshLine(QGraphicsEllipseItem *point, VGraphicsSimpleText
{
const QRectF nameRec = namePoint->sceneBoundingRect();
QPointF p1, p2;
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - point->scenePos()), p1, p2);
VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - point->scenePos()), p1,
p2);
const QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(point->scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - point->scenePos()));

View File

@ -176,8 +176,6 @@ void MoveDoubleLabel::Do(double mx, double my)
doc->SetAttribute(domElement, AttrMx2, QString().setNum(qApp->fromPixel(mx)));
doc->SetAttribute(domElement, AttrMy2, QString().setNum(qApp->fromPixel(my)));
}
emit NeedLiteParsing(Document::LitePPParse);
}
else
{

View File

@ -119,8 +119,6 @@ void MoveLabel::Do(double mx, double my)
{
doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(mx)));
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my)));
emit NeedLiteParsing(Document::LitePPParse);
}
else
{