Added a class to hold pattern piece data

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-06-17 16:42:38 +02:00
parent 80f396d636
commit 05b094deec
12 changed files with 251 additions and 3 deletions

View file

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='UTF-8'?>
<pattern>
<!--Valentina pattern format.-->
<version>0.2.4</version>
<version>0.3.1</version>
<unit>cm</unit>
<author/>
<description/>

View file

@ -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);

View file

@ -332,7 +332,7 @@
<xs:sequence>
<xs:element name="detail" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:sequence>
<xs:element name="node" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>

View file

@ -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");

View file

@ -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;

View file

@ -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();

View file

@ -512,6 +512,17 @@ QVector<VNodeDetail> 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.

View file

@ -33,6 +33,7 @@
#include <QVector>
#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<VNodeDetail> listNodePoint()const;
VPatternPieceData& GetPatternPieceData();
private:
QSharedDataPointer<VDetailData> d;

View file

@ -31,6 +31,7 @@
#include <QSharedData>
#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;
};

View file

@ -100,3 +100,9 @@ CONFIG(debug, debug|release){
}
}
}
HEADERS += \
vpatternpiecedata.h
SOURCES += \
vpatternpiecedata.cpp

View file

@ -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
** <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 "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;
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -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
** <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 <QList>
#include <QString>
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<MaterialCutPlacement> 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