Refactoring.
--HG-- branch : develop
This commit is contained in:
parent
bd58148080
commit
001c676ab5
|
@ -14,7 +14,8 @@ SOURCES += \
|
|||
$$PWD/variables/vlinelength.cpp \
|
||||
$$PWD/variables/vsplinelength.cpp \
|
||||
$$PWD/vformula.cpp \
|
||||
$$PWD/variables/varcradius.cpp
|
||||
$$PWD/variables/varcradius.cpp \
|
||||
$$PWD/variables/vcurvevariable.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/vcontainer.h \
|
||||
|
@ -32,10 +33,10 @@ HEADERS += \
|
|||
$$PWD/variables/vinternalvariable_p.h \
|
||||
$$PWD/variables/vvariable_p.h \
|
||||
$$PWD/variables/vincrement_p.h \
|
||||
$$PWD/variables/vcurvelength_p.h \
|
||||
$$PWD/variables/vlineangle_p.h \
|
||||
$$PWD/variables/vlinelength_p.h \
|
||||
$$PWD/variables/vmeasurement_p.h \
|
||||
$$PWD/vformula.h \
|
||||
$$PWD/variables/varcradius.h \
|
||||
$$PWD/variables/varcradius_p.h
|
||||
$$PWD/variables/vcurvevariable.h \
|
||||
$$PWD/variables/vcurvevariable_p.h
|
||||
|
|
|
@ -27,33 +27,30 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "varcradius.h"
|
||||
#include "varcradius_p.h"
|
||||
#include "../libs/vgeometry/varc.h"
|
||||
#include "../core/vapplication.h"
|
||||
|
||||
#include <QLineF>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VArcRadius::VArcRadius()
|
||||
:VInternalVariable(), d(new VArcRadiusData)
|
||||
:VCurveVariable()
|
||||
{
|
||||
SetType(VarType::ArcRadius);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VArcRadius::VArcRadius(const VArc *arc, quint32 arcId)
|
||||
:VInternalVariable(), d(new VArcRadiusData(arcId))
|
||||
VArcRadius::VArcRadius(const quint32 &id, const quint32 &parentId, const VArc *arc)
|
||||
:VCurveVariable(id, parentId)
|
||||
{
|
||||
SCASSERT(arc != nullptr);
|
||||
|
||||
SetType(VarType::ArcRadius);
|
||||
SetName(QString(radiusArc_+"%1").arg(arc->name()));
|
||||
SetValue(arc);
|
||||
SetValue(qApp->fromPixel(arc->GetRadius()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VArcRadius::VArcRadius(const VArcRadius &var)
|
||||
:VInternalVariable(var), d(var.d)
|
||||
:VCurveVariable(var)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -63,31 +60,10 @@ VArcRadius &VArcRadius::operator=(const VArcRadius &var)
|
|||
{
|
||||
return *this;
|
||||
}
|
||||
VInternalVariable::operator=(var);
|
||||
d = var.d;
|
||||
VCurveVariable::operator=(var);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VArcRadius::~VArcRadius()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VArcRadius::Filter(quint32 id)
|
||||
{
|
||||
return id == d->arcId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VArcRadius::SetValue(const VArc *arc)
|
||||
{
|
||||
SCASSERT(arc != nullptr);
|
||||
|
||||
VInternalVariable::SetValue(qApp->fromPixel(arc->GetRadius()));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VArcRadius::GetArcId() const
|
||||
{
|
||||
return d->arcId;
|
||||
}
|
||||
|
|
|
@ -29,25 +29,18 @@
|
|||
#ifndef VARCRADIUS_H
|
||||
#define VARCRADIUS_H
|
||||
|
||||
#include "vinternalvariable.h"
|
||||
#include "vcurvevariable.h"
|
||||
|
||||
class VArc;
|
||||
class VArcRadiusData;
|
||||
|
||||
class VArcRadius :public VInternalVariable
|
||||
class VArcRadius :public VCurveVariable
|
||||
{
|
||||
public:
|
||||
VArcRadius();
|
||||
VArcRadius(const VArc *arc, quint32 arcId);
|
||||
VArcRadius(const quint32 &id, const quint32 &parentId, const VArc *arc);
|
||||
VArcRadius(const VArcRadius &var);
|
||||
VArcRadius &operator=(const VArcRadius &var);
|
||||
virtual ~VArcRadius();
|
||||
|
||||
virtual bool Filter(quint32 id);
|
||||
void SetValue(const VArc *arc);
|
||||
quint32 GetArcId() const;
|
||||
private:
|
||||
QSharedDataPointer<VArcRadiusData> d;
|
||||
};
|
||||
|
||||
#endif // VARCRADIUS_H
|
||||
|
|
|
@ -27,20 +27,19 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vcurvelength.h"
|
||||
#include "vcurvelength_p.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../libs/vgeometry/vabstractcurve.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveLength::VCurveLength()
|
||||
:VInternalVariable(), d(new VCurveLengthData)
|
||||
:VCurveVariable()
|
||||
{
|
||||
SetType(VarType::Unknown);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve)
|
||||
:VInternalVariable(), d(new VCurveLengthData(id, parentId))
|
||||
:VCurveVariable(id, parentId)
|
||||
{
|
||||
SetType(VarType::Unknown);
|
||||
SCASSERT(curve != nullptr);
|
||||
|
@ -50,7 +49,7 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveLength::VCurveLength(const VCurveLength &var)
|
||||
:VInternalVariable(var), d(var.d)
|
||||
:VCurveVariable(var)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -60,50 +59,10 @@ VCurveLength &VCurveLength::operator=(const VCurveLength &var)
|
|||
{
|
||||
return *this;
|
||||
}
|
||||
VInternalVariable::operator=(var);
|
||||
d = var.d;
|
||||
VCurveVariable::operator=(var);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveLength::~VCurveLength()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCurveLength::Filter(quint32 id)
|
||||
{
|
||||
if (d->parentId != 0)//Do not check if value zero
|
||||
{// Not all curves have parents. Only those who was created after cutting the parent curve.
|
||||
return d->id == id || d->parentId == id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return d->id == id;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VCurveLength::GetId() const
|
||||
{
|
||||
return d->id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurveLength::SetId(const quint32 &id)
|
||||
{
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VCurveLength::GetParentId() const
|
||||
{
|
||||
return d->parentId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurveLength::SetParentId(const quint32 &value)
|
||||
{
|
||||
d->parentId = value;
|
||||
}
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#ifndef VCURVELENGTH_H
|
||||
#define VCURVELENGTH_H
|
||||
|
||||
#include "vinternalvariable.h"
|
||||
#include "vcurvevariable.h"
|
||||
|
||||
class VAbstractCurve;
|
||||
class VCurveLengthData;
|
||||
|
||||
class VCurveLength : public VInternalVariable
|
||||
class VCurveLength : public VCurveVariable
|
||||
{
|
||||
public:
|
||||
VCurveLength();
|
||||
|
@ -42,16 +41,6 @@ public:
|
|||
VCurveLength(const VCurveLength &var);
|
||||
VCurveLength &operator=(const VCurveLength &var);
|
||||
virtual ~VCurveLength();
|
||||
|
||||
virtual bool Filter(quint32 id);
|
||||
|
||||
quint32 GetId() const;
|
||||
void SetId(const quint32 &id);
|
||||
|
||||
quint32 GetParentId() const;
|
||||
void SetParentId(const quint32 &value);
|
||||
private:
|
||||
QSharedDataPointer<VCurveLengthData> d;
|
||||
};
|
||||
|
||||
#endif // VCURVELENGTH_H
|
||||
|
|
106
src/app/container/variables/vcurvevariable.cpp
Normal file
106
src/app/container/variables/vcurvevariable.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vcurvelength.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 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) 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 "vcurvevariable.h"
|
||||
#include "vcurvevariable_p.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../libs/vgeometry/vabstractcurve.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveVariable::VCurveVariable()
|
||||
:VInternalVariable(), d(new VCurveVariableData)
|
||||
{
|
||||
SetType(VarType::Unknown);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveVariable::VCurveVariable(const quint32 &id, const quint32 &parentId)
|
||||
:VInternalVariable(), d(new VCurveVariableData(id, parentId))
|
||||
{
|
||||
SetType(VarType::Unknown);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveVariable::VCurveVariable(const VCurveVariable &var)
|
||||
:VInternalVariable(var), d(var.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveVariable &VCurveVariable::operator=(const VCurveVariable &var)
|
||||
{
|
||||
if ( &var == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
VInternalVariable::operator=(var);
|
||||
d = var.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VCurveVariable::~VCurveVariable()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCurveVariable::Filter(quint32 id)
|
||||
{
|
||||
if (d->parentId != 0)//Do not check if value zero
|
||||
{// Not all curves have parents. Only those who was created after cutting the parent curve.
|
||||
return d->id == id || d->parentId == id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return d->id == id;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VCurveVariable::GetId() const
|
||||
{
|
||||
return d->id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurveVariable::SetId(const quint32 &id)
|
||||
{
|
||||
d->id = id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VCurveVariable::GetParentId() const
|
||||
{
|
||||
return d->parentId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCurveVariable::SetParentId(const quint32 &value)
|
||||
{
|
||||
d->parentId = value;
|
||||
}
|
57
src/app/container/variables/vcurvevariable.h
Normal file
57
src/app/container/variables/vcurvevariable.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vcurvelength.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 15 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) 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/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VCURVEVARIABLE_H
|
||||
#define VCURVEVARIABLE_H
|
||||
|
||||
#include "vinternalvariable.h"
|
||||
|
||||
class VAbstractCurve;
|
||||
class VCurveVariableData;
|
||||
|
||||
class VCurveVariable : public VInternalVariable
|
||||
{
|
||||
public:
|
||||
VCurveVariable();
|
||||
VCurveVariable(const quint32 &id, const quint32 &parentId);
|
||||
VCurveVariable(const VCurveVariable &var);
|
||||
VCurveVariable &operator=(const VCurveVariable &var);
|
||||
virtual ~VCurveVariable();
|
||||
|
||||
virtual bool Filter(quint32 id);
|
||||
|
||||
quint32 GetId() const;
|
||||
void SetId(const quint32 &id);
|
||||
|
||||
quint32 GetParentId() const;
|
||||
void SetParentId(const quint32 &value);
|
||||
private:
|
||||
QSharedDataPointer<VCurveVariableData> d;
|
||||
};
|
||||
|
||||
#endif // VCURVEVARIABLE_H
|
|
@ -36,29 +36,29 @@
|
|||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
#endif
|
||||
|
||||
class VCurveLengthData : public QSharedData
|
||||
class VCurveVariableData : public QSharedData
|
||||
{
|
||||
public:
|
||||
|
||||
VCurveLengthData()
|
||||
VCurveVariableData()
|
||||
:id(NULL_ID), parentId(NULL_ID)
|
||||
{}
|
||||
|
||||
VCurveLengthData(const quint32 &id, const quint32 &parentId)
|
||||
VCurveVariableData(const quint32 &id, const quint32 &parentId)
|
||||
:id(id), parentId(parentId)
|
||||
{}
|
||||
|
||||
VCurveLengthData(const VCurveLengthData &var)
|
||||
VCurveVariableData(const VCurveVariableData &var)
|
||||
:QSharedData(var), id(var.id), parentId(var.parentId)
|
||||
{}
|
||||
|
||||
virtual ~VCurveLengthData();
|
||||
virtual ~VCurveVariableData();
|
||||
|
||||
quint32 id;
|
||||
quint32 parentId;
|
||||
};
|
||||
|
||||
VCurveLengthData::~VCurveLengthData()
|
||||
VCurveVariableData::~VCurveVariableData()
|
||||
{}
|
||||
|
||||
#ifdef Q_CC_GNU
|
|
@ -321,7 +321,7 @@ void VContainer::AddArc(const quint32 &arcId, const quint32 &parentId)
|
|||
AddCurveLength<VArcLength>(arcId, parentId);
|
||||
|
||||
const QSharedPointer<VArc> arc = GeometricObject<VArc>(arcId);
|
||||
VArcRadius *radius = new VArcRadius(arc.data(), arcId);
|
||||
VArcRadius *radius = new VArcRadius(arcId, parentId, arc.data());
|
||||
AddVariable(radius->GetName(), radius);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user