Export group operations as part of pattern recipe.
--HG-- branch : develop
This commit is contained in:
parent
70a8547ae5
commit
45452d4d77
|
@ -117,6 +117,7 @@ const QString AttrTangent = QStringLiteral("tangent");
|
|||
const QString AttrCRadius = QStringLiteral("cRadius");
|
||||
const QString AttrArc = QStringLiteral("arc");
|
||||
const QString AttrSuffix = QStringLiteral("suffix");
|
||||
const QString AttrItem = QStringLiteral("item");
|
||||
const QString AttrIdObject = QStringLiteral("idObject");
|
||||
const QString AttrInLayout = QStringLiteral("inLayout");
|
||||
const QString AttrForbidFlipping = QStringLiteral("forbidFlipping");
|
||||
|
|
|
@ -135,6 +135,7 @@ extern const QString AttrTangent;
|
|||
extern const QString AttrCRadius;
|
||||
extern const QString AttrArc;
|
||||
extern const QString AttrSuffix;
|
||||
extern const QString AttrItem;
|
||||
extern const QString AttrIdObject;
|
||||
extern const QString AttrInLayout;
|
||||
extern const QString AttrForbidFlipping;
|
||||
|
|
|
@ -75,7 +75,7 @@ T *GetPatternTool(quint32 id)
|
|||
}
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObject *parent)
|
||||
|
@ -365,6 +365,14 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
return TrueDarts(tool);
|
||||
case Tool::EllipticalArc:
|
||||
return EllipticalArc(tool);
|
||||
case Tool::Rotation:
|
||||
return Rotation(tool);
|
||||
case Tool::FlippingByLine:
|
||||
return FlippingByLine(tool);
|
||||
case Tool::FlippingByAxis:
|
||||
return FlippingByAxis(tool);
|
||||
case Tool::Move:
|
||||
return Move(tool);
|
||||
//Because "history" not only show history of pattern, but help restore current data for each pattern's
|
||||
//piece, we need add record about details and nodes, but don't show them.
|
||||
case Tool::Piece:
|
||||
|
@ -375,10 +383,6 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
|||
case Tool::NodeSpline:
|
||||
case Tool::NodeSplinePath:
|
||||
case Tool::Group:
|
||||
case Tool::Rotation:
|
||||
case Tool::FlippingByLine:
|
||||
case Tool::FlippingByAxis:
|
||||
case Tool::Move:
|
||||
case Tool::PiecePath:
|
||||
case Tool::Pin:
|
||||
case Tool::PlaceLabel:
|
||||
|
@ -946,6 +950,76 @@ QDomElement VPatternRecipe::EllipticalArc(const VToolRecord &record)
|
|||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::Rotation(const VToolRecord &record)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolRotation>(record.getId());
|
||||
|
||||
QDomElement step = createElement(TagStep);
|
||||
|
||||
SetAttribute(step, AttrType, VToolRotation::ToolType);
|
||||
SetAttribute(step, AttrCenter, tool->OriginPointName());
|
||||
Formula(step, tool->GetFormulaAngle(), AttrAngle, AttrAngleValue);
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::FlippingByLine(const VToolRecord &record)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolFlippingByLine>(record.getId());
|
||||
|
||||
QDomElement step = createElement(TagStep);
|
||||
|
||||
SetAttribute(step, AttrType, VToolFlippingByLine::ToolType);
|
||||
SetAttribute(step, AttrP1Line, tool->FirstLinePointName());
|
||||
SetAttribute(step, AttrP2Line, tool->SecondLinePointName());
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::FlippingByAxis(const VToolRecord &record)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolFlippingByAxis>(record.getId());
|
||||
|
||||
QDomElement step = createElement(TagStep);
|
||||
|
||||
SetAttribute(step, AttrType, VToolFlippingByAxis::ToolType);
|
||||
SetAttribute(step, AttrCenter, tool->OriginPointName());
|
||||
SetAttribute(step, AttrAxisType, static_cast<int>(tool->GetAxisType()));
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::Move(const VToolRecord &record)
|
||||
{
|
||||
auto *tool = GetPatternTool<VToolMove>(record.getId());
|
||||
|
||||
QDomElement step = createElement(TagStep);
|
||||
|
||||
SetAttribute(step, AttrType, VToolMove::ToolType);
|
||||
Formula(step, tool->GetFormulaAngle(), AttrAngle, AttrAngleValue);
|
||||
Formula(step, tool->GetFormulaRotationAngle(), AttrRotationAngle, AttrRotationAngleValue);
|
||||
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
|
||||
SetAttribute(step, AttrCenter, tool->OriginPointName());
|
||||
SetAttribute(step, AttrSuffix, tool->Suffix());
|
||||
|
||||
step.appendChild(GroupOperationSource(tool, record.getId()));
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline void VPatternRecipe::Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr,
|
||||
const QString &formulaValue)
|
||||
|
@ -987,3 +1061,26 @@ inline void VPatternRecipe::ToolAttributes(QDomElement &step, T *tool)
|
|||
SetAttribute(step, AttrType, T::ToolType);
|
||||
SetAttribute(step, AttrLabel, tool->name());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint32 id)
|
||||
{
|
||||
SCASSERT(tool)
|
||||
|
||||
QDomElement nodes = createElement(QStringLiteral("nodes"));
|
||||
QVector<QString> names = tool->SourceItems();
|
||||
|
||||
if (names.isEmpty())
|
||||
{
|
||||
throw VExceptionInvalidHistory(QObject::tr("Empty list of nodes for tool with id '%1'.").arg(id));
|
||||
}
|
||||
|
||||
for (auto &nodeName : names)
|
||||
{
|
||||
QDomElement node = createElement(QStringLiteral("node"));
|
||||
SetAttribute(node, AttrItem, nodeName);
|
||||
nodes.appendChild(node);
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class VMeasurement;
|
|||
class VIncrement;
|
||||
class VToolRecord;
|
||||
class VFormula;
|
||||
class VAbstractOperation;
|
||||
|
||||
class VPatternRecipe : public VDomDocument
|
||||
{
|
||||
|
@ -94,6 +95,10 @@ private:
|
|||
QDomElement PointFromArcAndTangent(const VToolRecord &record);
|
||||
QDomElement TrueDarts(const VToolRecord &record);
|
||||
QDomElement EllipticalArc(const VToolRecord &record);
|
||||
QDomElement Rotation(const VToolRecord &record);
|
||||
QDomElement FlippingByLine(const VToolRecord &record);
|
||||
QDomElement FlippingByAxis(const VToolRecord &record);
|
||||
QDomElement Move(const VToolRecord &record);
|
||||
|
||||
void Formula(QDomElement &step, const VFormula &formula, const QString &formulaStr, const QString &formulaValue);
|
||||
|
||||
|
@ -105,6 +110,8 @@ private:
|
|||
|
||||
template <typename T>
|
||||
void CurveAttributes(QDomElement &step, T* tool);
|
||||
|
||||
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id);
|
||||
};
|
||||
|
||||
#endif // VPATTERNRECIPE_H
|
||||
|
|
|
@ -56,6 +56,28 @@ void VAbstractOperation::SetSuffix(const QString &suffix)
|
|||
SaveOption(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QString> VAbstractOperation::SourceItems() const
|
||||
{
|
||||
QVector<QString> itemNames;
|
||||
itemNames.reserve(source.size());
|
||||
|
||||
try
|
||||
{
|
||||
for (auto &item : source)
|
||||
{
|
||||
itemNames.append(VAbstractTool::data.GetGObject(item)->name());
|
||||
}
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
{
|
||||
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
|
||||
return QVector<QString>();
|
||||
}
|
||||
|
||||
return itemNames;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VAbstractOperation::GroupVisibility(quint32 object, bool visible)
|
||||
{
|
||||
|
|
|
@ -85,6 +85,8 @@ public:
|
|||
QString Suffix() const;
|
||||
void SetSuffix(const QString &suffix);
|
||||
|
||||
QVector<QString> SourceItems() const;
|
||||
|
||||
virtual void GroupVisibility(quint32 object, bool visible) override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
virtual void ChangeLabelPosition(quint32 id, const QPointF &pos) override;
|
||||
|
|
Loading…
Reference in New Issue
Block a user