From f78f19184343142a70b8424f54e99d331553a116 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 24 Jan 2018 16:50:25 +0200 Subject: [PATCH] Fix bug in copy piece tool. --HG-- branch : develop --- src/libs/vgeometry/vgobject_p.h | 2 +- src/libs/vtools/tools/nodeDetails/vabstractnode.h | 8 ++++++++ src/libs/vtools/tools/vtoolseamallowance.cpp | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/libs/vgeometry/vgobject_p.h b/src/libs/vgeometry/vgobject_p.h index 75ccf2a02..5c05027a4 100644 --- a/src/libs/vgeometry/vgobject_p.h +++ b/src/libs/vgeometry/vgobject_p.h @@ -61,7 +61,7 @@ public: /** @brief type type of graphical object */ GOType type; - /** @brief idObject id of parent object. Only for modeling. All another return 0. */ + /** @brief idObject id of parent object. */ quint32 idObject; /** @brief _name object name */ diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.h b/src/libs/vtools/tools/nodeDetails/vabstractnode.h index 1b67e288a..2094291bd 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.h +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.h @@ -73,6 +73,8 @@ public: ParentType GetParentType() const; void SetParentType(const ParentType &value); + quint32 GetIdTool() const; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; bool IsExluded() const; @@ -101,4 +103,10 @@ private: Q_DISABLE_COPY(VAbstractNode) }; +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 VAbstractNode::GetIdTool() const +{ + return idTool; +} + #endif // VABSTRACTNODE_H diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index fbdc78fcd..28641b30f 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -1898,6 +1898,8 @@ quint32 VToolSeamAllowance::DuplicateNode(const VPieceNode &node, const VToolSea SCASSERT(initData.data != nullptr) const QSharedPointer gobj = initData.data->GetGObject(node.GetId()); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(node.GetId())); + SCASSERT(tool != nullptr) VAbstractNodeInitData initNodeData; initNodeData.idObject = gobj->getIdObject(); @@ -1907,6 +1909,7 @@ quint32 VToolSeamAllowance::DuplicateNode(const VPieceNode &node, const VToolSea initNodeData.typeCreation = Source::FromGui; initNodeData.scene = initData.scene; initNodeData.drawName = initData.drawName; + initNodeData.idTool = tool->GetIdTool(); switch (node.GetTypeTool()) { @@ -1940,13 +1943,16 @@ quint32 VToolSeamAllowance::DuplicateNode(const VPieceNode &node, const VToolSea //--------------------------------------------------------------------------------------------------------------------- quint32 VToolSeamAllowance::DuplicatePiecePath(quint32 id, const VToolSeamAllowanceInitData &initData) { - VPiecePath path = initData.data->GetPiecePath(id); + const VPiecePath path = initData.data->GetPiecePath(id); VPiecePath newPath = path; QMap recordReplacements; // Not used newPath.SetNodes(DuplicateNodes(path, initData, recordReplacements)); const quint32 idPath = initData.data->AddPiecePath(newPath); + VAbstractNode *tool = qobject_cast(VAbstractPattern::getTool(id)); + SCASSERT(tool != nullptr) + VToolPiecePathInitData initNodeData; initNodeData.id = idPath; initNodeData.idObject = NULL_ID; // piece id @@ -1956,6 +1962,7 @@ quint32 VToolSeamAllowance::DuplicatePiecePath(quint32 id, const VToolSeamAllowa initNodeData.parse = Document::FullParse; initNodeData.typeCreation = Source::FromTool; initNodeData.drawName = initData.drawName; + initNodeData.idTool = tool->GetIdTool(); initNodeData.path = newPath; VToolPiecePath::Create(initNodeData);