Implicit Sharing for class VNodeDetail.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-20 13:33:29 +03:00
parent 35b3c654c6
commit ada855b4e6
5 changed files with 150 additions and 80 deletions

View file

@ -8,7 +8,8 @@ HEADERS += \
geometry/vgobject.h \
geometry/vpointf.h \
geometry/vequidistant.h \
geometry/vabstractcurve.h
geometry/vabstractcurve.h \
geometry/vnodedetail_p.h
SOURCES += \
geometry/vsplinepoint.cpp \

View file

@ -27,20 +27,21 @@
*************************************************************************/
#include "vnodedetail.h"
#include "vnodedetail_p.h"
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail()
:id(NULL_ID), typeTool(Tool::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0)
:d(new VNodeDetailData)
{}
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my)
:id(id), typeTool(typeTool), typeNode(typeNode), mx(mx), my(my)
:d(new VNodeDetailData(id, typeTool, typeNode, mx, my))
{}
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::VNodeDetail(const VNodeDetail &node)
:id(node.getId()), typeTool(node.getTypeTool()), typeNode(node.getTypeNode()), mx(node.getMx()), my(node.getMy())
:d (node.d)
{}
//---------------------------------------------------------------------------------------------------------------------
@ -50,10 +51,70 @@ VNodeDetail &VNodeDetail::operator =(const VNodeDetail &node)
{
return *this;
}
id = node.getId();
typeTool = node.getTypeTool();
typeNode = node.getTypeNode();
mx = node.getMx();
my = node.getMy();
d = node.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VNodeDetail::~VNodeDetail()
{}
//---------------------------------------------------------------------------------------------------------------------
quint32 VNodeDetail::getId() const
{
return d->id;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeDetail::setId(const quint32 &value)
{
d->id = value;
}
//---------------------------------------------------------------------------------------------------------------------
Tool VNodeDetail::getTypeTool() const
{
return d->typeTool;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeDetail::setTypeTool(const Tool &value)
{
d->typeTool = value;
}
//---------------------------------------------------------------------------------------------------------------------
NodeDetail VNodeDetail::getTypeNode() const
{
return d->typeNode;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeDetail::setTypeNode(const NodeDetail &value)
{
d->typeNode = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VNodeDetail::getMx() const
{
return d->mx;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeDetail::setMx(const qreal &value)
{
d->mx = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VNodeDetail::getMy() const
{
return d->my;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodeDetail::setMy(const qreal &value)
{
d->my = value;
}

View file

@ -31,8 +31,9 @@
#include "../options.h"
#include <QMetaType>
#include <QSharedDataPointer>
enum class NodeDetail : char { Contour, Modeling };
class VNodeDetailData;
/**
* @brief The VNodeDetail class keep information about detail node.
@ -64,6 +65,7 @@ public:
* @return node
*/
VNodeDetail &operator=(const VNodeDetail &node);
~VNodeDetail();
/**
* @brief getId return object id.
* @return id.
@ -115,78 +117,9 @@ public:
*/
void setMy(const qreal &value);
private:
/**
* @brief id object id.
*/
quint32 id;
/**
* @brief typeTool type of tool
*/
Tool typeTool;
/**
* @brief typeNode node type.
*/
NodeDetail typeNode;
/**
* @brief mx bias x axis.
*/
qreal mx;
/**
* @brief my bias y axis.
*/
qreal my;
QSharedDataPointer<VNodeDetailData> d;
};
inline quint32 VNodeDetail::getId() const
{
return id;
}
inline void VNodeDetail::setId(const quint32 &value)
{
id = value;
}
inline Tool VNodeDetail::getTypeTool() const
{
return typeTool;
}
inline void VNodeDetail::setTypeTool(const Tool &value)
{
typeTool = value;
}
inline NodeDetail VNodeDetail::getTypeNode() const
{
return typeNode;
}
inline void VNodeDetail::setTypeNode(const NodeDetail &value)
{
typeNode = value;
}
inline qreal VNodeDetail::getMx() const
{
return mx;
}
inline void VNodeDetail::setMx(const qreal &value)
{
mx = value;
}
inline qreal VNodeDetail::getMy() const
{
return my;
}
inline void VNodeDetail::setMy(const qreal &value)
{
my = value;
}
Q_DECLARE_METATYPE(VNodeDetail)
#endif // VNODEDETAIL_H

View file

@ -0,0 +1,74 @@
/************************************************************************
**
** @file vnodedetail_p.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 20 8, 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) 2014 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 VNODEDETAIL_P_H
#define VNODEDETAIL_P_H
#include <QSharedData>
#include "../options.h"
class VNodeDetailData : public QSharedData
{
public:
VNodeDetailData()
:id(NULL_ID), typeTool(Tool::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0)
{}
VNodeDetailData(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my)
:id(id), typeTool(typeTool), typeNode(typeNode), mx(mx), my(my)
{}
VNodeDetailData (const VNodeDetailData& node)
:QSharedData(node), id(node.id), typeTool(node.typeTool), typeNode(node.typeNode), mx(node.mx), my(node.my)
{}
~VNodeDetailData() {}
/**
* @brief id object id.
*/
quint32 id;
/**
* @brief typeTool type of tool
*/
Tool typeTool;
/**
* @brief typeNode node type.
*/
NodeDetail typeNode;
/**
* @brief mx bias x axis.
*/
qreal mx;
/**
* @brief my bias y axis.
*/
qreal my;
};
#endif // VNODEDETAIL_P_H

View file

@ -75,6 +75,7 @@ enum class Source : char { FromGui, FromFile, FromTool };
enum class Draw : char { Calculation, Modeling };
enum class Unit : char { Mm, Cm, Inch };
enum class MeasurementsType : char { Standard, Individual };
enum class NodeDetail : char { Contour, Modeling };
enum class GHeights : unsigned char { ALL,
H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134,