From 05b094deece7f60906191b1973d5d30e23aee52d Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Fri, 17 Jun 2016 16:42:38 +0200 Subject: [PATCH] Added a class to hold pattern piece data --HG-- branch : feature --- src/app/share/collection/TestDart.val | 2 +- src/app/valentina/xml/vpattern.cpp | 14 +++ src/libs/ifc/schema/pattern/v0.3.1.xsd | 2 +- src/libs/ifc/xml/vabstractpattern.cpp | 2 + src/libs/ifc/xml/vabstractpattern.h | 2 + src/libs/ifc/xml/vpatternconverter.cpp | 3 +- src/libs/vpatterndb/vdetail.cpp | 11 +++ src/libs/vpatterndb/vdetail.h | 3 + src/libs/vpatterndb/vdetail_p.h | 4 + src/libs/vpatterndb/vpatterndb.pro | 6 ++ src/libs/vpatterndb/vpatternpiecedata.cpp | 111 ++++++++++++++++++++++ src/libs/vpatterndb/vpatternpiecedata.h | 94 ++++++++++++++++++ 12 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 src/libs/vpatterndb/vpatternpiecedata.cpp create mode 100644 src/libs/vpatterndb/vpatternpiecedata.h diff --git a/src/app/share/collection/TestDart.val b/src/app/share/collection/TestDart.val index bc3d1d8c4..5808117af 100644 --- a/src/app/share/collection/TestDart.val +++ b/src/app/share/collection/TestDart.val @@ -1,7 +1,7 @@ - 0.2.4 + 0.3.1 cm diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index d6fd0c0c4..d188644db 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -629,6 +629,20 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document } detail.append(VNodeDetail(id, tool, nodeType, mx, my, reverse)); } + else if (element.tagName() == TagData) + { + try + { + QString qsName = GetParametrString(element, AttrName); + detail.GetPatternPieceData().SetName(qsName); + QString qsLetter = GetParametrString(element, AttrLetter); + detail.GetPatternPieceData().SetLetter(qsLetter); + qDebug() << "Data" << qsName << qsLetter; + } + catch(const VException& e) + { + } + } } } VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile); diff --git a/src/libs/ifc/schema/pattern/v0.3.1.xsd b/src/libs/ifc/schema/pattern/v0.3.1.xsd index d5af28adf..af3eaa1b6 100644 --- a/src/libs/ifc/schema/pattern/v0.3.1.xsd +++ b/src/libs/ifc/schema/pattern/v0.3.1.xsd @@ -332,7 +332,7 @@ - + diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index a8bc66609..534dc0110 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -60,12 +60,14 @@ const QString VAbstractPattern::TagGradation = QStringLiteral("gradation"); const QString VAbstractPattern::TagHeights = QStringLiteral("heights"); const QString VAbstractPattern::TagSizes = QStringLiteral("sizes"); const QString VAbstractPattern::TagUnit = QStringLiteral("unit"); +const QString VAbstractPattern::TagData = QStringLiteral("data"); const QString VAbstractPattern::AttrName = QStringLiteral("name"); const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); const QString VAbstractPattern::AttrObject = QStringLiteral("object"); const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); const QString VAbstractPattern::AttrType = QStringLiteral("type"); +const QString VAbstractPattern::AttrLetter = QStringLiteral("letter"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 172f7cce3..5f97aed21 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -155,12 +155,14 @@ public: static const QString TagHeights; static const QString TagSizes; static const QString TagUnit; + static const QString TagData; static const QString AttrName; static const QString AttrVisible; static const QString AttrObject; static const QString AttrTool; static const QString AttrType; + static const QString AttrLetter; static const QString AttrAll; diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index 5068702ef..b4019754c 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -163,7 +163,8 @@ void VPatternConverter::ApplyPatches() V_FALLTHROUGH case (0x000203): ToV0_2_4(); - ValidateXML(XSDSchema(0x000204), fileName); + //ValidateXML(XSDSchema(0x000204), fileName); + ValidateXML(XSDSchema(0x000302), fileName); V_FALLTHROUGH case (0x000204): ToV0_2_5(); diff --git a/src/libs/vpatterndb/vdetail.cpp b/src/libs/vpatterndb/vdetail.cpp index d7a2e8db2..71e44b97e 100644 --- a/src/libs/vpatterndb/vdetail.cpp +++ b/src/libs/vpatterndb/vdetail.cpp @@ -512,6 +512,17 @@ QVector VDetail::listNodePoint() const return list; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the full access to the pattern piece data object + * @return pattern piece data object + */ +VPatternPieceData& VDetail::GetPatternPieceData() +{ + return d->m_ppData; +} + + //--------------------------------------------------------------------------------------------------------------------- /** * @brief indexOfNode return index in list node using id object. diff --git a/src/libs/vpatterndb/vdetail.h b/src/libs/vpatterndb/vdetail.h index fb57ab56e..8e84b1393 100644 --- a/src/libs/vpatterndb/vdetail.h +++ b/src/libs/vpatterndb/vdetail.h @@ -33,6 +33,7 @@ #include #include "../vlayout/vabstractdetail.h" +#include "vpatternpiecedata.h" class VDetailData; class VContainer; @@ -84,6 +85,8 @@ public: QPainterPath ContourPath(const VContainer *data) const; QPainterPath SeamAllowancePath(const VContainer *data) const; QVector listNodePoint()const; + VPatternPieceData& GetPatternPieceData(); + private: QSharedDataPointer d; diff --git a/src/libs/vpatterndb/vdetail_p.h b/src/libs/vpatterndb/vdetail_p.h index 72aff357a..bcb470238 100644 --- a/src/libs/vpatterndb/vdetail_p.h +++ b/src/libs/vpatterndb/vdetail_p.h @@ -31,6 +31,7 @@ #include #include "vnodedetail.h" +#include "vpatternpiecedata.h" #include "../ifc/ifcdef.h" #ifdef Q_CC_GNU @@ -67,6 +68,9 @@ public: /** @brief my bias y axis. */ qreal my; + /** @brief Pattern piece data */ + VPatternPieceData m_ppData; + private: VDetailData &operator=(const VDetailData &) Q_DECL_EQ_DELETE; }; diff --git a/src/libs/vpatterndb/vpatterndb.pro b/src/libs/vpatterndb/vpatterndb.pro index 28d254840..5b38b1dee 100644 --- a/src/libs/vpatterndb/vpatterndb.pro +++ b/src/libs/vpatterndb/vpatterndb.pro @@ -100,3 +100,9 @@ CONFIG(debug, debug|release){ } } } + +HEADERS += \ + vpatternpiecedata.h + +SOURCES += \ + vpatternpiecedata.cpp diff --git a/src/libs/vpatterndb/vpatternpiecedata.cpp b/src/libs/vpatterndb/vpatternpiecedata.cpp new file mode 100644 index 000000000..e309202c5 --- /dev/null +++ b/src/libs/vpatterndb/vpatternpiecedata.cpp @@ -0,0 +1,111 @@ +/************************************************************************ + ** + ** @file vpatternpiecedata.h + ** @author Bojan Kverh + ** @date June 16, 2016 + ** + ** @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-2015 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 "vpatternpiecedata.h" + +//--------------------------------------------------------------------------------------------------------------------- + +VPatternPieceData::VPatternPieceData() +{} + +//--------------------------------------------------------------------------------------------------------------------- + +VPatternPieceData::~VPatternPieceData() +{} + +//--------------------------------------------------------------------------------------------------------------------- + +void VPatternPieceData::Append(const MaterialCutPlacement& rMCP) +{ + m_conMCP.append(rMCP); +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VPatternPieceData::Insert(int i, const MaterialCutPlacement& rMCP) +{ + Q_ASSERT(i >= 0); + Q_ASSERT(i <= GetMCPCount()); + m_conMCP.insert(i, rMCP); +} + +//--------------------------------------------------------------------------------------------------------------------- + +int VPatternPieceData::GetMCPCount() const +{ + return m_conMCP.count(); +} + +//--------------------------------------------------------------------------------------------------------------------- + +const MaterialCutPlacement& VPatternPieceData::GetMCP(int i) const +{ + Q_ASSERT(i >= 0); + Q_ASSERT(i < GetMCPCount()); + return m_conMCP[i]; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VPatternPieceData::RemoveMCP(int i) +{ + Q_ASSERT(i >= 0); + Q_ASSERT(i < GetMCPCount()); + m_conMCP.removeAt(i); +} + +//--------------------------------------------------------------------------------------------------------------------- + +QString VPatternPieceData::GetLetter() const +{ + return m_qsLetter; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VPatternPieceData::SetLetter(QString qsLetter) +{ + m_qsLetter = qsLetter.left(3); +} + +//--------------------------------------------------------------------------------------------------------------------- + +QString VPatternPieceData::GetName() const +{ + return m_qsName; +} + +//--------------------------------------------------------------------------------------------------------------------- + +void VPatternPieceData::SetName(QString qsName) +{ + m_qsName = qsName; +} + +//--------------------------------------------------------------------------------------------------------------------- + diff --git a/src/libs/vpatterndb/vpatternpiecedata.h b/src/libs/vpatterndb/vpatternpiecedata.h new file mode 100644 index 000000000..287971b98 --- /dev/null +++ b/src/libs/vpatterndb/vpatternpiecedata.h @@ -0,0 +1,94 @@ +#ifndef VPATTERNPIECEDATA_H +#define VPATTERNPIECEDATA_H + +/************************************************************************ + ** + ** @file vpatternpiecedata.h + ** @author Bojan Kverh + ** @date June 16, 2016 + ** + ** @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-2015 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 +#include + +enum class MaterialType : char +{ + mtFabric, + mtLining, + mtInterfacing, + mtInterlining, + mtUserDefined +}; + +enum class PlacementType : char { ptNone, ptCutOnFold }; + +/** + * @brief This structure holds a material, cut number and placement 3-tuple + */ +struct MaterialCutPlacement +{ + MaterialType m_eMaterial; + QString m_qsMaterialUserDef; + int m_iCutNumber; + PlacementType m_ePlacement; +}; + +typedef QList MCPContainer; + +/** + * @brief The VPatternPieceData class holds some information about a single + * piece like letter, name, material type, cut number and placement. + */ +class VPatternPieceData +{ +public: + VPatternPieceData(); + ~VPatternPieceData(); + + // methods, which operate on MaterialCutPlacement container + void Append(const MaterialCutPlacement& rMCP); + void Insert(int i, const MaterialCutPlacement& rMCP); + int GetMCPCount() const; + const MaterialCutPlacement& GetMCP(int i) const; + void RemoveMCP(int i); + + // methods, which operate on other members + QString GetLetter() const; + void SetLetter(QString qsLetter); + QString GetName() const; + void SetName(QString qsName); + +private: + /** @brief Pattern piece name + */ + QString m_qsName; + /** @brief Pattern piece letter (should be no more than 3 letters) + */ + QString m_qsLetter; + /** @brief List of material, cut number and placement 3-tuples + */ + MCPContainer m_conMCP; +}; + +#endif // VPATTERNPIECEDATA_H