Read/write Ignore margins setting.
This commit is contained in:
parent
addfcd94ad
commit
a9e5ea55cf
|
@ -331,7 +331,7 @@ void VPLayoutFileReader::ReadTiles(const VPLayoutPtr &layout)
|
|||
layout->LayoutSettings().SetTilesSize(ReadSize());
|
||||
break;
|
||||
case 1: // margin
|
||||
layout->LayoutSettings().SetTilesMargins(ReadMargins());
|
||||
ReadLayoutMargins(layout);
|
||||
break;
|
||||
default:
|
||||
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
|
||||
|
@ -403,7 +403,7 @@ void VPLayoutFileReader::ReadSheet(const VPLayoutPtr &layout)
|
|||
sheet->SetSheetSize(ReadSize());
|
||||
break;
|
||||
case 2: // margin
|
||||
sheet->SetSheetMargins(ReadMargins());
|
||||
ReadSheetMargins(sheet);
|
||||
break;
|
||||
case 3: // pieces
|
||||
ReadPieces(layout, sheet);
|
||||
|
@ -817,19 +817,37 @@ auto VPLayoutFileReader::ReadLabelLine() -> TextLine
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayoutFileReader::ReadMargins() -> QMarginsF
|
||||
QMarginsF VPLayoutFileReader::ReadLayoutMargins(const VPLayoutPtr &layout)
|
||||
{
|
||||
QMarginsF margins = QMarginsF();
|
||||
|
||||
QXmlStreamAttributes attribs = attributes();
|
||||
|
||||
QMarginsF margins = QMarginsF();
|
||||
margins.setLeft(ReadAttributeDouble(attribs, ML::AttrLeft, QChar('0')));
|
||||
margins.setTop(ReadAttributeDouble(attribs, ML::AttrTop, QChar('0')));
|
||||
margins.setRight(ReadAttributeDouble(attribs, ML::AttrRight, QChar('0')));
|
||||
margins.setBottom(ReadAttributeDouble(attribs, ML::AttrBottom, QChar('0')));
|
||||
layout->LayoutSettings().SetTilesMargins(margins);
|
||||
|
||||
layout->LayoutSettings().SetIgnoreTilesMargins(ReadAttributeBool(attribs, ML::AttrIgnoreMargins, falseStr));
|
||||
|
||||
readElementText();
|
||||
}
|
||||
|
||||
return margins;
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPLayoutFileReader::ReadSheetMargins(const VPSheetPtr &sheet) -> QMarginsF
|
||||
{
|
||||
QXmlStreamAttributes attribs = attributes();
|
||||
|
||||
QMarginsF margins = QMarginsF();
|
||||
margins.setLeft(ReadAttributeDouble(attribs, ML::AttrLeft, QChar('0')));
|
||||
margins.setTop(ReadAttributeDouble(attribs, ML::AttrTop, QChar('0')));
|
||||
margins.setRight(ReadAttributeDouble(attribs, ML::AttrRight, QChar('0')));
|
||||
margins.setBottom(ReadAttributeDouble(attribs, ML::AttrBottom, QChar('0')));
|
||||
sheet->SetSheetMargins(margins);
|
||||
|
||||
sheet->SetIgnoreMargins(ReadAttributeBool(attribs, ML::AttrIgnoreMargins, falseStr));
|
||||
|
||||
readElementText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -76,7 +76,8 @@ private:
|
|||
auto ReadLabelLines() -> VTextManager;
|
||||
auto ReadLabelLine() -> TextLine;
|
||||
|
||||
auto ReadMargins() -> QMarginsF;
|
||||
auto ReadLayoutMargins(const VPLayoutPtr &layout) -> QMarginsF;
|
||||
auto ReadSheetMargins(const VPSheetPtr &sheet) -> QMarginsF;
|
||||
auto ReadSize() -> QSizeF;
|
||||
|
||||
void AssertRootTag(const QString &tag) const;
|
||||
|
|
|
@ -214,7 +214,7 @@ void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet)
|
|||
|
||||
writeTextElement(ML::TagName, sheet->GetName());
|
||||
WriteSize(sheet->GetSheetSize());
|
||||
WriteMargins(sheet->GetSheetMargins());
|
||||
WriteMargins(sheet->GetSheetMargins(), sheet->IgnoreMargins());
|
||||
WritePieceList(sheet->GetPieces(), ML::TagPieces);
|
||||
|
||||
writeEndElement(); // sheet
|
||||
|
@ -231,7 +231,7 @@ void VPLayoutFileWriter::WriteTiles(const VPLayoutPtr &layout)
|
|||
SetAttribute(ML::AttrMatchingMarks, "standard"); // TODO / Fixme get the right value
|
||||
|
||||
WriteSize(layout->LayoutSettings().GetTilesSize());
|
||||
WriteMargins(layout->LayoutSettings().GetTilesMargins());
|
||||
WriteMargins(layout->LayoutSettings().GetTilesMargins(), layout->LayoutSettings().IgnoreTilesMargins());
|
||||
|
||||
writeEndElement(); // tiles
|
||||
}
|
||||
|
@ -366,13 +366,17 @@ void VPLayoutFileWriter::WriteLabelLines(const VTextManager &tm)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins)
|
||||
void VPLayoutFileWriter::WriteMargins(const QMarginsF &margins, bool ignore)
|
||||
{
|
||||
writeStartElement(ML::TagMargin);
|
||||
|
||||
SetAttributeOrRemoveIf<qreal>(ML::AttrLeft, margins.left(), [](qreal margin){return margin <= 0;});
|
||||
SetAttributeOrRemoveIf<qreal>(ML::AttrTop, margins.top(), [](qreal margin){return margin <= 0;});
|
||||
SetAttributeOrRemoveIf<qreal>(ML::AttrRight, margins.right(), [](qreal margin){return margin <= 0;});
|
||||
SetAttributeOrRemoveIf<qreal>(ML::AttrBottom, margins.bottom(), [](qreal margin){return margin <= 0;});
|
||||
|
||||
SetAttributeOrRemoveIf<bool>(ML::AttrIgnoreMargins, ignore, [](bool ignore){return not ignore;});
|
||||
|
||||
writeEndElement(); // margin
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ private:
|
|||
void WriteLabel(const QVector<QPointF> &labelShape, const VTextManager &tm, const QString &tagName);
|
||||
void WriteLabelLines(const VTextManager &tm);
|
||||
|
||||
void WriteMargins(const QMarginsF &margins);
|
||||
void WriteMargins(const QMarginsF &margins, bool ignore);
|
||||
void WriteSize(QSizeF size);
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -101,6 +101,7 @@ const QString AttrCopyNumber = QStringLiteral("copyNumber");
|
|||
const QString AttrGrainlineType = QStringLiteral("grainlineType");
|
||||
const QString AttrXScale = QStringLiteral("xScale");
|
||||
const QString AttrYScale = QStringLiteral("yScale");
|
||||
const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins");
|
||||
|
||||
const QString atFrontStr = QStringLiteral("atFront");
|
||||
const QString atRearStr = QStringLiteral("atRear");
|
||||
|
|
|
@ -106,6 +106,7 @@ extern const QString AttrCopyNumber;
|
|||
extern const QString AttrGrainlineType;
|
||||
extern const QString AttrXScale;
|
||||
extern const QString AttrYScale;
|
||||
extern const QString AttrIgnoreMargins;
|
||||
|
||||
extern const QString atFrontStr;
|
||||
extern const QString atRearStr;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<xs:attribute type="xs:float" name="right"/>
|
||||
<xs:attribute type="xs:float" name="bottom"/>
|
||||
<xs:attribute type="xs:float" name="left"/>
|
||||
<xs:attribute type="xs:boolean" name="ignoreMargins"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
|
@ -213,6 +214,7 @@
|
|||
<xs:attribute type="xs:float" name="right"/>
|
||||
<xs:attribute type="xs:float" name="bottom"/>
|
||||
<xs:attribute type="xs:float" name="left"/>
|
||||
<xs:attribute type="xs:boolean" name="ignoreMargins"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="pieces">
|
||||
|
|
Loading…
Reference in New Issue
Block a user