Added more additional Piece label fields.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-08-21 13:16:43 +03:00
parent 03e1256952
commit acf429518d
17 changed files with 263 additions and 18 deletions

View File

@ -893,16 +893,12 @@ void VPattern::ParsePieceDataTag(const QDomElement &domElement, VPiece &detail)
{
VPieceLabelData &ppData = detail.GetPatternPieceData();
ppData.SetVisible(GetParametrBool(domElement, AttrVisible, trueStr));
try
{
QString qsLetter = GetParametrString(domElement, AttrLetter, "");
ppData.SetLetter(qsLetter);
}
catch(const VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
ppData.SetLetter("");
}
ppData.SetLetter(GetParametrEmptyString(domElement, AttrLetter));
ppData.SetAnnotation(GetParametrEmptyString(domElement, AttrAnnotation));
ppData.SetOrientation(GetParametrEmptyString(domElement, AttrOrientation));
ppData.SetRotation(GetParametrEmptyString(domElement, AttrRotation));
ppData.SetTilt(GetParametrEmptyString(domElement, AttrTilt));
ppData.SetFoldPosition(GetParametrEmptyString(domElement, AttrFoldPosition));
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")));

View File

@ -516,6 +516,11 @@
</xs:element>
</xs:sequence>
<xs:attribute name="letter" type="xs:string"/>
<xs:attribute name="annotation" type="xs:string"/>
<xs:attribute name="orientation" type="xs:string"/>
<xs:attribute name="rotation" type="xs:string"/>
<xs:attribute name="tilt" type="xs:string"/>
<xs:attribute name="foldPosition" type="xs:string"/>
<xs:attribute name="visible" type="xs:boolean"/>
<xs:attribute name="onFold" type="xs:boolean"/>
<xs:attribute name="fontSize" type="xs:unsignedInt"/>

View File

@ -98,6 +98,11 @@ const QString VAbstractPattern::AttrObject = QStringLiteral("object")
const QString VAbstractPattern::AttrTool = QStringLiteral("tool");
const QString VAbstractPattern::AttrType = QStringLiteral("type");
const QString VAbstractPattern::AttrLetter = QStringLiteral("letter");
const QString VAbstractPattern::AttrAnnotation = QStringLiteral("annotation");
const QString VAbstractPattern::AttrOrientation = QStringLiteral("orientation");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrTilt = QStringLiteral("tilt");
const QString VAbstractPattern::AttrFoldPosition = QStringLiteral("foldPosition");
const QString VAbstractPattern::AttrQuantity = QStringLiteral("quantity");
const QString VAbstractPattern::AttrOnFold = QStringLiteral("onFold");
const QString VAbstractPattern::AttrDateFormat = QStringLiteral("dateFormat");
@ -116,7 +121,6 @@ const QString VAbstractPattern::AttrPath = QStringLiteral("path");
const QString VAbstractPattern::AttrEnd = QStringLiteral("end");
const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeAs");
const QString VAbstractPattern::AttrWidth = QStringLiteral("width");
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");

View File

@ -228,6 +228,11 @@ public:
static const QString AttrTool;
static const QString AttrType;
static const QString AttrLetter;
static const QString AttrAnnotation;
static const QString AttrOrientation;
static const QString AttrRotation;
static const QString AttrTilt;
static const QString AttrFoldPosition;
static const QString AttrQuantity;
static const QString AttrOnFold;
static const QString AttrDateFormat;
@ -246,7 +251,6 @@ public:
static const QString AttrEnd;
static const QString AttrIncludeAs;
static const QString AttrWidth;
static const QString AttrRotation;
static const QString AttrAll;

View File

@ -453,6 +453,21 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt
return parameter;
}
//---------------------------------------------------------------------------------------------------------------------
QString VDomDocument::GetParametrEmptyString(const QDomElement &domElement, const QString &name)
{
QString result;
try
{
result = GetParametrString(domElement, name, "");
}
catch(const VExceptionEmptyParameter &)
{
// do nothing
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief Returns the double value of the given attribute.

View File

@ -108,6 +108,7 @@ public:
static QString GetParametrString(const QDomElement& domElement, const QString &name,
const QString &defValue = QString());
static QString GetParametrEmptyString(const QDomElement& domElement, const QString &name);
static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue);
static quint32 GetParametrId(const QDomElement& domElement);

View File

@ -102,6 +102,11 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
// Piece tags
placeholders.insert(pl_pLetter, "");
placeholders.insert(pl_pAnnotation, "");
placeholders.insert(pl_pOrientation, "");
placeholders.insert(pl_pRotation, "");
placeholders.insert(pl_pTilt, "");
placeholders.insert(pl_pFoldPosition, "");
placeholders.insert(pl_pName, "");
placeholders.insert(pl_pQuantity, "");
placeholders.insert(pl_wOnFold, "");
@ -118,6 +123,11 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc)
void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &name, const VPieceLabelData& data)
{
placeholders[pl_pLetter] = data.GetLetter();
placeholders[pl_pAnnotation] = data.GetAnnotation();
placeholders[pl_pOrientation] = data.GetOrientation();
placeholders[pl_pRotation] = data.GetRotation();
placeholders[pl_pTilt] = data.GetTilt();
placeholders[pl_pFoldPosition] = data.GetFoldPosition();
placeholders[pl_pName] = name;
placeholders[pl_pQuantity] = QString::number(data.GetQuantity());

View File

@ -122,6 +122,11 @@ const QString pl_pFileName = QStringLiteral("pFileName");
const QString pl_mFileName = QStringLiteral("mFileName");
const QString pl_mExt = QStringLiteral("mExt");
const QString pl_pLetter = QStringLiteral("pLetter");
const QString pl_pAnnotation = QStringLiteral("pAnnotation");
const QString pl_pOrientation = QStringLiteral("pOrientation");
const QString pl_pRotation = QStringLiteral("pRotation");
const QString pl_pTilt = QStringLiteral("pTilt");
const QString pl_pFoldPosition = QStringLiteral("pFoldPosition");
const QString pl_pName = QStringLiteral("pName");
const QString pl_pQuantity = QStringLiteral("pQuantity");
const QString pl_mFabric = QStringLiteral("mFabric");
@ -144,6 +149,11 @@ const QStringList labelTemplatePlaceholders = QStringList() << pl_size
<< pl_mFileName
<< pl_mExt
<< pl_pLetter
<< pl_pAnnotation
<< pl_pOrientation
<< pl_pRotation
<< pl_pTilt
<< pl_pFoldPosition
<< pl_pName
<< pl_pQuantity
<< pl_mFabric

View File

@ -364,6 +364,11 @@ extern const QString pl_pFileName;
extern const QString pl_mFileName;
extern const QString pl_mExt;
extern const QString pl_pLetter;
extern const QString pl_pAnnotation;
extern const QString pl_pOrientation;
extern const QString pl_pRotation;
extern const QString pl_pTilt;
extern const QString pl_pFoldPosition;
extern const QString pl_pName;
extern const QString pl_pQuantity;
extern const QString pl_mFabric;

View File

@ -77,6 +77,66 @@ void VPieceLabelData::SetLetter(const QString &qsLetter)
d->m_qsLetter = qsLetter.left(3);
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetAnnotation() const
{
return d->m_annotation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetAnnotation(const QString &val)
{
d->m_annotation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetOrientation() const
{
return d->m_orientation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetOrientation(const QString &val)
{
d->m_orientation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetRotation() const
{
return d->m_rotation;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetRotation(const QString &val)
{
d->m_rotation = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetTilt() const
{
return d->m_tilt;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetTilt(const QString &val)
{
d->m_tilt = val;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPieceLabelData::GetFoldPosition() const
{
return d->m_foldPosition;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceLabelData::SetFoldPosition(const QString &val)
{
d->m_foldPosition = val;
}
//---------------------------------------------------------------------------------------------------------------------
int VPieceLabelData::GetQuantity() const
{

View File

@ -63,6 +63,21 @@ public:
QString GetLetter() const;
void SetLetter(const QString &qsLetter);
QString GetAnnotation() const;
void SetAnnotation(const QString &val);
QString GetOrientation() const;
void SetOrientation(const QString &val);
QString GetRotation() const;
void SetRotation(const QString &val);
QString GetTilt() const;
void SetTilt(const QString &val);
QString GetFoldPosition() const;
void SetFoldPosition(const QString &val);
int GetQuantity() const;
void SetQuantity(int val);

View File

@ -46,6 +46,11 @@ class VPieceLabelDataPrivate : public QSharedData
public:
VPieceLabelDataPrivate()
: m_qsLetter(),
m_annotation(),
m_orientation(),
m_rotation(),
m_tilt(),
m_foldPosition(),
m_quantity(1),
m_onFold(false),
m_lines()
@ -54,6 +59,11 @@ public:
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
: QSharedData(data),
m_qsLetter(data.m_qsLetter),
m_annotation(data.m_annotation),
m_orientation(data.m_orientation),
m_rotation(data.m_rotation),
m_tilt(data.m_tilt),
m_foldPosition(data.m_foldPosition),
m_quantity(data.m_quantity),
m_onFold(data.m_onFold),
m_lines(data.m_lines)
@ -62,7 +72,12 @@ public:
~VPieceLabelDataPrivate() Q_DECL_EQ_DEFAULT;
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
QString m_qsLetter;
QString m_qsLetter;
QString m_annotation;
QString m_orientation;
QString m_rotation;
QString m_tilt;
QString m_foldPosition;
int m_quantity;
bool m_onFold;

View File

@ -470,6 +470,11 @@ void VTranslateVars::InitPlaceholder()
placeholders.insert(pl_mFileName, translate("VTranslateVars", "mFileName", "placeholder"));
placeholders.insert(pl_mExt, translate("VTranslateVars", "mExt", "placeholder"));
placeholders.insert(pl_pLetter, translate("VTranslateVars", "pLetter", "placeholder"));
placeholders.insert(pl_pAnnotation, translate("VTranslateVars", "pAnnotation", "placeholder"));
placeholders.insert(pl_pOrientation, translate("VTranslateVars", "pOrientation", "placeholder"));
placeholders.insert(pl_pRotation, translate("VTranslateVars", "pRotation", "placeholder"));
placeholders.insert(pl_pTilt, translate("VTranslateVars", "pTilt", "placeholder"));
placeholders.insert(pl_pFoldPosition, translate("VTranslateVars", "pFoldPosition", "placeholder"));
placeholders.insert(pl_pName, translate("VTranslateVars", "pName", "placeholder"));
placeholders.insert(pl_pQuantity, translate("VTranslateVars", "pQuantity", "placeholder"));
placeholders.insert(pl_mFabric, translate("VTranslateVars", "mFabric", "placeholder"));

View File

@ -506,6 +506,11 @@ void DialogEditLabel::InitPlaceholders()
// Piece tags
m_placeholders.insert(pl_pLetter, qMakePair(tr("Piece letter"), QString("")));
m_placeholders.insert(pl_pAnnotation, qMakePair(tr("Piece annotation"), QString("")));
m_placeholders.insert(pl_pOrientation, qMakePair(tr("Piece orientation"), QString("")));
m_placeholders.insert(pl_pRotation, qMakePair(tr("Piece rotation"), QString("")));
m_placeholders.insert(pl_pTilt, qMakePair(tr("Piece tilt"), QString("")));
m_placeholders.insert(pl_pFoldPosition, qMakePair(tr("Piece fold position"), QString("")));
m_placeholders.insert(pl_pName, qMakePair(tr("Piece name"), QString("")));
m_placeholders.insert(pl_pQuantity, qMakePair(tr("Quantity"), QString("")));
m_placeholders.insert(pl_mFabric, qMakePair(tr("Material: Fabric"), tr("Fabric")));
@ -590,6 +595,11 @@ void DialogEditLabel::SetPiece(const VPiece &piece)
{
const VPieceLabelData& pieceData = piece.GetPatternPieceData();
m_placeholders[pl_pLetter].second = pieceData.GetLetter();
m_placeholders[pl_pAnnotation].second = pieceData.GetAnnotation();
m_placeholders[pl_pOrientation].second = pieceData.GetOrientation();
m_placeholders[pl_pRotation].second = pieceData.GetRotation();
m_placeholders[pl_pTilt].second = pieceData.GetTilt();
m_placeholders[pl_pFoldPosition].second = pieceData.GetFoldPosition();
m_placeholders[pl_pName].second = piece.GetName();
m_placeholders[pl_pQuantity].second = QString::number(pieceData.GetQuantity());
if (pieceData.IsOnFold())

View File

@ -244,14 +244,19 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
m_mx = piece.GetMx();
m_my = piece.GetMy();
uiTabLabels->lineEditLetter->setText(piece.GetPatternPieceData().GetLetter());
uiTabLabels->spinBoxQuantity->setValue(piece.GetPatternPieceData().GetQuantity());
uiTabLabels->checkBoxFold->setChecked(piece.GetPatternPieceData().IsOnFold());
m_templateLines = piece.GetPatternPieceData().GetLabelTemplate();
m_oldData = piece.GetPatternPieceData();
uiTabLabels->lineEditLetter->setText(m_oldData.GetLetter());
uiTabLabels->lineEditAnnotation->setText(m_oldData.GetAnnotation());
uiTabLabels->lineEditOrientation->setText(m_oldData.GetOrientation());
uiTabLabels->lineEditRotation->setText(m_oldData.GetRotation());
uiTabLabels->lineEditTilt->setText(m_oldData.GetTilt());
uiTabLabels->lineEditFoldPosition->setText(m_oldData.GetFoldPosition());
uiTabLabels->spinBoxQuantity->setValue(m_oldData.GetQuantity());
uiTabLabels->checkBoxFold->setChecked(m_oldData.IsOnFold());
m_templateLines = m_oldData.GetLabelTemplate();
uiTabGrainline->comboBoxArrow->setCurrentIndex(int(piece.GetGrainlineGeometry().GetArrowType()));
m_oldData = piece.GetPatternPieceData();
uiTabLabels->groupBoxDetailLabel->setChecked(m_oldData.IsVisible());
ChangeCurrentData(uiTabLabels->comboBoxDLCenterPin, m_oldData.CenterPin());
ChangeCurrentData(uiTabLabels->comboBoxDLTopLeftPin, m_oldData.TopLeftPin());
@ -1971,6 +1976,11 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetMy(m_my);
piece.SetFormulaSAWidth(GetFormulaFromUser(uiTabPaths->plainTextEditFormulaWidth), m_saWidth);
piece.GetPatternPieceData().SetLetter(uiTabLabels->lineEditLetter->text());
piece.GetPatternPieceData().SetAnnotation(uiTabLabels->lineEditAnnotation->text());
piece.GetPatternPieceData().SetOrientation(uiTabLabels->lineEditOrientation->text());
piece.GetPatternPieceData().SetRotation(uiTabLabels->lineEditRotation->text());
piece.GetPatternPieceData().SetTilt(uiTabLabels->lineEditTilt->text());
piece.GetPatternPieceData().SetFoldPosition(uiTabLabels->lineEditFoldPosition->text());
piece.GetPatternPieceData().SetQuantity(uiTabLabels->spinBoxQuantity->value());
piece.GetPatternPieceData().SetOnFold(uiTabLabels->checkBoxFold->isChecked());
piece.GetPatternPieceData().SetLabelTemplate(m_templateLines);
@ -2498,6 +2508,11 @@ void DialogSeamAllowance::InitPatternPieceDataTab()
{
uiTabLabels->lineEditName->setClearButtonEnabled(true);
uiTabLabels->lineEditLetter->setClearButtonEnabled(true);
uiTabLabels->lineEditAnnotation->setClearButtonEnabled(true);
uiTabLabels->lineEditOrientation->setClearButtonEnabled(true);
uiTabLabels->lineEditRotation->setClearButtonEnabled(true);
uiTabLabels->lineEditTilt->setClearButtonEnabled(true);
uiTabLabels->lineEditFoldPosition->setClearButtonEnabled(true);
connect(uiTabLabels->lineEditName, &QLineEdit::textChanged, this, &DialogSeamAllowance::NameDetailChanged);
connect(uiTabLabels->pushButtonEditPieceLabel, &QPushButton::clicked, this, &DialogSeamAllowance::EditLabel);

View File

@ -157,6 +157,76 @@
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Annotation:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="lineEditAnnotation">
<property name="placeholderText">
<string>A text field to add comments in</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Orientation:</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="lineEditOrientation">
<property name="placeholderText">
<string notr="true">&quot;Left&quot;/&quot;Right&quot;/&quot;Undefined&quot;</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Rotation:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="lineEditRotation">
<property name="placeholderText">
<string notr="true">&quot;1-Way&quot;/&quot;2-Way&quot;/&quot;4-Way&quot;/&quot;Any&quot;</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Tilt:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditTilt">
<property name="placeholderText">
<string notr="true">&quot;CW X&quot;/&quot;CCW X&quot;</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Fold position:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditFoldPosition">
<property name="placeholderText">
<string notr="true">&quot;Up/Down&quot;/&quot;Left/Right&quot;</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -302,6 +302,11 @@ void VToolSeamAllowance::AddPatternPieceData(VAbstractPattern *doc, QDomElement
QDomElement domData = doc->createElement(VAbstractPattern::TagData);
const VPieceLabelData& data = piece.GetPatternPieceData();
doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter());
doc->SetAttribute(domData, VAbstractPattern::AttrAnnotation, data.GetAnnotation());
doc->SetAttribute(domData, VAbstractPattern::AttrOrientation, data.GetOrientation());
doc->SetAttribute(domData, VAbstractPattern::AttrRotation, data.GetRotation());
doc->SetAttribute(domData, VAbstractPattern::AttrTilt, data.GetTilt());
doc->SetAttribute(domData, VAbstractPattern::AttrFoldPosition, data.GetFoldPosition());
doc->SetAttribute(domData, VAbstractPattern::AttrQuantity, data.GetQuantity());
doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible());
doc->SetAttribute(domData, VAbstractPattern::AttrOnFold, data.IsOnFold());