Read/Write layout file.

This commit is contained in:
Roman Telezhynskyi 2021-08-14 15:19:28 +03:00
parent 718ff2056a
commit 807183b2ce
17 changed files with 1395 additions and 127 deletions

View file

@ -31,6 +31,7 @@
#include "../vmisc/def.h"
#include "vpsheet.h"
#include "../vlayout/vtextmanager.h"
#include <QIcon>
#include <QLoggingCategory>
@ -169,3 +170,75 @@ void VPPiece::SetLayout(VPLayout *layout)
SCASSERT(layout != nullptr)
m_layout = layout;
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetGrainlineEnabled(bool enabled)
{
VLayoutPiece::SetGrainlineEnabled(enabled);
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetGrainlineAngle(qreal angle)
{
VLayoutPiece::SetGrainlineAngle(angle);
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetGrainlineArrowType(GrainlineArrowDirection type)
{
VLayoutPiece::SetGrainlineArrowType(type);
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetGrainlinePoints(const QVector<QPointF> &points)
{
VLayoutPiece::SetGrainlinePoints(points);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPPiece::GetPieceLabelRect() const -> QVector<QPointF>
{
return VLayoutPiece::GetPieceLabelRect();
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetPieceLabelRect(const QVector<QPointF> &rect)
{
VLayoutPiece::SetPieceLabelRect(rect);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPPiece::GetPieceLabelData() const -> VTextManager
{
return VLayoutPiece::GetPieceLabelData();
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetPieceLabelData(const VTextManager &data)
{
VLayoutPiece::SetPieceLabelData(data);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPPiece::GetPatternLabelRect() const -> QVector<QPointF>
{
return VLayoutPiece::GetPatternLabelRect();
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetPatternLabelRect(const QVector<QPointF> &rect)
{
VLayoutPiece::SetPatternLabelRect(rect);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPPiece::GetPatternLabelData() const -> VTextManager
{
return VLayoutPiece::GetPatternLabelData();
}
//---------------------------------------------------------------------------------------------------------------------
void VPPiece::SetPatternLabelData(const VTextManager &data)
{
VLayoutPiece::SetPatternLabelData(data);
}

View file

@ -83,6 +83,23 @@ public:
auto Layout() const -> VPLayout *;
void SetLayout(VPLayout *layout);
void SetGrainlineEnabled(bool enabled);
void SetGrainlineAngle(qreal angle);
void SetGrainlineArrowType(GrainlineArrowDirection type);
void SetGrainlinePoints(const QVector<QPointF> &points);
auto GetPieceLabelRect() const -> QVector<QPointF>;
void SetPieceLabelRect(const QVector<QPointF> &rect);
auto GetPieceLabelData() const ->VTextManager;
void SetPieceLabelData(const VTextManager &data);
auto GetPatternLabelRect() const -> QVector<QPointF>;
void SetPatternLabelRect(const QVector<QPointF> &rect);
auto GetPatternLabelData() const ->VTextManager;
void SetPatternLabelData(const VTextManager &data);
private:
Q_DISABLE_COPY(VPPiece)

View file

@ -33,19 +33,11 @@
#include <QtMath>
//---------------------------------------------------------------------------------------------------------------------
VPGraphicsSheet::VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent):
VPGraphicsSheet::VPGraphicsSheet(VPLayout *layout, QGraphicsItem *parent):
QGraphicsItem(parent),
m_sheet(sheet),
m_layout(layout),
m_boundingRect(GetSheetRect())
{
}
//---------------------------------------------------------------------------------------------------------------------
VPGraphicsSheet::~VPGraphicsSheet()
{
}
{}
//---------------------------------------------------------------------------------------------------------------------
void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -74,12 +66,12 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->drawRect(sheetRect);
}
if(m_sheet->GetLayout()->LayoutSettings().GetShowGrid())
if(m_layout->LayoutSettings().GetShowGrid())
{
pen.setColor(QColor(204,204,204));
painter->setPen(pen);
qreal colWidth = m_sheet->GetLayout()->LayoutSettings().GetGridColWidth();
qreal colWidth = m_layout->LayoutSettings().GetGridColWidth();
if(colWidth > 0)
{
qreal colX = colWidth;
@ -91,7 +83,7 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
}
}
qreal rowHeight = m_sheet->GetLayout()->LayoutSettings().GetGridRowHeight();
qreal rowHeight = m_layout->LayoutSettings().GetGridRowHeight();
if(rowHeight > 0)
{
qreal rowY = rowHeight;
@ -112,8 +104,8 @@ void VPGraphicsSheet::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QRectF VPGraphicsSheet::GetSheetRect() const
{
QPoint topLeft = QPoint(0,0);
QSizeF size = m_sheet->GetLayout()->LayoutSettings().GetSheetSize();
if(m_sheet->GetLayout()->LayoutSettings().GetOrientation() == PageOrientation::Landscape)
QSizeF size = m_layout->LayoutSettings().GetSheetSize();
if(m_layout->LayoutSettings().GetOrientation() == PageOrientation::Landscape)
{
size.transpose();
}
@ -124,10 +116,10 @@ QRectF VPGraphicsSheet::GetSheetRect() const
//---------------------------------------------------------------------------------------------------------------------
QRectF VPGraphicsSheet::GetMarginsRect() const
{
QMarginsF margins = m_sheet->GetLayout()->LayoutSettings().GetSheetMargins();
QSizeF size = m_sheet->GetLayout()->LayoutSettings().GetSheetSize();
QMarginsF margins = m_layout->LayoutSettings().GetSheetMargins();
QSizeF size = m_layout->LayoutSettings().GetSheetSize();
if(m_sheet->GetLayout()->LayoutSettings().GetOrientation() == PageOrientation::Landscape)
if(m_layout->LayoutSettings().GetOrientation() == PageOrientation::Landscape)
{
size.transpose();
}

View file

@ -32,18 +32,17 @@
#include <QGraphicsItem>
#include <QPainter>
class VPSheet;
class VPLayout;
class VPGraphicsSheet : public QGraphicsItem
{
public:
explicit VPGraphicsSheet(VPSheet *sheet, QGraphicsItem *parent = nullptr);
~VPGraphicsSheet();
explicit VPGraphicsSheet(VPLayout *sheet, QGraphicsItem *parent = nullptr);
~VPGraphicsSheet()=default;
QRectF boundingRect() const override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
QRectF GetSheetRect() const;
QRectF GetMarginsRect() const;
@ -62,7 +61,7 @@ public:
private:
Q_DISABLE_COPY(VPGraphicsSheet)
VPSheet *m_sheet{nullptr};
VPLayout *m_layout{nullptr};
QRectF m_boundingRect;
bool m_showMargin{true};

View file

@ -64,7 +64,7 @@ VPMainGraphicsView::VPMainGraphicsView(VPLayout *layout, VPTileFactory *tileFact
SCASSERT(m_layout != nullptr)
setScene(m_scene);
m_graphicsSheet = new VPGraphicsSheet(m_layout->GetFocusedSheet());
m_graphicsSheet = new VPGraphicsSheet(m_layout);
m_graphicsSheet->setPos(0, 0);
m_scene->addItem(m_graphicsSheet);

View file

@ -207,7 +207,9 @@ auto VPMainWindow::LoadFile(QString path) -> bool
// updates the properties with the loaded data
SetPropertiesData();
// TODO : update the Carrousel and the QGraphicView
m_carrousel->Refresh();
m_graphicsView->RefreshLayout();
m_graphicsView->RefreshPieces();
return true;
}

View file

@ -26,11 +26,15 @@
**
** *************************************************************************/
#include <Qt>
#include <QFont>
#include <QXmlStreamAttributes>
#include "vplayoutfilereader.h"
#include "vplayoutfilewriter.h"
#include "vplayoutliterals.h"
#include "../layout/vpsheet.h"
#include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionconversionerror.h"
@ -42,6 +46,138 @@ Q_LOGGING_CATEGORY(MLReader, "mlReader")
QT_WARNING_POP
namespace
{
//---------------------------------------------------------------------------------------------------------------------
auto StringToTransfrom(const QString &matrix) -> QTransform
{
QStringList elements = matrix.split(ML::groupSep);
if (elements.count() == 9)
{
qreal m11 = elements.at(0).toDouble();
qreal m12 = elements.at(1).toDouble();
qreal m13 = elements.at(2).toDouble();
qreal m21 = elements.at(3).toDouble();
qreal m22 = elements.at(4).toDouble();
qreal m23 = elements.at(5).toDouble();
qreal m31 = elements.at(6).toDouble();
qreal m32 = elements.at(7).toDouble();
qreal m33 = elements.at(8).toDouble();
return {m11, m12, m13, m21, m22, m23, m31, m32, m33};
}
return {};
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToPoint(const QString &point) -> QPointF
{
QStringList coordinates = point.split(ML::coordintatesSep);
if (coordinates.count() == 2)
{
return {coordinates.at(0).toDouble(), coordinates.at(1).toDouble()};
}
return {};
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToPath(const QString &path) -> QVector<QPointF>
{
QVector<QPointF> p;
QStringList points = path.split(ML::pointsSep);
for (const auto& point : points)
{
p.append(StringToPoint(point));
}
return p;
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToGrainlineArrowDirrection(const QString &dirrection) -> GrainlineArrowDirection
{
const QStringList arrows
{
ML::atFrontStr, // 0
ML::atRearStr, // 1
ML::atBothStr // 2
};
GrainlineArrowDirection arrowDirection = GrainlineArrowDirection::atBoth;
switch (arrows.indexOf(dirrection))
{
case 0:// at front
arrowDirection = GrainlineArrowDirection::atFront;
break;
case 1:// at rear
arrowDirection = GrainlineArrowDirection::atRear;
break;
case 2:// at both
default:
arrowDirection = GrainlineArrowDirection::atBoth;
break;
}
return arrowDirection;
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToLine(const QString &string) -> QLineF
{
QStringList points = string.split(ML::groupSep);
if (points.count() == 2)
{
return {StringToPoint(points.at(0)), StringToPoint(points.at(1))};
}
return {};
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToLines(const QString &string) -> QVector<QLineF>
{
QStringList lines = string.split(ML::itemsSep);
QVector<QLineF> path;
for (const auto& line : lines)
{
QLineF l = StringToLine(line);
if (not l.isNull())
{
path.append(StringToLine(line));
}
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToRect(const QString &string) -> QRectF
{
QStringList points = string.split(ML::groupSep);
if (points.count() == 4)
{
return {points.at(0).toDouble(), points.at(1).toDouble(), points.at(2).toDouble(), points.at(3).toDouble()};
}
return {};
}
//---------------------------------------------------------------------------------------------------------------------
auto StringToMarkerShape(const QString &string) -> PlaceLabelImg
{
PlaceLabelImg shape;
QStringList paths = string.split(ML::itemsSep);
for (const auto& path : paths)
{
shape.append(StringToPath(path));
}
return shape;
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadFile(VPLayout *layout, QFile *file) -> bool
{
@ -71,9 +207,7 @@ void VPLayoutFileReader::ReadLayout(VPLayout *layout)
{
ML::TagProperties, // 0
ML::TagUnplacedPieces, // 1
ML::TagSheets, // 2
ML::TagSize, // 3
ML::TagMargin // 4
ML::TagSheets // 2
};
while (readNextStartElement())
@ -89,12 +223,6 @@ void VPLayoutFileReader::ReadLayout(VPLayout *layout)
case 2: // ML::TagSheets
ReadSheets(layout);
break;
case 3: // size
layout->LayoutSettings().SetSheetSize(ReadSize());
break;
case 4: // margin
layout->LayoutSettings().SetSheetMargins(ReadMargins());
break;
default:
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
@ -113,8 +241,10 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout)
ML::TagUnit, // 0
ML::TagTitle, // 1
ML::TagDescription, // 2
ML::TagControl, // 3
ML::TagTiles // 4
ML::TagSize, // 3
ML::TagMargin, // 4
ML::TagControl, // 5
ML::TagTiles // 6
};
while (readNextStartElement())
@ -135,11 +265,17 @@ void VPLayoutFileReader::ReadProperties(VPLayout *layout)
qDebug("read description");
layout->LayoutSettings().SetDescription(readElementText());
break;
case 3:// control
case 3: // size
layout->LayoutSettings().SetSheetSize(ReadSize());
break;
case 4: // margin
layout->LayoutSettings().SetSheetMargins(ReadMargins());
break;
case 5: // control
qDebug("read control");
ReadControl(layout);
break;
case 4:// tiles
case 6: // tiles
qDebug("read tiles");
ReadTiles(layout);
break;
@ -160,6 +296,9 @@ void VPLayoutFileReader::ReadControl(VPLayout *layout)
layout->LayoutSettings().SetWarningSuperpositionOfPieces(
ReadAttributeBool(attribs, ML::AttrWarningSuperposition, trueStr));
layout->LayoutSettings().SetWarningPiecesOutOfBound(ReadAttributeBool(attribs, ML::AttrWarningOutOfBound, trueStr));
layout->LayoutSettings().SetStickyEdges(ReadAttributeBool(attribs, ML::AttrStickyEdges, trueStr));
layout->LayoutSettings().SetPiecesGap(ReadAttributeDouble(attribs, ML::AttrPiecesGap, QChar('0')));
// layout->LayoutSettings().SetFollowGrainline(ReadAttributeBool(attribs, ML::AttrFollowGrainLine, trueStr));
readElementText();
}
@ -302,26 +441,303 @@ void VPLayoutFileReader::ReadPiece(VPPiece *piece)
bool pieceMirrored = ReadAttributeBool(attribs, ML::AttrMirrored, falseStr);
piece->SetMirror(pieceMirrored);
// TODO read the further attributes
QString matrix = ReadAttributeEmptyString(attribs, ML::AttrTransform);
piece->SetMatrix(StringToTransfrom(matrix));
const QStringList tags
{
ML::TagSeamLine, // 0
ML::TagSeamAllowance, // 1
ML::TagGrainline, // 2
ML::TagNotches, // 3
ML::TagInternalPaths, // 4
ML::TagMarkers, // 5
ML::TagLabels // 6
};
while (readNextStartElement())
{
if (name() == QString("..."))
switch (tags.indexOf(name().toString()))
{
// TODO
readElementText();
case 0: // seam line
piece->SetCountourPoints(StringToPath(readElementText()));
break;
case 1: // seam allowance
ReadSeamAllowance(piece);
break;
case 2: // grainline
ReadGrainline(piece);
break;
case 3: // notches
ReadNotches(piece);
break;
case 4: // internal paths
ReadInternalPaths(piece);
break;
case 5: // markers
ReadMarkers(piece);
break;
case 6: // labels
ReadLabels(piece);
break;
default:
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
break;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadSeamAllowance(VPPiece *piece)
{
AssertRootTag(ML::TagSeamAllowance);
QXmlStreamAttributes attribs = attributes();
bool enabled = ReadAttributeBool(attribs, ML::AttrEnabled, falseStr);
piece->SetSeamAllowance(enabled);
bool builtIn = ReadAttributeBool(attribs, ML::AttrBuiltIn, falseStr);
QVector<QPointF> path = StringToPath(readElementText());
if (enabled)
{
if (not builtIn)
{
// TODO add check if not empty
piece->SetSeamAllowancePoints(path);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadGrainline(VPPiece *piece)
{
AssertRootTag(ML::TagGrainline);
QXmlStreamAttributes attribs = attributes();
bool enabled = ReadAttributeBool(attribs, ML::AttrEnabled, falseStr);
piece->SetGrainlineEnabled(enabled);
QVector<QPointF> path = StringToPath(readElementText());
if (enabled)
{
piece->SetGrainlineAngle(ReadAttributeDouble(attribs, ML::AttrAngle, QChar('0')));
QString arrowDirection = ReadAttributeEmptyString(attribs, ML::AttrArrowDirection);
piece->SetGrainlineArrowType(StringToGrainlineArrowDirrection(arrowDirection));
// TODO add check if not empty
piece->SetGrainlinePoints(path);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadNotches(VPPiece *piece)
{
AssertRootTag(ML::TagNotches);
QVector<VLayoutPassmark> passmarks;
while (readNextStartElement())
{
if (name() == ML::TagNotch)
{
passmarks.append(ReadNotch());
}
else
{
// TODO error handling, we encountered a tag that isn't defined in the specification
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
piece->SetPassmarks(passmarks);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadNotch() -> VLayoutPassmark
{
AssertRootTag(ML::TagNotch);
QXmlStreamAttributes attribs = attributes();
VLayoutPassmark passmark;
passmark.isBuiltIn = ReadAttributeBool(attribs, ML::AttrBuiltIn, falseStr);
passmark.baseLine = StringToLine(ReadAttributeEmptyString(attribs, ML::AttrBaseLine));
passmark.lines = StringToLines(ReadAttributeEmptyString(attribs, ML::AttrPath));
QString defaultType = QString::number(static_cast<int>(PassmarkLineType::OneLine));
passmark.type = static_cast<PassmarkLineType>(ReadAttributeUInt(attribs, ML::AttrType, defaultType));
readElementText();
return passmark;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadInternalPaths(VPPiece *piece)
{
AssertRootTag(ML::TagInternalPaths);
QVector<VLayoutPiecePath> internalPaths;
while (readNextStartElement())
{
if (name() == ML::TagInternalPath)
{
internalPaths.append(ReadInternalPath());
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
piece->SetInternalPaths(internalPaths);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadInternalPath() -> VLayoutPiecePath
{
AssertRootTag(ML::TagInternalPath);
VLayoutPiecePath path;
QXmlStreamAttributes attribs = attributes();
path.SetCutPath(ReadAttributeBool(attribs, ML::AttrCut, falseStr));
path.SetPenStyle(LineStyleToPenStyle(ReadAttributeString(attribs, ML::AttrPenStyle, TypeLineLine)));
// TODO check if not empty
path.SetPoints(StringToPath(readElementText()));
return path;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadMarkers(VPPiece *piece)
{
AssertRootTag(ML::TagMarkers);
QVector<VLayoutPlaceLabel> markers;
while (readNextStartElement())
{
if (name() == ML::TagMarker)
{
markers.append(ReadMarker());
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
piece->SetPlaceLabels(markers);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadMarker() -> VLayoutPlaceLabel
{
AssertRootTag(ML::TagMarker);
VLayoutPlaceLabel marker;
QXmlStreamAttributes attribs = attributes();
QString matrix = ReadAttributeEmptyString(attribs, ML::AttrTransform);
marker.rotationMatrix = StringToTransfrom(matrix);
marker.type = static_cast<PlaceLabelType>(ReadAttributeUInt(attribs, ML::AttrType, QChar('0')));
marker.center = StringToPoint(ReadAttributeEmptyString(attribs, ML::AttrCenter));
marker.box = StringToRect(ReadAttributeEmptyString(attribs, ML::AttrBox));
marker.shape = StringToMarkerShape(readElementText());
return marker;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileReader::ReadLabels(VPPiece *piece)
{
AssertRootTag(ML::TagLabels);
while (readNextStartElement())
{
if (name() == ML::TagPieceLabel)
{
QXmlStreamAttributes attribs = attributes();
piece->SetPieceLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
piece->SetPieceLabelData(ReadLabelLines());
}
else if (name() == ML::TagPatternLabel)
{
QXmlStreamAttributes attribs = attributes();
piece->SetPatternLabelRect(StringToPath(ReadAttributeEmptyString(attribs, ML::AttrShape)));
piece->SetPatternLabelData(ReadLabelLines());
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QMarginsF VPLayoutFileReader::ReadMargins()
auto VPLayoutFileReader::ReadLabelLines() -> VTextManager
{
AssertRootTag(ML::TagLabels);
VTextManager text;
QVector<TextLine> lines;
QXmlStreamAttributes attribs = attributes();
QFont f;
f.fromString(ReadAttributeEmptyString(attribs, ML::AttrFont));
text.SetFont(f);
while (readNextStartElement())
{
if (name() == ML::TagLine)
{
lines.append(ReadLabelLine());
}
else
{
qCDebug(MLReader, "Ignoring tag %s", qUtf8Printable(name().toString()));
skipCurrentElement();
}
}
text.SetAllSourceLines(lines);
return text;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadLabelLine() -> TextLine
{
AssertRootTag(ML::TagLine);
TextLine line;
QXmlStreamAttributes attribs = attributes();
line.m_iFontSize = ReadAttributeInt(attribs, ML::AttrFontSize, QString::number(MIN_FONT_SIZE));
line.m_bold = ReadAttributeBool(attribs, ML::AttrBold, falseStr);
line.m_italic = ReadAttributeBool(attribs, ML::AttrItalic, falseStr);
int alignment = ReadAttributeInt(attribs, ML::AttrAlignment, QString::number(static_cast<int>(Qt::AlignCenter)));
line.m_eAlign = static_cast<Qt::Alignment>(alignment);
line.m_qsText = readElementText();
return line;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadMargins() -> QMarginsF
{
QMarginsF margins = QMarginsF();
@ -337,7 +753,7 @@ QMarginsF VPLayoutFileReader::ReadMargins()
}
//---------------------------------------------------------------------------------------------------------------------
QSizeF VPLayoutFileReader::ReadSize()
auto VPLayoutFileReader::ReadSize() -> QSizeF
{
QSizeF size;
@ -360,8 +776,8 @@ void VPLayoutFileReader::AssertRootTag(const QString &tag) const
}
//---------------------------------------------------------------------------------------------------------------------
QString VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue)
auto VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> QString
{
const QString parameter = attribs.value(name).toString();
if (parameter.isEmpty())
@ -376,14 +792,14 @@ QString VPLayoutFileReader::ReadAttributeString(const QXmlStreamAttributes &attr
}
//---------------------------------------------------------------------------------------------------------------------
QString VPLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name)
auto VPLayoutFileReader::ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name) -> QString
{
return attribs.value(name).toString();
}
//---------------------------------------------------------------------------------------------------------------------
bool VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue)
auto VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> bool
{
QString parametr;
bool val = true;
@ -419,8 +835,8 @@ bool VPLayoutFileReader::ReadAttributeBool(const QXmlStreamAttributes &attribs,
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue)
auto VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> qreal
{
bool ok = false;
qreal param = 0;
@ -443,3 +859,55 @@ qreal VPLayoutFileReader::ReadAttributeDouble(const QXmlStreamAttributes &attrib
}
return param;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadAttributeUInt(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> quint32
{
bool ok = false;
quint32 param = 0;
const QString message = QObject::tr("Can't convert toUInt parameter");
try
{
QString parametr = ReadAttributeString(attribs, name, defValue);
param = parametr.replace(QChar(','), QChar('.')).toUInt(&ok);
if (not ok)
{
throw VExceptionConversionError(message, name);
}
}
catch (const VException &e)
{
VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
return param;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPLayoutFileReader::ReadAttributeInt(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> int
{
bool ok = false;
int param = 0;
const QString message = QObject::tr("Can't convert toInt parameter");
try
{
QString parametr = ReadAttributeString(attribs, name, defValue);
param = parametr.replace(QChar(','), QChar('.')).toInt(&ok);
if (not ok)
{
throw VExceptionConversionError(message, name);
}
}
catch (const VException &e)
{
VExceptionConversionError excep(message, name);
excep.AddMoreInformation(e.ErrorMessage());
throw excep;
}
return param;
}

View file

@ -38,6 +38,8 @@
Q_DECLARE_LOGGING_CATEGORY(MLReader)
struct TextLine;
class VPLayoutFileReader : public QXmlStreamReader
{
Q_DECLARE_TR_FUNCTIONS(VPLayoutFileReader)
@ -45,7 +47,7 @@ public:
VPLayoutFileReader()=default;
~VPLayoutFileReader()=default;
bool ReadFile(VPLayout *layout, QFile *file);
auto ReadFile(VPLayout *layout, QFile *file) -> bool;
private:
Q_DISABLE_COPY(VPLayoutFileReader)
@ -59,18 +61,34 @@ private:
void ReadSheet(VPLayout *layout);
void ReadPieces(VPLayout *layout, VPSheet *sheet=nullptr);
void ReadPiece(VPPiece *piece);
void ReadSeamAllowance(VPPiece *piece);
void ReadGrainline(VPPiece *piece);
void ReadNotches(VPPiece *piece);
auto ReadNotch() -> VLayoutPassmark;
void ReadInternalPaths(VPPiece *piece);
auto ReadInternalPath() -> VLayoutPiecePath;
void ReadMarkers(VPPiece *piece);
auto ReadMarker() -> VLayoutPlaceLabel;
void ReadLabels(VPPiece *piece);
auto ReadLabelLines() -> VTextManager;
auto ReadLabelLine() -> TextLine;
QMarginsF ReadMargins();
QSizeF ReadSize();
auto ReadMargins() -> QMarginsF;
auto ReadSize() -> QSizeF;
void AssertRootTag(const QString &tag) const;
static QString ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue);
static QString ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name);
static bool ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name, const QString &defValue);
static qreal ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue);
static auto ReadAttributeString(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> QString;
static auto ReadAttributeEmptyString(const QXmlStreamAttributes &attribs, const QString &name) -> QString;
static auto ReadAttributeBool(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> bool;
static auto ReadAttributeDouble(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> qreal;
static auto ReadAttributeUInt(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> quint32;
static auto ReadAttributeInt(const QXmlStreamAttributes &attribs, const QString &name,
const QString &defValue) -> int;
};
#endif // VPLAYOUTFILEREADER_H

View file

@ -33,6 +33,108 @@
#include "vplayoutliterals.h"
#include "../ifc/xml/vlayoutconverter.h"
#include "../vmisc/projectversion.h"
#include "../vlayout/vlayoutpiecepath.h"
#include "../vlayout/vtextmanager.h"
namespace
{
//---------------------------------------------------------------------------------------------------------------------
template <class T>
auto NumberToString(T number) -> QString
{
const QLocale locale = QLocale::c();
return locale.toString(number, 'g', 12).remove(locale.groupSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
auto TransformToString(const QTransform &m) -> QString
{
QStringList matrix
{
NumberToString(m.m11()),
NumberToString(m.m12()),
NumberToString(m.m13()),
NumberToString(m.m21()),
NumberToString(m.m22()),
NumberToString(m.m23()),
NumberToString(m.m31()),
NumberToString(m.m32()),
NumberToString(m.m33())
};
return matrix.join(ML::groupSep);
}
//---------------------------------------------------------------------------------------------------------------------
auto PointToString(const QPointF &p) -> QString
{
return NumberToString(p.x()) + ML::coordintatesSep + NumberToString(p.y());
}
//---------------------------------------------------------------------------------------------------------------------
auto PathToString(const QVector<QPointF> &pathPoints) -> QString
{
QStringList path;
for (auto point : pathPoints)
{
path.append(PointToString(point));
}
return path.join(ML::pointsSep);
}
//---------------------------------------------------------------------------------------------------------------------
auto RectToString(const QRectF &r) -> QString
{
return NumberToString(r.x()) + ML::groupSep +
NumberToString(r.y()) + ML::groupSep +
NumberToString(r.width()) + ML::groupSep +
NumberToString(r.height());
}
//---------------------------------------------------------------------------------------------------------------------
auto MarkerShapeToString(const PlaceLabelImg &shape) -> QString
{
QStringList s;
for (const auto& path : shape)
{
s.append(PathToString(path));
}
return s.join(ML::itemsSep);
}
//---------------------------------------------------------------------------------------------------------------------
auto LineToString(const QLineF &line) -> QString
{
return PointToString(line.p1()) + ML::groupSep + PointToString(line.p2());
}
//---------------------------------------------------------------------------------------------------------------------
auto LinesToString(const QVector<QLineF> &lines) -> QString
{
QStringList l;
for (auto line : lines)
{
l.append(LineToString(line));
}
return l.join(ML::itemsSep);
}
//---------------------------------------------------------------------------------------------------------------------
auto GrainlineArrowDirrectionToString(GrainlineArrowDirection type) -> QString
{
switch(type)
{
case GrainlineArrowDirection::atFront:
return ML::atFrontStr;
case GrainlineArrowDirection::atRear:
return ML::atRearStr;
case GrainlineArrowDirection::atBoth:
default:
return ML::atBothStr;
}
}
} // namespace
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteFile(VPLayout *layout, QFile *file)
@ -41,6 +143,8 @@ void VPLayoutFileWriter::WriteFile(VPLayout *layout, QFile *file)
setAutoFormatting(true);
writeStartDocument();
writeComment(QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).")
.arg(APP_VERSION_STR));
WriteLayout(layout);
writeEndDocument();
@ -52,13 +156,9 @@ void VPLayoutFileWriter::WriteLayout(VPLayout *layout)
{
writeStartElement(ML::TagLayout);
SetAttribute(ML::AttrVersion, VLayoutConverter::LayoutMaxVerStr);
writeComment(QStringLiteral("Layout created with Valentina v%1 (https://smart-pattern.com.ua/).")
.arg(APP_VERSION_STR));
WriteProperties(layout);
WritePieceList(layout->GetUnplacedPieces(), ML::TagUnplacedPieces);
WriteSheets(layout);
writeEndElement(); //layout
}
@ -76,6 +176,9 @@ void VPLayoutFileWriter::WriteProperties(VPLayout *layout)
writeStartElement(ML::TagControl);
SetAttribute(ML::AttrWarningSuperposition, layout->LayoutSettings().GetWarningSuperpositionOfPieces());
SetAttribute(ML::AttrWarningOutOfBound, layout->LayoutSettings().GetWarningPiecesOutOfBound());
SetAttribute(ML::AttrStickyEdges, layout->LayoutSettings().GetStickyEdges());
SetAttribute(ML::AttrPiecesGap, layout->LayoutSettings().GetPiecesGap());
// SetAttribute(ML::AttrFollowGrainLine, layout->LayoutSettings().GetFollowGrainline());
writeEndElement(); // control
WriteTiles(layout);
@ -142,19 +245,110 @@ void VPLayoutFileWriter::WritePiece(VPPiece *piece)
writeStartElement(ML::TagPiece);
SetAttribute(ML::AttrID, piece->GetUUID().toString());
SetAttribute(ML::AttrName, piece->GetName());
SetAttribute(ML::AttrMirrored, piece->IsMirror());
// SetAttribute(ML::AttrShowSeamline, piece->GetShowSeamLine());
SetAttribute(ML::AttrTransform, "string representation of the transformation"); // TODO / Fixme get the right value
SetAttributeOrRemoveIf<bool>(ML::AttrMirrored, piece->IsMirror(), [](bool mirrored){return not mirrored;});
SetAttribute(ML::AttrTransform, TransformToString(piece->GetMatrix()));
// TODO cuttingLine
// TODO seamLine
// TODO grainline
// TODO passmarks
// TODO internal paths
// TODO placeLabels (buttonholes etc.)
writeStartElement(ML::TagSeamLine);
writeCharacters(PathToString(piece->GetContourPoints()));
writeEndElement();
// TODO labels
writeStartElement(ML::TagSeamAllowance);
SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsSeamAllowance(), [](bool enabled){return not enabled;});
SetAttributeOrRemoveIf<bool>(ML::AttrBuiltIn, piece->IsSeamAllowanceBuiltIn(),
[](bool builtin){return not builtin;});
if (piece->IsSeamAllowance() && not piece->IsSeamAllowanceBuiltIn())
{
writeCharacters(PathToString(piece->GetSeamAllowancePoints()));
}
writeEndElement();
writeStartElement(ML::TagGrainline);
SetAttributeOrRemoveIf<bool>(ML::AttrEnabled, piece->IsGrainlineEnabled(), [](bool enabled){return not enabled;});
if (piece->IsGrainlineEnabled())
{
SetAttribute(ML::AttrAngle, piece->GrainlineAngle());
SetAttribute(ML::AttrArrowDirection, GrainlineArrowDirrectionToString(piece->GrainlineArrowType()));
writeCharacters(PathToString(piece->GetGrainline()));
}
writeEndElement();
writeStartElement(ML::TagNotches);
QVector<VLayoutPassmark> passmarks = piece->GetPassmarks();
for (const auto& passmark : passmarks)
{
writeStartElement(ML::TagNotch);
SetAttribute(ML::AttrBuiltIn, passmark.isBuiltIn);
SetAttribute(ML::AttrType, static_cast<int>(passmark.type));
SetAttribute(ML::AttrBaseLine, LineToString(passmark.baseLine));
SetAttribute(ML::AttrPath, LinesToString(passmark.lines));
writeEndElement();
}
writeEndElement();
writeStartElement(ML::TagInternalPaths);
QVector<VLayoutPiecePath> internalPaths = piece->GetInternalPaths();
for (const auto& path : internalPaths)
{
writeStartElement(ML::TagInternalPath);
SetAttribute(ML::AttrCut, path.IsCutPath());
SetAttribute(ML::AttrPenStyle, PenStyleToLineStyle(path.PenStyle()));
writeCharacters(PathToString(path.Points()));
writeEndElement();
}
writeEndElement();
writeStartElement(ML::TagMarkers);
QVector<VLayoutPlaceLabel> placelabels = piece->GetPlaceLabels();
for (const auto& label : placelabels)
{
writeStartElement(ML::TagMarker);
SetAttribute(ML::AttrTransform, TransformToString(label.rotationMatrix));
SetAttribute(ML::AttrType, static_cast<int>(label.type));
SetAttribute(ML::AttrCenter, PointToString(label.center));
SetAttribute(ML::AttrBox, RectToString(label.box));
writeCharacters(MarkerShapeToString(label.shape));
writeEndElement();
}
writeEndElement();
writeStartElement(ML::TagLabels);
WriteLabel(piece->GetPieceLabelRect(), piece->GetPieceLabelData(), ML::TagPieceLabel);
WriteLabel(piece->GetPatternLabelRect(), piece->GetPatternLabelData(), ML::TagPatternLabel);
writeEndElement();
writeEndElement();
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteLabel(const QVector<QPointF> &labelShape, const VTextManager &tm, const QString &tagName)
{
if (labelShape.size() > 2 && tm.GetSourceLinesCount() > 0)
{
writeStartElement(tagName);
SetAttribute(ML::AttrShape, PathToString(labelShape));
WriteLabelLines(tm);
writeEndElement();
}
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutFileWriter::WriteLabelLines(const VTextManager &tm)
{
writeStartElement(ML::TagLines);
SetAttribute(ML::AttrFont, tm.GetFont().toString());
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
{
writeStartElement(ML::TagLine);
const TextLine& tl = tm.GetSourceLine(i);
SetAttribute(ML::AttrFontSize, tl.m_iFontSize);
SetAttribute(ML::AttrBold, tl.m_bold);
SetAttribute(ML::AttrItalic, tl.m_italic);
SetAttribute(ML::AttrAlignment, static_cast<int>(tl.m_eAlign));
writeCharacters(tl.m_qsText);
writeEndElement();
}
writeEndElement();
}

View file

@ -42,6 +42,7 @@ class VPPieceList;
class VPPiece;
class QFile;
class QMarginsF;
class VTextManager;
class VPLayoutFileWriter : public QXmlStreamWriter
{
@ -60,6 +61,8 @@ private:
void WriteTiles(VPLayout *layout);
void WritePieceList(const QList<VPPiece *> &list, const QString &tagName);
void WritePiece(VPPiece *piece);
void WriteLabel(const QVector<QPointF> &labelShape, const VTextManager &tm, const QString &tagName);
void WriteLabelLines(const VTextManager &tm);
void WriteMargins(const QMarginsF &margins);
void WriteSize(QSizeF size);

View file

@ -44,6 +44,20 @@ const QString TagPiece = QStringLiteral("piece");
const QString TagSheets = QStringLiteral("sheets");
const QString TagSheet = QStringLiteral("sheet");
const QString TagName = QStringLiteral("name");
const QString TagSeamLine = QStringLiteral("seamLine");
const QString TagSeamAllowance = QStringLiteral("seamAllowance");
const QString TagGrainline = QStringLiteral("grainline");
const QString TagNotches = QStringLiteral("notches");
const QString TagNotch = QStringLiteral("notch");
const QString TagInternalPaths = QStringLiteral("internalPaths");
const QString TagInternalPath = QStringLiteral("internalPath");
const QString TagMarkers = QStringLiteral("markers");
const QString TagMarker = QStringLiteral("marker");
const QString TagLabels = QStringLiteral("labels");
const QString TagPieceLabel = QStringLiteral("pieceLabel");
const QString TagPatternLabel = QStringLiteral("patternLabel");
const QString TagLines = QStringLiteral("lines");
const QString TagLine = QStringLiteral("line");
const QString AttrVersion = QStringLiteral("version");
const QString AttrWarningSuperposition = QStringLiteral("warningSuperposition");
@ -64,4 +78,30 @@ const QString AttrID = QStringLiteral("id");
const QString AttrMirrored = QStringLiteral("mirrored");
const QString AttrTransform = QStringLiteral("transform");
const QString AttrShowSeamline = QStringLiteral("showSeamline");
const QString AttrEnabled = QStringLiteral("enabled");
const QString AttrBuiltIn = QStringLiteral("builtIn");
const QString AttrAngle = QStringLiteral("angle");
const QString AttrArrowDirection = QStringLiteral("arrowDirection");
const QString AttrType = QStringLiteral("type");
const QString AttrBaseLine = QStringLiteral("baseLine");
const QString AttrPath = QStringLiteral("path");
const QString AttrCut = QStringLiteral("cut");
const QString AttrPenStyle = QStringLiteral("penStyle");
const QString AttrCenter = QStringLiteral("center");
const QString AttrBox = QStringLiteral("box");
const QString AttrShape = QStringLiteral("shape");
const QString AttrFont = QStringLiteral("font");
const QString AttrFontSize = QStringLiteral("fontSize");
const QString AttrBold = QStringLiteral("bold");
const QString AttrItalic = QStringLiteral("italic");
const QString AttrAlignment = QStringLiteral("alignment");
const QString atFrontStr = QStringLiteral("atFront");
const QString atRearStr = QStringLiteral("atRear");
const QString atBothStr = QStringLiteral("atBoth");
const QChar groupSep = QLatin1Char(';');
const QChar coordintatesSep = QLatin1Char(',');
const QChar pointsSep = QLatin1Char(' ');
const QChar itemsSep = QLatin1Char('*');
} // namespace ML

View file

@ -49,6 +49,20 @@ extern const QString TagPiece;
extern const QString TagSheets;
extern const QString TagSheet;
extern const QString TagName;
extern const QString TagSeamLine;
extern const QString TagSeamAllowance;
extern const QString TagGrainline;
extern const QString TagNotches;
extern const QString TagNotch;
extern const QString TagInternalPaths;
extern const QString TagInternalPath;
extern const QString TagMarkers;
extern const QString TagMarker;
extern const QString TagLabels;
extern const QString TagPieceLabel;
extern const QString TagPatternLabel;
extern const QString TagLines;
extern const QString TagLine;
extern const QString AttrVersion;
extern const QString AttrWarningSuperposition;
@ -69,6 +83,32 @@ extern const QString AttrID;
extern const QString AttrMirrored;
extern const QString AttrTransform;
extern const QString AttrShowSeamline;
extern const QString AttrEnabled;
extern const QString AttrBuiltIn;
extern const QString AttrAngle;
extern const QString AttrArrowDirection;
extern const QString AttrType;
extern const QString AttrBaseLine;
extern const QString AttrPath;
extern const QString AttrCut;
extern const QString AttrPenStyle;
extern const QString AttrCenter;
extern const QString AttrBox;
extern const QString AttrShape;
extern const QString AttrFont;
extern const QString AttrFontSize;
extern const QString AttrBold;
extern const QString AttrItalic;
extern const QString AttrAlignment;
extern const QString atFrontStr;
extern const QString atRearStr;
extern const QString atBothStr;
extern const QChar groupSep;
extern const QChar coordintatesSep;
extern const QChar pointsSep;
extern const QChar itemsSep;
}

View file

@ -8,9 +8,22 @@
<xs:element type="units" name="unit"/>
<xs:element type="xs:string" name="title"/>
<xs:element type="xs:string" name="description"/>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
</xs:complexType>
</xs:element>
<xs:element name="control">
<xs:complexType>
<xs:attribute type="xs:boolean" name="followGrainLine"/>
<xs:attribute type="xs:boolean" name="warningSuperposition"/>
<xs:attribute type="xs:boolean" name="warningOutOfBound"/>
<xs:attribute type="xs:boolean" name="stickyEdges"/>
@ -48,17 +61,131 @@
<xs:element name="piece" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element type="PathNotEmpty" name="seamLine"/>
<xs:element name="seamAllowance">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="grainline">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:float" name="angle" use="optional"/>
<xs:attribute type="ArrowDirection" name="arrowDirection" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="notches">
<xs:complexType>
<xs:sequence>
<xs:element name="notch" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="internalPaths">
<xs:complexType>
<xs:sequence>
<xs:element name="internalPath" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathNotEmpty">
<xs:attribute type="xs:boolean" name="cut" use="optional"/>
<xs:attribute type="CurvePenStyle" name="penStyle" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="markers">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="marker" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="MarkerShapePath">
<xs:attribute type="Transformation" name="transform" use="required"/>
<xs:attribute type="MarkerType" name="type" use="required"/>
<xs:attribute type="PointPath" name="center" use="required"/>
<xs:attribute type="RectPath" name="box" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="labels">
<xs:complexType>
<xs:sequence>
<xs:element name="pieceLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="shape" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="xs:unsignedInt" name="alignment" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="shape" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="uuid"/>
<xs:attribute name="id" type="uuid" use="required"/>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="mirrored"/>
<xs:attribute type="xs:boolean" name="showSeamline"/>
<xs:attribute type="xs:string" name="transform"/>
<xs:attribute type="Transformation" name="transform"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="visible"/>
</xs:complexType>
</xs:element>
<xs:element name="sheets">
@ -68,39 +195,139 @@
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element name="size">
<xs:complexType>
<xs:attribute type="xs:float" name="width" use="required"/>
<xs:attribute type="xs:float" name="length" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="margin">
<xs:complexType>
<xs:attribute type="xs:float" name="top"/>
<xs:attribute type="xs:float" name="right"/>
<xs:attribute type="xs:float" name="bottom"/>
<xs:attribute type="xs:float" name="left"/>
</xs:complexType>
</xs:element>
<xs:element name="pieces">
<xs:complexType>
<xs:sequence>
<xs:element name="piece" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element type="PathNotEmpty" name="seamLine"/>
<xs:element name="seamAllowance">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="grainline">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathOrEmpty">
<xs:attribute type="xs:boolean" name="enabled" use="optional"/>
<xs:attribute type="xs:float" name="angle" use="optional"/>
<xs:attribute type="ArrowDirection" name="arrowDirection" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="notches">
<xs:complexType>
<xs:sequence>
<xs:element name="notch" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:boolean" name="builtIn" use="optional"/>
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="internalPaths">
<xs:complexType>
<xs:sequence>
<xs:element name="internalPath" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="PathNotEmpty">
<xs:attribute type="xs:boolean" name="cut" use="optional"/>
<xs:attribute type="CurvePenStyle" name="penStyle" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="markers">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="marker" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="MarkerShapePath">
<xs:attribute type="Transformation" name="transform" use="required"/>
<xs:attribute type="MarkerType" name="type" use="required"/>
<xs:attribute type="PointPath" name="center" use="required"/>
<xs:attribute type="RectPath" name="box" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="labels">
<xs:complexType>
<xs:sequence>
<xs:element name="pieceLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="PathNotEmpty" name="shape" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="patternLabel" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="lines">
<xs:complexType>
<xs:sequence>
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute type="xs:string" name="font" use="required"/>
<xs:attribute type="xs:boolean" name="bold" use="optional"/>
<xs:attribute type="xs:boolean" name="italic" use="optional"/>
<xs:attribute type="AlignmentType" name="alignment" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="PathNotEmpty" name="shape" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="uuid"/>
<xs:attribute name="id" type="uuid" use="required"/>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="mirrored"/>
<xs:attribute type="xs:boolean" name="showSeamline"/>
<xs:attribute type="xs:string" name="transform"/>
<xs:attribute type="Transformation" name="transform"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:boolean" name="visible"/>
</xs:complexType>
</xs:element>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
@ -129,4 +356,102 @@
<xs:pattern value="|\{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}\}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ArrowDirection">
<xs:restriction base="xs:string">
<xs:enumeration value="atFront"/>
<xs:enumeration value="atRear"/>
<xs:enumeration value="atBoth"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="NotchType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--OneLine-->
<xs:enumeration value="1"/>
<!--TwoLines-->
<xs:enumeration value="2"/>
<!--ThreeLines-->
<xs:enumeration value="3"/>
<!--TMark-->
<xs:enumeration value="4"/>
<!--VMark-->
<xs:enumeration value="5"/>
<!--VMark2-->
<xs:enumeration value="6"/>
<!--UMark-->
<xs:enumeration value="7"/>
<!--BoxMark-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CurvePenStyle">
<xs:restriction base="xs:string">
<xs:enumeration value="hair"/>
<xs:enumeration value="dashLine"/>
<xs:enumeration value="dotLine"/>
<xs:enumeration value="dashDotLine"/>
<xs:enumeration value="dashDotDotLine"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MarkerType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--Segment-->
<xs:enumeration value="1"/><!--Rectangle-->
<xs:enumeration value="2"/><!--Cross-->
<xs:enumeration value="3"/><!--Tshaped-->
<xs:enumeration value="4"/><!--Doubletree-->
<xs:enumeration value="5"/><!--Corner-->
<xs:enumeration value="6"/><!--Triangle-->
<xs:enumeration value="7"/><!--Hshaped-->
<xs:enumeration value="8"/><!--Button-->
<xs:enumeration value="9"/><!--Circle-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="AlignmentType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--default (no aligns)-->
<xs:enumeration value="1"/><!--aligns with the left edge-->
<xs:enumeration value="2"/><!--aligns with the right edge-->
<xs:enumeration value="4"/><!--Centers horizontally in the available space-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="Transformation">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?;){8,}[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PathNotEmpty">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PathOrEmpty">
<xs:restriction base="xs:string">
<xs:pattern value="|([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LinePath">
<xs:restriction base="xs:string">
<xs:pattern value="[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LinesPath">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\*){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?;[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="PointPath">
<xs:restriction base="xs:string">
<xs:pattern value="[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RectPath">
<xs:restriction base="xs:string">
<xs:pattern value="([-+]?\d+\.?\d*([eE][-+]?\d+)?;){3,}[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="MarkerShapePath">
<xs:restriction base="xs:string">
<xs:pattern value="(([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\*){0,}([-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?\s){0,}[-+]?\d+\.?\d*([eE][-+]?\d+)?,[-+]?\d+\.?\d*([eE][-+]?\d+)?"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View file

@ -719,6 +719,30 @@ void VLayoutPiece::SetPieceText(const QString& qsName, const VPieceLabelData& da
d->m_tmDetail.FitFontSize(labelWidth, labelHeight);
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetPieceLabelRect() const -> QVector<QPointF>
{
return d->detailLabel;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPieceLabelRect(const QVector<QPointF> &rect)
{
d->detailLabel = rect;
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetPieceLabelData() const -> VTextManager
{
return d->m_tmDetail;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPieceLabelData(const VTextManager &data)
{
d->m_tmDetail = data;
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VLayoutPiece::GetPatternTextPosition() const
{
@ -777,6 +801,30 @@ void VLayoutPiece::SetPatternInfo(VAbstractPattern* pDoc, const VPatternLabelDat
d->m_tmPattern.FitFontSize(labelWidth, labelHeight);
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetPatternLabelRect() const -> QVector<QPointF>
{
return d->patternInfo;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPatternLabelRect(const QVector<QPointF> &rect)
{
d->patternInfo = rect;
}
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::GetPatternLabelData() const -> VTextManager
{
return d->m_tmPattern;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetPatternLabelData(const VTextManager &data)
{
d->m_tmPattern = data;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetGrainline(const VGrainlineData& geom, const VContainer* pattern)
{
@ -814,6 +862,30 @@ bool VLayoutPiece::IsGrainlineEnabled() const
return d->grainlineEnabled;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetGrainlineEnabled(bool enabled)
{
d->grainlineEnabled = enabled;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetGrainlineAngle(qreal angle)
{
d->grainlineAngle = angle;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetGrainlineArrowType(GrainlineArrowDirection type)
{
d->grainlineArrowType = type;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::SetGrainlinePoints(const QVector<QPointF> &points)
{
d->grainlinePoints = points;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VLayoutPiece::GrainlineAngle() const
{
@ -1105,7 +1177,7 @@ QVector<QVector<QPointF> > VLayoutPiece::MappedInternalPathsForCut(bool cut) con
{
QVector<QVector<QPointF> > paths;
for (auto &path : d->m_internalPaths)
for (const auto &path : d->m_internalPaths)
{
if (path.IsCutPath() == cut)
{

View file

@ -167,6 +167,24 @@ public:
friend QDataStream& operator<< (QDataStream& dataStream, const VLayoutPiece& piece);
friend QDataStream& operator>> (QDataStream& dataStream, VLayoutPiece& piece);
protected:
void SetGrainlineEnabled(bool enabled);
void SetGrainlineAngle(qreal angle);
void SetGrainlineArrowType(GrainlineArrowDirection type);
void SetGrainlinePoints(const QVector<QPointF> &points);
auto GetPieceLabelRect() const -> QVector<QPointF>;
void SetPieceLabelRect(const QVector<QPointF> &rect);
auto GetPieceLabelData() const ->VTextManager;
void SetPieceLabelData(const VTextManager &data);
auto GetPatternLabelRect() const -> QVector<QPointF>;
void SetPatternLabelRect(const QVector<QPointF> &rect);
auto GetPatternLabelData() const ->VTextManager;
void SetPatternLabelData(const VTextManager &data);
private:
QSharedDataPointer<VLayoutPieceData> d;

View file

@ -51,7 +51,7 @@ const quint16 TextLine::classVersion = 1;
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator<<(QDataStream &dataStream, const TextLine &data)
auto operator<<(QDataStream &dataStream, const TextLine &data) -> QDataStream&
{
dataStream << TextLine::streamHeader << TextLine::classVersion;
@ -68,7 +68,7 @@ QDataStream& operator<<(QDataStream &dataStream, const TextLine &data)
}
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator>>(QDataStream &dataStream, TextLine &data)
auto operator>>(QDataStream &dataStream, TextLine &data) -> QDataStream&
{
quint32 actualStreamHeader = 0;
dataStream >> actualStreamHeader;
@ -113,7 +113,7 @@ const quint16 VTextManager::classVersion = 1;
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator<<(QDataStream &dataStream, const VTextManager &data)
auto operator<<(QDataStream &dataStream, const VTextManager &data) -> QDataStream&
{
dataStream << VTextManager::streamHeader << VTextManager::classVersion;
@ -127,7 +127,7 @@ QDataStream& operator<<(QDataStream &dataStream, const VTextManager &data)
}
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator>>(QDataStream &dataStream, VTextManager &data)
auto operator>>(QDataStream &dataStream, VTextManager &data) -> QDataStream&
{
quint32 actualStreamHeader = 0;
dataStream >> actualStreamHeader;
@ -167,7 +167,7 @@ namespace
{
//---------------------------------------------------------------------------------------------------------------------
QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data)
auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) -> QMap<QString, QString>
{
SCASSERT(doc != nullptr)
SCASSERT(data != nullptr)
@ -331,7 +331,7 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
}
//---------------------------------------------------------------------------------------------------------------------
QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line)
auto ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString line) -> QString
{
QChar per('%');
@ -359,7 +359,7 @@ QString ReplacePlaceholders(const QMap<QString, QString> &placeholders, QString
}
//---------------------------------------------------------------------------------------------------------------------
QVector<TextLine> PrepareLines(const QVector<VLabelTemplateLine> &lines)
auto PrepareLines(const QVector<VLabelTemplateLine> &lines) -> QVector<TextLine>
{
QVector<TextLine> textLines;
@ -412,7 +412,7 @@ VTextManager &VTextManager::operator=(const VTextManager &text)
* @brief GetSpacing returns the vertical spacing between the lines
* @return spacing
*/
int VTextManager::GetSpacing() const
auto VTextManager::GetSpacing() const -> int
{
return 0;
}
@ -432,7 +432,7 @@ void VTextManager::SetFont(const QFont& font)
* @brief GetFont returns the text base font
* @return text base font
*/
const QFont& VTextManager::GetFont() const
auto VTextManager::GetFont() const -> const QFont&
{
return m_font;
}
@ -448,17 +448,23 @@ void VTextManager::SetFontSize(int iFS)
}
//---------------------------------------------------------------------------------------------------------------------
QVector<TextLine> VTextManager::GetAllSourceLines() const
auto VTextManager::GetAllSourceLines() const -> QVector<TextLine>
{
return m_liLines;
}
//---------------------------------------------------------------------------------------------------------------------
void VTextManager::SetAllSourceLines(const QVector<TextLine> &lines)
{
m_liLines = lines;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VTextManager::GetSourceLinesCount returns the number of input text lines
* @return number of text lines that were added to the list by calling AddLine
*/
int VTextManager::GetSourceLinesCount() const
auto VTextManager::GetSourceLinesCount() const -> int
{
return m_liLines.count();
}
@ -469,7 +475,7 @@ int VTextManager::GetSourceLinesCount() const
* @param i index of the requested line
* @return reference to the requested TextLine object
*/
const TextLine& VTextManager::GetSourceLine(int i) const
auto VTextManager::GetSourceLine(int i) const -> const TextLine&
{
Q_ASSERT(i >= 0);
Q_ASSERT(i < m_liLines.count());

View file

@ -57,8 +57,8 @@ struct TextLine
bool m_italic{false};
Qt::Alignment m_eAlign{Qt::AlignCenter};
friend QDataStream& operator<<(QDataStream& dataStream, const TextLine& data);
friend QDataStream& operator>>(QDataStream& dataStream, TextLine& data);
friend auto operator<<(QDataStream& dataStream, const TextLine& data) -> QDataStream&;
friend auto operator>>(QDataStream& dataStream, TextLine& data) -> QDataStream&;
private:
static const quint32 streamHeader;
static const quint16 classVersion;
@ -78,22 +78,23 @@ public:
VTextManager(const VTextManager &text);
VTextManager &operator=(const VTextManager &text);
virtual int GetSpacing() const;
virtual auto GetSpacing() const -> int;
void SetFont(const QFont& font);
const QFont& GetFont() const;
void SetFontSize(int iFS);
void FitFontSize(qreal fW, qreal fH);
void SetFont(const QFont& font);
auto GetFont() const -> const QFont&;
void SetFontSize(int iFS);
void FitFontSize(qreal fW, qreal fH);
QVector<TextLine> GetAllSourceLines() const;
int GetSourceLinesCount() const;
const TextLine& GetSourceLine(int i) const;
auto GetAllSourceLines() const -> QVector<TextLine>;
void SetAllSourceLines(const QVector<TextLine> &lines);
auto GetSourceLinesCount() const -> int;
auto GetSourceLine(int i) const -> const TextLine&;
void Update(const QString& qsName, const VPieceLabelData& data, const VContainer *pattern);
void Update(VAbstractPattern* pDoc, const VContainer *pattern);
friend QDataStream& operator<<(QDataStream& dataStream, const VTextManager& data);
friend QDataStream& operator>>(QDataStream& dataStream, VTextManager& data);
friend auto operator<<(QDataStream& dataStream, const VTextManager& data) -> QDataStream&;
friend auto operator>>(QDataStream& dataStream, VTextManager& data) -> QDataStream&;
private:
QFont m_font;