Parsing standard measurements table.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-11 22:19:13 +02:00
parent b2d26e5ae8
commit ed568678be
17 changed files with 303 additions and 154 deletions

View File

@ -5,6 +5,18 @@
<xs:sequence>
<xs:element name="description" type="xs:string"></xs:element>
<xs:element name="unit" type="xs:string"></xs:element>
<xs:element name="size">
<xs:complexType>
<xs:attribute name="base" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="height">
<xs:complexType>
<xs:attribute name="base" type="xs:double"></xs:attribute>
<xs:attribute name="name" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="measurements">
<xs:complexType>
<xs:sequence>

View File

@ -1,6 +1,8 @@
<vst>
<number>Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см</number>
<description>Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см</description>
<unit>mm</unit>
<size base="500" name="Сг"/>
<height base="1760" name="Р"/>
<measurements>
<measurement name="Втос" gui_text="Высота точки основания шеи спереди" base="1450" size_increace="2" height_increase ="51" number="98"/>
<measurement name="Втош" gui_text="Высота точки основания шеи сбоку" base="1506" size_increace="2" height_increase ="54" number="4"/>
@ -16,8 +18,8 @@
<measurement name="ОгI" gui_text="Обхват груди первый" base="1034" size_increace="36" height_increase ="4" number="14"/>
<measurement name="ОгII" gui_text="Обхват груди второй" base="1044" size_increace="38" height_increase ="2" number="15"/>
<measurement name="ОгIII" gui_text="Обхват груди третий" base="1000" size_increace="40" height_increase ="0" number="16"/>
<measurement name="От" gui_text="Обхват талии" base="780" size_increace="40" height_increase ="0" number="18"/>
<measurement name="Об" gui_text="Обхват бедер с учетом выступания живота" base="984" size_increace="30" height_increase ="10" number="19"/>
<measurement name="От" gui_text="Обхват талии" base="780" size_increace="40" height_increase ="0" number="18"/>
<measurement name="Об" gui_text="Обхват бедер с учетом выступания живота" base="984" size_increace="30" height_increase ="10" number="19"/>
<measurement name="ОбI" gui_text="Обхват бедер без учета выступания живота" base="964" size_increace="24" height_increase ="12" number="20"/>
<measurement name="Обед" gui_text="Обхват бедра" base="566" size_increace="18" height_increase ="6" number="21"/>
<measurement name="Ок" gui_text="Обхват колена" base="386" size_increace="8" height_increase ="8" number="22"/>

View File

@ -34,14 +34,11 @@
quint32 VContainer::_id = 0;
VContainer::VContainer()
:base(QHash<QString, qint32>()), gObjects(QHash<quint32, VGObject *>()),
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
standardTable(QHash<QString, VStandardTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
{
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<QString, qint32>()), gObjects(QHash<quint32, VGObject *>()),
:_size(50), sizeName("Сг"), _height(176), heightName("P"), gObjects(QHash<quint32, VGObject *>()),
standardTable(QHash<QString, VStandardTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
@ -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<qreal> (size()/10.0) - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (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<qreal> (size()/10.0) - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (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));
}

View File

@ -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<quint32, VGObject*> *DataGObjects() const;
/**
* @brief data container with dataBase return container of data
* @return pointer on container of base data
*/
const QHash<QString, qint32> *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<QString, qint32> base;
qreal _size;
QString sizeName;
qreal _height;
QString heightName;
/**
* @brief gObjects graphicals objects of pattern.
*/
@ -463,9 +458,9 @@ private:
static quint32 AddObject(QHash<key, val> &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<quint32, VGObject *> *VContainer::DataGObjects() const
return &gObjects;
}
inline const QHash<QString, qint32> *VContainer::DataBase() const
{
return &base;
}
inline const QHash<QString, VStandardTableRow> *VContainer::DataStandardTable() const
{
return &standardTable;

View File

@ -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){}

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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())
{

View File

@ -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);

View File

@ -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");

View File

@ -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();
}

View File

@ -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.

View File

@ -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();

View File

@ -218,6 +218,7 @@ signals:
* @param id tool id.
*/
void ChangedCursor(quint32 id);
void UpdateMeasurements();
public slots:
/**
* @brief FullUpdateTree lite parse file.

View File

@ -27,7 +27,158 @@
*************************************************************************/
#include "vstandardmeasurements.h"
#include <QDebug>
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."<<Q_FUNC_INFO;
}
return desc;
}
void VStandardMeasurements::Measurements()
{
const QDomNodeList nodeList = this->elementsByTagName("measurement");
if (nodeList.isEmpty())
{
qWarning()<<"Measurement list is empty"<<Q_FUNC_INFO;
return;
}
else
{
for(qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomNode domNode = nodeList.at(i);
if (domNode.isNull() == false && domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
const QString name = GetParametrString(domElement, "name", "");
if (name.isEmpty())
{
continue;
}
const QString gui_text = GetParametrString(domElement, "gui_text", "");
const qreal base = GetParametrDouble(domElement, "base", "0.0");
const qreal size_increace = GetParametrDouble(domElement, "size_increace", "0.0");
const qreal height_increase = GetParametrDouble(domElement, "height_increase", "0.0");
const QString number = GetParametrString(domElement, "number", "");
if (Unit() == Valentina::Mm)//Convert to Cm.
{
data->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();
}

View File

@ -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