Read/write piece label.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-18 07:59:47 +03:00
parent bc037e15b5
commit ae78373f88
6 changed files with 26 additions and 4 deletions

View File

@ -903,6 +903,8 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
Q_UNUSED(e) Q_UNUSED(e)
ppData.SetLetter(""); ppData.SetLetter("");
} }
ppData.SetQuantity(static_cast<int>(GetParametrUInt(domElement, AttrQuantity, "1")));
ppData.SetOnFold(GetParametrBool(domElement, AttrOnFold, falseStr));
ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0"))); ppData.SetPos(QPointF(GetParametrDouble(domElement, AttrMx, "0"), GetParametrDouble(domElement, AttrMy, "0")));
ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1")); ppData.SetLabelWidth(GetParametrString(domElement, AttrWidth, "1"));
ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1")); ppData.SetLabelHeight(GetParametrString(domElement, VToolSeamAllowance::AttrHeight, "1"));
@ -911,6 +913,7 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR)); ppData.SetCenterPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrCenterPin, NULL_ID_STR));
ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR)); ppData.SetTopLeftPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrTopLeftPin, NULL_ID_STR));
ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR)); ppData.SetBottomRightPin(GetParametrUInt(domElement, VToolSeamAllowance::AttrBottomRightPin, NULL_ID_STR));
ppData.SetLabelTemplate(GetLabelTemplate(domElement));
QDomNodeList nodeListMCP = domElement.childNodes(); QDomNodeList nodeListMCP = domElement.childNodes();
for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP) for (int iMCP = 0; iMCP < nodeListMCP.count(); ++iMCP)

View File

@ -503,6 +503,15 @@
<xs:element name="data" minOccurs="0" maxOccurs="1"> <xs:element name="data" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="text" type="xs:string" use="required"/>
<xs:attribute name="bold" type="xs:boolean"/>
<xs:attribute name="italic" type="xs:boolean"/>
<xs:attribute name="alignment" type="alignmentType"/>
<xs:attribute name="sfIncrement" type="xs:unsignedInt"/>
</xs:complexType>
</xs:element>
<xs:element name="mcp" minOccurs="0" maxOccurs="unbounded"> <xs:element name="mcp" minOccurs="0" maxOccurs="unbounded">
<xs:complexType> <xs:complexType>
<xs:attribute name="cutNumber" type="xs:unsignedInt"/> <xs:attribute name="cutNumber" type="xs:unsignedInt"/>
@ -514,6 +523,7 @@
</xs:sequence> </xs:sequence>
<xs:attribute name="letter" type="xs:string"/> <xs:attribute name="letter" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/> <xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="onFold" type="xs:boolean"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/> <xs:attribute name="fontSize" type="xs:unsignedInt"/>
<xs:attribute name="mx" type="xs:double"/> <xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/> <xs:attribute name="my" type="xs:double"/>
@ -522,6 +532,7 @@
<xs:attribute name="rotation" type="xs:string"/> <xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="centerPin" type="xs:unsignedInt"/> <xs:attribute name="centerPin" type="xs:unsignedInt"/>
<xs:attribute name="topLeftPin" type="xs:unsignedInt"/> <xs:attribute name="topLeftPin" type="xs:unsignedInt"/>
<xs:attribute name="quantity" type="xs:unsignedInt"/>
<xs:attribute name="bottomRightPin" type="xs:unsignedInt"/> <xs:attribute name="bottomRightPin" type="xs:unsignedInt"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>

View File

@ -98,6 +98,8 @@ const QString VAbstractPattern::AttrObject = QStringLiteral("object")
const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type"); const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter"); const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrMaterial = QStringLiteral("material"); const QString VAbstractPattern::AttrMaterial = QStringLiteral("material");
const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef"); const QString VAbstractPattern::AttrUserDefined = QStringLiteral("userDef");
const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber"); const QString VAbstractPattern::AttrCutNumber = QStringLiteral("cutNumber");

View File

@ -220,6 +220,8 @@ public:
static const QString AttrTool; static const QString AttrTool;
static const QString AttrType; static const QString AttrType;
static const QString AttrLetter; static const QString AttrLetter;
static const QString AttrQuantity;
static const QString AttrOnFold;
static const QString AttrMaterial; static const QString AttrMaterial;
static const QString AttrUserDefined; static const QString AttrUserDefined;
static const QString AttrCutNumber; static const QString AttrCutNumber;

View File

@ -129,6 +129,9 @@ public:
static bool SafeCopy(const QString &source, const QString &destination, QString &error); static bool SafeCopy(const QString &source, const QString &destination, QString &error);
QVector<VLabelTemplateLine> GetLabelTemplate(const QDomElement &element) const;
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
protected: protected:
bool setTagText(const QString &tag, const QString &text); bool setTagText(const QString &tag, const QString &text);
bool setTagText(const QDomElement &domElement, const QString &text); bool setTagText(const QDomElement &domElement, const QString &text);
@ -137,9 +140,6 @@ protected:
void TestUniqueId() const; void TestUniqueId() const;
void CollectId(const QDomElement &node, QVector<quint32> &vector)const; void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
QVector<VLabelTemplateLine> GetLabelTemplate(const QDomElement &element) const;
void SetLabelTemplate(QDomElement &element, const QVector<VLabelTemplateLine> &lines);
private: private:
Q_DISABLE_COPY(VDomDocument) Q_DISABLE_COPY(VDomDocument)
/** @brief Map used for finding element by id. */ /** @brief Map used for finding element by id. */

View File

@ -302,7 +302,9 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
QDomElement domData = doc->createElement(VAbstractPattern::TagData); QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPieceLabelData& data = piece.GetPatternPieceData(); const VPieceLabelData& data = piece.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible() == true? trueStr : falseStr); doc->SetAttribute(domData, VAbstractPattern::AttrQuantity, data.GetQuantity());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible());
doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold());
doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMx, data.GetPos().x());
doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, AttrMy, data.GetPos().y());
doc->SetAttribute(domData, VAbstractPattern::AttrWidth, data.GetLabelWidth()); doc->SetAttribute(domData, VAbstractPattern::AttrWidth, data.GetLabelWidth());
@ -337,6 +339,8 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
domData.removeAttribute(AttrBottomRightPin); domData.removeAttribute(AttrBottomRightPin);
} }
doc->SetLabelTemplate(domData, data.GetLabelTemplate());
for (int i = 0; i < data.GetMCPCount(); ++i) for (int i = 0; i < data.GetMCPCount(); ++i)
{ {
const MaterialCutPlacement mcp = data.GetMCP(i); const MaterialCutPlacement mcp = data.GetMCP(i);