Saving dimensions. Reading dimensions.

This commit is contained in:
Roman Telezhynskyi 2020-10-01 13:32:02 +03:00
parent 484b92a38e
commit cea2671687
9 changed files with 240 additions and 98 deletions

View File

@ -170,9 +170,9 @@ DialogSetupMultisize::~DialogSetupMultisize()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QSharedPointer<VAbstartMeasurementDimension> > DialogSetupMultisize::Dimensions() const QVector<MeasurementDimension_p> DialogSetupMultisize::Dimensions() const
{ {
QVector<QSharedPointer<VAbstartMeasurementDimension> > dimensions; QVector<MeasurementDimension_p> dimensions;
if (ui->groupBoxXDimension->isChecked()) if (ui->groupBoxXDimension->isChecked())
{ {
@ -236,7 +236,7 @@ void DialogSetupMultisize::ShowFullCircumference()
{ {
auto ShowDimensionFullCircumference = [this](QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, auto ShowDimensionFullCircumference = [this](QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
QComboBox *comboBoxStep, QComboBox *comboBoxBase, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(spinboxMinValue != nullptr)
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(spinboxMaxValue != nullptr)
@ -302,7 +302,7 @@ void DialogSetupMultisize::CheckState()
int dimensions = 0; int dimensions = 0;
auto CheckDimension = [this](QGroupBox *group, bool &dimensionValid, int &dimensions, auto CheckDimension = [this](QGroupBox *group, bool &dimensionValid, int &dimensions,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(group != nullptr) SCASSERT(group != nullptr)
@ -346,7 +346,7 @@ void DialogSetupMultisize::CheckState()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(spinboxMinValue != nullptr)
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(spinboxMaxValue != nullptr)
@ -383,7 +383,7 @@ void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinB
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
@ -412,7 +412,7 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DialogSetupMultisize::InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
InitDimensionMinMax(spinboxMinValue, spinboxMaxValue, dimension); InitDimensionMinMax(spinboxMinValue, spinboxMaxValue, dimension);
InitDimensionStep(comboBoxStep, dimension); InitDimensionStep(comboBoxStep, dimension);
@ -449,7 +449,7 @@ void DialogSetupMultisize::InitZDimension()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
QComboBox *comboBoxBase, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMaxValue != nullptr) SCASSERT(spinboxMaxValue != nullptr)
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
@ -475,7 +475,7 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep, void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
QComboBox *comboBoxBase, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(spinboxMinValue != nullptr) SCASSERT(spinboxMinValue != nullptr)
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
@ -500,7 +500,7 @@ void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinbox
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase, void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
@ -516,7 +516,7 @@ void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxSt
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBase, void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)
@ -529,7 +529,7 @@ void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBa
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(comboBoxStep != nullptr) SCASSERT(comboBoxStep != nullptr)
@ -564,7 +564,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension) const MeasurementDimension_p &dimension)
{ {
SCASSERT(comboBoxBase != nullptr) SCASSERT(comboBoxBase != nullptr)

View File

@ -48,7 +48,7 @@ public:
explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr); explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr);
~DialogSetupMultisize(); ~DialogSetupMultisize();
QVector<QSharedPointer<VAbstartMeasurementDimension> > Dimensions() const; QVector<MeasurementDimension_p> Dimensions() const;
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
@ -70,11 +70,11 @@ private:
void CheckState(); void CheckState();
void InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, void InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void InitDimensionStep(QComboBox *comboBoxStep,const QSharedPointer<VAbstartMeasurementDimension> &dimension); void InitDimensionStep(QComboBox *comboBoxStep,const MeasurementDimension_p &dimension);
void InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void InitXDimension(); void InitXDimension();
void InitYDimension(); void InitYDimension();
void InitWDimension(); void InitWDimension();
@ -82,18 +82,18 @@ private:
void DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep, void DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
QComboBox *comboBoxBase, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep, void DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
QComboBox *comboBoxBase, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase, void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void DimensionBaseChanged(int index, QComboBox *comboBoxBase, void DimensionBaseChanged(int index, QComboBox *comboBoxBase,
const QSharedPointer<VAbstartMeasurementDimension> &dimension); const MeasurementDimension_p &dimension);
void UpdateSteps(QComboBox *comboBoxStep, const QSharedPointer<VAbstartMeasurementDimension> &dimension); void UpdateSteps(QComboBox *comboBoxStep, const MeasurementDimension_p &dimension);
void UpdateBase(QComboBox *comboBoxBase, const QSharedPointer<VAbstartMeasurementDimension> &dimension); void UpdateBase(QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
}; };
#endif // DIALOGSETUPMULTISIZE_H #endif // DIALOGSETUPMULTISIZE_H

View File

@ -92,8 +92,6 @@ TMainWindow::TMainWindow(QWidget *parent)
mUnit(Unit::Cm), mUnit(Unit::Cm),
pUnit(Unit::Cm), pUnit(Unit::Cm),
mType(MeasurementsType::Individual), mType(MeasurementsType::Individual),
currentSize(0),
currentHeight(0),
curFile(), curFile(),
gradationHeights(nullptr), gradationHeights(nullptr),
gradationSizes(nullptr), gradationSizes(nullptr),
@ -182,10 +180,10 @@ void TMainWindow::SetBaseMHeight(int height)
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
currentHeight = UnitConvertor(height, Unit::Cm, mUnit); currentDimensionA = UnitConvertor(height, Unit::Cm, mUnit);
gradationHeights->blockSignals(true); gradationHeights->blockSignals(true);
SetDefaultHeight(static_cast<int>(currentHeight)); SetDefaultHeight(static_cast<int>(currentDimensionA));
gradationHeights->blockSignals(false); gradationHeights->blockSignals(false);
RefreshData(); RefreshData();
@ -203,10 +201,10 @@ void TMainWindow::SetBaseMSize(int size)
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
currentSize = UnitConvertor(size, Unit::Cm, mUnit); currentDimensionB = UnitConvertor(size, Unit::Cm, mUnit);
gradationSizes->blockSignals(true); gradationSizes->blockSignals(true);
SetDefaultSize(static_cast<int>(currentSize)); SetDefaultSize(static_cast<int>(currentDimensionB));
gradationSizes->blockSignals(false); gradationSizes->blockSignals(false);
RefreshData(); RefreshData();
@ -298,8 +296,8 @@ bool TMainWindow::LoadFile(const QString &path)
mUnit = m->MUnit(); mUnit = m->MUnit();
pUnit = mUnit; pUnit = mUnit;
currentSize = m->BaseSize(); currentDimensionB = m->DimensionABase();
currentHeight = m->BaseHeight(); currentDimensionA = m->DimensionBBase();
ui->labelToolTip->setVisible(false); ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true); ui->tabWidget->setVisible(true);
@ -379,22 +377,17 @@ void TMainWindow::FileNew()
{ {
return; return;
} }
}
return; // temporary data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace()); m = new VMeasurements(mUnit, setup.Dimensions(), data);
// currentHeight = measurements.BaseHeight();
// currentSize = measurements.BaseSize();
if (mType == MeasurementsType::Multisize)
{
m = new VMeasurements(mUnit, /*measurements.BaseSize(), measurements.BaseHeight(),*/ data);
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer; m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr; m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
} }
else else
{ {
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
m = new VMeasurements(mUnit, data); m = new VMeasurements(mUnit, data);
m_curFileFormatVersion = VVITConverter::MeasurementMaxVer; m_curFileFormatVersion = VVITConverter::MeasurementMaxVer;
m_curFileFormatVersionStr = VVITConverter::MeasurementMaxVerStr; m_curFileFormatVersionStr = VVITConverter::MeasurementMaxVerStr;
@ -568,9 +561,9 @@ void TMainWindow::changeEvent(QEvent *event)
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + QChar(QChar::Space) + ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QChar(QChar::Space) + ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit))); labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit)));
@ -1468,7 +1461,7 @@ void TMainWindow::ImportFromPattern()
void TMainWindow::ChangedSize(const QString &text) void TMainWindow::ChangedSize(const QString &text)
{ {
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
currentSize = text.toInt(); currentDimensionB = text.toInt();
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -1478,7 +1471,7 @@ void TMainWindow::ChangedSize(const QString &text)
void TMainWindow::ChangedHeight(const QString &text) void TMainWindow::ChangedHeight(const QString &text)
{ {
const int row = ui->tableWidget->currentRow(); const int row = ui->tableWidget->currentRow();
currentHeight = text.toInt(); currentDimensionA = text.toInt();
RefreshData(); RefreshData();
search->RefreshList(ui->lineEditFind->text()); search->RefreshList(ui->lineEditFind->text());
ui->tableWidget->selectRow(row); ui->tableWidget->selectRow(row);
@ -2031,9 +2024,9 @@ void TMainWindow::InitWindow()
if (mType == MeasurementsType::Multisize) if (mType == MeasurementsType::Multisize)
{ {
ui->labelMType->setText(tr("Multisize measurements")); ui->labelMType->setText(tr("Multisize measurements"));
ui->labelBaseSizeValue->setText(QString().setNum(m->BaseSize()) + QChar(QChar::Space) + ui->labelBaseSizeValue->setText(QString().setNum(m->DimensionABase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QChar(QChar::Space) + ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
UnitsToStr(m->MUnit(), true)); UnitsToStr(m->MUnit(), true));
// Because Qt Designer doesn't know about our deleting we will create empty objects for correct // Because Qt Designer doesn't know about our deleting we will create empty objects for correct
@ -2379,7 +2372,7 @@ void TMainWindow::SetDefaultHeight(int value)
} }
else else
{ {
currentHeight = gradationHeights->currentText().toInt(); currentDimensionA = gradationHeights->currentText().toInt();
} }
} }
@ -2393,7 +2386,7 @@ void TMainWindow::SetDefaultSize(int value)
} }
else else
{ {
currentSize = gradationSizes->currentText().toInt(); currentDimensionB = gradationSizes->currentText().toInt();
} }
} }
@ -2402,7 +2395,7 @@ void TMainWindow::RefreshData(bool freshCall)
{ {
data->ClearUniqueNames(); data->ClearUniqueNames();
data->ClearVariables(VarType::Measurement); data->ClearVariables(VarType::Measurement);
m->ReadMeasurements(currentHeight, currentSize); m->ReadMeasurements(currentDimensionA, currentDimensionB);
RefreshTable(freshCall); RefreshTable(freshCall);
} }
@ -2884,8 +2877,8 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
mUnit = m->MUnit(); mUnit = m->MUnit();
pUnit = mUnit; pUnit = mUnit;
currentHeight = m->BaseHeight(); currentDimensionA = m->DimensionBBase();
currentSize = m->BaseSize(); currentDimensionB = m->DimensionABase();
ui->labelToolTip->setVisible(false); ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true); ui->tabWidget->setVisible(true);

