2014-03-10 16:55:51 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vindividualmeasurements.cpp
|
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
|
|
|
** @date 8 3, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vindividualmeasurements.h"
|
|
|
|
|
2014-03-21 11:08:29 +01:00
|
|
|
const QString VIndividualMeasurements::AttrIgnore = QStringLiteral("ignore");
|
|
|
|
const QString VIndividualMeasurements::AttrName = QStringLiteral("name");
|
|
|
|
const QString VIndividualMeasurements::AttrM_number = QStringLiteral("m_number");
|
|
|
|
const QString VIndividualMeasurements::AttrGui_text = QStringLiteral("gui_text");
|
|
|
|
const QString VIndividualMeasurements::AttrValue = QStringLiteral("value");
|
|
|
|
const QString VIndividualMeasurements::AttrDescription = QStringLiteral("description");
|
|
|
|
const QString VIndividualMeasurements::AttrLang = QStringLiteral("lang");
|
|
|
|
const QString VIndividualMeasurements::AttrFamily_name = QStringLiteral("family-name");
|
|
|
|
const QString VIndividualMeasurements::AttrGiven_name = QStringLiteral("given-name");
|
|
|
|
const QString VIndividualMeasurements::AttrBirth_date = QStringLiteral("birth-date");
|
|
|
|
const QString VIndividualMeasurements::AttrSex = QStringLiteral("sex");
|
|
|
|
|
2014-03-10 16:55:51 +01:00
|
|
|
VIndividualMeasurements::VIndividualMeasurements(VContainer *data):VDomDocument(data)
|
|
|
|
{
|
|
|
|
}
|
2014-03-14 15:12:53 +01:00
|
|
|
|
|
|
|
Valentina::Units VIndividualMeasurements::Unit()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
const QString unit = UniqueTagText(AttrUnit, UnitCM);
|
2014-03-14 15:12:53 +01:00
|
|
|
return VDomDocument::Units(unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VIndividualMeasurements::Measurements()
|
|
|
|
{
|
|
|
|
//head and neck
|
|
|
|
Measurement("head_girth");
|
|
|
|
Measurement("mid_neck_girth");
|
|
|
|
Measurement("neck_base_girth");
|
|
|
|
Measurement("head_and_neck_length");
|
|
|
|
//torso
|
|
|
|
Measurement("center_front_waist_length");
|
|
|
|
Measurement("center_back_waist_length");
|
|
|
|
Measurement("shoulder_length");
|
|
|
|
Measurement("side_waist_length");
|
|
|
|
Measurement("trunk_length");
|
|
|
|
Measurement("shoulder_girth");
|
|
|
|
Measurement("upper_chest_girth");
|
|
|
|
Measurement("bust__girth");
|
|
|
|
Measurement("under_bust_girth");
|
|
|
|
Measurement("waist_girth");
|
|
|
|
Measurement("high_hip_girth");
|
|
|
|
Measurement("hip_girth");
|
|
|
|
Measurement("upper_front_chest_width");
|
|
|
|
Measurement("front_chest_width");
|
|
|
|
Measurement("across_front_shoulder_width");
|
|
|
|
Measurement("across_back_shoulder_width");
|
|
|
|
Measurement("upper_back_width");
|
|
|
|
Measurement("back_width");
|
|
|
|
Measurement("bustpoint_to_bustpoint");
|
|
|
|
Measurement("halter_bustpoint_to_bustpoint");
|
|
|
|
Measurement("neck_to_bustpoint");
|
|
|
|
Measurement("crotch_length");
|
|
|
|
Measurement("rise_height");
|
|
|
|
Measurement("shoulder_drop");
|
|
|
|
Measurement("shoulder_slope_degrees");
|
|
|
|
Measurement("front_shoulder_slope_length");
|
|
|
|
Measurement("back_shoulder_slope_length");
|
|
|
|
Measurement("front_shoulder_to_waist_length");
|
|
|
|
Measurement("back_shoulder_to_waist_length");
|
|
|
|
Measurement("front_neck_arc");
|
|
|
|
Measurement("back_neck_arc");
|
|
|
|
Measurement("front_upper-bust_arc");
|
|
|
|
Measurement("back_upper-bust_arc");
|
|
|
|
Measurement("front_waist_arc");
|
|
|
|
Measurement("back_waist_arc");
|
|
|
|
Measurement("front_upper-hip_arc");
|
|
|
|
Measurement("back_upper-hip_arc");
|
|
|
|
Measurement("front_hip_arc");
|
|
|
|
Measurement("back_hip_arc");
|
|
|
|
Measurement("chest_slope");
|
|
|
|
Measurement("back_slope");
|
|
|
|
Measurement("front_waist_slope");
|
|
|
|
Measurement("back_waist_slope");
|
|
|
|
Measurement("front-neck_to_upper-chest_height");
|
|
|
|
Measurement("front-neck_to_bust_height");
|
|
|
|
//arm
|
|
|
|
Measurement("armscye_girth");
|
|
|
|
Measurement("elbow_girth");
|
|
|
|
Measurement("upper-arm_girth");
|
|
|
|
Measurement("wrist_girth");
|
|
|
|
Measurement("scye_depth");
|
|
|
|
Measurement("shoulder_and_arm_length");
|
|
|
|
Measurement("underarm_length");
|
|
|
|
Measurement("cervicale_to_wrist_length");
|
|
|
|
Measurement("shoulder_to_elbow_length");
|
|
|
|
Measurement("arm_length");
|
|
|
|
//hand
|
|
|
|
Measurement("hand_width");
|
|
|
|
Measurement("hand_length");
|
|
|
|
Measurement("hand_girth");
|
|
|
|
//leg
|
|
|
|
Measurement("thigh_girth");
|
|
|
|
Measurement("mid_thigh_girth");
|
|
|
|
Measurement("knee_girth");
|
|
|
|
Measurement("calf_girth");
|
|
|
|
Measurement("ankle_girth");
|
|
|
|
Measurement("knee_height");
|
|
|
|
Measurement("ankle_height");
|
|
|
|
//foot
|
|
|
|
Measurement("foot_width");
|
|
|
|
Measurement("foot_length");
|
|
|
|
//heights
|
|
|
|
Measurement("height");
|
|
|
|
Measurement("cervicale_height");
|
|
|
|
Measurement("cervicale_to_knee_height");
|
|
|
|
Measurement("waist_height");
|
|
|
|
Measurement("high_hip_height");
|
|
|
|
Measurement("hip_height");
|
|
|
|
Measurement("waist_to_hip_height");
|
|
|
|
Measurement("waist_to_knee_height");
|
|
|
|
Measurement("crotch_height");
|
|
|
|
}
|
|
|
|
|
|
|
|
void VIndividualMeasurements::Measurement(const QString &tag)
|
|
|
|
{
|
|
|
|
const QDomNodeList nodeList = this->elementsByTagName(tag);
|
|
|
|
if (nodeList.isEmpty())
|
|
|
|
{
|
|
|
|
qWarning()<<"Measurement" << tag <<"doesn't exist"<<Q_FUNC_INFO;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const QDomNode domNode = nodeList.at(0);
|
|
|
|
if (domNode.isNull() == false && domNode.isElement())
|
|
|
|
{
|
|
|
|
const QDomElement domElement = domNode.toElement();
|
|
|
|
if (domElement.isNull() == false)
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
const bool ignore = QVariant(GetParametrString(domElement, AttrIgnore, "false")).toBool();
|
2014-03-14 15:12:53 +01:00
|
|
|
if (ignore)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
const QString name = GetParametrString(domElement, AttrName, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
if (name.isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
const QString m_number = GetParametrString(domElement, AttrM_number, "");
|
|
|
|
const QString gui_text = GetParametrString(domElement, AttrGui_text, "");
|
|
|
|
const qreal value = GetParametrDouble(domElement, AttrValue, "0.0");
|
|
|
|
const QString description = GetParametrString(domElement, AttrDescription, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
|
|
|
|
if (Unit() == Valentina::Mm)//Convert to Cm.
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
data->AddMeasurement(name, VMeasurement(value/10.0, gui_text, description, tag));
|
2014-03-14 15:12:53 +01:00
|
|
|
if (m_number.isEmpty())
|
|
|
|
{
|
|
|
|
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
VMeasurement m(value/10.0, gui_text, description, tag);
|
|
|
|
m.setVirtual(true);
|
|
|
|
data->AddMeasurement(m_number, m);
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else//Cm or inch.
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
data->AddMeasurement(name, VMeasurement(value, gui_text, description, tag));
|
2014-03-14 15:12:53 +01:00
|
|
|
if (m_number.isEmpty())
|
|
|
|
{
|
|
|
|
qWarning()<<"Can't find language-independent measurement name for "<< tag;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
VMeasurement m(value, gui_text, description, tag);
|
|
|
|
m.setVirtual(true);
|
|
|
|
data->AddMeasurement(m_number, m);
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString VIndividualMeasurements::Language()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
return UniqueTagText(AttrLang, "en");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString VIndividualMeasurements::FamilyName()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
return UniqueTagText(AttrFamily_name, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString VIndividualMeasurements::GivenName()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
return UniqueTagText(AttrGiven_name, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString VIndividualMeasurements::BirthDate()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
return UniqueTagText(AttrBirth_date, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString VIndividualMeasurements::Sex()
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
return UniqueTagText(AttrSex, "");
|
2014-03-14 15:12:53 +01:00
|
|
|
}
|