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:sequence>
<xs:element name="description" type="xs:string"></xs:element> <xs:element name="description" type="xs:string"></xs:element>
<xs:element name="unit" 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:element name="measurements">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>

View File

@ -1,6 +1,8 @@
<vst> <vst>
<number>Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см</number> <description>Типовые фигуры мужчин 1-й полнотной группы, обхват груди 100 см</description>
<unit>mm</unit> <unit>mm</unit>
<size base="500" name="Сг"/>
<height base="1760" name="Р"/>
<measurements> <measurements>
<measurement name="Втос" gui_text="Высота точки основания шеи спереди" base="1450" size_increace="2" height_increase ="51" number="98"/> <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"/> <measurement name="Втош" gui_text="Высота точки основания шеи сбоку" base="1506" size_increace="2" height_increase ="54" number="4"/>

View File

@ -34,14 +34,11 @@
quint32 VContainer::_id = 0; quint32 VContainer::_id = 0;
VContainer::VContainer() 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>()), standardTable(QHash<QString, VStandardTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>()) lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
{ {
SetSize(500);
SetGrowth(1760);
CreateManTableIGroup ();
} }
VContainer &VContainer::operator =(const VContainer &data) VContainer &VContainer::operator =(const VContainer &data)
@ -51,7 +48,7 @@ VContainer &VContainer::operator =(const VContainer &data)
} }
VContainer::VContainer(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>()), standardTable(QHash<QString, VStandardTableRow>()), incrementTable(QHash<QString, VIncrementTableRow>()),
lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()), lengthLines(QHash<QString, qreal>()), lineAngles(QHash<QString, qreal>()), lengthSplines(QHash<QString, qreal>()),
lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>()) lengthArcs(QHash<QString, qreal>()), details(QHash<quint32, VDetail>())
@ -67,7 +64,10 @@ VContainer::~VContainer()
void VContainer::setData(const VContainer &data) void VContainer::setData(const VContainer &data)
{ {
base = *data.DataBase(); _size = data.size();
sizeName = data.SizeName();
_height = data.height();
heightName = data.HeightName();
qDeleteAll(gObjects); qDeleteAll(gObjects);
gObjects.clear(); gObjects.clear();
@ -248,21 +248,21 @@ void VContainer::AddLineAngle(const QString &name, const qreal &value)
lineAngles[name] = value; lineAngles[name] = value;
} }
qreal VContainer::GetValueStandardTableCell(const QString& name) const qreal VContainer::GetValueStandardTableRow(const QString& name) const
{ {
VStandardTableRow cell = GetStandardTableCell(name); const VStandardTableRow row = GetStandardTableCell(name);
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0; const qreal k_size = ( size() - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0; const qreal k_growth = ( height() - 176.0 ) / 6.0;
qreal value = cell.GetBase() + k_size*cell.GetKsize() + k_growth*cell.GetKgrowth(); const qreal value = row.GetBase() + k_size * row.GetKsize() + k_growth * row.GetKgrowth();
return value; return value;
} }
qreal VContainer::GetValueIncrementTableRow(const QString& name) const qreal VContainer::GetValueIncrementTableRow(const QString& name) const
{ {
VIncrementTableRow cell = GetIncrementTableRow(name); const VIncrementTableRow row = GetIncrementTableRow(name);
qreal k_size = ( static_cast<qreal> (size()/10.0) - 50.0 ) / 2.0; const qreal k_size = ( size() - 50.0 ) / 2.0;
qreal k_growth = ( static_cast<qreal> (growth()/10.0) - 176.0 ) / 6.0; const qreal k_growth = ( height() - 176.0 ) / 6.0;
qreal value = cell.getBase() + k_size*cell.getKsize() + k_growth*cell.getKgrowth(); const qreal value = row.getBase() + k_size * row.getKsize() + k_growth * row.getKgrowth();
return value; return value;
} }
@ -307,16 +307,20 @@ void VContainer::ClearCalculationGObjects()
qreal VContainer::FindVar(const QString &name, bool *ok)const qreal VContainer::FindVar(const QString &name, bool *ok)const
{ {
if (base.contains(name)) if (sizeName == name)
{ {
*ok = true; *ok = true;
return base.value(name); return _size;
}
if (heightName == name)
{
*ok = true;
return _height;
} }
if (standardTable.contains(name)) if (standardTable.contains(name))
{ {
*ok = true; *ok = true;
return GetValueStandardTableCell(name); return GetValueStandardTableRow(name);
} }
if (incrementTable.contains(name)) if (incrementTable.contains(name))
{ {
@ -400,65 +404,3 @@ void VContainer::AddLengthLine(const QString &name, const qreal &value)
Q_ASSERT(name.isEmpty() == false); Q_ASSERT(name.isEmpty() == false);
lengthLines[name] = value; 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); 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 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 * @brief AddIncrementTableRow add new row of increment table
* @param name name of new row of increment table * @param name name of new row of increment table
@ -252,7 +252,7 @@ public:
* @param name name of row * @param name name of row
* @return value in mm * @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 * @brief GetValueIncrementTableRow return value of increment table row by name
* @param name name of row * @param name name of row
@ -291,24 +291,28 @@ public:
void ClearDetails(); void ClearDetails();
/** /**
* @brief SetSize set value of size * @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 * @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 * @brief size return size
* @return size in mm * @return size in mm
*/ */
qint32 size() const; qreal size() const;
QString SizeName()const;
/** /**
* @brief growth return growth * @brief height return height
* @return growth in mm * @return height in pattern units
*/ */
qint32 growth() const; qreal height() const;
QString HeightName()const;
/** /**
* @brief FindVar return value of variable by name * @brief FindVar return value of variable by name
* @param name name of variable * @param name name of variable
@ -337,11 +341,6 @@ public:
* @return pointer on container of gObjects * @return pointer on container of gObjects
*/ */
const QHash<quint32, VGObject*> *DataGObjects() const; 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 * @brief data container with dataStandardTable return container of standard table
* @return pointer on container of standard table * @return pointer on container of standard table
@ -382,19 +381,15 @@ public:
* @param newId id * @param newId id
*/ */
static void UpdateId(quint32 newId); static void UpdateId(quint32 newId);
/**
* @brief CreateManTableIGroup generate man standard table of measurements
*/
void CreateManTableIGroup ();
private: private:
/** /**
* @brief _id current id. New object will have value +1. For empty class equal 0. * @brief _id current id. New object will have value +1. For empty class equal 0.
*/ */
static quint32 _id; static quint32 _id;
/** qreal _size;
* @brief base container of base data (size and growth) QString sizeName;
*/ qreal _height;
QHash<QString, qint32> base; QString heightName;
/** /**
* @brief gObjects graphicals objects of pattern. * @brief gObjects graphicals objects of pattern.
*/ */
@ -463,9 +458,9 @@ private:
static quint32 AddObject(QHash<key, val> &obj, val value); 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) inline void VContainer::UpdateStandardTableCell(const QString &name, VStandardTableRow cell)
@ -508,24 +503,44 @@ inline void VContainer::ClearDetails()
details.clear(); 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) inline bool VContainer::IncrementTableContains(const QString &name)
@ -543,11 +558,6 @@ inline const QHash<quint32, VGObject *> *VContainer::DataGObjects() const
return &gObjects; return &gObjects;
} }
inline const QHash<QString, qint32> *VContainer::DataBase() const
{
return &base;
}
inline const QHash<QString, VStandardTableRow> *VContainer::DataStandardTable() const inline const QHash<QString, VStandardTableRow> *VContainer::DataStandardTable() const
{ {
return &standardTable; return &standardTable;

View File

@ -29,8 +29,8 @@
#include "vstandardtablerow.h" #include "vstandardtablerow.h"
VStandardTableRow::VStandardTableRow() 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, VStandardTableRow::VStandardTableRow(const qreal &base, const qreal &ksize, const qreal &kgrowth,
const QString &description) const QString &description, const QString &number)
:base(base), ksize(ksize), kgrowth(kgrowth), description(description){} :base(base), ksize(ksize), kgrowth(kgrowth), gui_text(description), number(number){}

View File

@ -48,14 +48,14 @@ public:
* @param kgrowth increment in growths * @param kgrowth increment in growths
* @param description description of increment * @param description description of increment
*/ */
VStandardTableRow(const qint32 &base, const qreal &ksize, const qreal &kgrowth, VStandardTableRow(const qreal &base, const qreal &ksize, const qreal &kgrowth,
const QString &description = QString()); const QString &gui_text = QString(), const QString &number = QString());
~VStandardTableRow(){} ~VStandardTableRow(){}
/** /**
* @brief GetBase return value in base size and growth * @brief GetBase return value in base size and growth
* @return value * @return value
*/ */
qint32 GetBase() const; qreal GetBase() const;
/** /**
* @brief GetKsize return increment in sizes * @brief GetKsize return increment in sizes
* @return increment * @return increment
@ -71,11 +71,12 @@ public:
* @return description * @return description
*/ */
QString GetDescription() const; QString GetDescription() const;
QString GetNumber() const;
private: private:
/** /**
* @brief base value in base size and growth * @brief base value in base size and growth
*/ */
qint32 base; qreal base;
/** /**
* @brief ksize increment in sizes * @brief ksize increment in sizes
*/ */
@ -87,10 +88,11 @@ private:
/** /**
* @brief description description measurement * @brief description description measurement
*/ */
QString description; QString gui_text;
QString number;
}; };
inline qint32 VStandardTableRow::GetBase() const inline qreal VStandardTableRow::GetBase() const
{ {
return base; return base;
} }
@ -107,7 +109,12 @@ inline qreal VStandardTableRow::GetKgrowth() const
inline QString VStandardTableRow::GetDescription() const inline QString VStandardTableRow::GetDescription() const
{ {
return description; return gui_text;
}
inline QString VStandardTableRow::GetNumber() const
{
return number;
} }
#endif // VSTANDARDTABLEROW_H #endif // VSTANDARDTABLEROW_H

