diff --git a/share/resources/schema/standard_measurements.xsd b/share/resources/schema/standard_measurements.xsd index 7159630a7..98f4759ad 100644 --- a/share/resources/schema/standard_measurements.xsd +++ b/share/resources/schema/standard_measurements.xsd @@ -5,6 +5,18 @@ + + + + + + + + + + + + diff --git a/share/tables/standard/GOST_man_ru.vst b/share/tables/standard/GOST_man_ru.vst index b0289246d..4d61516ab 100644 --- a/share/tables/standard/GOST_man_ru.vst +++ b/share/tables/standard/GOST_man_ru.vst @@ -1,6 +1,8 @@ - Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см + Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см mm + + @@ -16,8 +18,8 @@ - - + + diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp index 2f2f4a0d9..3dc327aa2 100644 --- a/src/container/vcontainer.cpp +++ b/src/container/vcontainer.cpp @@ -34,14 +34,11 @@ quint32 VContainer::_id = 0; VContainer::VContainer() - :base(QHash()), gObjects(QHash()), + :_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash()), standardTable(QHash()), incrementTable(QHash()), lengthLines(QHash()), lineAngles(QHash()), lengthSplines(QHash()), lengthArcs(QHash()), details(QHash()) { - SetSize(500); - SetGrowth(1760); - CreateManTableIGroup (); } VContainer &VContainer::operator =(const VContainer &data) @@ -51,7 +48,7 @@ VContainer &VContainer::operator =(const VContainer &data) } VContainer::VContainer(const VContainer &data) - :base(QHash()), gObjects(QHash()), + :_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash()), standardTable(QHash()), incrementTable(QHash()), lengthLines(QHash()), lineAngles(QHash()), lengthSplines(QHash()), lengthArcs(QHash()), details(QHash()) @@ -67,7 +64,10 @@ VContainer::~VContainer() void VContainer::setData(const VContainer &data) { - base = *data.DataBase(); + _size = data.size(); + sizeName = data.SizeName(); + _height = data.height(); + heightName = data.HeightName(); qDeleteAll(gObjects); gObjects.clear(); @@ -248,21 +248,21 @@ void VContainer::AddLineAngle(const QString &name, const qreal &value) lineAngles[name] = value; } -qreal VContainer::GetValueStandardTableCell(const QString& name) const +qreal VContainer::GetValueStandardTableRow(const QString& name) const { - VStandardTableRow cell = GetStandardTableCell(name); - qreal k_size = ( static_cast (size()/10.0) - 50.0 ) / 2.0; - qreal k_growth = ( static_cast (growth()/10.0) - 176.0 ) / 6.0; - qreal value = cell.GetBase() + k_size*cell.GetKsize() + k_growth*cell.GetKgrowth(); + const VStandardTableRow row = GetStandardTableCell(name); + const qreal k_size = ( size() - 50.0 ) / 2.0; + const qreal k_growth = ( height() - 176.0 ) / 6.0; + const qreal value = row.GetBase() + k_size * row.GetKsize() + k_growth * row.GetKgrowth(); return value; } qreal VContainer::GetValueIncrementTableRow(const QString& name) const { - VIncrementTableRow cell = GetIncrementTableRow(name); - qreal k_size = ( static_cast (size()/10.0) - 50.0 ) / 2.0; - qreal k_growth = ( static_cast (growth()/10.0) - 176.0 ) / 6.0; - qreal value = cell.getBase() + k_size*cell.getKsize() + k_growth*cell.getKgrowth(); + const VIncrementTableRow row = GetIncrementTableRow(name); + const qreal k_size = ( size() - 50.0 ) / 2.0; + const qreal k_growth = ( height() - 176.0 ) / 6.0; + const qreal value = row.getBase() + k_size * row.getKsize() + k_growth * row.getKgrowth(); return value; } @@ -307,16 +307,20 @@ void VContainer::ClearCalculationGObjects() qreal VContainer::FindVar(const QString &name, bool *ok)const { - if (base.contains(name)) + if (sizeName == name) { *ok = true; - return base.value(name); + return _size; + } + if (heightName == name) + { + *ok = true; + return _height; } - if (standardTable.contains(name)) { *ok = true; - return GetValueStandardTableCell(name); + return GetValueStandardTableRow(name); } if (incrementTable.contains(name)) { @@ -400,65 +404,3 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value) Q_ASSERT(name.isEmpty() == false); lengthLines[name] = value; } - -void VContainer::CreateManTableIGroup () -{ - AddStandardTableCell("Pkor", VStandardTableRow(84, 0, 3)); - AddStandardTableCell("Vtos", VStandardTableRow(1450, 2, 51)); - AddStandardTableCell("Vtosh", VStandardTableRow(1506, 2, 54)); - AddStandardTableCell("Vpt", VStandardTableRow(1438, 3, 52)); - AddStandardTableCell("Vst", VStandardTableRow(1257, -1, 49)); - AddStandardTableCell("Vlt", VStandardTableRow(1102, 0, 43)); - AddStandardTableCell("Vk", VStandardTableRow(503, 0, 22)); - AddStandardTableCell("Vsht", VStandardTableRow(1522, 2, 54)); - AddStandardTableCell("Vzy", VStandardTableRow(1328, 0, 49)); - AddStandardTableCell("Vlop", VStandardTableRow(1320, 0, 49)); - AddStandardTableCell("Vps", VStandardTableRow(811, -1, 36)); - AddStandardTableCell("Ssh", VStandardTableRow(202, 4, 1)); - AddStandardTableCell("SgI", VStandardTableRow(517, 18, 2)); - AddStandardTableCell("SgII", VStandardTableRow(522, 19, 1)); - AddStandardTableCell("SgIII", VStandardTableRow(500, 20, 0)); - AddStandardTableCell("SbI", VStandardTableRow(482, 12, 6)); - AddStandardTableCell("Obed", VStandardTableRow(566, 18, 6)); - AddStandardTableCell("Ok", VStandardTableRow(386, 8, 8)); - AddStandardTableCell("Oi", VStandardTableRow(380, 8, 6)); - AddStandardTableCell("Osch", VStandardTableRow(234, 4, 4)); - AddStandardTableCell("Dsb", VStandardTableRow(1120, 0, 44)); - AddStandardTableCell("Dsp", VStandardTableRow(1110, 0, 43)); - AddStandardTableCell("Dn", VStandardTableRow(826, -3, 37)); - AddStandardTableCell("Dps", VStandardTableRow(316, 4, 7)); - AddStandardTableCell("Dpob", VStandardTableRow(783, 14, 15)); - AddStandardTableCell("Ds", VStandardTableRow(260, 1, 6)); - AddStandardTableCell("Op", VStandardTableRow(316, 12, 0)); - AddStandardTableCell("Ozap", VStandardTableRow(180, 4, 0)); - AddStandardTableCell("Pkis", VStandardTableRow(250, 4, 0)); - AddStandardTableCell("SHp", VStandardTableRow(160, 1, 4)); - AddStandardTableCell("Dlych", VStandardTableRow(500, 2, 15)); - AddStandardTableCell("Dzap", VStandardTableRow(768, 2, 24)); - AddStandardTableCell("DIIIp", VStandardTableRow(970, 2, 29)); - AddStandardTableCell("Vprp", VStandardTableRow(214, 3, 3)); - AddStandardTableCell("Vg", VStandardTableRow(262, 8, 3)); - AddStandardTableCell("Dtp", VStandardTableRow(460, 7, 9)); - AddStandardTableCell("Dp", VStandardTableRow(355, 5, 5)); - AddStandardTableCell("Vprz", VStandardTableRow(208, 3, 5)); - AddStandardTableCell("Dts", VStandardTableRow(438, 2, 10)); - AddStandardTableCell("DtsI", VStandardTableRow(469, 2, 10)); - AddStandardTableCell("Dvcht", VStandardTableRow(929, 9, 19)); - AddStandardTableCell("SHg", VStandardTableRow(370, 14, 4)); - AddStandardTableCell("Cg", VStandardTableRow(224, 6, 0)); - AddStandardTableCell("SHs", VStandardTableRow(416, 10, 2)); - AddStandardTableCell("dpzr", VStandardTableRow(121, 6, 0)); - AddStandardTableCell("Ogol", VStandardTableRow(576, 4, 4)); - AddStandardTableCell("Ssh1", VStandardTableRow(205, 5, 0)); - - //TODO Posible duplicate. Need check. - //AddStandardTableCell("St", VStandardTableRow(410, 20, 0)); - AddStandardTableCell("St", VStandardTableRow(390, 20, 0)); - - AddStandardTableCell("Drzap", VStandardTableRow(594, 3, 19)); - AddStandardTableCell("DbII", VStandardTableRow(1020, 0, 44)); - - //TODO Posible duplicate. Need check. - //AddStandardTableCell("Sb", VStandardTableRow(504, 15, 4)); - AddStandardTableCell("Sb", VStandardTableRow(492, 15, 5)); -} diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h index 03c2e66cd..08e7c1f07 100644 --- a/src/container/vcontainer.h +++ b/src/container/vcontainer.h @@ -166,11 +166,11 @@ public: */ quint32 AddDetail(VDetail detail); /** - * @brief AddStandardTableCell add new row of standard table + * @brief AddStandardTableRow add new row of standard table * @param name name of row of standard table - * @param cell row of standard table + * @param row row of standard table */ - void AddStandardTableCell(const QString& name, const VStandardTableRow &cell); + void AddStandardTableRow(const QString& name, const VStandardTableRow &row); /** * @brief AddIncrementTableRow add new row of increment table * @param name name of new row of increment table @@ -252,7 +252,7 @@ public: * @param name name of row * @return value in mm */ - qreal GetValueStandardTableCell(const QString& name) const; + qreal GetValueStandardTableRow(const QString& name) const; /** * @brief GetValueIncrementTableRow return value of increment table row by name * @param name name of row @@ -291,24 +291,28 @@ public: void ClearDetails(); /** * @brief SetSize set value of size - * @param size value of size in mm + * @param size value of size */ - void SetSize(qint32 size); + void SetSize(qreal size); + void SetSizeName(const QString &name); /** * @brief SetGrowth set value of growth - * @param growth value of growth in mm + * @param growth value of growth */ - void SetGrowth(qint32 growth); + void SetHeight(qreal height); + void SetHeightName(const QString &name); /** * @brief size return size * @return size in mm */ - qint32 size() const; + qreal size() const; + QString SizeName()const; /** - * @brief growth return growth - * @return growth in mm + * @brief height return height + * @return height in pattern units */ - qint32 growth() const; + qreal height() const; + QString HeightName()const; /** * @brief FindVar return value of variable by name * @param name name of variable @@ -337,11 +341,6 @@ public: * @return pointer on container of gObjects */ const QHash *DataGObjects() const; - /** - * @brief data container with dataBase return container of data - * @return pointer on container of base data - */ - const QHash *DataBase() const; /** * @brief data container with dataStandardTable return container of standard table * @return pointer on container of standard table @@ -382,19 +381,15 @@ public: * @param newId id */ static void UpdateId(quint32 newId); - /** - * @brief CreateManTableIGroup generate man standard table of measurements - */ - void CreateManTableIGroup (); private: /** * @brief _id current id. New object will have value +1. For empty class equal 0. */ static quint32 _id; - /** - * @brief base container of base data (size and growth) - */ - QHash base; + qreal _size; + QString sizeName; + qreal _height; + QString heightName; /** * @brief gObjects graphicals objects of pattern. */ @@ -463,9 +458,9 @@ private: static quint32 AddObject(QHash &obj, val value); }; -inline void VContainer::AddStandardTableCell(const QString &name, const VStandardTableRow &cell) +inline void VContainer::AddStandardTableRow(const QString &name, const VStandardTableRow &row) { - standardTable[name] = cell; + standardTable[name] = row; } inline void VContainer::UpdateStandardTableCell(const QString &name, VStandardTableRow cell) @@ -508,24 +503,44 @@ inline void VContainer::ClearDetails() details.clear(); } -inline void VContainer::SetSize(qint32 size) +inline void VContainer::SetSize(qreal size) { - base["Сг"] = size; + _size = size; } -inline void VContainer::SetGrowth(qint32 growth) +inline void VContainer::SetSizeName(const QString &name) { - base["Р"] = growth; + sizeName = name; } -inline qint32 VContainer::size() const +inline void VContainer::SetHeight(qreal height) { - return base.value("Сг"); + _height = height; } -inline qint32 VContainer::growth() const +inline void VContainer::SetHeightName(const QString &name) { - return base.value("Р"); + heightName = name; +} + +inline qreal VContainer::size() const +{ + return _size; +} + +inline QString VContainer::SizeName() const +{ + return sizeName; +} + +inline qreal VContainer::height() const +{ + return _height; +} + +inline QString VContainer::HeightName() const +{ + return heightName; } inline bool VContainer::IncrementTableContains(const QString &name) @@ -543,11 +558,6 @@ inline const QHash *VContainer::DataGObjects() const return &gObjects; } -inline const QHash *VContainer::DataBase() const -{ - return &base; -} - inline const QHash *VContainer::DataStandardTable() const { return &standardTable; diff --git a/src/container/vstandardtablerow.cpp b/src/container/vstandardtablerow.cpp index 0c2586cc9..a150460df 100644 --- a/src/container/vstandardtablerow.cpp +++ b/src/container/vstandardtablerow.cpp @@ -29,8 +29,8 @@ #include "vstandardtablerow.h" VStandardTableRow::VStandardTableRow() - :base(0), ksize(0), kgrowth(0), description(QString()){} + :base(0), ksize(0), kgrowth(0), gui_text(QString()), number(QString()){} -VStandardTableRow::VStandardTableRow(const qint32 &base, const qreal &ksize, const qreal &kgrowth, - const QString &description) - :base(base), ksize(ksize), kgrowth(kgrowth), description(description){} +VStandardTableRow::VStandardTableRow(const qreal &base, const qreal &ksize, const qreal &kgrowth, + const QString &description, const QString &number) + :base(base), ksize(ksize), kgrowth(kgrowth), gui_text(description), number(number){} diff --git a/src/container/vstandardtablerow.h b/src/container/vstandardtablerow.h index 5dafdbac6..6305e6746 100644 --- a/src/container/vstandardtablerow.h +++ b/src/container/vstandardtablerow.h @@ -48,14 +48,14 @@ public: * @param kgrowth increment in growths * @param description description of increment */ - VStandardTableRow(const qint32 &base, const qreal &ksize, const qreal &kgrowth, - const QString &description = QString()); + VStandardTableRow(const qreal &base, const qreal &ksize, const qreal &kgrowth, + const QString &gui_text = QString(), const QString &number = QString()); ~VStandardTableRow(){} /** * @brief GetBase return value in base size and growth * @return value */ - qint32 GetBase() const; + qreal GetBase() const; /** * @brief GetKsize return increment in sizes * @return increment @@ -71,11 +71,12 @@ public: * @return description */ QString GetDescription() const; + QString GetNumber() const; private: /** * @brief base value in base size and growth */ - qint32 base; + qreal base; /** * @brief ksize increment in sizes */ @@ -87,10 +88,11 @@ private: /** * @brief description description measurement */ - QString description; + QString gui_text; + QString number; }; -inline qint32 VStandardTableRow::GetBase() const +inline qreal VStandardTableRow::GetBase() const { return base; } @@ -107,7 +109,12 @@ inline qreal VStandardTableRow::GetKgrowth() const inline QString VStandardTableRow::GetDescription() const { - return description; + return gui_text; +} + +inline QString VStandardTableRow::GetNumber() const +{ + return number; } #endif // VSTANDARDTABLEROW_H diff --git a/src/dialogs/app/dialogincrements.cpp b/src/dialogs/app/dialogincrements.cpp index 38cda7ffe..96b27bae5 100644 --- a/src/dialogs/app/dialogincrements.cpp +++ b/src/dialogs/app/dialogincrements.cpp @@ -79,7 +79,7 @@ void DialogIncrements::FillStandardTable() item->setFont(QFont("Times", 12, QFont::Bold)); ui->tableWidgetStandard->setItem(currentRow, 0, item); - item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableCell(i.key()))); + item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(i.key()))); item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetStandard->setItem(currentRow, 1, item); diff --git a/src/dialogs/tools/dialogpointofcontact.cpp b/src/dialogs/tools/dialogpointofcontact.cpp index 334878e2b..0ff100e3d 100644 --- a/src/dialogs/tools/dialogpointofcontact.cpp +++ b/src/dialogs/tools/dialogpointofcontact.cpp @@ -67,8 +67,8 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); - ShowVariable(data->DataBase()); - connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeGrowth); + SizeHeight(); + connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeHeight); connect(ui.radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandardTable); connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); diff --git a/src/dialogs/tools/dialogtool.cpp b/src/dialogs/tools/dialogtool.cpp index 82ad1925f..ba6efc9aa 100644 --- a/src/dialogs/tools/dialogtool.cpp +++ b/src/dialogs/tools/dialogtool.cpp @@ -524,9 +524,24 @@ void DialogTool::EvalFormula() Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); } -void DialogTool::SizeGrowth() +void DialogTool::SizeHeight() { - ShowVariable(data->DataBase()); + Q_CHECK_PTR(listWidget); + disconnect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); + listWidget->clear(); + + { + QListWidgetItem *item = new QListWidgetItem(data->HeightName()); + item->setFont(QFont("Times", 12, QFont::Bold)); + listWidget->addItem(item); + } + + QListWidgetItem *item = new QListWidgetItem(data->SizeName()); + item->setFont(QFont("Times", 12, QFont::Bold)); + listWidget->addItem(item); + + connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); + listWidget->setCurrentRow (0); } void DialogTool::StandardTable() @@ -587,12 +602,12 @@ void DialogTool::ValChenged(int row) QListWidgetItem *item = listWidget->item( row ); if (radioButtonSizeGrowth->isChecked()) { - if (item->text()=="Р") + if (item->text()==data->HeightName()) { - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->growth()).arg(tr("Height")); + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->height()).arg(tr("Height")); labelDescription->setText(desc); } - if (item->text()=="Сг") + if (item->text()==data->SizeName()) { QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size")); labelDescription->setText(desc); @@ -602,7 +617,7 @@ void DialogTool::ValChenged(int row) if (radioButtonStandardTable->isChecked()) { VStandardTableRow stable = data->GetStandardTableCell(item->text()); - QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandardTableCell(item->text())) + QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetValueStandardTableRow(item->text())) .arg(stable.GetDescription()); labelDescription->setText(desc); return; @@ -649,7 +664,7 @@ void DialogTool::UpdateList() if (radioButtonSizeGrowth->isChecked()) { - ShowVariable(data->DataBase()); + SizeHeight(); } if (radioButtonStandardTable->isChecked()) { diff --git a/src/dialogs/tools/dialogtool.h b/src/dialogs/tools/dialogtool.h index dad41b0b5..054fcb015 100644 --- a/src/dialogs/tools/dialogtool.h +++ b/src/dialogs/tools/dialogtool.h @@ -137,9 +137,9 @@ public slots: */ void EvalFormula(); /** - * @brief SizeGrowth show in list base variables + * @brief SizeHeight show in list base variables */ - void SizeGrowth(); + void SizeHeight(); /** * @brief StandardTable show in list standard table variables */ @@ -428,8 +428,8 @@ protected: connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); - ShowVariable(data->DataBase()); - connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeGrowth); + SizeHeight(); + connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); connect(radioButtonStandardTable, &QRadioButton::clicked, this, &DialogTool::StandardTable); connect(radioButtonIncrements, &QRadioButton::clicked, this, &DialogTool::Increments); connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines); diff --git a/src/main.cpp b/src/main.cpp index aaedb8c55..f604eac08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,7 @@ #include "options.h" //Default pattern unit. -Valentina::Units patternUnit = Valentina::Mm; +Valentina::Units patternUnit = Valentina::Cm; #ifdef Q_OS_WIN const QString translationsPath = QString("/translations"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 591c56d5e..543875485 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -975,7 +975,7 @@ void MainWindow::ChangedSize(const QString & text) void MainWindow::ChangedHeight(const QString &text) { qint32 growth = text.toInt(); - pattern->SetGrowth(growth*10); + pattern->SetHeight(growth*10); doc->FullUpdateTree(); } diff --git a/src/xml/vdomdocument.h b/src/xml/vdomdocument.h index e1a944956..fe667ff64 100644 --- a/src/xml/vdomdocument.h +++ b/src/xml/vdomdocument.h @@ -111,7 +111,7 @@ public: * @return true if validation successful. */ static bool ValidatePattern(const QString &schema, const QString &fileName, QString &errorMsg, qint64 &errorLine, - qint64 &errorColumn); + qint64 &errorColumn); protected: /** * @brief data container with data. diff --git a/src/xml/vpattern.cpp b/src/xml/vpattern.cpp index 5131e3aa2..821feb487 100644 --- a/src/xml/vpattern.cpp +++ b/src/xml/vpattern.cpp @@ -1283,7 +1283,7 @@ void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsSc { TestUniqueId(); data->Clear(); - data->CreateManTableIGroup(); + emit UpdateMeasurements(); nameActivDraw.clear(); sceneDraw->clear(); sceneDetail->clear(); diff --git a/src/xml/vpattern.h b/src/xml/vpattern.h index d748f693a..102e53c0a 100644 --- a/src/xml/vpattern.h +++ b/src/xml/vpattern.h @@ -218,6 +218,7 @@ signals: * @param id tool id. */ void ChangedCursor(quint32 id); + void UpdateMeasurements(); public slots: /** * @brief FullUpdateTree lite parse file. diff --git a/src/xml/vstandardmeasurements.cpp b/src/xml/vstandardmeasurements.cpp index 1aaf4cf46..92c88a976 100644 --- a/src/xml/vstandardmeasurements.cpp +++ b/src/xml/vstandardmeasurements.cpp @@ -27,7 +27,158 @@ *************************************************************************/ #include "vstandardmeasurements.h" +#include VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data) { } + +Valentina::Units VStandardMeasurements::Unit() +{ + const QString unit = UniqueTagText("unit", "cm"); + QStringList units; + units << "mm" << "cm" << "in"; + Valentina::Units result = Valentina::Cm; + switch (units.indexOf(unit)) + { + case 0:// mm + result = Valentina::Mm; + break; + case 1:// cm + result = Valentina::Cm; + break; + case 2:// in + result = Valentina::In; + break; + default: + result = Valentina::Cm; + break; + } + return result; +} + +QString VStandardMeasurements::Description() +{ + const QString desc = UniqueTagText("description", ""); + if (desc.isEmpty()) + { + qWarning()<<"Empty description in standard table."<elementsByTagName("measurement"); + if (nodeList.isEmpty()) + { + qWarning()<<"Measurement list is empty"<AddStandardTableRow(name, VStandardTableRow(base/10.0, size_increace/10.0, + height_increase/10.0, gui_text, number)); + } + else//Cm or inch. + { + data->AddStandardTableRow(name, VStandardTableRow(base, size_increace, height_increase, + gui_text, number)); + } + } + } + } + } +} + +void VStandardMeasurements::SetSize() +{ + const QDomNodeList nodeList = this->elementsByTagName("size"); + if (nodeList.isEmpty()) + { + data->SetSize(50); + data->SetSizeName("Сг"); + } + else + { + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + const QString name = GetParametrString(domElement, "name", "Сг"); + const qreal base = GetParametrDouble(domElement, "base", "50.0"); + if (Unit() == Valentina::Mm)//Convert to Cm. + { + data->SetSize(base/10.0); + data->SetSizeName(name); + } + else//Cm or inch. + { + data->SetSize(base); + data->SetSizeName(name); + } + } + } + } +} + +void VStandardMeasurements::SetHeight() +{ + const QDomNodeList nodeList = this->elementsByTagName("height"); + if (nodeList.isEmpty()) + { + data->SetHeight(176); + data->SetHeightName("P"); + } + else + { + const QDomNode domNode = nodeList.at(0); + if (domNode.isNull() == false && domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + const QString name = GetParametrString(domElement, "name", "Р"); + const qreal base = GetParametrDouble(domElement, "base", "176.0"); + if (Unit() == Valentina::Mm)//Convert to Cm. + { + data->SetHeight(base/10.0); + data->SetHeightName(name); + } + else//Cm or inch. + { + data->SetHeight(base); + data->SetHeightName(name); + } + } + } + } +} + +void VStandardMeasurements::Update() +{ + Measurements(); +} diff --git a/src/xml/vstandardmeasurements.h b/src/xml/vstandardmeasurements.h index 003af3625..7df93d3c0 100644 --- a/src/xml/vstandardmeasurements.h +++ b/src/xml/vstandardmeasurements.h @@ -30,11 +30,20 @@ #define VSTANDARDMEASUREMENTS_H #include "vdomdocument.h" +#include "../options.h" -class VStandardMeasurements:public VDomDocument +class VStandardMeasurements:public QObject, public VDomDocument { + Q_OBJECT public: VStandardMeasurements(VContainer *data); + Valentina::Units Unit(); + QString Description(); + void Measurements(); + void SetSize(); + void SetHeight(); +public slots: + void Update(); }; #endif // VSTANDARDMEASUREMENTS_H