2014-03-10 16:55:51 +01:00
|
|
|
|
/************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** @file vstandardmeasurements.cpp
|
2014-04-30 07:38:52 +02:00
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2014-03-10 16:55:51 +01:00
|
|
|
|
** @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 "vstandardmeasurements.h"
|
2014-03-11 21:19:13 +01:00
|
|
|
|
#include <QDebug>
|
2014-03-10 16:55:51 +01:00
|
|
|
|
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString VStandardMeasurements::TagMeasurement = QStringLiteral("measurement");
|
|
|
|
|
const QString VStandardMeasurements::TagDescription = QStringLiteral("description");
|
|
|
|
|
const QString VStandardMeasurements::TagSize = QStringLiteral("size");
|
|
|
|
|
const QString VStandardMeasurements::TagHeight = QStringLiteral("height");
|
|
|
|
|
const QString VStandardMeasurements::AttrName = QStringLiteral("name");
|
|
|
|
|
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::AttrHeight_increase = QStringLiteral("height_increase");
|
|
|
|
|
const QString VStandardMeasurements::AttrNumber = QStringLiteral("number");
|
|
|
|
|
|
2014-03-10 16:55:51 +01:00
|
|
|
|
VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data)
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-03-11 21:19:13 +01:00
|
|
|
|
|
|
|
|
|
Valentina::Units VStandardMeasurements::Unit()
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString unit = UniqueTagText(AttrUnit, UnitCM);
|
2014-03-24 16:02:57 +01:00
|
|
|
|
return VDomDocument::StrToUnits(unit);
|
2014-03-11 21:19:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString VStandardMeasurements::Description()
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString desc = UniqueTagText(TagDescription, "");
|
2014-03-11 21:19:13 +01:00
|
|
|
|
if (desc.isEmpty())
|
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
|
qDebug()<<"Empty description in standard table."<<Q_FUNC_INFO;
|
2014-03-11 21:19:13 +01:00
|
|
|
|
}
|
|
|
|
|
return desc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VStandardMeasurements::Measurements()
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QDomNodeList nodeList = this->elementsByTagName(TagMeasurement);
|
2014-03-11 21:19:13 +01:00
|
|
|
|
if (nodeList.isEmpty())
|
|
|
|
|
{
|
2014-03-28 14:11:46 +01:00
|
|
|
|
qDebug()<<"Measurement list is empty"<<Q_FUNC_INFO;
|
2014-03-11 21:19:13 +01:00
|
|
|
|
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)
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString name = GetParametrString(domElement, AttrName, "");
|
2014-03-11 21:19:13 +01:00
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
|
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 height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0");
|
|
|
|
|
const QString number = GetParametrString(domElement, AttrNumber, "");
|
2014-03-11 21:19:13 +01:00
|
|
|
|
|
2014-03-21 11:08:29 +01:00
|
|
|
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
2014-03-14 15:12:53 +01:00
|
|
|
|
data->AddMeasurement(name, VMeasurement(base/10.0, size_increace/10.0, height_increase/10.0,
|
|
|
|
|
gui_text, number));
|
2014-03-11 21:19:13 +01:00
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
|
else// Cm or inch.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
2014-03-14 15:12:53 +01:00
|
|
|
|
data->AddMeasurement(name, VMeasurement(base, size_increace, height_increase,
|
2014-03-11 21:19:13 +01:00
|
|
|
|
gui_text, number));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VStandardMeasurements::SetSize()
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QDomNodeList nodeList = this->elementsByTagName(TagSize);
|
2014-03-11 21:19:13 +01:00
|
|
|
|
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)
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString name = GetParametrString(domElement, AttrName, "Сг");
|
|
|
|
|
const qreal base = GetParametrDouble(domElement, AttrBase, "50.0");
|
|
|
|
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
|
|
|
|
data->SetSize(base/10.0);
|
|
|
|
|
data->SetSizeName(name);
|
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
|
else// Cm or inch.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
|
|
|
|
data->SetSize(base);
|
|
|
|
|
data->SetSizeName(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VStandardMeasurements::SetHeight()
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QDomNodeList nodeList = this->elementsByTagName(TagHeight);
|
2014-03-11 21:19:13 +01:00
|
|
|
|
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)
|
|
|
|
|
{
|
2014-03-21 11:08:29 +01:00
|
|
|
|
const QString name = GetParametrString(domElement, AttrName, "Р");
|
|
|
|
|
const qreal base = GetParametrDouble(domElement, AttrBase, "176.0");
|
|
|
|
|
if (Unit() == Valentina::Mm)// Convert to Cm.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
|
|
|
|
data->SetHeight(base/10.0);
|
|
|
|
|
data->SetHeightName(name);
|
|
|
|
|
}
|
2014-03-21 11:08:29 +01:00
|
|
|
|
else// Cm or inch.
|
2014-03-11 21:19:13 +01:00
|
|
|
|
{
|
|
|
|
|
data->SetHeight(base);
|
|
|
|
|
data->SetHeightName(name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|