From 20f8da230d26b06ac1a9406d27845d94a65bd410 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 25 Nov 2016 16:37:32 +0200 Subject: [PATCH] Increment custom seam allowance in tool seam allowance. --HG-- branch : feature --- src/libs/vtools/tools/vtoolseamallowance.cpp | 65 ++++++++++++-------- src/libs/vtools/tools/vtoolseamallowance.h | 3 + 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 37ac7e0c8..14fa9bfbc 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -665,30 +665,8 @@ VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, m_seamAllowance(new VNoBrushScalePathItem(this)) { VPiece detail = data->GetPiece(id); - for (int i = 0; i< detail.GetPath().CountNodes(); ++i) - { - switch (detail.GetPath().at(i).GetTypeTool()) - { - case (Tool::NodePoint): - { - VNodePoint *tool = InitTool(scene, detail.GetPath().at(i)); - connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent); - break; - } - case (Tool::NodeArc): - doc->IncrementReferens(detail.GetPath().at(i).GetId()); - break; - case (Tool::NodeSpline): - doc->IncrementReferens(detail.GetPath().at(i).GetId()); - break; - case (Tool::NodeSplinePath): - doc->IncrementReferens(detail.GetPath().at(i).GetId()); - break; - default: - qDebug()<<"Get wrong tool type. Ignore."; - break; - } - } + InitNodes(detail, scene); + InitCSAPaths(detail); this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); RefreshGeometry(); @@ -754,6 +732,45 @@ void VToolSeamAllowance::SaveDialogChange() qApp->getUndoStack()->push(saveCommand); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InitNodes(const VPiece &detail, VMainGraphicsScene *scene) +{ + for (int i = 0; i< detail.GetPath().CountNodes(); ++i) + { + switch (detail.GetPath().at(i).GetTypeTool()) + { + case (Tool::NodePoint): + { + VNodePoint *tool = InitTool(scene, detail.GetPath().at(i)); + connect(tool, &VNodePoint::ShowContextMenu, this, &VToolSeamAllowance::contextMenuEvent); + break; + } + case (Tool::NodeArc): + doc->IncrementReferens(detail.GetPath().at(i).GetId()); + break; + case (Tool::NodeSpline): + doc->IncrementReferens(detail.GetPath().at(i).GetId()); + break; + case (Tool::NodeSplinePath): + doc->IncrementReferens(detail.GetPath().at(i).GetId()); + break; + default: + qDebug()<<"Get wrong tool type. Ignore."; + break; + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSeamAllowance::InitCSAPaths(const VPiece &detail) +{ + QVector records = detail.GetCustomSARecords(); + for (int i = 0; i < records.size(); ++i) + { + doc->IncrementReferens(records.at(i).path); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::DeleteTool(bool ask) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 50037c4ae..cd15875c8 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -130,6 +130,9 @@ private: void RefreshGeometry(); void SaveDialogChange(); + void InitNodes(const VPiece &detail, VMainGraphicsScene *scene); + void InitCSAPaths(const VPiece &detail); + template Tool* InitTool(VMainGraphicsScene *scene, const VPieceNode &node); };