From 120f4cf56585f01023938576cd551cf96030f030 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 19 Jan 2015 16:13:26 +0200 Subject: [PATCH] Speed optimization. --HG-- branch : feature --- src/libs/vlayout/vlayoutdetail.cpp | 23 ++++++++++++++++++----- src/libs/vlayout/vlayoutdetail_p.h | 3 ++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/libs/vlayout/vlayoutdetail.cpp b/src/libs/vlayout/vlayoutdetail.cpp index a4cdc5cce..965f6ade4 100644 --- a/src/libs/vlayout/vlayoutdetail.cpp +++ b/src/libs/vlayout/vlayoutdetail.cpp @@ -190,17 +190,30 @@ QLineF VLayoutDetail::Edge(int i) const { // Doesn't exist such edge return QLineF(); } - const QVector points = GetLayoutAllowencePoints(); - QLineF edge; + + int i1, i2; if (i < EdgesCount()) { - edge = QLineF(points.at(i-1), points.at(i)); + i1 = i-1; + i2 = i; } else { - edge = QLineF(points.at(EdgesCount()-1), points.at(0)); + i1 = EdgesCount()-1; + i2 = 0; + } + + if (d->mirror) + { + const int oldI1 = i1; + i1 = (d->layoutAllowence.size()-1) - i2; + i2 = (d->layoutAllowence.size()-1) - oldI1; + return QLineF(d->matrix.map(d->layoutAllowence.at(i2)), d->matrix.map(d->layoutAllowence.at(i1))); + } + else + { + return QLineF(d->matrix.map(d->layoutAllowence.at(i1)), d->matrix.map(d->layoutAllowence.at(i2))); } - return edge; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vlayout/vlayoutdetail_p.h b/src/libs/vlayout/vlayoutdetail_p.h index 296f1c780..04c687d05 100644 --- a/src/libs/vlayout/vlayoutdetail_p.h +++ b/src/libs/vlayout/vlayoutdetail_p.h @@ -49,7 +49,8 @@ public: VLayoutDetailData(const VLayoutDetailData &detail) :QSharedData(detail), contour(detail.contour), seamAllowence(detail.seamAllowence), - layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), layoutWidth(detail.layoutWidth), mirror(false) + layoutAllowence(detail.layoutAllowence), matrix(detail.matrix), layoutWidth(detail.layoutWidth), + mirror(detail.mirror) {} ~VLayoutDetailData() {}