From 98ebfd11c60825175c24524599e459157b0089fb Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 21 Nov 2017 11:55:37 +0200 Subject: [PATCH] Fix stand-alone piece updating. It should call updating internal paths in this case. --HG-- branch : develop --- .../vtools/tools/nodeDetails/vtoolpiecepath.h | 4 +-- src/libs/vtools/tools/vtoolseamallowance.cpp | 29 +++++++++++++++++-- src/libs/vtools/tools/vtoolseamallowance.h | 3 +- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h index bcf7f5d28..138256aa5 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h @@ -63,6 +63,8 @@ public: virtual void incrementReferens() Q_DECL_OVERRIDE; virtual void decrementReferens() Q_DECL_OVERRIDE; + void RefreshGeometry(); + static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path); public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; @@ -81,8 +83,6 @@ private: VToolPiecePath(const VToolPiecePathInitData &initData, QObject *qoParent = nullptr, QGraphicsItem *parent = nullptr); - void RefreshGeometry(); - void IncrementNodes(const VPiecePath &path) const; void DecrementNodes(const VPiecePath &path) const; }; diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 3708605a4..aa3ba2f5b 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -578,7 +578,8 @@ void VToolSeamAllowance::GroupVisibility(quint32 object, bool visible) //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::FullUpdateFromFile() { - RefreshGeometry(); + const bool updateChildren = false;// Chilren have their own signals. Avoid double refresh. + RefreshGeometry(updateChildren); } //--------------------------------------------------------------------------------------------------------------------- @@ -1309,7 +1310,27 @@ void VToolSeamAllowance::UpdateExcludeState() } //--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::RefreshGeometry() +void VToolSeamAllowance::UpdateInternalPaths() +{ + const VPiece detail = VAbstractTool::data.GetPiece(m_id); + for (int i = 0; i < detail.GetInternalPaths().size(); ++i) + { + try + { + if (auto *tool = qobject_cast(VAbstractPattern::getTool(detail.GetInternalPaths().at(i)))) + { + tool->RefreshGeometry(); + } + } + catch(const VExceptionBadId &) + { + // ignore + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::RefreshGeometry(bool updateChildren) { this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); @@ -1361,6 +1382,10 @@ void VToolSeamAllowance::RefreshGeometry() UpdatePatternInfo(); UpdateGrainline(); UpdateExcludeState(); + if (updateChildren) + { + UpdateInternalPaths(); + } this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 47c68015c..37c4bd127 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -108,7 +108,7 @@ public: void DisconnectOutsideSignals(); void ConnectOutsideSignals(); void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene); - void RefreshGeometry(); + void RefreshGeometry(bool updateChildren = true); virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Tool::Piece)}; @@ -187,6 +187,7 @@ private: VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr); void UpdateExcludeState(); + void UpdateInternalPaths(); VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos);