diff --git a/src/libs/vformat/vpatternrecipe.cpp b/src/libs/vformat/vpatternrecipe.cpp index 0d86747e6..f2db3cd7e 100644 --- a/src/libs/vformat/vpatternrecipe.cpp +++ b/src/libs/vformat/vpatternrecipe.cpp @@ -89,7 +89,7 @@ VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObj QDomElement recipeElement = createElement(QStringLiteral("recipe")); recipeElement.appendChild(createComment(FileComment())); - SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.2.0")); + SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.3.0")); recipeElement.appendChild(Prerequisite()); recipeElement.appendChild(Content()); @@ -811,6 +811,8 @@ QDomElement VPatternRecipe::CutArc(const VToolRecord &record) Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue); SetAttribute(step, AttrArc, tool->CurveName()); + CutCurveAttributes(step, tool); + return step; } @@ -825,6 +827,8 @@ QDomElement VPatternRecipe::CutSpline(const VToolRecord &record) Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue); SetAttribute(step, VToolCutSpline::AttrSpline, tool->CurveName()); + CutCurveAttributes(step, tool); + return step; } @@ -839,6 +843,8 @@ QDomElement VPatternRecipe::CutSplinePath(const VToolRecord &record) Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue); SetAttribute(step, VToolCutSplinePath::AttrSplinePath, tool->CurveName()); + CutCurveAttributes(step, tool); + return step; } @@ -1097,6 +1103,16 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool) SetAttribute(step, AttrPenStyle, tool->GetPenStyle()); SetAttribute(step, AttrAScale, tool->GetApproximationScale()); SetAttribute(step, AttrDuplicate, tool->GetDuplicate()); + SetAttribute(step, AttrAlias, tool->GetAliasSuffix()); +} + + +//--------------------------------------------------------------------------------------------------------------------- +template +void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool) +{ + SetAttribute(step, AttrAlias1, tool->GetAliasSuffix1()); + SetAttribute(step, AttrAlias2, tool->GetAliasSuffix2()); } //--------------------------------------------------------------------------------------------------------------------- @@ -1114,17 +1130,34 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint SCASSERT(tool) QDomElement nodes = createElement(QStringLiteral("nodes")); - QVector names = tool->SourceItems(); + QVector items = tool->SourceItems(); - if (names.isEmpty()) + if (items.isEmpty()) { throw VExceptionInvalidHistory(QObject::tr("Empty list of nodes for tool with id '%1'.").arg(id)); } - for (auto &nodeName : names) + for (auto &item : items) { QDomElement node = createElement(QStringLiteral("node")); - SetAttribute(node, AttrItem, nodeName); + + QSharedPointer obj; + + try + { + obj = m_data->GetGObject(item.id); + } + catch (const VExceptionBadId &e) + { + qCritical() << e.ErrorMessage()<name()); + if (not obj->GetAlias().isEmpty()) + { + SetAttribute(node, AttrAlias, obj->GetAlias()); + } nodes.appendChild(node); } diff --git a/src/libs/vformat/vpatternrecipe.h b/src/libs/vformat/vpatternrecipe.h index 4b53304a2..890dfe144 100644 --- a/src/libs/vformat/vpatternrecipe.h +++ b/src/libs/vformat/vpatternrecipe.h @@ -115,6 +115,9 @@ private: template void CurveAttributes(QDomElement &step, T* tool); + template + void CutCurveAttributes(QDomElement &step, T* tool); + QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id); }; diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp index fc4b3bbb7..ddb2a3125 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.cpp @@ -89,25 +89,9 @@ void VAbstractOperation::SetSuffix(const QString &suffix) } //--------------------------------------------------------------------------------------------------------------------- -QVector VAbstractOperation::SourceItems() const +QVector VAbstractOperation::SourceItems() const { - QVector itemNames; - itemNames.reserve(source.size()); - - try - { - for (auto &item : source) - { - itemNames.append(VAbstractTool::data.GetGObject(item.id)->ObjectName()); - } - } - catch (const VExceptionBadId &e) - { - qCritical() << e.ErrorMessage()<(); - } - - return itemNames; + return source; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index dc077446d..29ff7c12c 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -86,7 +86,7 @@ public: QString Suffix() const; void SetSuffix(const QString &suffix); - QVector SourceItems() const; + QVector SourceItems() const; virtual void GroupVisibility(quint32 object, bool visible) override; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;