Seep up method VToolSeamAllowance::RefreshGeometry() with multithread.
--HG-- branch : develop
This commit is contained in:
parent
d63cb30935
commit
cf8c12f16a
|
@ -53,6 +53,8 @@
|
||||||
#include "../vwidgets/vnobrushscalepathitem.h"
|
#include "../vwidgets/vnobrushscalepathitem.h"
|
||||||
#include "../qmuparser/qmutokenparser.h"
|
#include "../qmuparser/qmutokenparser.h"
|
||||||
|
|
||||||
|
#include <QFuture>
|
||||||
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
@ -1338,35 +1340,47 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||||
|
|
||||||
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
|
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
|
||||||
QPainterPath path = detail.MainPathPath(this->getData());
|
QFuture<QPainterPath > futurePath = QtConcurrent::run(detail, &VPiece::MainPathPath, this->getData());
|
||||||
|
QFuture<QVector<QPointF> > 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())
|
if (not detail.IsHideMainPath() || not detail.IsSeamAllowance() || detail.IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
m_mainPath = QPainterPath();
|
m_mainPath = QPainterPath();
|
||||||
m_mainPathRect = QRectF();
|
m_mainPathRect = QRectF();
|
||||||
m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern));
|
m_seamAllowance->setBrush(QBrush(Qt::Dense7Pattern));
|
||||||
|
path = futurePath.result();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_seamAllowance->setBrush(QBrush(Qt::NoBrush)); // Disable if the main path was hidden
|
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
|
// need for returning a bounding rect when main path is not visible
|
||||||
m_mainPath = path;
|
m_mainPath = futurePath.result();
|
||||||
m_mainPathRect = m_mainPath.controlPointRect();
|
m_mainPathRect = m_mainPath.controlPointRect();
|
||||||
path = QPainterPath();
|
path = QPainterPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setPath(path);
|
this->setPath(path);
|
||||||
|
|
||||||
|
m_placeLabels->setPath(detail.PlaceLabelPath(this->getData()));
|
||||||
|
|
||||||
QVector<QPointF> seamAllowancePoints;
|
QVector<QPointF> seamAllowancePoints;
|
||||||
|
|
||||||
if (detail.IsSeamAllowance())
|
if (detail.IsSeamAllowance())
|
||||||
{
|
{
|
||||||
seamAllowancePoints = detail.SeamAllowancePoints(this->getData());
|
seamAllowancePoints = futureSeamAllowance.result();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_passmarks->setPath(detail.PassmarksPath(this->getData(), seamAllowancePoints));
|
QFuture<QPainterPath > futurePassmarks = QtConcurrent::run(detail, &VPiece::PassmarksPath, this->getData(),
|
||||||
|
seamAllowancePoints);
|
||||||
this->setPos(detail.GetMx(), detail.GetMy());
|
|
||||||
|
|
||||||
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
|
@ -1379,8 +1393,6 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
|
||||||
m_seamAllowance->setPath(QPainterPath());
|
m_seamAllowance->setPath(QPainterPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_placeLabels->setPath(detail.PlaceLabelPath(this->getData()));
|
|
||||||
|
|
||||||
UpdateDetailLabel();
|
UpdateDetailLabel();
|
||||||
UpdatePatternInfo();
|
UpdatePatternInfo();
|
||||||
UpdateGrainline();
|
UpdateGrainline();
|
||||||
|
@ -1390,6 +1402,8 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
|
||||||
UpdateInternalPaths();
|
UpdateInternalPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_passmarks->setPath(futurePassmarks.result());
|
||||||
|
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user