View File

@ -79,7 +79,7 @@ void DialogIncrements::FillStandardTable()
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
ui->tableWidgetStandard->setItem(currentRow, 0, item); 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); item->setTextAlignment(Qt::AlignHCenter);
ui->tableWidgetStandard->setItem(currentRow, 1, item); 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::itemDoubleClicked, this, &DialogPointOfContact::PutVal);
connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged);
ShowVariable(data->DataBase()); SizeHeight();
connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeGrowth); connect(ui.radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogPointOfContact::SizeHeight);
connect(ui.radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandardTable); connect(ui.radioButtonStandardTable, &QRadioButton::clicked, this, &DialogPointOfContact::StandardTable);
connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments); connect(ui.radioButtonIncrements, &QRadioButton::clicked, this, &DialogPointOfContact::Increments);
connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines); connect(ui.radioButtonLengthLine, &QRadioButton::clicked, this, &DialogPointOfContact::LengthLines);

View File

@ -524,9 +524,24 @@ void DialogTool::EvalFormula()
Eval(lineEditFormula, flagFormula, timerFormula, labelResultCalculation); 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() void DialogTool::StandardTable()
@ -587,12 +602,12 @@ void DialogTool::ValChenged(int row)
QListWidgetItem *item = listWidget->item( row ); QListWidgetItem *item = listWidget->item( row );
if (radioButtonSizeGrowth->isChecked()) 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); 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")); QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->size()).arg(tr("Size"));
labelDescription->setText(desc); labelDescription->setText(desc);
@ -602,7 +617,7 @@ void DialogTool::ValChenged(int row)
if (radioButtonStandardTable->isChecked()) if (radioButtonStandardTable->isChecked())
{ {
VStandardTableRow stable = data->GetStandardTableCell(item->text()); 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()); .arg(stable.GetDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
return; return;
@ -649,7 +664,7 @@ void DialogTool::UpdateList()
if (radioButtonSizeGrowth->isChecked()) if (radioButtonSizeGrowth->isChecked())
{ {
ShowVariable(data->DataBase()); SizeHeight();
} }
if (radioButtonStandardTable->isChecked()) if (radioButtonStandardTable->isChecked())
{ {

View File

@ -137,9 +137,9 @@ public slots:
*/ */
void EvalFormula(); 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 * @brief StandardTable show in list standard table variables
*/ */
@ -428,8 +428,8 @@ protected:
connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged);
ShowVariable(data->DataBase()); SizeHeight();
connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeGrowth); connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight);
connect(radioButtonStandardTable, &QRadioButton::clicked, this, &DialogTool::StandardTable); connect(radioButtonStandardTable, &QRadioButton::clicked, this, &DialogTool::StandardTable);
connect(radioButtonIncrements, &QRadioButton::clicked, this, &DialogTool::Increments); connect(radioButtonIncrements, &QRadioButton::clicked, this, &DialogTool::Increments);
connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines); connect(radioButtonLengthLine, &QRadioButton::clicked, this, &DialogTool::LengthLines);

