Implicit Sharing for class VLengthLine.
--HG-- branch : develop
This commit is contained in:
parent
3e9d5aa975
commit
2557cb1133
|
@ -28,4 +28,5 @@ HEADERS += \
|
||||||
container/vvariable_p.h \
|
container/vvariable_p.h \
|
||||||
container/vincrement_p.h \
|
container/vincrement_p.h \
|
||||||
container/vcurvelength_p.h \
|
container/vcurvelength_p.h \
|
||||||
container/vlineangle_p.h
|
container/vlineangle_p.h \
|
||||||
|
container/vlinelength_p.h
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vlinelength.h"
|
#include "vlinelength.h"
|
||||||
|
#include "vlinelength_p.h"
|
||||||
#include "../geometry/vpointf.h"
|
#include "../geometry/vpointf.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
|
|
||||||
|
@ -34,14 +35,14 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLengthLine::VLengthLine()
|
VLengthLine::VLengthLine()
|
||||||
:VInternalVariable(), p1Id(NULL_ID), p2Id(NULL_ID)
|
:VInternalVariable(), d(new VLengthLineData)
|
||||||
{
|
{
|
||||||
SetType(VarType::LineLength);
|
SetType(VarType::LineLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id)
|
VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *p2, const quint32 &p2Id)
|
||||||
:VInternalVariable(), p1Id(p1Id), p2Id(p2Id)
|
:VInternalVariable(), d(new VLengthLineData(p1Id, p2Id))
|
||||||
{
|
{
|
||||||
SCASSERT(p1 != nullptr);
|
SCASSERT(p1 != nullptr);
|
||||||
SCASSERT(p2 != nullptr);
|
SCASSERT(p2 != nullptr);
|
||||||
|
@ -53,7 +54,7 @@ VLengthLine::VLengthLine(const VPointF *p1, const quint32 &p1Id, const VPointF *
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLengthLine::VLengthLine(const VLengthLine &var)
|
VLengthLine::VLengthLine(const VLengthLine &var)
|
||||||
:VInternalVariable(var), p1Id(var.GetP1Id()), p2Id(var.GetP2Id())
|
:VInternalVariable(var), d(var.d)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -64,8 +65,7 @@ VLengthLine &VLengthLine::operator=(const VLengthLine &var)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
VInternalVariable::operator=(var);
|
VInternalVariable::operator=(var);
|
||||||
this->p1Id = var.GetP1Id();
|
d = var.d;
|
||||||
this->p2Id = var.GetP2Id();
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ VLengthLine::~VLengthLine()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VLengthLine::Filter(quint32 id)
|
bool VLengthLine::Filter(quint32 id)
|
||||||
{
|
{
|
||||||
return id == p1Id || id == p2Id;
|
return id == d->p1Id || id == d->p2Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -87,3 +87,15 @@ void VLengthLine::SetValue(const VPointF *p1, const VPointF *p2)
|
||||||
|
|
||||||
VInternalVariable::SetValue(qApp->fromPixel(QLineF(p1->toQPointF(), p2->toQPointF()).length()));
|
VInternalVariable::SetValue(qApp->fromPixel(QLineF(p1->toQPointF(), p2->toQPointF()).length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
quint32 VLengthLine::GetP1Id() const
|
||||||
|
{
|
||||||
|
return d->p1Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
quint32 VLengthLine::GetP2Id() const
|
||||||
|
{
|
||||||
|
return d->p2Id;
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "vinternalvariable.h"
|
#include "vinternalvariable.h"
|
||||||
|
|
||||||
class VPointF;
|
class VPointF;
|
||||||
|
class VLengthLineData;
|
||||||
|
|
||||||
class VLengthLine :public VInternalVariable
|
class VLengthLine :public VInternalVariable
|
||||||
{
|
{
|
||||||
|
@ -47,20 +48,7 @@ public:
|
||||||
quint32 GetP1Id() const;
|
quint32 GetP1Id() const;
|
||||||
quint32 GetP2Id() const;
|
quint32 GetP2Id() const;
|
||||||
private:
|
private:
|
||||||
quint32 p1Id;
|
QSharedDataPointer<VLengthLineData> d;
|
||||||
quint32 p2Id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline quint32 VLengthLine::GetP1Id() const
|
|
||||||
{
|
|
||||||
return p1Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
inline quint32 VLengthLine::GetP2Id() const
|
|
||||||
{
|
|
||||||
return p2Id;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // VLINELENGTH_H
|
#endif // VLINELENGTH_H
|
||||||
|
|
58
src/app/container/vlinelength_p.h
Normal file
58
src/app/container/vlinelength_p.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vlinelength_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 VLINELENGTH_P_H
|
||||||
|
#define VLINELENGTH_P_H
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
#include "../options.h"
|
||||||
|
|
||||||
|
class VLengthLineData : public QSharedData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
VLengthLineData()
|
||||||
|
:p1Id(NULL_ID), p2Id(NULL_ID)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VLengthLineData(const quint32 &p1Id, const quint32 &p2Id)
|
||||||
|
:p1Id(p1Id), p2Id(p2Id)
|
||||||
|
{}
|
||||||
|
|
||||||
|
VLengthLineData(const VLengthLineData &var)
|
||||||
|
:QSharedData(var), p1Id(var.p1Id), p2Id(var.p2Id)
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual ~VLengthLineData() {}
|
||||||
|
|
||||||
|
quint32 p1Id;
|
||||||
|
quint32 p2Id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // VLINELENGTH_P_H
|
Loading…
Reference in New Issue
Block a user