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