View File

@ -34,7 +34,7 @@
#include "options.h" #include "options.h"
//Default pattern unit. //Default pattern unit.
Valentina::Units patternUnit = Valentina::Mm; Valentina::Units patternUnit = Valentina::Cm;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
const QString translationsPath = QString("/translations"); const QString translationsPath = QString("/translations");

View File

@ -975,7 +975,7 @@ void MainWindow::ChangedSize(const QString & text)
void MainWindow::ChangedHeight(const QString &text) void MainWindow::ChangedHeight(const QString &text)
{ {
qint32 growth = text.toInt(); qint32 growth = text.toInt();
pattern->SetGrowth(growth*10); pattern->SetHeight(growth*10);
doc->FullUpdateTree(); doc->FullUpdateTree();
} }

View File

@ -1283,7 +1283,7 @@ void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsSc
{ {
TestUniqueId(); TestUniqueId();
data->Clear(); data->Clear();
data->CreateManTableIGroup(); emit UpdateMeasurements();
nameActivDraw.clear(); nameActivDraw.clear();
sceneDraw->clear(); sceneDraw->clear();
sceneDetail->clear(); sceneDetail->clear();

View File

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

View File

@ -27,7 +27,158 @@
*************************************************************************/ *************************************************************************/
#include "vstandardmeasurements.h" #include "vstandardmeasurements.h"
#include <QDebug>
VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data) 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 #define VSTANDARDMEASUREMENTS_H
#include "vdomdocument.h" #include "vdomdocument.h"
#include "../options.h"
class VStandardMeasurements:public VDomDocument class VStandardMeasurements:public QObject, public VDomDocument
{ {
Q_OBJECT
public: public:
VStandardMeasurements(VContainer *data); VStandardMeasurements(VContainer *data);
Valentina::Units Unit();
QString Description();
void Measurements();
void SetSize();
void SetHeight();
public slots:
void Update();
}; };
#endif // VSTANDARDMEASUREMENTS_H #endif // VSTANDARDMEASUREMENTS_H