Alias support for pattern recipe.
This commit is contained in:
parent
e5a9092e25
commit
91da094f2b
|
@ -89,7 +89,7 @@ VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObj
|
||||||
|
|
||||||
QDomElement recipeElement = createElement(QStringLiteral("recipe"));
|
QDomElement recipeElement = createElement(QStringLiteral("recipe"));
|
||||||
recipeElement.appendChild(createComment(FileComment()));
|
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(Prerequisite());
|
||||||
recipeElement.appendChild(Content());
|
recipeElement.appendChild(Content());
|
||||||
|
@ -811,6 +811,8 @@ QDomElement VPatternRecipe::CutArc(const VToolRecord &record)
|
||||||
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
||||||
SetAttribute(step, AttrArc, tool->CurveName());
|
SetAttribute(step, AttrArc, tool->CurveName());
|
||||||
|
|
||||||
|
CutCurveAttributes(step, tool);
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,6 +827,8 @@ QDomElement VPatternRecipe::CutSpline(const VToolRecord &record)
|
||||||
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
||||||
SetAttribute(step, VToolCutSpline::AttrSpline, tool->CurveName());
|
SetAttribute(step, VToolCutSpline::AttrSpline, tool->CurveName());
|
||||||
|
|
||||||
|
CutCurveAttributes(step, tool);
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,6 +843,8 @@ QDomElement VPatternRecipe::CutSplinePath(const VToolRecord &record)
|
||||||
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
||||||
SetAttribute(step, VToolCutSplinePath::AttrSplinePath, tool->CurveName());
|
SetAttribute(step, VToolCutSplinePath::AttrSplinePath, tool->CurveName());
|
||||||
|
|
||||||
|
CutCurveAttributes(step, tool);
|
||||||
|
|
||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1097,6 +1103,16 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
|
||||||
SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
|
SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
|
||||||
SetAttribute(step, AttrAScale, tool->GetApproximationScale());
|
SetAttribute(step, AttrAScale, tool->GetApproximationScale());
|
||||||
SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
|
SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
|
||||||
|
SetAttribute(step, AttrAlias, tool->GetAliasSuffix());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template<typename T>
|
||||||
|
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)
|
SCASSERT(tool)
|
||||||
|
|
||||||
QDomElement nodes = createElement(QStringLiteral("nodes"));
|
QDomElement nodes = createElement(QStringLiteral("nodes"));
|
||||||
QVector<QString> names = tool->SourceItems();
|
QVector<SourceItem> items = tool->SourceItems();
|
||||||
|
|
||||||
if (names.isEmpty())
|
if (items.isEmpty())
|
||||||
{
|
{
|
||||||
throw VExceptionInvalidHistory(QObject::tr("Empty list of nodes for tool with id '%1'.").arg(id));
|
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"));
|
QDomElement node = createElement(QStringLiteral("node"));
|
||||||
SetAttribute(node, AttrItem, nodeName);
|
|
||||||
|
QSharedPointer<VGObject> obj;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
obj = m_data->GetGObject(item.id);
|
||||||
|
}
|
||||||
|
catch (const VExceptionBadId &e)
|
||||||
|
{
|
||||||
|
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAttribute(node, AttrItem, obj->name());
|
||||||
|
if (not obj->GetAlias().isEmpty())
|
||||||
|
{
|
||||||
|
SetAttribute(node, AttrAlias, obj->GetAlias());
|
||||||
|
}
|
||||||
nodes.appendChild(node);
|
nodes.appendChild(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,9 @@ private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void CurveAttributes(QDomElement &step, T* tool);
|
void CurveAttributes(QDomElement &step, T* tool);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void CutCurveAttributes(QDomElement &step, T* tool);
|
||||||
|
|
||||||
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id);
|
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -89,25 +89,9 @@ void VAbstractOperation::SetSuffix(const QString &suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QString> VAbstractOperation::SourceItems() const
|
QVector<SourceItem> VAbstractOperation::SourceItems() const
|
||||||
{
|
{
|
||||||
QVector<QString> itemNames;
|
return source;
|
||||||
itemNames.reserve(source.size());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
for (auto &item : source)
|
|
||||||
{
|
|
||||||
itemNames.append(VAbstractTool::data.GetGObject(item.id)->ObjectName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const VExceptionBadId &e)
|
|
||||||
{
|
|
||||||
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
|
|
||||||
return QVector<QString>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return itemNames;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
QString Suffix() const;
|
QString Suffix() const;
|
||||||
void SetSuffix(const QString &suffix);
|
void SetSuffix(const QString &suffix);
|
||||||
|
|
||||||
QVector<QString> SourceItems() const;
|
QVector<SourceItem> SourceItems() const;
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) override;
|
virtual void GroupVisibility(quint32 object, bool visible) override;
|
||||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user