To speed up opening a pattern delay piece RafreshGeometry().

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-11-19 11:07:31 +02:00
parent 5004c12342
commit 7c17b3629f
3 changed files with 24 additions and 3 deletions

View File

@ -67,6 +67,7 @@
#include <QtConcurrentMap>
#include <QFuture>
#include <QtConcurrentRun>
#include <QTimer>
#ifdef Q_CC_MSVC
#include <functional>
@ -91,7 +92,7 @@ void GatherCount(int &count, const int nodes)
//---------------------------------------------------------------------------------------------------------------------
VPattern::VPattern(VContainer *data, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, QObject *parent)
: VAbstractPattern(parent), data(data), sceneDraw(sceneDraw), sceneDetail(sceneDetail)
: VAbstractPattern(parent), data(data), sceneDraw(sceneDraw), sceneDetail(sceneDetail), updatePieces()
{
SCASSERT(sceneDraw != nullptr)
SCASSERT(sceneDetail != nullptr)
@ -255,6 +256,7 @@ void VPattern::Parse(const Document &parse)
}
domNode = domNode.nextSibling();
}
QTimer::singleShot(2000, Qt::VeryCoarseTimer, this, SLOT(RefreshPieceGeometry()));
emit CheckLayout();
}
@ -877,7 +879,11 @@ void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse
initData.parse = parse;
initData.typeCreation = Source::FromFile;
VToolSeamAllowance::Create(initData);
VToolSeamAllowance *piece = VToolSeamAllowance::Create(initData);
if (parse == Document::FullParse)
{
updatePieces.append(piece);
}
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (w != initData.width)
{
@ -3507,6 +3513,17 @@ quint32 VPattern::LastToolId() const
return (not localHistory.isEmpty() ? localHistory.last().getId() : NULL_ID);
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::RefreshPieceGeometry()
{
for(auto piece : qAsConst(updatePieces))
{
piece->RefreshGeometry(true); // Refresh internal paths
}
updatePieces.clear();
VMainGraphicsView::NewSceneRect(sceneDetail, qApp->getSceneView());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ParseSplineElement parse spline tag.

View File

@ -38,6 +38,7 @@ class VMainGraphicsScene;
class VNodeDetail;
struct VToolSinglePointInitData;
struct VToolLinePointInitData;
class VToolSeamAllowance;
/**
* @brief The VPattern class working with pattern file.
@ -119,6 +120,9 @@ public slots:
protected:
virtual void customEvent(QEvent * event) override;
private slots:
void RefreshPieceGeometry();
private:
Q_DISABLE_COPY(VPattern)
@ -127,6 +131,7 @@ private:
VMainGraphicsScene *sceneDraw;
VMainGraphicsScene *sceneDetail;
QVector<VToolSeamAllowance *> updatePieces;
VNodeDetail ParseDetailNode(const QDomElement &domElement) const;

View File

@ -145,7 +145,6 @@ VToolSeamAllowance *VToolSeamAllowance::Create(VToolSeamAllowanceInitData &initD
initData.scene->addItem(piece);
VMainGraphicsView::NewSceneRect(initData.scene, qApp->getSceneView(), piece);
VAbstractPattern::AddTool(initData.id, piece);
piece->RefreshGeometry(true); // Refresh internal paths
}
//Very important to delete it. Only this tool need this special variable.
initData.data->RemoveVariable(currentSeamAllowance);