New placeholders CurrentArea and CurrentSeamLineArea. #193
This commit is contained in:
parent
234995fa7a
commit
386760ff3f
|
@ -278,6 +278,9 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) ->
|
|||
VContainer completeData = doc->GetCompleteData();
|
||||
completeData.FillPiecesAreas(VAbstractValApplication::VApp()->patternUnits());
|
||||
|
||||
placeholders.insert(pl_currentArea, QString());
|
||||
placeholders.insert(pl_currentSeamLineArea, QString());
|
||||
|
||||
for (int i=0; i < measurements.size(); ++i)
|
||||
{
|
||||
const VFinalMeasurement &m = measurements.at(i);
|
||||
|
@ -319,7 +322,8 @@ auto PreparePlaceholders(const VAbstractPattern *doc, const VContainer *data) ->
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &name, const VPieceLabelData& data)
|
||||
void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &name, const VPieceLabelData& data,
|
||||
const VContainer *pattern)
|
||||
{
|
||||
placeholders[pl_pLetter] = data.GetLetter();
|
||||
placeholders[pl_pAnnotation] = data.GetAnnotation();
|
||||
|
@ -334,6 +338,37 @@ void InitPiecePlaceholders(QMap<QString, QString> &placeholders, const QString &
|
|||
{
|
||||
placeholders[pl_wOnFold] = QObject::tr("on fold");
|
||||
}
|
||||
|
||||
VContainer completeData = *pattern;
|
||||
completeData.FillPiecesAreas(VAbstractValApplication::VApp()->patternUnits());
|
||||
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
|
||||
try
|
||||
{
|
||||
const QString formula = pieceArea_ + data.GetAreaShartName();
|
||||
const qreal result = cal->EvalFormula(completeData.DataVariables(), formula);
|
||||
placeholders[pl_currentArea] = QString::number(result);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const QString formula = pieceSeamLineArea_ + data.GetAreaShartName();
|
||||
const qreal result = cal->EvalFormula(completeData.DataVariables(), formula);
|
||||
placeholders[pl_currentSeamLineArea] = QString::number(result);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -592,7 +627,7 @@ void VTextManager::Update(const QString& qsName, const VPieceLabelData& data, co
|
|||
|
||||
QMap<QString, QString> placeholders =
|
||||
PreparePlaceholders(VAbstractValApplication::VApp()->getCurrentDocument(), pattern);
|
||||
InitPiecePlaceholders(placeholders, qsName, data);
|
||||
InitPiecePlaceholders(placeholders, qsName, data, pattern);
|
||||
|
||||
QVector<VLabelTemplateLine> lines = data.GetLabelTemplate();
|
||||
|
||||
|
|
|
@ -122,38 +122,40 @@ const QString pl_dimensionYLabel = QStringLiteral("dimensionYLabel");
|
|||
const QString pl_dimensionWLabel = QStringLiteral("dimensionWLabel");
|
||||
const QString pl_dimensionZLabel = QStringLiteral("dimensionZLabel");
|
||||
|
||||
const QString pl_date = QStringLiteral("date");
|
||||
const QString pl_time = QStringLiteral("time");
|
||||
const QString pl_birthDate = QStringLiteral("birthDate");
|
||||
const QString pl_patternName = QStringLiteral("patternName");
|
||||
const QString pl_patternNumber = QStringLiteral("patternNumber");
|
||||
const QString pl_author = QStringLiteral("author");
|
||||
const QString pl_customer = QStringLiteral("customer");
|
||||
const QString pl_email = QStringLiteral("email");
|
||||
const QString pl_userMaterial = QStringLiteral("userMaterial");
|
||||
const QString pl_pExt = QStringLiteral("pExt");
|
||||
const QString pl_pUnits = QStringLiteral("pUnits");
|
||||
const QString pl_pFileName = QStringLiteral("pFileName");
|
||||
const QString pl_mFileName = QStringLiteral("mFileName");
|
||||
const QString pl_mExt = QStringLiteral("mExt");
|
||||
const QString pl_mUnits = QStringLiteral("mUnits");
|
||||
const QString pl_mSizeUnits = QStringLiteral("mSizeUnits");
|
||||
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");
|
||||
const QString pl_mLining = QStringLiteral("mLining");
|
||||
const QString pl_mInterfacing = QStringLiteral("mInterfacing");
|
||||
const QString pl_mInterlining = QStringLiteral("mInterlining");
|
||||
const QString pl_wCut = QStringLiteral("wCut");
|
||||
const QString pl_wOnFold = QStringLiteral("wOnFold");
|
||||
const QString pl_measurement = QStringLiteral("measurement_");
|
||||
const QString pl_finalMeasurement = QStringLiteral("finalMeasurement_");
|
||||
const QString pl_date = QStringLiteral("date");
|
||||
const QString pl_time = QStringLiteral("time");
|
||||
const QString pl_birthDate = QStringLiteral("birthDate");
|
||||
const QString pl_patternName = QStringLiteral("patternName");
|
||||
const QString pl_patternNumber = QStringLiteral("patternNumber");
|
||||
const QString pl_author = QStringLiteral("author");
|
||||
const QString pl_customer = QStringLiteral("customer");
|
||||
const QString pl_email = QStringLiteral("email");
|
||||
const QString pl_userMaterial = QStringLiteral("userMaterial");
|
||||
const QString pl_pExt = QStringLiteral("pExt");
|
||||
const QString pl_pUnits = QStringLiteral("pUnits");
|
||||
const QString pl_pFileName = QStringLiteral("pFileName");
|
||||
const QString pl_mFileName = QStringLiteral("mFileName");
|
||||
const QString pl_mExt = QStringLiteral("mExt");
|
||||
const QString pl_mUnits = QStringLiteral("mUnits");
|
||||
const QString pl_mSizeUnits = QStringLiteral("mSizeUnits");
|
||||
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");
|
||||
const QString pl_mLining = QStringLiteral("mLining");
|
||||
const QString pl_mInterfacing = QStringLiteral("mInterfacing");
|
||||
const QString pl_mInterlining = QStringLiteral("mInterlining");
|
||||
const QString pl_wCut = QStringLiteral("wCut");
|
||||
const QString pl_wOnFold = QStringLiteral("wOnFold");
|
||||
const QString pl_measurement = QStringLiteral("measurement_");
|
||||
const QString pl_finalMeasurement = QStringLiteral("finalMeasurement_");
|
||||
const QString pl_currentArea = QStringLiteral("currentArea");
|
||||
const QString pl_currentSeamLineArea = QStringLiteral("currentSeamLineArea");
|
||||
|
||||
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
||||
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
||||
|
|
|
@ -137,6 +137,8 @@ extern const QString pl_wCut;
|
|||
extern const QString pl_wOnFold;
|
||||
extern const QString pl_measurement;
|
||||
extern const QString pl_finalMeasurement;
|
||||
extern const QString pl_currentArea;
|
||||
extern const QString pl_currentSeamLineArea;
|
||||
|
||||
extern const QString cursorArrowOpenHand;
|
||||
extern const QString cursorArrowCloseHand;
|
||||
|
|
|
@ -177,6 +177,18 @@ void VPieceLabelData::SetOnFold(bool onFold)
|
|||
d->m_onFold = onFold;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPieceLabelData::GetAreaShartName() const
|
||||
{
|
||||
return d->m_areaShortName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPieceLabelData::SetAreaShartName(const QString &val)
|
||||
{
|
||||
d->m_areaShortName = val;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<VLabelTemplateLine> VPieceLabelData::GetLabelTemplate() const
|
||||
{
|
||||
|
|
|
@ -82,6 +82,9 @@ public:
|
|||
bool IsOnFold() const;
|
||||
void SetOnFold(bool onFold);
|
||||
|
||||
QString GetAreaShartName() const;
|
||||
void SetAreaShartName(const QString &val);
|
||||
|
||||
QVector<VLabelTemplateLine> GetLabelTemplate() const;
|
||||
void SetLabelTemplate(const QVector<VLabelTemplateLine> &lines);
|
||||
|
||||
|
|
|
@ -43,48 +43,26 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
|||
class VPieceLabelDataPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
VPieceLabelDataPrivate()
|
||||
: m_qsLetter(),
|
||||
m_annotation(),
|
||||
m_orientation(),
|
||||
m_rotationWay(),
|
||||
m_tilt(),
|
||||
m_foldPosition(),
|
||||
m_quantity(1),
|
||||
m_onFold(false),
|
||||
m_lines()
|
||||
{}
|
||||
|
||||
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data)
|
||||
: QSharedData(data),
|
||||
m_qsLetter(data.m_qsLetter),
|
||||
m_annotation(data.m_annotation),
|
||||
m_orientation(data.m_orientation),
|
||||
m_rotationWay(data.m_rotationWay),
|
||||
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)
|
||||
{}
|
||||
|
||||
VPieceLabelDataPrivate() = default;
|
||||
VPieceLabelDataPrivate(const VPieceLabelDataPrivate &data) = default;
|
||||
~VPieceLabelDataPrivate() = default;
|
||||
|
||||
/** @brief m_qsLetter Detail letter (should be no more than 3 characters) */
|
||||
QString m_qsLetter;
|
||||
QString m_annotation;
|
||||
QString m_orientation;
|
||||
QString m_rotationWay;
|
||||
QString m_tilt;
|
||||
QString m_foldPosition;
|
||||
QString m_qsLetter{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_annotation{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_orientation{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_rotationWay{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_tilt{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_foldPosition{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
QString m_areaShortName{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
||||
quint16 m_quantity;
|
||||
bool m_onFold;
|
||||
quint16 m_quantity{1}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
bool m_onFold{false}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
||||
QVector<VLabelTemplateLine> m_lines;
|
||||
QVector<VLabelTemplateLine> m_lines{}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||
|
||||
private:
|
||||
Q_DISABLE_ASSIGN(VPieceLabelDataPrivate)
|
||||
Q_DISABLE_ASSIGN_MOVE(VPieceLabelDataPrivate) // NOLINT
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
|
|
@ -46,15 +46,7 @@ VPieceArea::VPieceArea(PieceAreaType type, quint32 pieceId, const VPiece &piece,
|
|||
// cppcheck-suppress unknownMacro
|
||||
SCASSERT(data != nullptr)
|
||||
|
||||
QString shortName = piece.GetShortName();
|
||||
if (shortName.isEmpty())
|
||||
{
|
||||
shortName = piece.GetName().replace(QChar(QChar::Space), '_').left(25);
|
||||
if (shortName.isEmpty() || not QRegularExpression(VPiece::ShortNameRegExp()).match(shortName).hasMatch())
|
||||
{
|
||||
shortName = QObject::tr("Unknown", "piece area");
|
||||
}
|
||||
}
|
||||
QString shortName = PieceShortName(piece);
|
||||
|
||||
if (type == PieceAreaType::External)
|
||||
{
|
||||
|
@ -116,3 +108,19 @@ auto VPieceArea::GetPieceId() const -> quint32
|
|||
{
|
||||
return d->m_pieceId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPieceArea::PieceShortName(const VPiece &piece) -> QString
|
||||
{
|
||||
QString shortName = piece.GetShortName();
|
||||
if (shortName.isEmpty())
|
||||
{
|
||||
shortName = piece.GetName().replace(QChar(QChar::Space), '_').left(25);
|
||||
if (shortName.isEmpty() || not QRegularExpression(VPiece::ShortNameRegExp()).match(shortName).hasMatch())
|
||||
{
|
||||
shortName = QObject::tr("Unknown", "piece area");
|
||||
}
|
||||
}
|
||||
|
||||
return shortName;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,8 @@ public:
|
|||
void SetValue(quint32 pieceId, const VPiece &piece, const VContainer *data, Unit unit);
|
||||
|
||||
auto GetPieceId() const -> quint32;
|
||||
|
||||
static auto PieceShortName(const VPiece &piece) -> QString;
|
||||
private:
|
||||
QSharedDataPointer<VPieceAreaData> d;
|
||||
};
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../vmisc/testpath.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "../vpatterndb/variables/vpiecearea.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
@ -572,6 +573,7 @@ QVector<quint32> VPiece::MissingPlaceLabels(const VPiece &det) const
|
|||
void VPiece::SetPatternPieceData(const VPieceLabelData &data)
|
||||
{
|
||||
d->m_ppData = data;
|
||||
d->m_ppData.SetAreaShartName(VPieceArea::PieceShortName(*this));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
|
||||
#include "../vpatterndb/calculator.h"
|
||||
#include "../vpatterndb/variables/vmeasurement.h"
|
||||
#include "../vpatterndb/variables/vpiecearea.h"
|
||||
#include "../tools/dialogtool.h"
|
||||
|
||||
#include <QDir>
|
||||
|
@ -625,6 +626,9 @@ void DialogEditLabel::InitPlaceholders()
|
|||
VContainer completeData = m_doc->GetCompleteData();
|
||||
completeData.FillPiecesAreas(VAbstractValApplication::VApp()->patternUnits());
|
||||
|
||||
m_placeholders.insert(pl_currentArea, qMakePair(tr("Piece full area"), QString()));
|
||||
m_placeholders.insert(pl_currentSeamLineArea, qMakePair(tr("Piece seam line area"), QString()));
|
||||
|
||||
for (int i=0; i < measurements.size(); ++i)
|
||||
{
|
||||
const VFinalMeasurement &m = measurements.at(i);
|
||||
|
@ -770,6 +774,37 @@ void DialogEditLabel::SetPiece(const VPiece &piece)
|
|||
{
|
||||
m_placeholders[pl_wOnFold].second = tr("on fold");
|
||||
}
|
||||
|
||||
VContainer completeData = m_doc->GetCompleteData();
|
||||
completeData.FillPiecesAreas(VAbstractValApplication::VApp()->patternUnits());
|
||||
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
|
||||
try
|
||||
{
|
||||
const QString formula = pieceArea_ + VPieceArea::PieceShortName(piece);
|
||||
const qreal result = cal->EvalFormula(completeData.DataVariables(), formula);
|
||||
m_placeholders[pl_currentArea].second = QString::number(result);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Failed to prepare full piece area placeholder. %2.").arg(e.GetMsg());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
const QString formula = pieceSeamLineArea_ + VPieceArea::PieceShortName(piece);
|
||||
const qreal result = cal->EvalFormula(completeData.DataVariables(), formula);
|
||||
m_placeholders[pl_currentSeamLineArea].second = QString::number(result);
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Failed to prepare piece seam line area placeholder. %2.").arg(e.GetMsg());
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user