View File

@ -135,8 +135,9 @@ private:
Unit mUnit; Unit mUnit;
Unit pUnit; Unit pUnit;
MeasurementsType mType; MeasurementsType mType;
qreal currentSize; int currentDimensionA{0};
qreal currentHeight; int currentDimensionB{0};
int currentDimensionC{0};
QString curFile; QString curFile;
QComboBox *gradationHeights; QComboBox *gradationHeights;
QComboBox *gradationSizes; QComboBox *gradationSizes;

View File

@ -499,8 +499,8 @@ bool MainWindow::LoadMeasurements(const QString &path)
return false; return false;
} }
const qreal size = UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit()); const qreal size = UnitConvertor(m->DimensionABase(), m->MUnit(), *m->GetData()->GetPatternUnit());
const qreal height = UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit()); const qreal height = UnitConvertor(m->DimensionBBase(), m->MUnit(), *m->GetData()->GetPatternUnit());
try try
{ {

View File

@ -34,12 +34,16 @@
enum class MeasurementDimension: qint8 enum class MeasurementDimension: qint8
{ {
X, // height X = 0, // height
Y, // size (chest half circumference) Y = 1, // size (chest half circumference)
W, // hip half circumference W = 2, // hip half circumference
Z // waist half circumference Z = 3 // waist half circumference
}; };
class VAbstartMeasurementDimension;
template <class T> class QSharedPointer;
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
class VAbstartMeasurementDimension class VAbstartMeasurementDimension
{ {

View File

@ -60,8 +60,6 @@ const QString VMeasurements::TagVST = QStringLiteral("vst");
const QString VMeasurements::TagVIT = QStringLiteral("vit"); const QString VMeasurements::TagVIT = QStringLiteral("vit");
const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements"); const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements");
const QString VMeasurements::TagNotes = QStringLiteral("notes"); const QString VMeasurements::TagNotes = QStringLiteral("notes");
const QString VMeasurements::TagSize = QStringLiteral("size");
const QString VMeasurements::TagHeight = QStringLiteral("height");
const QString VMeasurements::TagPersonal = QStringLiteral("personal"); const QString VMeasurements::TagPersonal = QStringLiteral("personal");
const QString VMeasurements::TagCustomer = QStringLiteral("customer"); const QString VMeasurements::TagCustomer = QStringLiteral("customer");
const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date"); const QString VMeasurements::TagBirthDate = QStringLiteral("birth-date");
@ -70,6 +68,9 @@ const QString VMeasurements::TagPMSystem = QStringLiteral("pm_system");
const QString VMeasurements::TagEmail = QStringLiteral("email"); const QString VMeasurements::TagEmail = QStringLiteral("email");
const QString VMeasurements::TagReadOnly = QStringLiteral("read-only"); const QString VMeasurements::TagReadOnly = QStringLiteral("read-only");
const QString VMeasurements::TagMeasurement = QStringLiteral("m"); const QString VMeasurements::TagMeasurement = QStringLiteral("m");
const QString VMeasurements::TagDimensions = QStringLiteral("dimensions");
const QString VMeasurements::TagDimension = QStringLiteral("dimension");
const QString VMeasurements::TagRestrictions = QStringLiteral("restrictions");
const QString VMeasurements::AttrBase = QStringLiteral("base"); const QString VMeasurements::AttrBase = QStringLiteral("base");
const QString VMeasurements::AttrValue = QStringLiteral("value"); const QString VMeasurements::AttrValue = QStringLiteral("value");
@ -78,11 +79,20 @@ const QString VMeasurements::AttrHeightIncrease = QStringLiteral("height_increas
const QString VMeasurements::AttrDescription = QStringLiteral("description"); const QString VMeasurements::AttrDescription = QStringLiteral("description");
const QString VMeasurements::AttrName = QStringLiteral("name"); const QString VMeasurements::AttrName = QStringLiteral("name");
const QString VMeasurements::AttrFullName = QStringLiteral("full_name"); 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::GenderMale = QStringLiteral("male"); const QString VMeasurements::GenderMale = QStringLiteral("male");
const QString VMeasurements::GenderFemale = QStringLiteral("female"); const QString VMeasurements::GenderFemale = QStringLiteral("female");
const QString VMeasurements::GenderUnknown = QStringLiteral("unknown"); const QString VMeasurements::GenderUnknown = QStringLiteral("unknown");
const QString VMeasurements::DimensionX = QStringLiteral("x");
const QString VMeasurements::DimensionY = QStringLiteral("y");
const QString VMeasurements::DimensionW = QStringLiteral("w");
const QString VMeasurements::DimensionZ = QStringLiteral("z");
namespace namespace
{ {
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01"))) Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01")))
@ -112,18 +122,19 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
{ {
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
CreateEmptyIndividualFile(unit); CreateEmptyIndividualFile(unit);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data) VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
VContainer *data)
:VDomDocument(), :VDomDocument(),
data(data), data(data),
type(MeasurementsType::Multisize) type(MeasurementsType::Multisize)
{ {
SCASSERT(data != nullptr) SCASSERT(data != nullptr)
CreateEmptyMultisizeFile(unit, baseSize, baseHeight); CreateEmptyMultisizeFile(unit, dimensions);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -282,8 +293,8 @@ void VMeasurements::ReadMeasurements(qreal height, qreal size) const
qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, QChar('0')); qreal ksize = GetParametrDouble(dom, AttrSizeIncrease, QChar('0'));
qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, QChar('0')); qreal kheight = GetParametrDouble(dom, AttrHeightIncrease, QChar('0'));
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, BaseSize(), tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, DimensionABase(),
BaseHeight(), base, ksize, kheight)); DimensionBBase(), base, ksize, kheight));
tempMeash->SetSize(size); tempMeash->SetSize(size);
tempMeash->SetHeight(height); tempMeash->SetHeight(height);
tempMeash->SetUnit(data->GetPatternUnit()); tempMeash->SetUnit(data->GetPatternUnit());
@ -292,8 +303,8 @@ void VMeasurements::ReadMeasurements(qreal height, qreal size) const
ksize = UnitConvertor(ksize, MUnit(), *data->GetPatternUnit()); ksize = UnitConvertor(ksize, MUnit(), *data->GetPatternUnit());
kheight = UnitConvertor(kheight, MUnit(), *data->GetPatternUnit()); kheight = UnitConvertor(kheight, MUnit(), *data->GetPatternUnit());
const qreal baseSize = UnitConvertor(BaseSize(), MUnit(), *data->GetPatternUnit()); const qreal baseSize = UnitConvertor(DimensionABase(), MUnit(), *data->GetPatternUnit());
const qreal baseHeight = UnitConvertor(BaseHeight(), MUnit(), *data->GetPatternUnit()); const qreal baseHeight = UnitConvertor(DimensionBBase(), MUnit(), *data->GetPatternUnit());
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight, meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
base, ksize, kheight, fullName, description)); base, ksize, kheight, fullName, description));
@ -352,29 +363,48 @@ MeasurementsType VMeasurements::Type() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::BaseSize() const int VMeasurements::DimensionABase() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
return static_cast<int>(UniqueTagAttr(TagSize, AttrBase, 50)); const auto dimensions = Dimensions();
} if (not dimensions.isEmpty())
else {
{ return dimensions.first()->BaseValue();
return 0; }
} }
return 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VMeasurements::BaseHeight() const int VMeasurements::DimensionBBase() const
{ {
if (type == MeasurementsType::Multisize) if (type == MeasurementsType::Multisize)
{ {
return static_cast<int>(UniqueTagAttr(TagHeight, AttrBase, 176)); const auto dimensions = Dimensions();
if (not dimensions.isEmpty() && dimensions.size() >= 2)
{
return dimensions.values().at(1)->BaseValue();
}
} }
else
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
int VMeasurements::DimensionCBase() const
{
if (type == MeasurementsType::Multisize)
{ {
return 0; const auto dimensions = Dimensions();
if (not dimensions.isEmpty() && dimensions.size() >= 3)
{
return dimensions.last()->BaseValue();
}
} }
return 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -577,6 +607,45 @@ void VMeasurements::SetMFullName(const QString &name, const QString &text)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QMap<MeasurementDimension, MeasurementDimension_p > VMeasurements::Dimensions() const
{
QMap<MeasurementDimension, MeasurementDimension_p > dimesions;
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 int min = GetParametrInt(dom, AttrMin, QChar('0'));
const int max = GetParametrInt(dom, AttrMax, QChar('0'));
const int step = GetParametrInt(dom, AttrStep, QString("-1"));
if (type == MeasurementDimension::X)
{
dimesions.insert(type, QSharedPointer<VXMeasurementDimension>::create(units, min, max, step));
}
else if (type == MeasurementDimension::Y)
{
auto dimension = QSharedPointer<VYMeasurementDimension>::create(units, min, max, step);
dimension->SetCircumference(GetParametrBool(dom, AttrCircumference, trueStr));
dimesions.insert(type, dimension);
}
else if (type == MeasurementDimension::W)
{
dimesions.insert(type, QSharedPointer<VWMeasurementDimension>::create(units, min, max, step));
}
else if (type == MeasurementDimension::Z)
{
dimesions.insert(type, QSharedPointer<VZMeasurementDimension>::create(units, min, max, step));
}
}
return dimesions;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::GenderToStr(const GenderType &sex) QString VMeasurements::GenderToStr(const GenderType &sex)
{ {
@ -608,6 +677,41 @@ GenderType VMeasurements::StrToGender(const QString &sex)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VMeasurements::DimensionTypeToStr(const MeasurementDimension &type)
{
switch (type)
{
case MeasurementDimension::Y:
return DimensionY;
case MeasurementDimension::W:
return DimensionW;
case MeasurementDimension::Z:
return DimensionZ;
case MeasurementDimension::X:
default:
return DimensionX;
}
}
//---------------------------------------------------------------------------------------------------------------------
MeasurementDimension VMeasurements::StrToDimensionType(const QString &type)
{
const QStringList dimensions = QStringList{DimensionX, DimensionY, DimensionW, DimensionZ};
switch (dimensions.indexOf(type))
{
case 1: // DimensionY
return MeasurementDimension::Y;
case 2: // DimensionW
return MeasurementDimension::W;
case 3: // DimensionZ
return MeasurementDimension::Z;
case 0: // DimensionX
default:
return MeasurementDimension::X;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QStringList VMeasurements::ListAll() const QStringList VMeasurements::ListAll() const
{ {
@ -672,7 +776,8 @@ VContainer *VMeasurements::GetData() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMeasurements::CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight) void VMeasurements::CreateEmptyMultisizeFile(Unit unit,
const QVector<MeasurementDimension_p > &dimensions)
{ {
this->clear(); this->clear();
QDomElement mElement = this->createElement(TagVST); QDomElement mElement = this->createElement(TagVST);
@ -683,15 +788,8 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHe
mElement.appendChild(createElement(TagNotes)); mElement.appendChild(createElement(TagNotes));
mElement.appendChild(CreateElementWithText(TagUnit, UnitsToStr(unit))); mElement.appendChild(CreateElementWithText(TagUnit, UnitsToStr(unit)));
mElement.appendChild(CreateElementWithText(TagPMSystem, ClearPMCode(p998_S))); mElement.appendChild(CreateElementWithText(TagPMSystem, ClearPMCode(p998_S)));
mElement.appendChild(CreateDimensions(dimensions));
QDomElement size = createElement(TagSize); mElement.appendChild(createElement(TagRestrictions));
SetAttribute(size, AttrBase, QString().setNum(baseSize));
mElement.appendChild(size);
QDomElement height = createElement(TagHeight);
SetAttribute(height, AttrBase, QString().setNum(baseHeight));
mElement.appendChild(height);
mElement.appendChild(createElement(TagBodyMeasurements)); mElement.appendChild(createElement(TagBodyMeasurements));
this->appendChild(mElement); this->appendChild(mElement);
@ -727,6 +825,32 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild()); QStringLiteral("version=\"1.0\" encoding=\"UTF-8\"")), this->firstChild());
} }
//---------------------------------------------------------------------------------------------------------------------
QDomElement VMeasurements::CreateDimensions(const QVector<MeasurementDimension_p > &dimensions)
{
QDomElement dimensionsTag = createElement(TagDimensions);
for(auto &dimension : dimensions)
{
QDomElement dimensionTag = createElement(TagDimension);
SetAttribute(dimensionTag, AttrType, DimensionTypeToStr(dimension->Type()));
SetAttribute(dimensionTag, AttrBase, dimension->BaseValue());
SetAttribute(dimensionTag, AttrMin, dimension->MinValue());
SetAttribute(dimensionTag, AttrMax, dimension->MaxValue());
SetAttribute(dimensionTag, AttrStep, dimension->Step());
if (dimension->Type() == MeasurementDimension::Y)
{
SetAttribute(dimensionTag, AttrCircumference, dimension->IsCircumference());
}
dimensionsTag.appendChild(dimensionTag);
}
return dimensionsTag;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const qreal VMeasurements::UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const
{ {

View File

@ -38,6 +38,7 @@
#include "../ifc/xml/vdomdocument.h" #include "../ifc/xml/vdomdocument.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vdimensions.h"
class VContainer; class VContainer;
@ -49,7 +50,8 @@ class VMeasurements : public VDomDocument
public: public:
explicit VMeasurements(VContainer *data); explicit VMeasurements(VContainer *data);
VMeasurements(Unit unit, VContainer *data); VMeasurements(Unit unit, VContainer *data);
VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data); VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
VContainer *data);
virtual ~VMeasurements() Q_DECL_EQ_DEFAULT; virtual ~VMeasurements() Q_DECL_EQ_DEFAULT;
virtual void setXMLContent(const QString &fileName) override; virtual void setXMLContent(const QString &fileName) override;
@ -69,8 +71,9 @@ public:
void ClearForExport(); void ClearForExport();
MeasurementsType Type() const; MeasurementsType Type() const;
int BaseSize() const; int DimensionABase() const;
int BaseHeight() const; int DimensionBBase() const;
int DimensionCBase() const;
QString Notes() const; QString Notes() const;
void SetNotes(const QString &text); void SetNotes(const QString &text);
@ -101,12 +104,12 @@ public:
void SetMDescription(const QString &name, const QString &text); void SetMDescription(const QString &name, const QString &text);
void SetMFullName(const QString &name, const QString &text); void SetMFullName(const QString &name, const QString &text);
QMap<MeasurementDimension, MeasurementDimension_p > Dimensions() const;
static const QString TagVST; static const QString TagVST;
static const QString TagVIT; static const QString TagVIT;
static const QString TagBodyMeasurements; static const QString TagBodyMeasurements;
static const QString TagNotes; static const QString TagNotes;
static const QString TagSize;
static const QString TagHeight;
static const QString TagPersonal; static const QString TagPersonal;
static const QString TagCustomer; static const QString TagCustomer;
static const QString TagBirthDate; static const QString TagBirthDate;
@ -115,6 +118,9 @@ public:
static const QString TagEmail; static const QString TagEmail;
static const QString TagReadOnly; static const QString TagReadOnly;
static const QString TagMeasurement; static const QString TagMeasurement;
static const QString TagDimensions;
static const QString TagDimension;
static const QString TagRestrictions;
static const QString AttrBase; static const QString AttrBase;
static const QString AttrValue; static const QString AttrValue;
@ -123,14 +129,26 @@ public:
static const QString AttrDescription; static const QString AttrDescription;
static const QString AttrName; static const QString AttrName;
static const QString AttrFullName; static const QString AttrFullName;
static const QString AttrMin;
static const QString AttrMax;
static const QString AttrStep;
static const QString AttrCircumference;
static const QString GenderMale; static const QString GenderMale;
static const QString GenderFemale; static const QString GenderFemale;
static const QString GenderUnknown; static const QString GenderUnknown;
static const QString DimensionX;
static const QString DimensionY;
static const QString DimensionW;
static const QString DimensionZ;
static QString GenderToStr(const GenderType &sex); static QString GenderToStr(const GenderType &sex);
static GenderType StrToGender(const QString &sex); static GenderType StrToGender(const QString &sex);
static QString DimensionTypeToStr(const MeasurementDimension &type);
static MeasurementDimension StrToDimensionType(const QString &type);
QStringList ListAll() const; QStringList ListAll() const;
QStringList ListKnown() const; QStringList ListKnown() const;
@ -148,9 +166,11 @@ private:
/** @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};
void CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHeight); void CreateEmptyMultisizeFile(Unit unit, const QVector<MeasurementDimension_p > &dimensions);
void CreateEmptyIndividualFile(Unit unit); void CreateEmptyIndividualFile(Unit unit);
QDomElement CreateDimensions(const QVector<MeasurementDimension_p > &dimensions);
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const; qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
QDomElement MakeEmpty(const QString &name, const QString &formula); QDomElement MakeEmpty(const QString &name, const QString &formula);

View File

@ -57,7 +57,7 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
data->SetSize(size); data->SetSize(size);
QSharedPointer<VMeasurements> m = QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data())); QSharedPointer<VMeasurements>(new VMeasurements(mUnit, /*size, height,*/ data.data()));
QTemporaryFile file; QTemporaryFile file;
QString fileName; QString fileName;
@ -147,7 +147,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
data->SetSize(size); data->SetSize(size);
QSharedPointer<VMeasurements> m = QSharedPointer<VMeasurements> m =
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data())); QSharedPointer<VMeasurements>(new VMeasurements(mUnit, /*size, height,*/ data.data()));
const QStringList listSystems = ListPMSystems(); const QStringList listSystems = ListPMSystems();
for (int i = 0; i < listSystems.size(); ++i) for (int i = 0; i < listSystems.size(); ++i)