diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 2c91d447c..d19873b66 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #ifdef Q_CC_MSVC #include @@ -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. diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index 8eef79597..75cd6d1ab 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -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 updatePieces; VNodeDetail ParseDetailNode(const QDomElement &domElement) const; diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 595158577..efe7635a3 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -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);