Redesing VDetail class. Meet new classes VPiece and VPieceNode.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-03 17:59:53 +02:00
parent a50df3a33c
commit 27d6198657
7 changed files with 512 additions and 2 deletions

View file

@ -21,7 +21,9 @@ SOURCES += \
$$PWD/vpatternpiecedata.cpp \
$$PWD/vpatterninfogeometry.cpp \
$$PWD/vgrainlinegeometry.cpp \
$$PWD/variables/vcurveclength.cpp
$$PWD/variables/vcurveclength.cpp \
$$PWD/vpiece.cpp \
$$PWD/vpiecenode.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -57,4 +59,8 @@ HEADERS += \
$$PWD/vpatternpiecedata.h \
$$PWD/vpatterninfogeometry.h \
$$PWD/vgrainlinegeometry.h \
$$PWD/variables/vcurveclength.h
$$PWD/variables/vcurveclength.h \
$$PWD/vpiece.h \
$$PWD/vpiece_p.h \
$$PWD/vpiecenode.h \
$$PWD/vpiecenode_p.h

View file

@ -0,0 +1,132 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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 "vpiece.h"
#include "vpiece_p.h"
//---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece()
: d(new VPieceData)
{}
//---------------------------------------------------------------------------------------------------------------------
VPiece::VPiece(const VPiece &piece)
: d (piece.d)
{}
//---------------------------------------------------------------------------------------------------------------------
VPiece &VPiece::operator=(const VPiece &piece)
{
if ( &piece == this )
{
return *this;
}
d = piece.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VPiece::~VPiece()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief append append in the end of list node.
* @param node new node.
*/
void VPiece::Append(const VPieceNode &node)
{
d->nodes.append(node);
}
//---------------------------------------------------------------------------------------------------------------------
/** @brief Clear detail full clear. */
void VPiece::Clear()
{
ClearNodes();
}
//---------------------------------------------------------------------------------------------------------------------
/** @brief ClearNodes clear list of nodes. */
void VPiece::ClearNodes()
{
d->nodes.clear();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CountNode return count nodes.
* @return count.
*/
qint32 VPiece::CountNode() const
{
return d->nodes.size();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief operator [] find node by index in list.
* @param indx index node in list.
* @return node
*/
VPieceNode &VPiece::operator [](int indx)
{
return d->nodes[indx];
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief at find node by index in list.
* @param indx index node in list.
* @return const node.
*/
const VPieceNode &VPiece::at(int indx) const
{
return d->nodes.at(indx);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getNodes return list of nodes.
* @return list of nodes.
*/
QVector<VPieceNode> VPiece::GetNodes() const
{
return d->nodes;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setNodes set list of nodes
* @param value list of nodes
*/
// cppcheck-suppress unusedFunction
void VPiece::SetNodes(const QVector<VPieceNode> &nodes)
{
d->nodes = nodes;
}

View file

@ -0,0 +1,62 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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/>.
**
*************************************************************************/
#ifndef VPIECE_H
#define VPIECE_H
#include <QtGlobal>
#include <QSharedDataPointer>
class VPieceData;
class VPieceNode;
class VPiece
{
public:
VPiece();
VPiece(const VPiece &piece);
VPiece &operator=(const VPiece &piece);
virtual ~VPiece();
void Append(const VPieceNode &node);
void Clear();
void ClearNodes();
qint32 CountNode() const;
VPieceNode & operator[](int indx);
const VPieceNode & at ( int indx ) const;
QVector<VPieceNode> GetNodes() const;
void SetNodes(const QVector<VPieceNode> &nodes);
private:
QSharedDataPointer<VPieceData> d;
};
Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE);
#endif // VPIECE_H

View file

@ -0,0 +1,68 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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/>.
**
*************************************************************************/
#ifndef VPIECE_P_H
#define VPIECE_P_H
#include <QSharedData>
#include <QVector>
#include "../vmisc/diagnostic.h"
#include "vpiecenode.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
class VPieceData : public QSharedData
{
public:
VPieceData()
: nodes()
{}
VPieceData(const VPieceData &detail)
: QSharedData(detail),
nodes(detail.nodes)
{}
~VPieceData();
/** @brief nodes list detail nodes. */
QVector<VPieceNode> nodes;
private:
VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE;
};
VPieceData::~VPieceData()
{}
QT_WARNING_POP
#endif // VPIECE_P_H

View file

@ -0,0 +1,96 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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 "vpiecenode.h"
#include "vpiecenode_p.h"
//---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode()
: d(new VPieceNodeData)
{}
//---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode(quint32 id, Tool typeTool, bool reverse)
: d(new VPieceNodeData(id, typeTool, reverse))
{}
//---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode(const VPieceNode &node)
: d (node.d)
{}
//---------------------------------------------------------------------------------------------------------------------
VPieceNode &VPieceNode::operator=(const VPieceNode &node)
{
if ( &node == this )
{
return *this;
}
d = node.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VPieceNode::~VPieceNode()
{}
//---------------------------------------------------------------------------------------------------------------------
quint32 VPieceNode::GetId() const
{
return d->id;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetId(quint32 id)
{
d->id = id;
}
//---------------------------------------------------------------------------------------------------------------------
Tool VPieceNode::GetTypeTool() const
{
return d->typeTool;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetTypeTool(Tool value)
{
d->typeTool = value;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPieceNode::GetReverse() const
{
return d->reverse;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetReverse(bool reverse)
{
d->reverse = reverse;
}

View file

@ -0,0 +1,64 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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/>.
**
*************************************************************************/
#ifndef VPIECENODE_H
#define VPIECENODE_H
#include <QtGlobal>
#include <QSharedDataPointer>
#include <QMetaType>
#include "../vmisc/def.h"
class VPieceNodeData;
class VPieceNode
{
public:
VPieceNode();
VPieceNode(quint32 id, Tool typeTool, bool reverse = false);
VPieceNode(const VPieceNode &node);
VPieceNode &operator=(const VPieceNode &node);
~VPieceNode();
quint32 GetId() const;
void SetId(quint32 id);
Tool GetTypeTool() const;
void SetTypeTool(Tool value);
bool GetReverse() const;
void SetReverse(bool reverse);
private:
QSharedDataPointer<VPieceNodeData> d;
};
Q_DECLARE_METATYPE(VPieceNode)
Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE);
#endif // VPIECENODE_H

View file

@ -0,0 +1,82 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 3 11, 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) 2016 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/>.
**
*************************************************************************/
#ifndef VPIECENODE_P_H
#define VPIECENODE_P_H
#include <QSharedData>
#include "../ifc/ifcdef.h"
#include "../vmisc/diagnostic.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
class VPieceNodeData : public QSharedData
{
public:
VPieceNodeData()
: id(NULL_ID),
typeTool(Tool::NodePoint),
reverse(false)
{}
VPieceNodeData(quint32 id, Tool typeTool, bool reverse)
: id(id),
typeTool(typeTool),
reverse(reverse)
{}
VPieceNodeData (const VPieceNodeData& node)
: QSharedData(node),
id(node.id),
typeTool(node.typeTool),
reverse(node.reverse)
{}
~VPieceNodeData();
/** @brief id object id. */
quint32 id;
/** @brief typeTool type of tool */
Tool typeTool;
/** @brief reverse true if need reverse points list for node. */
bool reverse;
private:
VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE;
};
VPieceNodeData::~VPieceNodeData()
{}
QT_WARNING_POP
#endif // VPIECENODE_P_H