Fix regression. Incorrect data caching.
This commit is contained in:
parent
abdebbbfaa
commit
69da5ba9b7
|
@ -9,6 +9,7 @@
|
||||||
- [smart-pattern/valentina#123] Error inside Save layout dialog.
|
- [smart-pattern/valentina#123] Error inside Save layout dialog.
|
||||||
- Improve error handling for the dxf export.
|
- Improve error handling for the dxf export.
|
||||||
- Fix correct handle a final measurement formula error when exporting a pattern recipe.
|
- Fix correct handle a final measurement formula error when exporting a pattern recipe.
|
||||||
|
- Fix regression. Incorrect data caching.
|
||||||
|
|
||||||
# Version 0.7.46 Mar 31, 2021
|
# Version 0.7.46 Mar 31, 2021
|
||||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||||
|
|
|
@ -332,7 +332,7 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
throw VException(tr("File contains invalid known measurement(s)."));
|
throw VException(tr("File contains invalid known measurement(s)."));
|
||||||
}
|
}
|
||||||
|
|
||||||
mUnit = m->MUnit();
|
mUnit = m->Units();
|
||||||
pUnit = mUnit;
|
pUnit = mUnit;
|
||||||
|
|
||||||
currentDimensionA = m->DimensionABase();
|
currentDimensionA = m->DimensionABase();
|
||||||
|
@ -2672,7 +2672,7 @@ void TMainWindow::InitMenu()
|
||||||
void TMainWindow::InitDimensionsBaseValue()
|
void TMainWindow::InitDimensionsBaseValue()
|
||||||
{
|
{
|
||||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||||
const QString unit = UnitsToStr(m->MUnit(), true);
|
const QString unit = UnitsToStr(m->Units(), true);
|
||||||
const bool fc = m->IsFullCircumference();
|
const bool fc = m->IsFullCircumference();
|
||||||
|
|
||||||
auto DimensionsBaseValue = [this, dimensions, unit, fc](int index, QLabel *name, QLabel *base)
|
auto DimensionsBaseValue = [this, dimensions, unit, fc](int index, QLabel *name, QLabel *base)
|
||||||
|
@ -2726,7 +2726,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
SCASSERT(control != nullptr)
|
SCASSERT(control != nullptr)
|
||||||
|
|
||||||
const bool fc = m->IsFullCircumference();
|
const bool fc = m->IsFullCircumference();
|
||||||
const QString unit = UnitsToStr(m->MUnit(), true);
|
const QString unit = UnitsToStr(m->Units(), true);
|
||||||
|
|
||||||
qreal current = -1;
|
qreal current = -1;
|
||||||
if (control->currentIndex() != -1)
|
if (control->currentIndex() != -1)
|
||||||
|
@ -2811,7 +2811,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
|
||||||
void TMainWindow::InitDimensionControls()
|
void TMainWindow::InitDimensionControls()
|
||||||
{
|
{
|
||||||
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
const QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||||
const QString unit = UnitsToStr(m->MUnit(), true);
|
const QString unit = UnitsToStr(m->Units(), true);
|
||||||
|
|
||||||
auto InitControl = [this, dimensions, unit](int index, QLabel *&name, QComboBox *&control)
|
auto InitControl = [this, dimensions, unit](int index, QLabel *&name, QComboBox *&control)
|
||||||
{
|
{
|
||||||
|
@ -3574,7 +3574,7 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
throw VException(tr("File contains invalid known measurement(s)."));
|
throw VException(tr("File contains invalid known measurement(s)."));
|
||||||
}
|
}
|
||||||
|
|
||||||
mUnit = m->MUnit();
|
mUnit = m->Units();
|
||||||
pUnit = mUnit;
|
pUnit = mUnit;
|
||||||
|
|
||||||
currentDimensionA = m->DimensionABase();
|
currentDimensionA = m->DimensionABase();
|
||||||
|
@ -4358,7 +4358,7 @@ void TMainWindow::InitMeasurementUnits()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString units;
|
QString units;
|
||||||
switch (m->MUnit())
|
switch (m->Units())
|
||||||
{
|
{
|
||||||
case Unit::Mm:
|
case Unit::Mm:
|
||||||
units = tr("Millimeters");
|
units = tr("Millimeters");
|
||||||
|
|
|
@ -2064,7 +2064,7 @@ void MainWindow::CleanWaterkmarkEditors()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::StoreMultisizeMDimensions()
|
void MainWindow::StoreMultisizeMDimensions()
|
||||||
{
|
{
|
||||||
VAbstractValApplication::VApp()->SetMeasurementsUnits(m->MUnit());
|
VAbstractValApplication::VApp()->SetMeasurementsUnits(m->Units());
|
||||||
|
|
||||||
QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
|
||||||
|
|
||||||
|
@ -2090,7 +2090,7 @@ void MainWindow::StoreMultisizeMDimensions()
|
||||||
labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase)));
|
labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase)));
|
||||||
const bool circumference = dimension->IsCircumference();
|
const bool circumference = dimension->IsCircumference();
|
||||||
VAbstractValApplication::VApp()
|
VAbstractValApplication::VApp()
|
||||||
->SetDimensionSizeUnits(circumference ? m->MUnit() : Unit::LAST_UNIT_DO_NOT_USE);
|
->SetDimensionSizeUnits(circumference ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MeasurementDimension::W:
|
case MeasurementDimension::W:
|
||||||
|
@ -5197,7 +5197,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
|
||||||
{
|
{
|
||||||
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
|
doc->SetMPath(RelativeMPath(fileName, customMeasureFile));
|
||||||
}
|
}
|
||||||
VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit());
|
VAbstractValApplication::VApp()->SetPatternUnits(doc->Units());
|
||||||
|
|
||||||
QString path = AbsoluteMPath(fileName, doc->MPath());
|
QString path = AbsoluteMPath(fileName, doc->MPath());
|
||||||
QString fixedMPath;
|
QString fixedMPath;
|
||||||
|
@ -5284,7 +5284,7 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
|
||||||
{
|
{
|
||||||
doc->SetMPath(RelativeMPath(fileName, fixedMPath));
|
doc->SetMPath(RelativeMPath(fileName, fixedMPath));
|
||||||
}
|
}
|
||||||
VAbstractValApplication::VApp()->SetPatternUnits(doc->MUnit());
|
VAbstractValApplication::VApp()->SetPatternUnits(doc->Units());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
|
|
|
@ -141,6 +141,9 @@ void VPattern::CreateEmptyFile()
|
||||||
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
||||||
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
|
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")),
|
||||||
this->firstChild());
|
this->firstChild());
|
||||||
|
|
||||||
|
// Cache values
|
||||||
|
m_units = VAbstractValApplication::VApp()->patternUnits();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -41,6 +41,19 @@ VAbstractMConverter::VAbstractMConverter(const QString &fileName)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VAbstractMConverter::Units() const -> Unit
|
||||||
|
{
|
||||||
|
Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM));
|
||||||
|
|
||||||
|
if (units == Unit::Px)
|
||||||
|
{
|
||||||
|
units = Unit::Cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractMConverter::AddRootComment()
|
void VAbstractMConverter::AddRootComment()
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,6 +43,8 @@ public:
|
||||||
explicit VAbstractMConverter(const QString &fileName);
|
explicit VAbstractMConverter(const QString &fileName);
|
||||||
virtual ~VAbstractMConverter() Q_DECL_EQ_DEFAULT;
|
virtual ~VAbstractMConverter() Q_DECL_EQ_DEFAULT;
|
||||||
|
|
||||||
|
auto Units() const -> Unit;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddRootComment();
|
void AddRootComment();
|
||||||
static QMultiMap<QString, QString> OldNamesToNewNames_InV0_3_0();
|
static QMultiMap<QString, QString> OldNamesToNewNames_InV0_3_0();
|
||||||
|
|
|
@ -155,14 +155,6 @@ bool VAbstractPattern::patternLabelWasChanged = false;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// Need to be reinited in setXMLContent as well
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, patternNumberCached, (unknownCharacter))
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, labelDateFormatCached, (unknownCharacter))
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, patternNameCached, (unknownCharacter))
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, MPathCached, (unknownCharacter))
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, WatermarkPathCached, (unknownCharacter))
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(QString, companyNameCached, (unknownCharacter))
|
|
||||||
|
|
||||||
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
void ReadExpressionAttribute(QVector<VFormulaField> &expressions, const QDomElement &element, const QString &attribute)
|
||||||
{
|
{
|
||||||
VFormulaField formula;
|
VFormulaField formula;
|
||||||
|
@ -592,17 +584,26 @@ void VAbstractPattern::setXMLContent(const QString &fileName)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
VDomDocument::setXMLContent(fileName);
|
VDomDocument::setXMLContent(fileName);
|
||||||
|
m_patternNumber = ReadPatternNumber();
|
||||||
|
m_labelDateFormat = ReadLabelDateFormat();
|
||||||
|
m_patternName = ReadPatternName();
|
||||||
|
m_MPath = ReadMPath();
|
||||||
|
m_watermarkPath = ReadWatermarkPath();
|
||||||
|
m_companyName = ReadCompanyName();
|
||||||
|
m_units = ReadUnits();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::Clear()
|
void VAbstractPattern::Clear()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
*patternNumberCached = unknownCharacter;
|
m_patternNumber.clear();
|
||||||
*labelDateFormatCached = unknownCharacter;
|
m_labelDateFormat.clear();
|
||||||
*patternNameCached = unknownCharacter;
|
m_patternName.clear();
|
||||||
*MPathCached = unknownCharacter;
|
m_MPath.clear();
|
||||||
*companyNameCached = unknownCharacter;
|
m_watermarkPath.clear();
|
||||||
|
m_companyName.clear();
|
||||||
|
m_units = Unit::LAST_UNIT_DO_NOT_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -820,11 +821,7 @@ QVector<VToolRecord> VAbstractPattern::getLocalHistory() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::MPath() const
|
QString VAbstractPattern::MPath() const
|
||||||
{
|
{
|
||||||
if (*MPathCached == unknownCharacter)
|
return m_MPath;
|
||||||
{
|
|
||||||
*MPathCached = UniqueTagText(TagMeasurements);
|
|
||||||
}
|
|
||||||
return *MPathCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -832,9 +829,10 @@ void VAbstractPattern::SetMPath(const QString &path)
|
||||||
{
|
{
|
||||||
if (setTagText(TagMeasurements, path))
|
if (setTagText(TagMeasurements, path))
|
||||||
{
|
{
|
||||||
emit patternChanged(false);
|
m_MPath = path;
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
*MPathCached = path;
|
modified = true;
|
||||||
|
emit patternChanged(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -932,19 +930,15 @@ void VAbstractPattern::SetNotes(const QString &text)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::GetPatternName() const
|
QString VAbstractPattern::GetPatternName() const
|
||||||
{
|
{
|
||||||
if (*patternNameCached == unknownCharacter)
|
return m_patternName;
|
||||||
{
|
|
||||||
*patternNameCached = UniqueTagText(TagPatternName);
|
|
||||||
}
|
|
||||||
return *patternNameCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetPatternName(const QString &qsName)
|
void VAbstractPattern::SetPatternName(const QString &qsName)
|
||||||
{
|
{
|
||||||
*patternNameCached = qsName;
|
m_patternName = qsName;
|
||||||
CheckTagExists(TagPatternName);
|
CheckTagExists(TagPatternName);
|
||||||
setTagText(TagPatternName, *patternNameCached);
|
setTagText(TagPatternName, m_patternName);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
|
@ -953,19 +947,15 @@ void VAbstractPattern::SetPatternName(const QString &qsName)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::GetCompanyName() const
|
QString VAbstractPattern::GetCompanyName() const
|
||||||
{
|
{
|
||||||
if (*companyNameCached == unknownCharacter)
|
return m_companyName;
|
||||||
{
|
|
||||||
*companyNameCached = UniqueTagText(TagCompanyName);
|
|
||||||
}
|
|
||||||
return *companyNameCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetCompanyName(const QString& qsName)
|
void VAbstractPattern::SetCompanyName(const QString& qsName)
|
||||||
{
|
{
|
||||||
*companyNameCached = qsName;
|
m_companyName = qsName;
|
||||||
CheckTagExists(TagCompanyName);
|
CheckTagExists(TagCompanyName);
|
||||||
setTagText(TagCompanyName, *companyNameCached);
|
setTagText(TagCompanyName, m_companyName);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
|
@ -974,19 +964,15 @@ void VAbstractPattern::SetCompanyName(const QString& qsName)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::GetPatternNumber() const
|
QString VAbstractPattern::GetPatternNumber() const
|
||||||
{
|
{
|
||||||
if (*patternNumberCached == unknownCharacter)
|
return m_patternNumber;
|
||||||
{
|
|
||||||
*patternNumberCached = UniqueTagText(TagPatternNum);
|
|
||||||
}
|
|
||||||
return *patternNumberCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetPatternNumber(const QString& qsNum)
|
void VAbstractPattern::SetPatternNumber(const QString& qsNum)
|
||||||
{
|
{
|
||||||
*patternNumberCached = qsNum;
|
m_patternNumber = qsNum;
|
||||||
CheckTagExists(TagPatternNum);
|
CheckTagExists(TagPatternNum);
|
||||||
setTagText(TagPatternNum, *patternNumberCached);
|
setTagText(TagPatternNum, m_patternNumber);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
|
@ -1043,34 +1029,15 @@ void VAbstractPattern::SetCustomerEmail(const QString &email)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::GetLabelDateFormat() const
|
QString VAbstractPattern::GetLabelDateFormat() const
|
||||||
{
|
{
|
||||||
if (*labelDateFormatCached == unknownCharacter)
|
return m_labelDateFormat;
|
||||||
{
|
|
||||||
const QString globalLabelDateFormat = VAbstractApplication::VApp()->Settings()->GetLabelDateFormat();
|
|
||||||
|
|
||||||
const QDomNodeList list = elementsByTagName(TagPatternLabel);
|
|
||||||
if (list.isEmpty())
|
|
||||||
{
|
|
||||||
return globalLabelDateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
*labelDateFormatCached = GetParametrString(list.at(0).toElement(), AttrDateFormat);
|
|
||||||
}
|
|
||||||
catch (const VExceptionEmptyParameter &)
|
|
||||||
{
|
|
||||||
return globalLabelDateFormat;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *labelDateFormatCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractPattern::SetLabelDateFormat(const QString &format)
|
void VAbstractPattern::SetLabelDateFormat(const QString &format)
|
||||||
{
|
{
|
||||||
*labelDateFormatCached = format;
|
m_labelDateFormat = format;
|
||||||
QDomElement tag = CheckTagExists(TagPatternLabel);
|
QDomElement tag = CheckTagExists(TagPatternLabel);
|
||||||
SetAttribute(tag, AttrDateFormat, *labelDateFormatCached);
|
SetAttribute(tag, AttrDateFormat, m_labelDateFormat);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
modified = true;
|
modified = true;
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
|
@ -1142,7 +1109,8 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path)
|
||||||
|
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
*WatermarkPathCached = path;
|
m_watermarkPath = path;
|
||||||
|
modified = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1151,7 +1119,8 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path)
|
||||||
{
|
{
|
||||||
emit patternChanged(false);
|
emit patternChanged(false);
|
||||||
patternLabelWasChanged = true;
|
patternLabelWasChanged = true;
|
||||||
*WatermarkPathCached = path;
|
m_watermarkPath = path;
|
||||||
|
modified = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1165,11 +1134,7 @@ bool VAbstractPattern::SetWatermarkPath(const QString &path)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VAbstractPattern::GetWatermarkPath() const
|
QString VAbstractPattern::GetWatermarkPath() const
|
||||||
{
|
{
|
||||||
if (*WatermarkPathCached == unknownCharacter)
|
return m_watermarkPath;
|
||||||
{
|
|
||||||
*WatermarkPathCached = UniqueTagText(TagWatermark);
|
|
||||||
}
|
|
||||||
return *WatermarkPathCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2277,6 +2242,73 @@ bool VAbstractPattern::GroupHasItem(const QDomElement &groupDomElement, quint32
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VAbstractPattern::ReadUnits() const -> Unit
|
||||||
|
{
|
||||||
|
Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM));
|
||||||
|
|
||||||
|
if (units == Unit::Px)
|
||||||
|
{
|
||||||
|
units = Unit::Cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadPatternNumber() const
|
||||||
|
{
|
||||||
|
return UniqueTagText(TagPatternNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadLabelDateFormat() const
|
||||||
|
{
|
||||||
|
const QString globalLabelDateFormat = VAbstractApplication::VApp()->Settings()->GetLabelDateFormat();
|
||||||
|
|
||||||
|
const QDomNodeList list = elementsByTagName(TagPatternLabel);
|
||||||
|
if (list.isEmpty())
|
||||||
|
{
|
||||||
|
return globalLabelDateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString labelDateFormat;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
labelDateFormat = GetParametrString(list.at(0).toElement(), AttrDateFormat);
|
||||||
|
}
|
||||||
|
catch (const VExceptionEmptyParameter &)
|
||||||
|
{
|
||||||
|
return globalLabelDateFormat;
|
||||||
|
}
|
||||||
|
return labelDateFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadPatternName() const
|
||||||
|
{
|
||||||
|
return UniqueTagText(TagPatternName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadMPath() const
|
||||||
|
{
|
||||||
|
return UniqueTagText(TagMeasurements);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadWatermarkPath() const
|
||||||
|
{
|
||||||
|
return UniqueTagText(TagWatermark);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractPattern::ReadCompanyName() const
|
||||||
|
{
|
||||||
|
return UniqueTagText(TagCompanyName);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief Adds an item to the given group with the given toolId and objectId
|
* @brief Adds an item to the given group with the given toolId and objectId
|
||||||
|
@ -2455,6 +2487,12 @@ VContainer VAbstractPattern::GetCompletePPData(const QString &name) const
|
||||||
return VContainer(nullptr, nullptr, VContainer::UniqueNamespace());
|
return VContainer(nullptr, nullptr, VContainer::UniqueNamespace());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
Unit VAbstractPattern::Units() const
|
||||||
|
{
|
||||||
|
return m_units;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VAbstractPattern::FilterGroupTags(const QString &tags)
|
QStringList VAbstractPattern::FilterGroupTags(const QString &tags)
|
||||||
{
|
{
|
||||||
|
|
|
@ -233,6 +233,8 @@ public:
|
||||||
virtual VContainer GetCompleteData() const;
|
virtual VContainer GetCompleteData() const;
|
||||||
virtual VContainer GetCompletePPData(const QString &name) const;
|
virtual VContainer GetCompletePPData(const QString &name) const;
|
||||||
|
|
||||||
|
auto Units() const -> Unit;
|
||||||
|
|
||||||
static const QString TagPattern;
|
static const QString TagPattern;
|
||||||
static const QString TagCalculation;
|
static const QString TagCalculation;
|
||||||
static const QString TagModeling;
|
static const QString TagModeling;
|
||||||
|
@ -396,6 +398,14 @@ protected:
|
||||||
/** @brief modified keep state of the document for cases that do not cover QUndoStack*/
|
/** @brief modified keep state of the document for cases that do not cover QUndoStack*/
|
||||||
mutable bool modified;
|
mutable bool modified;
|
||||||
|
|
||||||
|
Unit m_units{Unit::LAST_UNIT_DO_NOT_USE};
|
||||||
|
QString m_patternNumber{};
|
||||||
|
QString m_labelDateFormat{};
|
||||||
|
QString m_patternName{};
|
||||||
|
QString m_MPath{};
|
||||||
|
QString m_watermarkPath{};
|
||||||
|
QString m_companyName{};
|
||||||
|
|
||||||
/** @brief tools list with pointer on tools. */
|
/** @brief tools list with pointer on tools. */
|
||||||
static QHash<quint32, VDataTool*> tools;
|
static QHash<quint32, VDataTool*> tools;
|
||||||
/** @brief patternLabelLines list to speed up reading a template by many pieces. */
|
/** @brief patternLabelLines list to speed up reading a template by many pieces. */
|
||||||
|
@ -421,6 +431,15 @@ protected:
|
||||||
QVector<VToolRecord> getLocalHistory(const QString &draw) const;
|
QVector<VToolRecord> getLocalHistory(const QString &draw) const;
|
||||||
|
|
||||||
bool GroupHasItem(const QDomElement &groupDomElement, quint32 toolId, quint32 objectId);
|
bool GroupHasItem(const QDomElement &groupDomElement, quint32 toolId, quint32 objectId);
|
||||||
|
|
||||||
|
auto ReadUnits() const -> Unit;
|
||||||
|
auto ReadPatternNumber() const ->QString;
|
||||||
|
auto ReadLabelDateFormat() const ->QString;
|
||||||
|
auto ReadPatternName() const ->QString;
|
||||||
|
auto ReadMPath() const ->QString;
|
||||||
|
auto ReadWatermarkPath() const -> QString;
|
||||||
|
auto ReadCompanyName() const -> QString;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractPattern)
|
Q_DISABLE_COPY(VAbstractPattern)
|
||||||
|
|
||||||
|
|
|
@ -232,8 +232,6 @@ bool LessThen(const QDomNode &element1, const QDomNode &element2)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit mUnitCached = Unit::LAST_UNIT_DO_NOT_USE;
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(vXML, "v.xml")
|
Q_LOGGING_CATEGORY(vXML, "v.xml")
|
||||||
|
@ -636,22 +634,6 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement)
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
Unit VDomDocument::MUnit() const
|
|
||||||
{
|
|
||||||
if (mUnitCached == Unit::LAST_UNIT_DO_NOT_USE)
|
|
||||||
{
|
|
||||||
mUnitCached = StrToUnits(UniqueTagText(TagUnit, unitCM));
|
|
||||||
|
|
||||||
if (mUnitCached == Unit::Px)
|
|
||||||
{
|
|
||||||
mUnitCached = Unit::Cm;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mUnitCached;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const
|
QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVal) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,8 +118,6 @@ public:
|
||||||
static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue);
|
static qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue);
|
||||||
static quint32 GetParametrId(const QDomElement& domElement);
|
static quint32 GetParametrId(const QDomElement& domElement);
|
||||||
|
|
||||||
Unit MUnit() const;
|
|
||||||
|
|
||||||
virtual void setXMLContent(const QString &fileName);
|
virtual void setXMLContent(const QString &fileName);
|
||||||
static QString UnitsHelpString();
|
static QString UnitsHelpString();
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ void VVSTConverter::AddNewTagsForV0_5_0()
|
||||||
return GetParametrInt(baseTag, QStringLiteral("base"), QChar('0'));
|
return GetParametrInt(baseTag, QStringLiteral("base"), QChar('0'));
|
||||||
};
|
};
|
||||||
|
|
||||||
const Unit units = MUnit();
|
const Unit units = Units();
|
||||||
|
|
||||||
{
|
{
|
||||||
const int step = static_cast<int>(UnitConvertor(6, Unit::Cm, units));
|
const int step = static_cast<int>(UnitConvertor(6, Unit::Cm, units));
|
||||||
|
|
|
@ -109,10 +109,7 @@ const QString VMeasurements::DimensionZ = QStringLiteral("z");
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
using VDimensions = QMap<MeasurementDimension, MeasurementDimension_p>;
|
|
||||||
|
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01")))
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01")))
|
||||||
Q_GLOBAL_STATIC(VDimensions, dimensionsCached)
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString FileComment()
|
QString FileComment()
|
||||||
|
@ -124,8 +121,7 @@ QString FileComment()
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VMeasurements::VMeasurements(VContainer *data)
|
VMeasurements::VMeasurements(VContainer *data)
|
||||||
:VDomDocument(),
|
: data(data),
|
||||||
data(data),
|
|
||||||
type(MeasurementsType::Unknown)
|
type(MeasurementsType::Unknown)
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
@ -133,8 +129,7 @@ VMeasurements::VMeasurements(VContainer *data)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
||||||
:VDomDocument(),
|
: data(data),
|
||||||
data(data),
|
|
||||||
type(MeasurementsType::Individual)
|
type(MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
@ -145,8 +140,7 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
|
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
|
||||||
VContainer *data)
|
VContainer *data)
|
||||||
:VDomDocument(),
|
: data(data),
|
||||||
data(data),
|
|
||||||
type(MeasurementsType::Multisize)
|
type(MeasurementsType::Multisize)
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr)
|
SCASSERT(data != nullptr)
|
||||||
|
@ -159,6 +153,8 @@ void VMeasurements::setXMLContent(const QString &fileName)
|
||||||
{
|
{
|
||||||
VDomDocument::setXMLContent(fileName);
|
VDomDocument::setXMLContent(fileName);
|
||||||
type = ReadType();
|
type = ReadType();
|
||||||
|
m_units = ReadUnits();
|
||||||
|
m_dimensions = ReadDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -277,6 +273,12 @@ void VMeasurements::MoveBottom(const QString &name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VMeasurements::Units() const -> Unit
|
||||||
|
{
|
||||||
|
return m_units;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::StoreNames(bool store)
|
void VMeasurements::StoreNames(bool store)
|
||||||
{
|
{
|
||||||
|
@ -327,25 +329,25 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
|
||||||
|
|
||||||
if (not specialUnits)
|
if (not specialUnits)
|
||||||
{
|
{
|
||||||
base = UnitConvertor(base, MUnit(), *data->GetPatternUnit());
|
base = UnitConvertor(base, Units(), *data->GetPatternUnit());
|
||||||
shiftA = UnitConvertor(shiftA, MUnit(), *data->GetPatternUnit());
|
shiftA = UnitConvertor(shiftA, Units(), *data->GetPatternUnit());
|
||||||
shiftB = UnitConvertor(shiftB, MUnit(), *data->GetPatternUnit());
|
shiftB = UnitConvertor(shiftB, Units(), *data->GetPatternUnit());
|
||||||
shiftC = UnitConvertor(shiftC, MUnit(), *data->GetPatternUnit());
|
shiftC = UnitConvertor(shiftC, Units(), *data->GetPatternUnit());
|
||||||
|
|
||||||
QMutableMapIterator<QString, qreal> iterator(corrections);
|
QMutableMapIterator<QString, qreal> iterator(corrections);
|
||||||
while (iterator.hasNext())
|
while (iterator.hasNext())
|
||||||
{
|
{
|
||||||
iterator.next();
|
iterator.next();
|
||||||
iterator.setValue(UnitConvertor(iterator.value(), MUnit(), *data->GetPatternUnit()));
|
iterator.setValue(UnitConvertor(iterator.value(), Units(), *data->GetPatternUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
convertedBaseA = UnitConvertor(convertedBaseA, MUnit(), *data->GetPatternUnit());
|
convertedBaseA = UnitConvertor(convertedBaseA, Units(), *data->GetPatternUnit());
|
||||||
convertedBaseB = UnitConvertor(convertedBaseB, MUnit(), *data->GetPatternUnit());
|
convertedBaseB = UnitConvertor(convertedBaseB, Units(), *data->GetPatternUnit());
|
||||||
convertedBaseC = UnitConvertor(convertedBaseC, MUnit(), *data->GetPatternUnit());
|
convertedBaseC = UnitConvertor(convertedBaseC, Units(), *data->GetPatternUnit());
|
||||||
|
|
||||||
convertedStepA = UnitConvertor(convertedStepA, MUnit(), *data->GetPatternUnit());
|
convertedStepA = UnitConvertor(convertedStepA, Units(), *data->GetPatternUnit());
|
||||||
convertedStepB = UnitConvertor(convertedStepB, MUnit(), *data->GetPatternUnit());
|
convertedStepB = UnitConvertor(convertedStepB, Units(), *data->GetPatternUnit());
|
||||||
convertedStepC = UnitConvertor(convertedStepC, MUnit(), *data->GetPatternUnit());
|
convertedStepC = UnitConvertor(convertedStepC, Units(), *data->GetPatternUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
|
meash = QSharedPointer<VMeasurement>::create(static_cast<quint32>(i), name,
|
||||||
|
@ -380,7 +382,7 @@ void VMeasurements::ReadMeasurements(qreal baseA, qreal baseB, qreal baseC) cons
|
||||||
|
|
||||||
if (not specialUnits)
|
if (not specialUnits)
|
||||||
{
|
{
|
||||||
value = UnitConvertor(value, MUnit(), *data->GetPatternUnit());
|
value = UnitConvertor(value, Units(), *data->GetPatternUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
|
meash = QSharedPointer<VMeasurement>::create(data, static_cast<quint32>(i), name, value, formula, ok);
|
||||||
|
@ -846,61 +848,9 @@ QString VMeasurements::MeasurementForDimension(IMD type) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VMeasurements::Dimensions() const -> QMap<MeasurementDimension, MeasurementDimension_p >
|
auto VMeasurements::Dimensions() const -> VDimensions
|
||||||
{
|
{
|
||||||
if (type != MeasurementsType::Multisize)
|
return m_dimensions;
|
||||||
{
|
|
||||||
return QMap<MeasurementDimension, MeasurementDimension_p>();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dimensionsCached->isEmpty())
|
|
||||||
{
|
|
||||||
const Unit units = MUnit();
|
|
||||||
const QDomNodeList list = elementsByTagName(TagDimension);
|
|
||||||
for (int i=0; i < list.size(); ++i)
|
|
||||||
{
|
|
||||||
const QDomElement dom = list.at(i).toElement();
|
|
||||||
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
|
|
||||||
const qreal min = GetParametrDouble(dom, AttrMin, QChar('0'));
|
|
||||||
const qreal max = GetParametrDouble(dom, AttrMax, QChar('0'));
|
|
||||||
const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1"));
|
|
||||||
const qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
|
|
||||||
|
|
||||||
const DimesionLabels labels = ReadDimensionLabels(dom);
|
|
||||||
|
|
||||||
if (type == MeasurementDimension::X)
|
|
||||||
{
|
|
||||||
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
|
|
||||||
dimension->SetBaseValue(base);
|
|
||||||
dimension->SetLabels(labels);
|
|
||||||
dimensionsCached->insert(type, dimension);
|
|
||||||
}
|
|
||||||
else if (type == MeasurementDimension::Y)
|
|
||||||
{
|
|
||||||
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
|
|
||||||
dimension->SetBaseValue(base);
|
|
||||||
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
|
|
||||||
dimension->SetLabels(labels);
|
|
||||||
dimensionsCached->insert(type, dimension);
|
|
||||||
}
|
|
||||||
else if (type == MeasurementDimension::W)
|
|
||||||
{
|
|
||||||
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
|
|
||||||
dimension->SetBaseValue(base);
|
|
||||||
dimension->SetLabels(labels);
|
|
||||||
dimensionsCached->insert(type, dimension);
|
|
||||||
}
|
|
||||||
else if (type == MeasurementDimension::Z)
|
|
||||||
{
|
|
||||||
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
|
|
||||||
dimension->SetBaseValue(base);
|
|
||||||
dimension->SetLabels(labels);
|
|
||||||
dimensionsCached->insert(type, dimension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return *dimensionsCached;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -976,7 +926,7 @@ void VMeasurements::SetDimensionLabels(const QMap<MeasurementDimension, Dimesion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dimensionsCached->clear(); // Invalidate cache
|
m_dimensions = ReadDimensions(); // Refresh cache
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1187,6 +1137,10 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit,
|
||||||
this->appendChild(mElement);
|
this->appendChild(mElement);
|
||||||
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
||||||
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
||||||
|
|
||||||
|
// Cache data
|
||||||
|
m_units = unit;
|
||||||
|
m_dimensions = ReadDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1215,6 +1169,10 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
|
||||||
this->appendChild(mElement);
|
this->appendChild(mElement);
|
||||||
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
insertBefore(createProcessingInstruction(QStringLiteral("xml"),
|
||||||
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
|
||||||
|
|
||||||
|
// Cache data
|
||||||
|
m_units = unit;
|
||||||
|
m_dimensions = ReadDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1246,7 +1204,7 @@ QDomElement VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const
|
qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const
|
||||||
{
|
{
|
||||||
const qreal defVal = UnitConvertor(defValue, Unit::Cm, MUnit());
|
const qreal defVal = UnitConvertor(defValue, Unit::Cm, Units());
|
||||||
|
|
||||||
const QDomNodeList nodeList = this->elementsByTagName(tag);
|
const QDomNodeList nodeList = this->elementsByTagName(tag);
|
||||||
if (nodeList.isEmpty())
|
if (nodeList.isEmpty())
|
||||||
|
@ -1332,6 +1290,76 @@ MeasurementsType VMeasurements::ReadType() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VMeasurements::ReadUnits() const -> Unit
|
||||||
|
{
|
||||||
|
Unit units = StrToUnits(UniqueTagText(TagUnit, unitCM));
|
||||||
|
|
||||||
|
if (units == Unit::Px)
|
||||||
|
{
|
||||||
|
units = Unit::Cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VMeasurements::ReadDimensions() const -> VDimensions
|
||||||
|
{
|
||||||
|
if (type != MeasurementsType::Multisize)
|
||||||
|
{
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
VDimensions dimensions;
|
||||||
|
|
||||||
|
const Unit units = Units();
|
||||||
|
const QDomNodeList list = elementsByTagName(TagDimension);
|
||||||
|
for (int i=0; i < list.size(); ++i)
|
||||||
|
{
|
||||||
|
const QDomElement dom = list.at(i).toElement();
|
||||||
|
const MeasurementDimension type = StrToDimensionType(GetParametrString(dom, AttrType));
|
||||||
|
const qreal min = GetParametrDouble(dom, AttrMin, QChar('0'));
|
||||||
|
const qreal max = GetParametrDouble(dom, AttrMax, QChar('0'));
|
||||||
|
const qreal step = GetParametrDouble(dom, AttrStep, QStringLiteral("-1"));
|
||||||
|
const qreal base = GetParametrDouble(dom, AttrBase, QChar('0'));
|
||||||
|
|
||||||
|
const DimesionLabels labels = ReadDimensionLabels(dom);
|
||||||
|
|
||||||
|
if (type == MeasurementDimension::X)
|
||||||
|
{
|
||||||
|
auto dimension = QSharedPointer<VXMeasurementDimension>::create(units, min, max, step);
|
||||||
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
|
dimensions.insert(type, dimension);
|
||||||
|
}
|
||||||
|
else if (type == MeasurementDimension::Y)
|
||||||
|
{
|
||||||
|
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
|
||||||
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
|
||||||
|
dimension->SetLabels(labels);
|
||||||
|
dimensions.insert(type, dimension);
|
||||||
|
}
|
||||||
|
else if (type == MeasurementDimension::W)
|
||||||
|
{
|
||||||
|
auto dimension = QSharedPointer<VWMeasurementDimension>::create(units, min, max, step);
|
||||||
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
|
dimensions.insert(type, dimension);
|
||||||
|
}
|
||||||
|
else if (type == MeasurementDimension::Z)
|
||||||
|
{
|
||||||
|
auto dimension = QSharedPointer<VZMeasurementDimension>::create(units, min, max, step);
|
||||||
|
dimension->SetBaseValue(base);
|
||||||
|
dimension->SetLabels(labels);
|
||||||
|
dimensions.insert(type, dimension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dimensions;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
|
qreal VMeasurements::EvalFormula(VContainer *data, const QString &formula, bool *ok) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,8 @@ class VContainer;
|
||||||
|
|
||||||
enum class GenderType : qint8 { Male, Female, Unknown };
|
enum class GenderType : qint8 { Male, Female, Unknown };
|
||||||
|
|
||||||
|
using VDimensions = QMap<MeasurementDimension, MeasurementDimension_p>;
|
||||||
|
|
||||||
class VMeasurements : public VDomDocument
|
class VMeasurements : public VDomDocument
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(VMeasurements)
|
Q_DECLARE_TR_FUNCTIONS(VMeasurements)
|
||||||
|
@ -65,6 +67,8 @@ public:
|
||||||
void MoveDown(const QString &name);
|
void MoveDown(const QString &name);
|
||||||
void MoveBottom(const QString &name);
|
void MoveBottom(const QString &name);
|
||||||
|
|
||||||
|
auto Units() const -> Unit;
|
||||||
|
|
||||||
void StoreNames(bool store);
|
void StoreNames(bool store);
|
||||||
|
|
||||||
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
|
void ReadMeasurements(qreal baseA, qreal baseB=0, qreal baseC=0) const;
|
||||||
|
@ -117,7 +121,7 @@ public:
|
||||||
|
|
||||||
QString MeasurementForDimension(IMD type) const;
|
QString MeasurementForDimension(IMD type) const;
|
||||||
|
|
||||||
auto Dimensions() const -> QMap<MeasurementDimension, MeasurementDimension_p >;
|
auto Dimensions() const -> VDimensions;
|
||||||
|
|
||||||
auto GetRestrictions() const -> QMap<QString, VDimensionRestriction >;
|
auto GetRestrictions() const -> QMap<QString, VDimensionRestriction >;
|
||||||
void SetRestrictions(const QMap<QString, VDimensionRestriction > &restrictions);
|
void SetRestrictions(const QMap<QString, VDimensionRestriction > &restrictions);
|
||||||
|
@ -201,6 +205,10 @@ private:
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
MeasurementsType type;
|
MeasurementsType type;
|
||||||
|
|
||||||
|
// Cache data to quick access
|
||||||
|
Unit m_units{Unit::LAST_UNIT_DO_NOT_USE};
|
||||||
|
VDimensions m_dimensions{};
|
||||||
|
|
||||||
/** @brief m_keepNames store names in container to check uniqueness. */
|
/** @brief m_keepNames store names in container to check uniqueness. */
|
||||||
bool m_keepNames{true};
|
bool m_keepNames{true};
|
||||||
|
|
||||||
|
@ -214,6 +222,8 @@ private:
|
||||||
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
||||||
QDomElement FindM(const QString &name) const;
|
QDomElement FindM(const QString &name) const;
|
||||||
MeasurementsType ReadType() const;
|
MeasurementsType ReadType() const;
|
||||||
|
auto ReadUnits() const -> Unit;
|
||||||
|
auto ReadDimensions() const -> VDimensions;
|
||||||
|
|
||||||
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
|
qreal EvalFormula(VContainer *data, const QString &formula, bool *ok) const;
|
||||||
|
|
||||||
|
|
|
@ -34,4 +34,3 @@ const QString preferencesOtherIcon = QStringLiteral("preferences-other");
|
||||||
const QString degreeSymbol = QStringLiteral("°");
|
const QString degreeSymbol = QStringLiteral("°");
|
||||||
const QString trueStr = QStringLiteral("true");
|
const QString trueStr = QStringLiteral("true");
|
||||||
const QString falseStr = QStringLiteral("false");
|
const QString falseStr = QStringLiteral("false");
|
||||||
const QString unknownCharacter = QStringLiteral("<EFBFBD>");
|
|
||||||
|
|
|
@ -40,6 +40,5 @@ extern const QString preferencesOtherIcon;
|
||||||
extern const QString degreeSymbol;
|
extern const QString degreeSymbol;
|
||||||
extern const QString trueStr;
|
extern const QString trueStr;
|
||||||
extern const QString falseStr;
|
extern const QString falseStr;
|
||||||
extern const QString unknownCharacter;
|
|
||||||
|
|
||||||
#endif // LITERALS_H
|
#endif // LITERALS_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user