From 27d61986571f70bc80f44f444fd532d32cf4c55e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 3 Nov 2016 17:59:53 +0200 Subject: [PATCH] Redesing VDetail class. Meet new classes VPiece and VPieceNode. --HG-- branch : feature --- src/libs/vpatterndb/vpatterndb.pri | 10 ++- src/libs/vpatterndb/vpiece.cpp | 132 +++++++++++++++++++++++++++++ src/libs/vpatterndb/vpiece.h | 62 ++++++++++++++ src/libs/vpatterndb/vpiece_p.h | 68 +++++++++++++++ src/libs/vpatterndb/vpiecenode.cpp | 96 +++++++++++++++++++++ src/libs/vpatterndb/vpiecenode.h | 64 ++++++++++++++ src/libs/vpatterndb/vpiecenode_p.h | 82 ++++++++++++++++++ 7 files changed, 512 insertions(+), 2 deletions(-) create mode 100644 src/libs/vpatterndb/vpiece.cpp create mode 100644 src/libs/vpatterndb/vpiece.h create mode 100644 src/libs/vpatterndb/vpiece_p.h create mode 100644 src/libs/vpatterndb/vpiecenode.cpp create mode 100644 src/libs/vpatterndb/vpiecenode.h create mode 100644 src/libs/vpatterndb/vpiecenode_p.h diff --git a/src/libs/vpatterndb/vpatterndb.pri b/src/libs/vpatterndb/vpatterndb.pri index c1ae5168a..49256369c 100644 --- a/src/libs/vpatterndb/vpatterndb.pri +++ b/src/libs/vpatterndb/vpatterndb.pri @@ -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 diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp new file mode 100644 index 000000000..372231fc0 --- /dev/null +++ b/src/libs/vpatterndb/vpiece.cpp @@ -0,0 +1,132 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 "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 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 &nodes) +{ + d->nodes = nodes; +} diff --git a/src/libs/vpatterndb/vpiece.h b/src/libs/vpatterndb/vpiece.h new file mode 100644 index 000000000..90dc2ddc4 --- /dev/null +++ b/src/libs/vpatterndb/vpiece.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VPIECE_H +#define VPIECE_H + +#include +#include + +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 GetNodes() const; + void SetNodes(const QVector &nodes); +private: + QSharedDataPointer d; +}; + +Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); + +#endif // VPIECE_H diff --git a/src/libs/vpatterndb/vpiece_p.h b/src/libs/vpatterndb/vpiece_p.h new file mode 100644 index 000000000..f673dc340 --- /dev/null +++ b/src/libs/vpatterndb/vpiece_p.h @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VPIECE_P_H +#define VPIECE_P_H + +#include +#include + +#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 nodes; + +private: + VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE; +}; + +VPieceData::~VPieceData() +{} + +QT_WARNING_POP + +#endif // VPIECE_P_H + diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp new file mode 100644 index 000000000..1b0d4c523 --- /dev/null +++ b/src/libs/vpatterndb/vpiecenode.cpp @@ -0,0 +1,96 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 "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; +} diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h new file mode 100644 index 000000000..385d9bf6b --- /dev/null +++ b/src/libs/vpatterndb/vpiecenode.h @@ -0,0 +1,64 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VPIECENODE_H +#define VPIECENODE_H + +#include +#include +#include + +#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 d; +}; + +Q_DECLARE_METATYPE(VPieceNode) +Q_DECLARE_TYPEINFO(VPieceNode, Q_MOVABLE_TYPE); + +#endif // VPIECENODE_H diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h new file mode 100644 index 000000000..59c0f4ae2 --- /dev/null +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef VPIECENODE_P_H +#define VPIECENODE_P_H + +#include +#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 +