From cf8c12f16a89058a0ae4c670378960acfc2db92c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 20 Jan 2018 17:59:11 +0200 Subject: [PATCH] Seep up method VToolSeamAllowance::RefreshGeometry() with multithread. --HG-- branch : develop --- src/libs/vtools/tools/vtoolseamallowance.cpp | 30 ++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 784bc4f45..fbdc78fcd 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -53,6 +53,8 @@ #include "../vwidgets/vnobrushscalepathitem.h" #include "../qmuparser/qmutokenparser.h" +#include +#include #include #include #include @@ -1338,35 +1340,47 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); const VPiece detail = VAbstractTool::data.GetPiece(m_id); - QPainterPath path = detail.MainPathPath(this->getData()); + QFuture futurePath = QtConcurrent::run(detail, &VPiece::MainPathPath, this->getData()); + QFuture > futureSeamAllowance; + + if (detail.IsSeamAllowance()) + { + futureSeamAllowance = QtConcurrent::run(detail, &VPiece::SeamAllowancePoints, this->getData()); + } + + this->setPos(detail.GetMx(), detail.GetMy()); + + QPainterPath path; if (not detail.IsHideMainPath() || not detail.IsSeamAllowance() || detail.IsSeamAllowanceBuiltIn()) { m_mainPath = QPainterPath(); m_mainPathRect = QRectF(); m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern)); + path = futurePath.result(); } else { m_seamAllowance->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden // need for returning a bounding rect when main path is not visible - m_mainPath = path; + m_mainPath = futurePath.result(); m_mainPathRect = m_mainPath.controlPointRect(); path = QPainterPath(); } this->setPath(path); + m_placeLabels->setPath(detail.PlaceLabelPath(this->getData())); + QVector seamAllowancePoints; if (detail.IsSeamAllowance()) { - seamAllowancePoints = detail.SeamAllowancePoints(this->getData()); + seamAllowancePoints = futureSeamAllowance.result(); } - m_passmarks->setPath(detail.PassmarksPath(this->getData(), seamAllowancePoints)); - - this->setPos(detail.GetMx(), detail.GetMy()); + QFuture futurePassmarks = QtConcurrent::run(detail, &VPiece::PassmarksPath, this->getData(), + seamAllowancePoints); if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn()) { @@ -1379,8 +1393,6 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) m_seamAllowance->setPath(QPainterPath()); } - m_placeLabels->setPath(detail.PlaceLabelPath(this->getData())); - UpdateDetailLabel(); UpdatePatternInfo(); UpdateGrainline(); @@ -1390,6 +1402,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) UpdateInternalPaths(); } + m_passmarks->setPath(futurePassmarks.result()); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); }