Saving dimensions. Reading dimensions.
This commit is contained in:
parent
484b92a38e
commit
cea2671687
|
@ -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())
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ void DialogSetupMultisize::ShowFullCircumference()
|
|||
{
|
||||
auto ShowDimensionFullCircumference = [this](QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
|
||||
QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
|
@ -302,7 +302,7 @@ void DialogSetupMultisize::CheckState()
|
|||
int dimensions = 0;
|
||||
|
||||
auto CheckDimension = [this](QGroupBox *group, bool &dimensionValid, int &dimensions,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(group != nullptr)
|
||||
|
||||
|
@ -346,7 +346,7 @@ void DialogSetupMultisize::CheckState()
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
|
@ -383,7 +383,7 @@ void DialogSetupMultisize::InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinB
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
|
||||
|
@ -412,7 +412,7 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep,
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
InitDimensionMinMax(spinboxMinValue, spinboxMaxValue, dimension);
|
||||
InitDimensionStep(comboBoxStep, dimension);
|
||||
|
@ -449,7 +449,7 @@ void DialogSetupMultisize::InitZDimension()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMaxValue != nullptr)
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
|
@ -475,7 +475,7 @@ void DialogSetupMultisize::DimensionMinValueChanged(int value, QSpinBox *spinbox
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(spinboxMinValue != nullptr)
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
|
@ -500,7 +500,7 @@ void DialogSetupMultisize::DimensionMaxValueChanged(int value, QSpinBox *spinbox
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
@ -516,7 +516,7 @@ void DialogSetupMultisize::DimensionStepChanged(int index, QComboBox *comboBoxSt
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
|
@ -529,7 +529,7 @@ void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBa
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(comboBoxStep != nullptr)
|
||||
|
||||
|
@ -564,7 +564,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep,
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension)
|
||||
const MeasurementDimension_p &dimension)
|
||||
{
|
||||
SCASSERT(comboBoxBase != nullptr)
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
explicit DialogSetupMultisize(Unit unit, QWidget *parent = nullptr);
|
||||
~DialogSetupMultisize();
|
||||
|
||||
QVector<QSharedPointer<VAbstartMeasurementDimension> > Dimensions() const;
|
||||
QVector<MeasurementDimension_p> Dimensions() const;
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
@ -70,11 +70,11 @@ private:
|
|||
void CheckState();
|
||||
|
||||
void InitDimensionMinMax(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
void InitDimensionStep(QComboBox *comboBoxStep,const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
void InitDimensionStep(QComboBox *comboBoxStep,const MeasurementDimension_p &dimension);
|
||||
|
||||
void InitDimension(QSpinBox *spinboxMinValue, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
void InitXDimension();
|
||||
void InitYDimension();
|
||||
void InitWDimension();
|
||||
|
@ -82,18 +82,18 @@ private:
|
|||
|
||||
void DimensionMinValueChanged(int value, QSpinBox *spinboxMaxValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
void DimensionMaxValueChanged(int value, QSpinBox *spinboxMinValue, QComboBox *comboBoxStep,
|
||||
QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
|
||||
void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
void DimensionBaseChanged(int index, QComboBox *comboBoxBase,
|
||||
const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
const MeasurementDimension_p &dimension);
|
||||
|
||||
void UpdateSteps(QComboBox *comboBoxStep, const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
void UpdateBase(QComboBox *comboBoxBase, const QSharedPointer<VAbstartMeasurementDimension> &dimension);
|
||||
void UpdateSteps(QComboBox *comboBoxStep, const MeasurementDimension_p &dimension);
|
||||
void UpdateBase(QComboBox *comboBoxBase, const MeasurementDimension_p &dimension);
|
||||
};
|
||||
|
||||
#endif // DIALOGSETUPMULTISIZE_H
|
||||
|
|
|
@ -92,8 +92,6 @@ TMainWindow::TMainWindow(QWidget *parent)
|
|||
mUnit(Unit::Cm),
|
||||
pUnit(Unit::Cm),
|
||||
mType(MeasurementsType::Individual),
|
||||
currentSize(0),
|
||||
currentHeight(0),
|
||||
curFile(),
|
||||
gradationHeights(nullptr),
|
||||
gradationSizes(nullptr),
|
||||
|
@ -182,10 +180,10 @@ void TMainWindow::SetBaseMHeight(int height)
|
|||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
currentHeight = UnitConvertor(height, Unit::Cm, mUnit);
|
||||
currentDimensionA = UnitConvertor(height, Unit::Cm, mUnit);
|
||||
|
||||
gradationHeights->blockSignals(true);
|
||||
SetDefaultHeight(static_cast<int>(currentHeight));
|
||||
SetDefaultHeight(static_cast<int>(currentDimensionA));
|
||||
gradationHeights->blockSignals(false);
|
||||
|
||||
RefreshData();
|
||||
|
@ -203,10 +201,10 @@ void TMainWindow::SetBaseMSize(int size)
|
|||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
currentSize = UnitConvertor(size, Unit::Cm, mUnit);
|
||||
currentDimensionB = UnitConvertor(size, Unit::Cm, mUnit);
|
||||
|
||||
gradationSizes->blockSignals(true);
|
||||
SetDefaultSize(static_cast<int>(currentSize));
|
||||
SetDefaultSize(static_cast<int>(currentDimensionB));
|
||||
gradationSizes->blockSignals(false);
|
||||
|
||||
RefreshData();
|
||||
|
@ -298,8 +296,8 @@ bool TMainWindow::LoadFile(const QString &path)
|
|||
mUnit = m->MUnit();
|
||||
pUnit = mUnit;
|
||||
|
||||
currentSize = m->BaseSize();
|
||||
currentHeight = m->BaseHeight();
|
||||
currentDimensionB = m->DimensionABase();
|
||||
currentDimensionA = m->DimensionBBase();
|
||||
|
||||
ui->labelToolTip->setVisible(false);
|
||||
ui->tabWidget->setVisible(true);
|
||||
|
@ -379,22 +377,17 @@ void TMainWindow::FileNew()
|
|||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return; // temporary
|
||||
|
||||
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
|
||||
// currentHeight = measurements.BaseHeight();
|
||||
// currentSize = measurements.BaseSize();
|
||||
|
||||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
m = new VMeasurements(mUnit, /*measurements.BaseSize(), measurements.BaseHeight(),*/ data);
|
||||
m = new VMeasurements(mUnit, setup.Dimensions(), data);
|
||||
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
|
||||
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = new VContainer(qApp->TrVars(), &mUnit, VContainer::UniqueNamespace());
|
||||
|
||||
m = new VMeasurements(mUnit, data);
|
||||
m_curFileFormatVersion = VVITConverter::MeasurementMaxVer;
|
||||
m_curFileFormatVersionStr = VVITConverter::MeasurementMaxVerStr;
|
||||
|
@ -568,9 +561,9 @@ void TMainWindow::changeEvent(QEvent *event)
|
|||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
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));
|
||||
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QChar(QChar::Space) +
|
||||
ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
|
||||
UnitsToStr(m->MUnit(), true));
|
||||
|
||||
labelGradationHeights->setText(tr("Height (%1):").arg(UnitsToStr(mUnit)));
|
||||
|
@ -1468,7 +1461,7 @@ void TMainWindow::ImportFromPattern()
|
|||
void TMainWindow::ChangedSize(const QString &text)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
currentSize = text.toInt();
|
||||
currentDimensionB = text.toInt();
|
||||
RefreshData();
|
||||
search->RefreshList(ui->lineEditFind->text());
|
||||
ui->tableWidget->selectRow(row);
|
||||
|
@ -1478,7 +1471,7 @@ void TMainWindow::ChangedSize(const QString &text)
|
|||
void TMainWindow::ChangedHeight(const QString &text)
|
||||
{
|
||||
const int row = ui->tableWidget->currentRow();
|
||||
currentHeight = text.toInt();
|
||||
currentDimensionA = text.toInt();
|
||||
RefreshData();
|
||||
search->RefreshList(ui->lineEditFind->text());
|
||||
ui->tableWidget->selectRow(row);
|
||||
|
@ -2031,9 +2024,9 @@ void TMainWindow::InitWindow()
|
|||
if (mType == MeasurementsType::Multisize)
|
||||
{
|
||||
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));
|
||||
ui->labelBaseHeightValue->setText(QString().setNum(m->BaseHeight()) + QChar(QChar::Space) +
|
||||
ui->labelBaseHeightValue->setText(QString().setNum(m->DimensionBBase()) + QChar(QChar::Space) +
|
||||
UnitsToStr(m->MUnit(), true));
|
||||
|
||||
// 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
|
||||
{
|
||||
currentHeight = gradationHeights->currentText().toInt();
|
||||
currentDimensionA = gradationHeights->currentText().toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2393,7 +2386,7 @@ void TMainWindow::SetDefaultSize(int value)
|
|||
}
|
||||
else
|
||||
{
|
||||
currentSize = gradationSizes->currentText().toInt();
|
||||
currentDimensionB = gradationSizes->currentText().toInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2402,7 +2395,7 @@ void TMainWindow::RefreshData(bool freshCall)
|
|||
{
|
||||
data->ClearUniqueNames();
|
||||
data->ClearVariables(VarType::Measurement);
|
||||
m->ReadMeasurements(currentHeight, currentSize);
|
||||
m->ReadMeasurements(currentDimensionA, currentDimensionB);
|
||||
|
||||
RefreshTable(freshCall);
|
||||
}
|
||||
|
@ -2884,8 +2877,8 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
|||
mUnit = m->MUnit();
|
||||
pUnit = mUnit;
|
||||
|
||||
currentHeight = m->BaseHeight();
|
||||
currentSize = m->BaseSize();
|
||||
currentDimensionA = m->DimensionBBase();
|
||||
currentDimensionB = m->DimensionABase();
|
||||
|
||||
ui->labelToolTip->setVisible(false);
|
||||
ui->tabWidget->setVisible(true);
|
||||
|
|
|
@ -135,8 +135,9 @@ private:
|
|||
Unit mUnit;
|
||||
Unit pUnit;
|
||||
MeasurementsType mType;
|
||||
qreal currentSize;
|
||||
qreal currentHeight;
|
||||
int currentDimensionA{0};
|
||||
int currentDimensionB{0};
|
||||
int currentDimensionC{0};
|
||||
QString curFile;
|
||||
QComboBox *gradationHeights;
|
||||
QComboBox *gradationSizes;
|
||||
|
|
|
@ -499,8 +499,8 @@ bool MainWindow::LoadMeasurements(const QString &path)
|
|||
return false;
|
||||
}
|
||||
|
||||
const qreal size = UnitConvertor(m->BaseSize(), m->MUnit(), *m->GetData()->GetPatternUnit());
|
||||
const qreal height = UnitConvertor(m->BaseHeight(), m->MUnit(), *m->GetData()->GetPatternUnit());
|
||||
const qreal size = UnitConvertor(m->DimensionABase(), m->MUnit(), *m->GetData()->GetPatternUnit());
|
||||
const qreal height = UnitConvertor(m->DimensionBBase(), m->MUnit(), *m->GetData()->GetPatternUnit());
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -34,12 +34,16 @@
|
|||
|
||||
enum class MeasurementDimension: qint8
|
||||
{
|
||||
X, // height
|
||||
Y, // size (chest half circumference)
|
||||
W, // hip half circumference
|
||||
Z // waist half circumference
|
||||
X = 0, // height
|
||||
Y = 1, // size (chest half circumference)
|
||||
W = 2, // hip half circumference
|
||||
Z = 3 // waist half circumference
|
||||
};
|
||||
|
||||
class VAbstartMeasurementDimension;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
using MeasurementDimension_p = QSharedPointer<VAbstartMeasurementDimension>;
|
||||
|
||||
class VAbstartMeasurementDimension
|
||||
{
|
||||
|
|
|
@ -60,8 +60,6 @@ const QString VMeasurements::TagVST = QStringLiteral("vst");
|
|||
const QString VMeasurements::TagVIT = QStringLiteral("vit");
|
||||
const QString VMeasurements::TagBodyMeasurements = QStringLiteral("body-measurements");
|
||||
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::TagCustomer = QStringLiteral("customer");
|
||||
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::TagReadOnly = QStringLiteral("read-only");
|
||||
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::AttrValue = QStringLiteral("value");
|
||||
|
@ -78,11 +79,20 @@ const QString VMeasurements::AttrHeightIncrease = QStringLiteral("height_increas
|
|||
const QString VMeasurements::AttrDescription = QStringLiteral("description");
|
||||
const QString VMeasurements::AttrName = QStringLiteral("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::GenderFemale = QStringLiteral("female");
|
||||
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
|
||||
{
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, defBirthDate, (QLatin1String("1800-01-01")))
|
||||
|
@ -116,14 +126,15 @@ VMeasurements::VMeasurements(Unit unit, VContainer *data)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VMeasurements::VMeasurements(Unit unit, int baseSize, int baseHeight, VContainer *data)
|
||||
VMeasurements::VMeasurements(Unit unit, const QVector<MeasurementDimension_p > &dimensions,
|
||||
VContainer *data)
|
||||
:VDomDocument(),
|
||||
data(data),
|
||||
type(MeasurementsType::Multisize)
|
||||
{
|
||||
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 kheight = GetParametrDouble(dom, AttrHeightIncrease, QChar('0'));
|
||||
|
||||
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, BaseSize(),
|
||||
BaseHeight(), base, ksize, kheight));
|
||||
tempMeash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, DimensionABase(),
|
||||
DimensionBBase(), base, ksize, kheight));
|
||||
tempMeash->SetSize(size);
|
||||
tempMeash->SetHeight(height);
|
||||
tempMeash->SetUnit(data->GetPatternUnit());
|
||||
|
@ -292,8 +303,8 @@ void VMeasurements::ReadMeasurements(qreal height, qreal size) const
|
|||
ksize = UnitConvertor(ksize, MUnit(), *data->GetPatternUnit());
|
||||
kheight = UnitConvertor(kheight, MUnit(), *data->GetPatternUnit());
|
||||
|
||||
const qreal baseSize = UnitConvertor(BaseSize(), MUnit(), *data->GetPatternUnit());
|
||||
const qreal baseHeight = UnitConvertor(BaseHeight(), MUnit(), *data->GetPatternUnit());
|
||||
const qreal baseSize = UnitConvertor(DimensionABase(), MUnit(), *data->GetPatternUnit());
|
||||
const qreal baseHeight = UnitConvertor(DimensionBBase(), MUnit(), *data->GetPatternUnit());
|
||||
|
||||
meash = QSharedPointer<VMeasurement>(new VMeasurement(static_cast<quint32>(i), name, baseSize, baseHeight,
|
||||
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)
|
||||
{
|
||||
return static_cast<int>(UniqueTagAttr(TagSize, AttrBase, 50));
|
||||
}
|
||||
else
|
||||
const auto dimensions = Dimensions();
|
||||
if (not dimensions.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
return dimensions.first()->BaseValue();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::BaseHeight() const
|
||||
int VMeasurements::DimensionBBase() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
return static_cast<int>(UniqueTagAttr(TagHeight, AttrBase, 176));
|
||||
}
|
||||
else
|
||||
const auto dimensions = Dimensions();
|
||||
if (not dimensions.isEmpty() && dimensions.size() >= 2)
|
||||
{
|
||||
return 0;
|
||||
return dimensions.values().at(1)->BaseValue();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VMeasurements::DimensionCBase() const
|
||||
{
|
||||
if (type == MeasurementsType::Multisize)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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();
|
||||
QDomElement mElement = this->createElement(TagVST);
|
||||
|
@ -683,15 +788,8 @@ void VMeasurements::CreateEmptyMultisizeFile(Unit unit, int baseSize, int baseHe
|
|||
mElement.appendChild(createElement(TagNotes));
|
||||
mElement.appendChild(CreateElementWithText(TagUnit, UnitsToStr(unit)));
|
||||
mElement.appendChild(CreateElementWithText(TagPMSystem, ClearPMCode(p998_S)));
|
||||
|
||||
QDomElement size = createElement(TagSize);
|
||||
SetAttribute(size, AttrBase, QString().setNum(baseSize));
|
||||
mElement.appendChild(size);
|
||||
|
||||
QDomElement height = createElement(TagHeight);
|
||||
SetAttribute(height, AttrBase, QString().setNum(baseHeight));
|
||||
mElement.appendChild(height);
|
||||
|
||||
mElement.appendChild(CreateDimensions(dimensions));
|
||||
mElement.appendChild(createElement(TagRestrictions));
|
||||
mElement.appendChild(createElement(TagBodyMeasurements));
|
||||
|
||||
this->appendChild(mElement);
|
||||
|
@ -727,6 +825,32 @@ void VMeasurements::CreateEmptyIndividualFile(Unit unit)
|
|||
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
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../vmisc/def.h"
|
||||
#include "vdimensions.h"
|
||||
|
||||
class VContainer;
|
||||
|
||||
|
@ -49,7 +50,8 @@ class VMeasurements : public VDomDocument
|
|||
public:
|
||||
explicit VMeasurements(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 void setXMLContent(const QString &fileName) override;
|
||||
|
@ -69,8 +71,9 @@ public:
|
|||
void ClearForExport();
|
||||
|
||||
MeasurementsType Type() const;
|
||||
int BaseSize() const;
|
||||
int BaseHeight() const;
|
||||
int DimensionABase() const;
|
||||
int DimensionBBase() const;
|
||||
int DimensionCBase() const;
|
||||
|
||||
QString Notes() const;
|
||||
void SetNotes(const QString &text);
|
||||
|
@ -101,12 +104,12 @@ public:
|
|||
void SetMDescription(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 TagVIT;
|
||||
static const QString TagBodyMeasurements;
|
||||
static const QString TagNotes;
|
||||
static const QString TagSize;
|
||||
static const QString TagHeight;
|
||||
static const QString TagPersonal;
|
||||
static const QString TagCustomer;
|
||||
static const QString TagBirthDate;
|
||||
|
@ -115,6 +118,9 @@ public:
|
|||
static const QString TagEmail;
|
||||
static const QString TagReadOnly;
|
||||
static const QString TagMeasurement;
|
||||
static const QString TagDimensions;
|
||||
static const QString TagDimension;
|
||||
static const QString TagRestrictions;
|
||||
|
||||
static const QString AttrBase;
|
||||
static const QString AttrValue;
|
||||
|
@ -123,14 +129,26 @@ public:
|
|||
static const QString AttrDescription;
|
||||
static const QString AttrName;
|
||||
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 GenderFemale;
|
||||
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 GenderType StrToGender(const QString &sex);
|
||||
|
||||
static QString DimensionTypeToStr(const MeasurementDimension &type);
|
||||
static MeasurementDimension StrToDimensionType(const QString &type);
|
||||
|
||||
QStringList ListAll() const;
|
||||
QStringList ListKnown() const;
|
||||
|
||||
|
@ -148,9 +166,11 @@ private:
|
|||
/** @brief m_keepNames store names in container to check uniqueness. */
|
||||
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);
|
||||
|
||||
QDomElement CreateDimensions(const QVector<MeasurementDimension_p > &dimensions);
|
||||
|
||||
qreal UniqueTagAttr(const QString &tag, const QString &attr, qreal defValue) const;
|
||||
|
||||
QDomElement MakeEmpty(const QString &name, const QString &formula);
|
||||
|
|
|
@ -57,7 +57,7 @@ void TST_VMeasurements::CreateEmptyMultisizeFile()
|
|||
data->SetSize(size);
|
||||
|
||||
QSharedPointer<VMeasurements> m =
|
||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, size, height, data.data()));
|
||||
QSharedPointer<VMeasurements>(new VMeasurements(mUnit, /*size, height,*/ data.data()));
|
||||
|
||||
QTemporaryFile file;
|
||||
QString fileName;
|
||||
|
@ -147,7 +147,7 @@ void TST_VMeasurements::ValidPMCodesMultisizeFile()
|
|||
data->SetSize(size);
|
||||
|
||||
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();
|
||||
for (int i = 0; i < listSystems.size(); ++i)
|
||||
|
|
Loading…
Reference in New Issue
Block a user