Change for reading standard measurements.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-16 13:34:12 +03:00
parent 3fc99547fb
commit 91c7a3c9a3
2 changed files with 173 additions and 57 deletions

View File

@ -28,17 +28,14 @@
#include "vstandardmeasurements.h" #include "vstandardmeasurements.h"
#include <QDebug> #include <QDebug>
#include "../widgets/vapplication.h"
const QString VStandardMeasurements::TagMeasurement = QStringLiteral("measurement");
const QString VStandardMeasurements::TagDescription = QStringLiteral("description"); const QString VStandardMeasurements::TagDescription = QStringLiteral("description");
const QString VStandardMeasurements::TagSize = QStringLiteral("size"); const QString VStandardMeasurements::TagSize = QStringLiteral("size");
const QString VStandardMeasurements::TagHeight = QStringLiteral("height"); const QString VStandardMeasurements::TagHeight = QStringLiteral("height");
const QString VStandardMeasurements::AttrName = QStringLiteral("name"); const QString VStandardMeasurements::AttrValue = QStringLiteral("value");
const QString VStandardMeasurements::AttrGui_text = QStringLiteral("gui_text");
const QString VStandardMeasurements::AttrBase = QStringLiteral("base");
const QString VStandardMeasurements::AttrSize_increace = QStringLiteral("size_increace"); const QString VStandardMeasurements::AttrSize_increace = QStringLiteral("size_increace");
const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase"); const QString VStandardMeasurements::AttrHeight_increase = QStringLiteral("height_increase");
const QString VStandardMeasurements::AttrNumber = QStringLiteral("number");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data) VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data)
@ -65,43 +62,173 @@ QString VStandardMeasurements::Description()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::Measurements() void VStandardMeasurements::Measurements()
{ {
const QDomNodeList nodeList = this->elementsByTagName(TagMeasurement); //head and neck
Measurement(headGirth);
Measurement(midNeckGirth);
Measurement(neckBaseGirth);
Measurement(headAndNeckLength);
//torso
Measurement(centerFrontWaistLength);
Measurement(centerBackWaistLength);
Measurement(shoulderLength);
Measurement(sideWaistLength);
Measurement(trunkLength);
Measurement(shoulderGirth);
Measurement(upperChestGirth);
Measurement(bustGirth);
Measurement(underBustGirth);
Measurement(waistGirth);
Measurement(highHipGirth);
Measurement(hipGirth);
Measurement(upperFrontChestWidth);
Measurement(frontChestWidth);
Measurement(acrossFrontShoulderWidth);
Measurement(acrossBackShoulderWidth);
Measurement(upperBackWidth);
Measurement(backWidth);
Measurement(bustpointToBustpoint);
Measurement(halterBustpointToBustpoint);
Measurement(neckToBustpoint);
Measurement(crotchLength);
Measurement(riseHeight);
Measurement(shoulderDrop);
Measurement(shoulderSlopeDegrees);
Measurement(frontShoulderSlopeLength);
Measurement(backShoulderSlopeLength);
Measurement(frontShoulderToWaistLength);
Measurement(backShoulderToWaistLength);
Measurement(frontNeckArc);
Measurement(backNeckArc);
Measurement(frontUpperChestArc);
Measurement(backUpperChestArc);
Measurement(frontWaistArc);
Measurement(backWaistArc);
Measurement(frontUpperHipArc);
Measurement(backUpperHipArc);
Measurement(frontHipArc);
Measurement(backHipArc);
Measurement(chestSlope);
Measurement(backSlope);
Measurement(frontWaistSlope);
Measurement(backWaistSlope);
Measurement(frontNeckToUpperChestHeight);
Measurement(frontNeckToBustHeight);
//arm
Measurement(armscyeGirth);
Measurement(elbowGirth);
Measurement(upperArmGirth);
Measurement(wristGirth);
Measurement(scyeDepth);
Measurement(shoulderAndArmLength);
Measurement(underarmLength);
Measurement(cervicaleToWristLength);
Measurement(shoulderToElbowLength);
Measurement(armLength);
//hand
Measurement(handWidth);
Measurement(handLength);
Measurement(handGirth);
//leg
Measurement(thighGirth);
Measurement(midThighGirth);
Measurement(kneeGirth);
Measurement(calfGirth);
Measurement(ankleGirth);
Measurement(kneeHeight);
Measurement(ankleHeight);
//foot
Measurement(footWidth);
Measurement(footLength);
//heights
Measurement(cervicaleHeight);
Measurement(cervicaleToKneeHeight);
Measurement(waistHeight);
Measurement(highHipHeight);
Measurement(hipHeight);
Measurement(waistToHipHeight);
Measurement(waistToKneeHeight);
Measurement(crotchHeight);
//extended
Measurement(heightFrontNeckBasePoint);
Measurement(heightBaseNeckSidePoint);
Measurement(heightShoulderPoint);
Measurement(heightNipplePoint);
Measurement(heightBackAngleAxilla);
Measurement(heightScapularPoint);
Measurement(heightUnderButtockFolds);
Measurement(hipsExcludingProtrudingAbdomen);
Measurement(girthFootInstep);
Measurement(sideWaistToFloor);
Measurement(frontWaistToFloor);
Measurement(arcThroughGroinArea);
Measurement(waistToPlaneSeat);
Measurement(neckToRadialPoint);
Measurement(neckToThirdFinger);
Measurement(neckToFirstLineChestCircumference);
Measurement(frontWaistLength);
Measurement(arcThroughShoulderJoint);
Measurement(neckToBackLineChestCircumference);
Measurement(waistToNeckSide);
Measurement(arcLengthUpperBody);
Measurement(chestWidth);
Measurement(anteroposteriorDiameterHands);
Measurement(heightClavicularPoint);
Measurement(heightArmholeSlash);
Measurement(slashShoulderHeight);
Measurement(halfGirthNeck);
Measurement(halfGirthNeckForShirts);
Measurement(halfGirthChestFirst);
Measurement(halfGirthChestSecond);
Measurement(halfGirthChestThird);
Measurement(halfGirthWaist);
Measurement(halfGirthHipsConsideringProtrudingAbdomen);
Measurement(halfGirthHipsExcludingProtrudingAbdomen);
Measurement(girthKneeFlexedFeet);
Measurement(neckTransverseDiameter);
Measurement(frontSlashShoulderHeight);
Measurement(neckToFrontWaistLine);
Measurement(handVerticalDiameter);
Measurement(neckToKneePoint);
Measurement(waistToKnee);
Measurement(shoulderHeight);
Measurement(headHeight);
Measurement(bodyPosition);
Measurement(arcBehindShoulderGirdle);
Measurement(neckToNeckBase);
Measurement(depthWaistFirst);
Measurement(depthWaistSecond);
}
//---------------------------------------------------------------------------------------------------------------------
void VStandardMeasurements::Measurement(const QString &tag)
{
const QDomNodeList nodeList = this->elementsByTagName(tag);
if (nodeList.isEmpty()) if (nodeList.isEmpty())
{ {
qDebug()<<"Measurement list is empty"<<Q_FUNC_INFO; qDebug()<<"Measurement" << tag <<"doesn't exist"<<Q_FUNC_INFO;
return; return;
} }
else else
{ {
for (qint32 i = 0; i < nodeList.size(); ++i) const QDomNode domNode = nodeList.at(0);
{
const QDomNode domNode = nodeList.at(i);
if (domNode.isNull() == false && domNode.isElement()) if (domNode.isNull() == false && domNode.isElement())
{ {
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
const QString name = GetParametrString(domElement, AttrName, ""); const qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
if (name.isEmpty())
{
continue;
}
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
const qreal base = GetParametrDouble(domElement, AttrBase, "0.0");
const qreal size_increace = GetParametrDouble(domElement, AttrSize_increace, "0.0"); const qreal size_increace = GetParametrDouble(domElement, AttrSize_increace, "0.0");
const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0");
const QString number = GetParametrString(domElement, AttrNumber, "");
if (Unit() == Valentina::Mm)// Convert to Cm. if (Unit() == Valentina::Mm)// Convert to Cm.
{ {
data->AddMeasurement(name, VMeasurement(base/10.0, size_increace/10.0, height_increase/10.0, data->AddMeasurement(tag, VMeasurement(value/10.0, size_increace/10.0, height_increase/10.0,
gui_text, number)); qApp->GuiText(tag), qApp->Description(tag), tag));
} }
else// Cm or inch. else// Cm or inch.
{ {
data->AddMeasurement(name, VMeasurement(base, size_increace, height_increase, data->AddMeasurement(tag, VMeasurement(value, size_increace, height_increase, qApp->GuiText(tag),
gui_text, number)); qApp->Description(tag), tag));
}
} }
} }
} }
@ -115,7 +242,7 @@ void VStandardMeasurements::SetSize()
if (nodeList.isEmpty()) if (nodeList.isEmpty())
{ {
data->SetSize(50); data->SetSize(50);
data->SetSizeName("Сг"); data->SetSizeName(size);
} }
else else
{ {
@ -125,18 +252,13 @@ void VStandardMeasurements::SetSize()
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
const QString name = GetParametrString(domElement, AttrName, "Сг"); qreal value = GetParametrDouble(domElement, AttrValue, "50.0");
const qreal base = GetParametrDouble(domElement, AttrBase, "50.0");
if (Unit() == Valentina::Mm)// Convert to Cm. if (Unit() == Valentina::Mm)// Convert to Cm.
{ {
data->SetSize(base/10.0); value = value/10.0;
data->SetSizeName(name);
}
else// Cm or inch.
{
data->SetSize(base);
data->SetSizeName(name);
} }
data->SetSize(value);
data->SetSizeName(size);
} }
} }
} }
@ -149,7 +271,7 @@ void VStandardMeasurements::SetHeight()
if (nodeList.isEmpty()) if (nodeList.isEmpty())
{ {
data->SetHeight(176); data->SetHeight(176);
data->SetHeightName("P"); data->SetHeightName(height);
} }
else else
{ {
@ -159,18 +281,13 @@ void VStandardMeasurements::SetHeight()
const QDomElement domElement = domNode.toElement(); const QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false) if (domElement.isNull() == false)
{ {
const QString name = GetParametrString(domElement, AttrName, "Р"); qreal value = GetParametrDouble(domElement, AttrValue, "176.0");
const qreal base = GetParametrDouble(domElement, AttrBase, "176.0");
if (Unit() == Valentina::Mm)// Convert to Cm. if (Unit() == Valentina::Mm)// Convert to Cm.
{ {
data->SetHeight(base/10.0); value = value / 10.0;
data->SetHeightName(name);
}
else// Cm or inch.
{
data->SetHeight(base);
data->SetHeightName(name);
} }
data->SetHeight(value);
data->SetHeightName(height);
} }
} }
} }

View File

@ -44,12 +44,11 @@ public:
static const QString TagDescription; static const QString TagDescription;
static const QString TagSize; static const QString TagSize;
static const QString TagHeight; static const QString TagHeight;
static const QString AttrName; static const QString AttrValue;
static const QString AttrGui_text;
static const QString AttrBase;
static const QString AttrSize_increace; static const QString AttrSize_increace;
static const QString AttrHeight_increase; static const QString AttrHeight_increase;
static const QString AttrNumber; private:
void Measurement(const QString &tag);
}; };
#endif // VSTANDARDMEASUREMENTS_H #endif // VSTANDARDMEASUREMENTS_H