Fix Setup multisize measurements dialog. Improved handling Height dimension.

This commit is contained in:
Roman Telezhynskyi 2022-07-19 20:00:34 +03:00
parent be430f8c7e
commit 672278209d
17 changed files with 290 additions and 144 deletions

View File

@ -10,6 +10,7 @@
- Fix warning while segmenting flipped arc.
- Tape app. "Export from existing ..." now supports multisize measurements.
- Fix main path validation. False positive double curve.
- Fix Setup multisize measurements dialog. Improved handling Height dimension.
# Valentina 0.7.51 April 18, 2022
- Z value change for a layout piece.

View File

@ -205,7 +205,7 @@ auto DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimensi
if (dimension->Type() == MeasurementDimension::Y)
{
if (dimension->IsCircumference())
if (dimension->IsBodyMeasurement())
{
return QString::number(m_fullCircumference ? value*2 : value);
}

View File

@ -756,7 +756,7 @@ void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const Measu
}
else
{
if (dimension->IsCircumference())
if (dimension->IsBodyMeasurement())
{
control->addItem(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units), base);
}
@ -787,7 +787,7 @@ void DialogRestrictDimension::FillBases(const QVector<qreal> &bases, const Measu
auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
const MeasurementDimension_p &dimension) const -> QStringList
{
const bool showUnits = dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X;
const bool showUnits = dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X;
const QString units = showUnits ? UnitsToStr(dimension->Units(), true) : QString();
const DimesionLabels dimensionLabels = dimension->Labels();
@ -817,7 +817,7 @@ auto DialogRestrictDimension::DimensionLabels(const QVector<qreal> &bases,
}
else
{
if (dimension->IsCircumference())
if (dimension->IsBodyMeasurement())
{
labels.append(QStringLiteral("%1 %2").arg(m_fullCircumference ? base*2 : base).arg(units));
}

View File

@ -166,14 +166,14 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) :
connect(ui->checkBoxFullCircumference, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::ShowFullCircumference);
connect(ui->checkBoxXDimensionCircumference, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::XDimensionCircumferenceChanged);
connect(ui->checkBoxYDimensionCircumference, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::YDimensionCircumferenceChanged);
connect(ui->checkBoxWDimensionCircumference, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::WDimensionCircumferenceChanged);
connect(ui->checkBoxZDimensionCircumference, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::ZDimensionCircumferenceChanged);
connect(ui->checkBoxXDimensionBodyMeasurement, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::XDimensionBodyMeasurementChanged);
connect(ui->checkBoxYDimensionBodyMeasurement, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::YDimensionBodyMeasurementChanged);
connect(ui->checkBoxWDimensionBodyMeasurement, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::WDimensionBodyMeasurementChanged);
connect(ui->checkBoxZDimensionBodyMeasurement, &QCheckBox::stateChanged,
this, &DialogSetupMultisize::ZDimensionBodyMeasurementChanged);
connect(ui->lineEditCustomXDimensionName, &QLineEdit::textChanged, this, [this](const QString &text)
{
@ -307,8 +307,6 @@ void DialogSetupMultisize::ShowFullCircumference()
comboBoxBase->blockSignals(false);
};
ShowDimensionFullCircumference(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue,
ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension);
ShowDimensionFullCircumference(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue,
ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension);
ShowDimensionFullCircumference(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue,
@ -320,16 +318,10 @@ void DialogSetupMultisize::ShowFullCircumference()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::XDimensionCircumferenceChanged()
void DialogSetupMultisize::XDimensionBodyMeasurementChanged()
{
bool checked = ui->checkBoxXDimensionCircumference->isChecked();
m_xDimension->SetCircumference(checked);
const bool c = m_xDimension->IsCircumference();
const QString unitStr = c ? " " + UnitsToStr(m_xDimension->Units()) : QString();
ui->doubleSpinBoxXDimensionMinValue->setSuffix(unitStr);
ui->doubleSpinBoxXDimensionMaxValue->setSuffix(unitStr);
bool checked = ui->checkBoxXDimensionBodyMeasurement->isChecked();
m_xDimension->SetBodyMeasurement(checked);
InitDimension(ui->doubleSpinBoxXDimensionMinValue, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep,
m_xDimension);
@ -348,16 +340,10 @@ void DialogSetupMultisize::XDimensionCircumferenceChanged()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::YDimensionCircumferenceChanged()
void DialogSetupMultisize::YDimensionBodyMeasurementChanged()
{
bool checked = ui->checkBoxYDimensionCircumference->isChecked();
m_yDimension->SetCircumference(checked);
const bool c = m_yDimension->IsCircumference();
const QString unitStr = c ? " " + UnitsToStr(m_yDimension->Units()) : QString();
ui->doubleSpinBoxYDimensionMinValue->setSuffix(unitStr);
ui->doubleSpinBoxYDimensionMaxValue->setSuffix(unitStr);
bool checked = ui->checkBoxYDimensionBodyMeasurement->isChecked();
m_yDimension->SetBodyMeasurement(checked);
InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep,
m_yDimension);
@ -376,16 +362,10 @@ void DialogSetupMultisize::YDimensionCircumferenceChanged()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::WDimensionCircumferenceChanged()
void DialogSetupMultisize::WDimensionBodyMeasurementChanged()
{
bool checked = ui->checkBoxWDimensionCircumference->isChecked();
m_wDimension->SetCircumference(checked);
const bool c = m_wDimension->IsCircumference();
const QString unitStr = c ? " " + UnitsToStr(m_wDimension->Units()) : QString();
ui->doubleSpinBoxWDimensionMinValue->setSuffix(unitStr);
ui->doubleSpinBoxWDimensionMaxValue->setSuffix(unitStr);
bool checked = ui->checkBoxWDimensionBodyMeasurement->isChecked();
m_wDimension->SetBodyMeasurement(checked);
InitDimension(ui->doubleSpinBoxWDimensionMinValue, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep,
m_wDimension);
@ -404,16 +384,10 @@ void DialogSetupMultisize::WDimensionCircumferenceChanged()
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::ZDimensionCircumferenceChanged()
void DialogSetupMultisize::ZDimensionBodyMeasurementChanged()
{
bool checked = ui->checkBoxZDimensionCircumference->isChecked();
m_zDimension->SetCircumference(checked);
const bool c = m_zDimension->IsCircumference();
const QString unitStr = c ? " " + UnitsToStr(m_zDimension->Units()) : QString();
ui->doubleSpinBoxZDimensionMinValue->setSuffix(unitStr);
ui->doubleSpinBoxZDimensionMaxValue->setSuffix(unitStr);
bool checked = ui->checkBoxZDimensionBodyMeasurement->isChecked();
m_zDimension->SetBodyMeasurement(checked);
InitDimension(ui->doubleSpinBoxZDimensionMinValue, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep,
m_zDimension);
@ -513,33 +487,25 @@ void DialogSetupMultisize::InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinV
dimension->SetMinValue(dimension->RangeMin());
dimension->SetMaxValue(dimension->RangeMax());
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
const QString unitStr = m ? " " + UnitsToStr(m_xDimension->Units()) : QString();
doubleSpinBoxMinValue->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units());
if (c || dimension->Type() == MeasurementDimension::X)
{
doubleSpinBoxMinValue->setSuffix(unitStr);
}
doubleSpinBoxMinValue->setSuffix(unitStr);
doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
doubleSpinBoxMinValue->setMinimum(c && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
doubleSpinBoxMinValue->setMaximum(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
doubleSpinBoxMinValue->setValue(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
doubleSpinBoxMinValue->setMinimum(m && fc ? dimension->RangeMin()*2 : dimension->RangeMin());
doubleSpinBoxMinValue->setMaximum(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
doubleSpinBoxMinValue->setValue(m && fc ? dimension->MinValue()*2 : dimension->MinValue());
doubleSpinBoxMinValue->blockSignals(false);
doubleSpinBoxMaxValue->blockSignals(true);
if (c || dimension->Type() == MeasurementDimension::X)
{
doubleSpinBoxMaxValue->setSuffix(unitStr);
}
doubleSpinBoxMaxValue->setSuffix(unitStr);
doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1);
doubleSpinBoxMaxValue->setMinimum(c && fc ? dimension->MinValue()*2 : dimension->MinValue());
doubleSpinBoxMaxValue->setMaximum(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
doubleSpinBoxMaxValue->setValue(c && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
doubleSpinBoxMaxValue->setValue(c && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
doubleSpinBoxMaxValue->setMinimum(m && fc ? dimension->MinValue()*2 : dimension->MinValue());
doubleSpinBoxMaxValue->setMaximum(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
doubleSpinBoxMaxValue->setValue(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax());
doubleSpinBoxMaxValue->setValue(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue());
doubleSpinBoxMaxValue->blockSignals(false);
}
@ -549,9 +515,9 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
{
SCASSERT(comboBoxStep != nullptr)
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const QString unitStr = " " + UnitsToStr(dimension->Units());
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
dimension->SetStep(-1);
@ -560,8 +526,7 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
comboBoxStep->clear();
for(auto step : steps)
{
comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step*2 : step)
.arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), step);
comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step*2 : step).arg(unitStr), step);
}
comboBoxStep->setCurrentIndex(-1); // force a user to select
@ -621,16 +586,16 @@ void DialogSetupMultisize::DimensionMinValueChanged(qreal value, QDoubleSpinBox
SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr)
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
dimension->SetMinValue(c && fc ? value / 2 : value);
dimension->SetMinValue(m && fc ? value / 2 : value);
doubleSpinBoxMaxValue->blockSignals(true);
doubleSpinBoxMaxValue->setMinimum(value);
doubleSpinBoxMaxValue->blockSignals(false);
dimension->SetMaxValue(c && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value());
dimension->SetMaxValue(m && fc ? doubleSpinBoxMaxValue->value() / 2 : doubleSpinBoxMaxValue->value());
UpdateSteps(comboBoxStep, dimension);
UpdateBase(comboBoxBase, dimension);
@ -647,16 +612,16 @@ void DialogSetupMultisize::DimensionMaxValueChanged(qreal value, QDoubleSpinBox
SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr)
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
dimension->SetMaxValue(c && fc ? value / 2 : value);
dimension->SetMaxValue(m && fc ? value / 2 : value);
doubleSpinBoxMinValue->blockSignals(true);
doubleSpinBoxMinValue->setMaximum(value);
doubleSpinBoxMinValue->blockSignals(false);
dimension->SetMinValue(c && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value());
dimension->SetMinValue(m && fc ? doubleSpinBoxMinValue->value() / 2 : doubleSpinBoxMinValue->value());
UpdateSteps(comboBoxStep, dimension);
UpdateBase(comboBoxBase, dimension);
@ -707,17 +672,16 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
comboBoxStep->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units());
const QVector<qreal> steps = dimension->ValidSteps();
comboBoxStep->clear();
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
for(auto step : steps)
{
comboBoxStep->addItem(QStringLiteral("%1%2").arg(c && fc ? step * 2 : step)
.arg(c ? unitStr : QString()), step);
comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step * 2 : step).arg(unitStr), step);
}
comboBoxStep->setCurrentIndex(comboBoxStep->findData(oldStep));
@ -742,16 +706,15 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
comboBoxBase->blockSignals(true);
const QString unitStr = " " + UnitsToStr(dimension->Units());
const QVector<qreal> bases = dimension->ValidBases();
comboBoxBase->clear();
const bool fc = ui->checkBoxFullCircumference->isChecked();
const bool c = dimension->IsCircumference();
const bool fc = dimension->Type() != MeasurementDimension::X ? ui->checkBoxFullCircumference->isChecked() : false;
const bool m = dimension->IsBodyMeasurement();
const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString();
for(auto base : bases)
{
comboBoxBase->addItem(QStringLiteral("%1%2").arg(c && fc ? base * 2 : base)
.arg(c || dimension->Type() == MeasurementDimension::X ? unitStr : QString()), base);
comboBoxBase->addItem(QStringLiteral("%1%2").arg(m && fc ? base * 2 : base).arg(unitStr), base);
}
comboBoxBase->setCurrentIndex(comboBoxBase->findData(oldBase));

View File

@ -62,13 +62,13 @@ protected:
private slots:
void ShowFullCircumference();
void XDimensionCircumferenceChanged();
void YDimensionCircumferenceChanged();
void WDimensionCircumferenceChanged();
void ZDimensionCircumferenceChanged();
void XDimensionBodyMeasurementChanged();
void YDimensionBodyMeasurementChanged();
void WDimensionBodyMeasurementChanged();
void ZDimensionBodyMeasurementChanged();
private:
Q_DISABLE_COPY_MOVE(DialogSetupMultisize)
Q_DISABLE_COPY_MOVE(DialogSetupMultisize) // NOLINT
Ui::DialogSetupMultisize *ui;
bool m_isInitialized{false};
QSharedPointer<VXMeasurementDimension> m_xDimension;

View File

@ -147,9 +147,12 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxXDimensionCircumference">
<widget class="QCheckBox" name="checkBoxXDimensionBodyMeasurement">
<property name="toolTip">
<string>A body measurement measured in units of length.</string>
</property>
<property name="text">
<string>Circumference</string>
<string>Body Measurement</string>
</property>
<property name="checked">
<bool>true</bool>
@ -282,9 +285,12 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxYDimensionCircumference">
<widget class="QCheckBox" name="checkBoxYDimensionBodyMeasurement">
<property name="toolTip">
<string>A body measurement measured in units of length. Circumference.</string>
</property>
<property name="text">
<string>Circumference</string>
<string>Body Measurement</string>
</property>
<property name="checked">
<bool>true</bool>
@ -417,9 +423,12 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxWDimensionCircumference">
<widget class="QCheckBox" name="checkBoxWDimensionBodyMeasurement">
<property name="toolTip">
<string>A body measurement measured in units of length. Circumference.</string>
</property>
<property name="text">
<string>Circumference</string>
<string>Body Measurement</string>
</property>
<property name="checked">
<bool>true</bool>
@ -552,9 +561,12 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxZDimensionCircumference">
<widget class="QCheckBox" name="checkBoxZDimensionBodyMeasurement">
<property name="toolTip">
<string>A body measurement measured in units of length. Circumference.</string>
</property>
<property name="text">
<string>Circumference</string>
<string>Body Measurement</string>
</property>
<property name="checked">
<bool>true</bool>

View File

@ -2761,7 +2761,7 @@ void TMainWindow::InitDimensionsBaseValue()
}
else
{
if (dimension->IsCircumference() || dimension->Type() == MeasurementDimension::X)
if (dimension->IsBodyMeasurement() || dimension->Type() == MeasurementDimension::X)
{
if (dimension->Type() != MeasurementDimension::X && fc)
{
@ -2829,7 +2829,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
}
else
{
if (dimension->IsCircumference())
if (dimension->IsBodyMeasurement())
{
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
}

View File

@ -2146,7 +2146,7 @@ void MainWindow::StoreMultisizeMDimensions()
QList<MeasurementDimension_p> dimensions = m->Dimensions().values();
if (dimensions.size() > 0)
if (not dimensions.isEmpty())
{
if (not dimensionALabel.isNull())
{
@ -2190,9 +2190,9 @@ void MainWindow::StoreMultisizeMDimensions()
VAbstractValApplication::VApp()->SetDimensionSize(fc ? currentBase*2 : currentBase);
VAbstractValApplication::VApp()->SetDimensionSizeLabel(
labels.value(currentBase, QString::number(fc ? currentBase*2 : currentBase)));
const bool circumference = dimension->IsCircumference();
const bool measurement = dimension->IsBodyMeasurement();
VAbstractValApplication::VApp()
->SetDimensionSizeUnits(circumference ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE);
->SetDimensionSizeUnits(measurement ? m->Units() : Unit::LAST_UNIT_DO_NOT_USE);
break;
}
case MeasurementDimension::W:
@ -4614,7 +4614,7 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p
}
else
{
if (dimension->IsCircumference())
if (dimension->IsBodyMeasurement())
{
control->addItem(QString("%1 %2").arg(fc ? base*2 : base).arg(unit), base);
}

View File

@ -76,6 +76,7 @@
<file>schema/multisize_measurements/v0.5.1.xsd</file>
<file>schema/multisize_measurements/v0.5.2.xsd</file>
<file>schema/multisize_measurements/v0.5.3.xsd</file>
<file>schema/multisize_measurements/v0.5.4.xsd</file>
<file>schema/individual_measurements/v0.2.0.xsd</file>
<file>schema/individual_measurements/v0.3.0.xsd</file>
<file>schema/individual_measurements/v0.3.1.xsd</file>

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="vst">
<xs:complexType>
<xs:sequence>
<xs:element name="version" type="formatVersion"/>
<xs:element name="read-only" type="xs:boolean"/>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="unit" type="units"/>
<xs:element name="pm_system" type="psCode"/>
<xs:element name="dimensions">
<xs:complexType>
<xs:sequence>
<xs:element name="dimension" minOccurs="1" maxOccurs="3">
<xs:complexType>
<xs:sequence>
<xs:element name="labels" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="label" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="value" type="dimesionValue" use="required"/>
<xs:attribute name="label" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="dimensionType" use="required"/>
<xs:attribute name="base" type="dimesionValue" use="required"/>
<xs:attribute name="min" type="dimesionValue" use="required"/>
<xs:attribute name="max" type="dimesionValue" use="required"/>
<xs:attribute name="step" type="dimensionStep" use="required"/>
<xs:attribute name="measurement" type="xs:boolean"/>
<xs:attribute name="customName" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="fullCircumference" type="xs:boolean"/>
</xs:complexType>
</xs:element>
<xs:element name="restrictions">
<xs:complexType>
<xs:sequence>
<xs:element name="restriction" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="coordinates" type="xs:string" use="required"/>
<xs:attribute name="min" type="dimesionValue"/>
<xs:attribute name="max" type="dimesionValue"/>
<xs:attribute name="exclude" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="body-measurements">
<xs:complexType>
<xs:sequence>
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="corrections" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="correction" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="coordinates" type="xs:string" use="required"/>
<xs:attribute name="correction" type="xs:double" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="name" type="shortName" use="required"/>
<xs:attribute name="base" type="xs:double"/>
<xs:attribute name="shiftA" type="xs:double"/>
<xs:attribute name="shiftB" type="xs:double"/>
<xs:attribute name="shiftC" type="xs:double"/>
<xs:attribute name="full_name" type="xs:string"/>
<xs:attribute name="description" type="xs:string"/>
<xs:attribute name="specialUnits" type="xs:boolean"/>
<xs:attribute name="type" type="measurementType"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="measurementName">
<xs:selector xpath="body-measurements/m"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
<xs:simpleType name="shortName">
<xs:restriction base="xs:string">
<xs:pattern value="([^\p{Nd}\p{Zs}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;\&quot;]){0,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="units">
<xs:restriction base="xs:string">
<xs:enumeration value="mm"/>
<xs:enumeration value="cm"/>
<xs:enumeration value="inch"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="formatVersion">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="psCode">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimensionType">
<xs:restriction base="xs:string">
<xs:enumeration value="x"/>
<xs:enumeration value="y"/>
<xs:enumeration value="w"/>
<xs:enumeration value="z"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimesionValue">
<xs:restriction base="xs:double">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="2720"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="dimensionStep">
<xs:restriction base="xs:double">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="80"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="measurementType">
<xs:restriction base="xs:string">
<xs:enumeration value="measurement"/>
<xs:enumeration value="separator"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@ -54,8 +54,8 @@
*/
const QString VVSTConverter::MeasurementMinVerStr = QStringLiteral("0.3.0");
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.3");
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.3.xsd");
const QString VVSTConverter::MeasurementMaxVerStr = QStringLiteral("0.5.4");
const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/multisize_measurements/v0.5.4.xsd");
//VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -63,6 +63,9 @@ const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/mu
namespace
{
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagRead_Only, (QLatin1String("read-only")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrCircumference, (QLatin1String("circumference")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strAttrMeasurement, (QLatin1String("measurement")))
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strTagDimension, (QLatin1String("dimension")))
}
//---------------------------------------------------------------------------------------------------------------------
@ -86,7 +89,8 @@ auto VVSTConverter::XSDSchema(unsigned ver) const -> QString
std::make_pair(FormatVersion(0, 5, 0), QStringLiteral("://schema/multisize_measurements/v0.5.0.xsd")),
std::make_pair(FormatVersion(0, 5, 1), QStringLiteral("://schema/multisize_measurements/v0.5.1.xsd")),
std::make_pair(FormatVersion(0, 5, 2), QStringLiteral("://schema/multisize_measurements/v0.5.2.xsd")),
std::make_pair(FormatVersion(0, 5, 3), CurrentSchema),
std::make_pair(FormatVersion(0, 5, 3), QStringLiteral("://schema/multisize_measurements/v0.5.3.xsd")),
std::make_pair(FormatVersion(0, 5, 4), CurrentSchema),
};
if (schemas.contains(ver))
@ -119,10 +123,11 @@ void VVSTConverter::ApplyPatches()
case (FormatVersion(0, 5, 0)):
case (FormatVersion(0, 5, 1)):
case (FormatVersion(0, 5, 2)):
ToV0_5_3();
case (FormatVersion(0, 5, 3)):
ToV0_5_4();
ValidateXML(CurrentSchema);
Q_FALLTHROUGH();
case (FormatVersion(0, 5, 3)):
case (FormatVersion(0, 5, 4)):
break;
default:
InvalidVersion(m_ver);
@ -141,7 +146,7 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
auto VVSTConverter::IsReadOnly() const -> bool
{
// Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 3),
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == FormatVersion(0, 5, 4),
"Check attribute read-only.");
// Possibly in future attribute read-only will change position etc.
@ -415,6 +420,22 @@ void VVSTConverter::ConvertMeasurementsToV0_5_0()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VVSTConverter::ConvertCircumferenceAttreibuteToV0_5_4()
{
const QDomNodeList list = elementsByTagName(*strTagDimension);
for (int i=0; i < list.size(); ++i)
{
QDomElement dom = list.at(i).toElement();
if (dom.hasAttribute(*strAttrCircumference))
{
bool m = GetParametrBool(dom, *strAttrCircumference, trueStr);
dom.removeAttribute(*strAttrCircumference);
SetAttribute(dom, *strAttrMeasurement, m);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void VVSTConverter::ToV0_4_0()
{
@ -469,12 +490,13 @@ void VVSTConverter::ToV0_5_0()
}
//---------------------------------------------------------------------------------------------------------------------
void VVSTConverter::ToV0_5_3()
void VVSTConverter::ToV0_5_4()
{
// TODO. Delete if minimal supported version is 0.5.3
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 3),
// TODO. Delete if minimal supported version is 0.5.4
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMinVer < FormatVersion(0, 5, 4),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.5.3"));
SetVersion(QStringLiteral("0.5.4"));
ConvertCircumferenceAttreibuteToV0_5_4();
Save();
}

View File

@ -49,7 +49,7 @@ public:
static const QString MeasurementMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const unsigned MeasurementMinVer = FormatVersion(0, 3, 0);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 3);
static Q_DECL_CONSTEXPR const unsigned MeasurementMaxVer = FormatVersion(0, 5, 4);
protected:
virtual unsigned MinVer() const override;
@ -78,11 +78,13 @@ private:
void RemoveTagsForV0_5_0();
void ConvertMeasurementsToV0_5_0();
void ConvertCircumferenceAttreibuteToV0_5_4();
void ToV0_4_0();
void ToV0_4_1();
void ToV0_4_2();
void ToV0_5_0();
void ToV0_5_3();
void ToV0_5_4();
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -54,7 +54,7 @@ auto VAbstartMeasurementDimension::IsValid() -> bool
//---------------------------------------------------------------------------------------------------------------------
auto VAbstartMeasurementDimension::RangeMin() const -> int
{
if (m_circumference)
if (m_measurement)
{
const int rangeMinCm = 20;
const int rangeMinMm = 200;
@ -79,7 +79,7 @@ auto VAbstartMeasurementDimension::RangeMin() const -> int
//---------------------------------------------------------------------------------------------------------------------
auto VAbstartMeasurementDimension::RangeMax() const -> int
{
if (m_circumference)
if (m_measurement)
{
const int rangeMaxCm = 272;
const int rangeMaxMm = 2720;
@ -276,19 +276,19 @@ auto VAbstartMeasurementDimension::DimensionToolTip(const MeasurementDimension_p
switch(dimension->Type())
{
case MeasurementDimension::Y:
if (dimension->CustomName().isEmpty() && dimension->IsCircumference())
if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement())
{
return fc ? tr("Chest full circumference", "dimension") : tr("Chest half circumference", "dimension");
}
return {};
case MeasurementDimension::W:
if (dimension->CustomName().isEmpty() && dimension->IsCircumference())
if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement())
{
return fc ? tr("Waist full circumference", "dimension") : tr("Waist half circumference", "dimension");
}
return {};
case MeasurementDimension::Z:
if (dimension->CustomName().isEmpty() && dimension->IsCircumference())
if (dimension->CustomName().isEmpty() && dimension->IsBodyMeasurement())
{
return fc ? tr("Hip full circumference", "dimension") : tr("Hip half circumference", "dimension");
}

View File

@ -83,8 +83,8 @@ public:
// cppcheck-suppress functionStatic
auto Units() const -> Unit;
auto IsCircumference() const -> bool;
void SetCircumference(bool circumference);
auto IsBodyMeasurement() const -> bool;
void SetBodyMeasurement(bool measurement);
auto RangeMin() const -> int;
auto RangeMax() const -> int;
@ -124,7 +124,7 @@ private:
qreal m_baseValue{0};
QString m_error{};
DimesionLabels m_labels{};
bool m_circumference{true};
bool m_measurement{true};
QString m_customName{};
};
@ -189,15 +189,15 @@ inline auto VAbstartMeasurementDimension::Units() const -> Unit
}
//---------------------------------------------------------------------------------------------------------------------
inline auto VAbstartMeasurementDimension::IsCircumference() const -> bool
inline auto VAbstartMeasurementDimension::IsBodyMeasurement() const -> bool
{
return m_circumference;
return m_measurement;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VAbstartMeasurementDimension::SetCircumference(bool circumference)
inline void VAbstartMeasurementDimension::SetBodyMeasurement(bool measurement)
{
m_circumference = circumference;
m_measurement = measurement;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -93,7 +93,7 @@ const QString VMeasurements::AttrFullName = QStringLiteral("full_name")
const QString VMeasurements::AttrMin = QStringLiteral("min");
const QString VMeasurements::AttrMax = QStringLiteral("max");
const QString VMeasurements::AttrStep = QStringLiteral("step");
const QString VMeasurements::AttrCircumference = QStringLiteral("circumference");
const QString VMeasurements::AttrMeasurement = QStringLiteral("measurement");
const QString VMeasurements::AttrFullCircumference = QStringLiteral("fullCircumference");
const QString VMeasurements::AttrLabel = QStringLiteral("label");
const QString VMeasurements::AttrDimension = QStringLiteral("dimension");
@ -1250,7 +1250,7 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dimensions)
auto VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dimensions) -> QDomElement
{
QDomElement dimensionsTag = createElement(TagDimensions);
@ -1263,8 +1263,8 @@ QDomElement VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p
SetAttribute(dimensionTag, AttrMin, dimension->MinValue());
SetAttribute(dimensionTag, AttrMax, dimension->MaxValue());
SetAttribute(dimensionTag, AttrStep, dimension->Step());
SetAttributeOrRemoveIf<bool>(dimensionTag, AttrCircumference, dimension->IsCircumference(),
[](bool c) noexcept {return c;});
SetAttributeOrRemoveIf<bool>(dimensionTag, AttrMeasurement, dimension->IsBodyMeasurement(),
[](bool m) noexcept {return m;});
SetAttributeOrRemoveIf<QString>(dimensionTag, AttrCustomName, dimension->CustomName(),
[](const QString &name) noexcept {return name.isEmpty();});
@ -1427,7 +1427,7 @@ auto VMeasurements::ReadDimensions() const -> VDimensions
}
dimension->SetBaseValue(GetParametrDouble(dom, AttrBase, QChar('0')));
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
dimension->SetBodyMeasurement(GetParametrBool(dom, AttrMeasurement, trueStr));
dimension->SetCustomName(GetParametrEmptyString(dom, AttrCustomName));
dimension->SetLabels(ReadDimensionLabels(dom));
dimensions.insert(type, dimension);

View File

@ -168,7 +168,7 @@ public:
static const QString AttrMin;
static const QString AttrMax;
static const QString AttrStep;
static const QString AttrCircumference;
static const QString AttrMeasurement;
static const QString AttrFullCircumference;
static const QString AttrLabel;
static const QString AttrDimension;

View File

@ -56,7 +56,7 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
auto m_yDimension = QSharedPointer<VYMeasurementDimension>::create(mUnit, 22, 72, 2);
m_yDimension->SetBaseValue(50);
m_yDimension->SetCircumference(true);
m_yDimension->SetBodyMeasurement(true);
QVector<MeasurementDimension_p > dimensions{m_xDimension, m_yDimension};
@ -151,7 +151,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
auto m_yDimension = QSharedPointer<VYMeasurementDimension>::create(mUnit, 22, 72, 2);
m_yDimension->SetBaseValue(50);
m_yDimension->SetCircumference(true);
m_yDimension->SetBodyMeasurement(true);
QVector<MeasurementDimension_p > dimensions{m_xDimension, m_yDimension};