From e6dcfd708b7dc3cfad2064f1ede88651d424eb11 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 5 Jan 2018 21:07:47 +0200 Subject: [PATCH] New internal variable RotationElArc. --HG-- branch : develop --- ChangeLog.txt | 1 + src/libs/ifc/ifcdef.cpp | 5 ++- src/libs/ifc/ifcdef.h | 2 ++ src/libs/vpatterndb/variables/vcurveangle.cpp | 33 +++++++++++-------- src/libs/vpatterndb/variables/vcurveangle.h | 15 +++++++-- src/libs/vpatterndb/vcontainer.cpp | 3 ++ src/libs/vpatterndb/vtranslatevars.cpp | 1 + .../TranslationsTest/tst_buitinregexp.cpp | 1 + 8 files changed, 43 insertions(+), 18 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 6bbe4128b..4074b6c94 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -36,6 +36,7 @@ - [#783] Flipping control. - [#790] Generate unique name for each detail. - [#792] New feature. Visibility trigger for internal path. +- New internal variable RotationElArc. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions. diff --git a/src/libs/ifc/ifcdef.cpp b/src/libs/ifc/ifcdef.cpp index 7cf49e776..0dd41191e 100644 --- a/src/libs/ifc/ifcdef.cpp +++ b/src/libs/ifc/ifcdef.cpp @@ -283,6 +283,8 @@ const QString angle2SplPath = angle2_V + splPath; const QString seg_ = QStringLiteral("Seg_"); const QString currentLength = QStringLiteral("CurrentLength"); const QString currentSeamAllowance = QStringLiteral("CurrentSeamAllowance"); +const QString rotation_V = QStringLiteral("Rotation"); +const QString rotationElArc_ = rotation_V + elarc_; const QStringList builInVariables = QStringList() << measurement_ << increment_ @@ -309,4 +311,5 @@ const QStringList builInVariables = QStringList() << measurement_ << c1LengthSpl_ << c2LengthSpl_ << c1LengthSplPath - << c2LengthSplPath; + << c2LengthSplPath + << rotationElArc_; diff --git a/src/libs/ifc/ifcdef.h b/src/libs/ifc/ifcdef.h index 9a1b95892..34cce0ea5 100644 --- a/src/libs/ifc/ifcdef.h +++ b/src/libs/ifc/ifcdef.h @@ -219,6 +219,8 @@ extern const QString angle2SplPath; extern const QString seg_; extern const QString currentLength; extern const QString currentSeamAllowance; +extern const QString rotation_V; +extern const QString rotationElArc_; extern const QStringList builInVariables; diff --git a/src/libs/vpatterndb/variables/vcurveangle.cpp b/src/libs/vpatterndb/variables/vcurveangle.cpp index 351fd5526..d10a3dfcd 100644 --- a/src/libs/vpatterndb/variables/vcurveangle.cpp +++ b/src/libs/vpatterndb/variables/vcurveangle.cpp @@ -35,6 +35,7 @@ #include "../ifc/ifcdef.h" #include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vspline.h" +#include "../vgeometry/vellipticalarc.h" #include "vcurvevariable.h" //--------------------------------------------------------------------------------------------------------------------- @@ -44,6 +45,13 @@ VCurveAngle::VCurveAngle() SetType(VarType::CurveAngle); } +//--------------------------------------------------------------------------------------------------------------------- +VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId) + :VCurveVariable(id, parentId) +{ + SetType(VarType::CurveAngle); +} + //--------------------------------------------------------------------------------------------------------------------- VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, CurveAngle angle) :VCurveVariable(id, parentId) @@ -81,21 +89,18 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const QStri } //--------------------------------------------------------------------------------------------------------------------- -VCurveAngle::VCurveAngle(const VCurveAngle &var) - :VCurveVariable(var) -{} - -//--------------------------------------------------------------------------------------------------------------------- -VCurveAngle &VCurveAngle::operator=(const VCurveAngle &var) +VEllipticalArcRotation::VEllipticalArcRotation() + : VCurveAngle() { - if ( &var == this ) - { - return *this; - } - VCurveVariable::operator=(var); - return *this; + SetType(VarType::CurveAngle); } //--------------------------------------------------------------------------------------------------------------------- -VCurveAngle::~VCurveAngle() -{} +VEllipticalArcRotation::VEllipticalArcRotation(const quint32 &id, const quint32 &parentId, const VEllipticalArc *elArc) + : VCurveAngle(id, parentId) +{ + SetType(VarType::CurveAngle); + SCASSERT(elArc != nullptr) + SetValue(elArc->GetRotationAngle()); + SetName(rotation_V + elArc->name()); +} diff --git a/src/libs/vpatterndb/variables/vcurveangle.h b/src/libs/vpatterndb/variables/vcurveangle.h index e7f7f9278..b47e08fa8 100644 --- a/src/libs/vpatterndb/variables/vcurveangle.h +++ b/src/libs/vpatterndb/variables/vcurveangle.h @@ -37,6 +37,7 @@ class VAbstractCurve; class VSpline; +class VEllipticalArc; enum class CurveAngle : char { StartAngle, EndAngle }; @@ -47,9 +48,17 @@ public: VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, CurveAngle angle); VCurveAngle(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl, CurveAngle angle, qint32 segment); - VCurveAngle(const VCurveAngle &var); - VCurveAngle &operator=(const VCurveAngle &var); - virtual ~VCurveAngle() Q_DECL_OVERRIDE; + virtual ~VCurveAngle() =default; +protected: + VCurveAngle(const quint32 &id, const quint32 &parentId); +}; + +class VEllipticalArcRotation : public VCurveAngle +{ +public: + VEllipticalArcRotation(); + VEllipticalArcRotation(const quint32 &id, const quint32 &parentId, const VEllipticalArc *elArc); + virtual ~VEllipticalArcRotation() =default; }; #endif // VCURVEANGLE_H diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 749e64e3e..672a2cac1 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -376,6 +376,9 @@ void VContainer::AddArc(const QSharedPointer &arc, const quint32 VArcRadius *radius2 = new VArcRadius(id, parentId, casted.data(), 2, *GetPatternUnit()); AddVariable(radius2->GetName(), radius2); + + VEllipticalArcRotation *rotation = new VEllipticalArcRotation(id, parentId, casted.data()); + AddVariable(rotation->GetName(), rotation); } } diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index de3a90860..1c459c9a0 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -401,6 +401,7 @@ void VTranslateVars::InitVariables() "Do not add symbol _ to the end of the name")); variables.insert(c2LengthSplPath, translate("VTranslateVars", "C2LengthSplPath", "Do not add symbol _ to the end of the name")); + variables.insert(rotationElArc_, translate("VTranslateVars", "RotationElArc_", "Left symbol _ in the name")); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/test/TranslationsTest/tst_buitinregexp.cpp b/src/test/TranslationsTest/tst_buitinregexp.cpp index 26190f1f0..b799d9f2d 100644 --- a/src/test/TranslationsTest/tst_buitinregexp.cpp +++ b/src/test/TranslationsTest/tst_buitinregexp.cpp @@ -145,6 +145,7 @@ void TST_BuitInRegExp::TestCheckUnderlineExists_data() data.insert(c2LengthSpl_, true); data.insert(c1LengthSplPath, false); data.insert(c2LengthSplPath, false); + data.insert(rotationElArc_, true); //Catch case when new internal variable appears. QCOMPARE(data.size(), builInVariables.size());