Fix stand-alone piece updating. It should call updating internal paths in this

case.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-11-21 11:55:37 +02:00
parent 191e4e7d08
commit 98ebfd11c6
3 changed files with 31 additions and 5 deletions

View file

@ -63,6 +63,8 @@ public:
virtual void incrementReferens() Q_DECL_OVERRIDE; virtual void incrementReferens() Q_DECL_OVERRIDE;
virtual void decrementReferens() Q_DECL_OVERRIDE; virtual void decrementReferens() Q_DECL_OVERRIDE;
void RefreshGeometry();
static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path); static void AddAttributes(VAbstractPattern *doc, QDomElement &domElement, quint32 id, const VPiecePath &path);
public slots: public slots:
virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromFile () Q_DECL_OVERRIDE;
@ -81,8 +83,6 @@ private:
VToolPiecePath(const VToolPiecePathInitData &initData, QObject *qoParent = nullptr, VToolPiecePath(const VToolPiecePathInitData &initData, QObject *qoParent = nullptr,
QGraphicsItem *parent = nullptr); QGraphicsItem *parent = nullptr);
void RefreshGeometry();
void IncrementNodes(const VPiecePath &path) const; void IncrementNodes(const VPiecePath &path) const;
void DecrementNodes(const VPiecePath &path) const; void DecrementNodes(const VPiecePath &path) const;
}; };

View file

@ -578,7 +578,8 @@ void VToolSeamAllowance::GroupVisibility(quint32 object, bool visible)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::FullUpdateFromFile() 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<VToolPiecePath*>(VAbstractPattern::getTool(detail.GetInternalPaths().at(i))))
{
tool->RefreshGeometry();
}
}
catch(const VExceptionBadId &)
{
// ignore
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
{ {
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
@ -1361,6 +1382,10 @@ void VToolSeamAllowance::RefreshGeometry()
UpdatePatternInfo(); UpdatePatternInfo();
UpdateGrainline(); UpdateGrainline();
UpdateExcludeState(); UpdateExcludeState();
if (updateChildren)
{
UpdateInternalPaths();
}
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
} }

View file

@ -108,7 +108,7 @@ public:
void DisconnectOutsideSignals(); void DisconnectOutsideSignals();
void ConnectOutsideSignals(); void ConnectOutsideSignals();
void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene); void ReinitInternals(const VPiece &detail, VMainGraphicsScene *scene);
void RefreshGeometry(); void RefreshGeometry(bool updateChildren = true);
virtual int type() const Q_DECL_OVERRIDE {return Type;} virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Piece)}; enum { Type = UserType + static_cast<int>(Tool::Piece)};
@ -187,6 +187,7 @@ private:
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr); VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
void UpdateExcludeState(); void UpdateExcludeState();
void UpdateInternalPaths();
VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth, VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth,
qreal &labelHeight, QPointF &pos); qreal &labelHeight, QPointF &pos);