Final measurement printout on pattern piece. Closes #85
This commit is contained in:
parent
c47664d86c
commit
8b15f4aed6
|
@ -12,6 +12,7 @@
|
||||||
- New warning. Grainline is not valid.
|
- New warning. Grainline is not valid.
|
||||||
- [smart-pattern/valentina#87] Add support for TIFF format.
|
- [smart-pattern/valentina#87] Add support for TIFF format.
|
||||||
- [smart-pattern/valentina#88] Allow insertion of multiple nodes by setting their number.
|
- [smart-pattern/valentina#88] Allow insertion of multiple nodes by setting their number.
|
||||||
|
- [smart-pattern/valentina#85] Final measurement printout on pattern piece.
|
||||||
|
|
||||||
# Version 0.7.41 Dec 4, 2020
|
# Version 0.7.41 Dec 4, 2020
|
||||||
- Bug fixes.
|
- Bug fixes.
|
||||||
|
|
|
@ -45,7 +45,7 @@ class DialogFinalMeasurements : public QDialog
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogFinalMeasurements(VPattern *doc, QWidget *parent = nullptr);
|
explicit DialogFinalMeasurements(VPattern *doc, QWidget *parent = nullptr);
|
||||||
virtual ~DialogFinalMeasurements();
|
virtual ~DialogFinalMeasurements();
|
||||||
|
|
||||||
QVector<VFinalMeasurement> FinalMeasurements() const;
|
QVector<VFinalMeasurement> FinalMeasurements() const;
|
||||||
|
|
|
@ -4820,6 +4820,7 @@ void MainWindow::CreateActions()
|
||||||
if (result == QDialog::Accepted)
|
if (result == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
doc->SetFinalMeasurements(dialogFMeasurements->FinalMeasurements());
|
doc->SetFinalMeasurements(dialogFMeasurements->FinalMeasurements());
|
||||||
|
emit doc->UpdatePatternLabel();
|
||||||
}
|
}
|
||||||
dialogFMeasurements->close();
|
dialogFMeasurements->close();
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
# include "../vmisc/vdatastreamenum.h"
|
# include "../vmisc/vdatastreamenum.h"
|
||||||
#endif
|
#endif
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "vtextmanager.h"
|
#include "vtextmanager.h"
|
||||||
|
|
||||||
const quint32 TextLine::streamHeader = 0xA3881E49; // CRC-32Q string "TextLine"
|
const quint32 TextLine::streamHeader = 0xA3881E49; // CRC-32Q string "TextLine"
|
||||||
|
@ -234,13 +235,38 @@ QMap<QString, QString> PreparePlaceholders(const VAbstractPattern *doc, const VC
|
||||||
placeholders.insert(pl_userMaterial + number, value);
|
placeholders.insert(pl_userMaterial + number, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, QSharedPointer<VMeasurement> > measurements = data->DataMeasurements();
|
|
||||||
auto i = measurements.constBegin();
|
|
||||||
while (i != measurements.constEnd())
|
|
||||||
{
|
{
|
||||||
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
const QMap<QString, QSharedPointer<VMeasurement> > measurements = data->DataMeasurements();
|
||||||
placeholders.insert(pl_measurement + i.key(), QString::number(*i.value()->GetValue()));
|
auto i = measurements.constBegin();
|
||||||
++i;
|
while (i != measurements.constEnd())
|
||||||
|
{
|
||||||
|
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
||||||
|
placeholders.insert(pl_measurement + i.key(), QString::number(*i.value()->GetValue()));
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const QVector<VFinalMeasurement> measurements = doc->GetFinalMeasurements();
|
||||||
|
const VContainer completeData = doc->GetCompleteData();
|
||||||
|
|
||||||
|
for (int i=0; i < measurements.size(); ++i)
|
||||||
|
{
|
||||||
|
const VFinalMeasurement &m = measurements.at(i);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
|
const qreal result = cal->EvalFormula(completeData.DataVariables(), m.formula);
|
||||||
|
|
||||||
|
placeholders.insert(pl_finalMeasurement + m.name, QString::number(result));
|
||||||
|
}
|
||||||
|
catch (qmu::QmuParserError &e)
|
||||||
|
{
|
||||||
|
qCritical("%s\n\n%s", qUtf8Printable(QObject::tr("Failed to prepare final measurement placeholder.")),
|
||||||
|
qUtf8Printable(QObject::tr("Parser error at line %1: %2.").arg(i+1).arg(e.GetMsg())));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Piece tags
|
// Piece tags
|
||||||
|
|
|
@ -169,6 +169,7 @@ const QString pl_mInterlining = QStringLiteral("mInterlining");
|
||||||
const QString pl_wCut = QStringLiteral("wCut");
|
const QString pl_wCut = QStringLiteral("wCut");
|
||||||
const QString pl_wOnFold = QStringLiteral("wOnFold");
|
const QString pl_wOnFold = QStringLiteral("wOnFold");
|
||||||
const QString pl_measurement = QStringLiteral("measurement_");
|
const QString pl_measurement = QStringLiteral("measurement_");
|
||||||
|
const QString pl_finalMeasurement = QStringLiteral("finalMeasurement_");
|
||||||
|
|
||||||
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
const QString cursorArrowOpenHand = QStringLiteral("://cursor/cursor-arrow-openhand.png");
|
||||||
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-closehand.png");
|
||||||
|
|
|
@ -437,6 +437,7 @@ extern const QString pl_mInterlining;
|
||||||
extern const QString pl_wCut;
|
extern const QString pl_wCut;
|
||||||
extern const QString pl_wOnFold;
|
extern const QString pl_wOnFold;
|
||||||
extern const QString pl_measurement;
|
extern const QString pl_measurement;
|
||||||
|
extern const QString pl_finalMeasurement;
|
||||||
|
|
||||||
// Don't forget to syncronize with XSD schema.
|
// Don't forget to syncronize with XSD schema.
|
||||||
const int userMaterialPlaceholdersQuantity = 20;
|
const int userMaterialPlaceholdersQuantity = 20;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "../vpatterndb/vpiece.h"
|
#include "../vpatterndb/vpiece.h"
|
||||||
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
|
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
|
||||||
|
#include "../vpatterndb/calculator.h"
|
||||||
#include "../tools/dialogtool.h"
|
#include "../tools/dialogtool.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -549,14 +550,40 @@ void DialogEditLabel::InitPlaceholders()
|
||||||
m_placeholders.insert(pl_userMaterial + number, qMakePair(materialDescription + number, value));
|
m_placeholders.insert(pl_userMaterial + number, qMakePair(materialDescription + number, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMap<QString, QSharedPointer<VMeasurement> > measurements = m_data->DataMeasurements();
|
|
||||||
auto i = measurements.constBegin();
|
|
||||||
while (i != measurements.constEnd())
|
|
||||||
{
|
{
|
||||||
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
const QMap<QString, QSharedPointer<VMeasurement> > measurements = m_data->DataMeasurements();
|
||||||
m_placeholders.insert(pl_measurement + i.key(), qMakePair(tr("Measurement: %1").arg(description),
|
auto i = measurements.constBegin();
|
||||||
QString::number(*i.value()->GetValue())));
|
while (i != measurements.constEnd())
|
||||||
++i;
|
{
|
||||||
|
QString description = i.value()->GetGuiText().isEmpty() ? i.key() : i.value()->GetGuiText();
|
||||||
|
m_placeholders.insert(pl_measurement + i.key(), qMakePair(tr("Measurement: %1").arg(description),
|
||||||
|
QString::number(*i.value()->GetValue())));
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const QVector<VFinalMeasurement> measurements = m_doc->GetFinalMeasurements();
|
||||||
|
const VContainer completeData = m_doc->GetCompleteData();
|
||||||
|
|
||||||
|
for (int i=0; i < measurements.size(); ++i)
|
||||||
|
{
|
||||||
|
const VFinalMeasurement &m = measurements.at(i);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QScopedPointer<Calculator> cal(new Calculator());
|
||||||
|
const qreal result = cal->EvalFormula(completeData.DataVariables(), m.formula);
|
||||||
|
|
||||||
|
m_placeholders.insert(pl_finalMeasurement + m.name, qMakePair(tr("Final measurement: %1").arg(m.name),
|
||||||
|
QString::number(result)));
|
||||||
|
}
|
||||||
|
catch (qmu::QmuParserError &e)
|
||||||
|
{
|
||||||
|
qCritical("%s\n\n%s", qUtf8Printable(QObject::tr("Failed to prepare final measurement placeholder.")),
|
||||||
|
qUtf8Printable(QObject::tr("Parser error at line %1: %2.").arg(i+1).arg(e.GetMsg())));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Piece tags
|
// Piece tags
|
||||||
|
|
Loading…
Reference in New Issue
Block a user