/************************************************************************ ** ** @file vstandardmeasurements.cpp ** @author Roman Telezhinsky ** @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 ** 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 . ** *************************************************************************/ #include "vstandardmeasurements.h" #include VStandardMeasurements::VStandardMeasurements(VContainer *data):VDomDocument(data) { } Valentina::Units VStandardMeasurements::Unit() { const QString unit = UniqueTagText("unit", "cm"); return VDomDocument::Units(unit); } QString VStandardMeasurements::Description() { const QString desc = UniqueTagText("description", ""); if (desc.isEmpty()) { qWarning()<<"Empty description in standard table."<elementsByTagName("measurement"); if (nodeList.isEmpty()) { qWarning()<<"Measurement list is empty"<AddMeasurement(name, VMeasurement(base/10.0, size_increace/10.0, height_increase/10.0, gui_text, number)); } else//Cm or inch. { data->AddMeasurement(name, VMeasurement(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(); }