Added new curve path segment variables.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-04-02 00:15:04 +03:00
parent d1480132a0
commit c99cdb69ec
13 changed files with 89 additions and 21 deletions

View File

@ -1,4 +1,5 @@
# Version 0.5.0 # Version 0.5.0
- Added new curve path segment variables.
- Toggle ScrollHandDrag mode by clicking a middle mouse button. - Toggle ScrollHandDrag mode by clicking a middle mouse button.
- Added horizontal scrolling by pressiong Shift + mouse wheel. - Added horizontal scrolling by pressiong Shift + mouse wheel.
- [#366] Update 'Point from Distance and Angle' tool to read distance and angle between points. - [#366] Update 'Point from Distance and Angle' tool to read distance and angle between points.

View File

@ -160,6 +160,7 @@ const QString angle1Spl_ = angle1_V + spl_;
const QString angle2Spl_ = angle2_V + spl_; const QString angle2Spl_ = angle2_V + spl_;
const QString angle1SplPath = angle1_V + splPath; const QString angle1SplPath = angle1_V + splPath;
const QString angle2SplPath = angle2_V + splPath; const QString angle2SplPath = angle2_V + splPath;
const QString seg_ = QStringLiteral("Seg_");
const QStringList builInVariables = QStringList() << line_ const QStringList builInVariables = QStringList() << line_
<< angleLine_ << angleLine_
@ -175,4 +176,5 @@ const QStringList builInVariables = QStringList() << line_
<< angle1Spl_ << angle1Spl_
<< angle2Spl_ << angle2Spl_
<< angle1SplPath << angle1SplPath
<< angle2SplPath; << angle2SplPath
<< seg_;

View File

@ -167,6 +167,7 @@ extern const QString angle1Spl_;
extern const QString angle2Spl_; extern const QString angle2Spl_;
extern const QString angle1SplPath; extern const QString angle1SplPath;
extern const QString angle2SplPath; extern const QString angle2SplPath;
extern const QString seg_;
extern const QStringList builInVariables; extern const QStringList builInVariables;

View File

@ -28,6 +28,7 @@
#include "vcurveangle.h" #include "vcurveangle.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vspline.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCurveAngle::VCurveAngle() VCurveAngle::VCurveAngle()
@ -45,12 +46,30 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbst
if (angle == CurveAngle::StartAngle) if (angle == CurveAngle::StartAngle)
{ {
SetValue(curve->GetStartAngle()); SetValue(curve->GetStartAngle());
SetName(QString(angle1_V+"%1").arg(curve->name())); SetName(angle1_V + curve->name());
} }
else else
{ {
SetValue(curve->GetEndAngle()); SetValue(curve->GetEndAngle());
SetName(QString(angle2_V+"%1").arg(curve->name())); SetName(angle2_V + curve->name());
}
}
//---------------------------------------------------------------------------------------------------------------------
VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
CurveAngle angle, qint32 segment)
:VCurveVariable(id, parentId)
{
SetType(VarType::CurveAngle);
if (angle == CurveAngle::StartAngle)
{
SetValue(spl.GetStartAngle());
SetName(angle1_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
}
else
{
SetValue(spl.GetEndAngle());
SetName(angle2_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
} }
} }

View File

@ -32,6 +32,7 @@
#include "../vpatterndb/variables/vcurvevariable.h" #include "../vpatterndb/variables/vcurvevariable.h"
class VAbstractCurve; class VAbstractCurve;
class VSpline;
enum class CurveAngle : char { StartAngle, EndAngle }; enum class CurveAngle : char { StartAngle, EndAngle };
@ -40,6 +41,8 @@ class VCurveAngle : public VCurveVariable
public: public:
VCurveAngle(); VCurveAngle();
VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, CurveAngle angle); 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(const VCurveAngle &var);
VCurveAngle &operator=(const VCurveAngle &var); VCurveAngle &operator=(const VCurveAngle &var);
virtual ~VCurveAngle() Q_DECL_OVERRIDE; virtual ~VCurveAngle() Q_DECL_OVERRIDE;

View File

@ -28,6 +28,7 @@
#include "vcurvelength.h" #include "vcurvelength.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vspline.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCurveLength::VCurveLength() VCurveLength::VCurveLength()
@ -46,6 +47,18 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb
SetValue(FromPixel(curve->GetLength(), patternUnit)); SetValue(FromPixel(curve->GetLength(), patternUnit));
} }
//---------------------------------------------------------------------------------------------------------------------
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
Unit patternUnit, qint32 segment)
:VCurveVariable(id, parentId)
{
SCASSERT(not baseCurveName.isEmpty())
SetType(VarType::CurveLength);
SetName(baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetValue(FromPixel(spl.GetLength(), patternUnit));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VCurveLength::VCurveLength(const VCurveLength &var) VCurveLength::VCurveLength(const VCurveLength &var)
:VCurveVariable(var) :VCurveVariable(var)

View File

@ -33,12 +33,15 @@
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
class VAbstractCurve; class VAbstractCurve;
class VSpline;
class VCurveLength : public VCurveVariable class VCurveLength : public VCurveVariable
{ {
public: public:
VCurveLength(); VCurveLength();
VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, Unit patternUnit); VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, Unit patternUnit);
VCurveLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
Unit patternUnit, qint32 segment);
VCurveLength(const VCurveLength &var); VCurveLength(const VCurveLength &var);
VCurveLength &operator=(const VCurveLength &var); VCurveLength &operator=(const VCurveLength &var);
virtual ~VCurveLength() Q_DECL_OVERRIDE; virtual ~VCurveLength() Q_DECL_OVERRIDE;

View File

@ -379,7 +379,7 @@ void VContainer::AddArc(const QSharedPointer<VArc> &arc, const quint32 &id, cons
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, const quint32 &parentId) void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId)
{ {
const GOType curveType = curve->getType(); const GOType curveType = curve->getType();
if (curveType != GOType::Spline && curveType != GOType::SplinePath && if (curveType != GOType::Spline && curveType != GOType::SplinePath &&
@ -399,6 +399,27 @@ void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const qui
AddVariable(endAngle->GetName(), endAngle); AddVariable(endAngle->GetName(), endAngle);
} }
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
quint32 parentId)
{
AddCurve(curve, id, parentId);
for (qint32 i = 1; i <= curve->CountSubSpl(); ++i)
{
const VSpline spl = curve->GetSpline(i);
VCurveLength *length = new VCurveLength(id, parentId, curve->name(), spl, *GetPatternUnit(), i);
AddVariable(length->GetName(), length);
VCurveAngle *startAngle = new VCurveAngle(id, parentId, curve->name(), spl, CurveAngle::StartAngle, i);
AddVariable(startAngle->GetName(), startAngle);
VCurveAngle *endAngle = new VCurveAngle(id, parentId, curve->name(), spl, CurveAngle::EndAngle, i);
AddVariable(endAngle->GetName(), endAngle);
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief AddObject add object to container * @brief AddObject add object to container

View File

@ -34,6 +34,7 @@
#include "../vgeometry/vgobject.h" #include "../vgeometry/vgobject.h"
#include "../ifc/exception/vexceptionbadid.h" #include "../ifc/exception/vexceptionbadid.h"
#include "../vgeometry/vabstractcurve.h" #include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vabstractcubicbezierpath.h"
#include "vtranslatevars.h" #include "vtranslatevars.h"
#include <QCoreApplication> #include <QCoreApplication>
@ -122,7 +123,9 @@ public:
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
void AddArc(const QSharedPointer<VArc> &arc, const quint32 &arcId, const quint32 &parentId = 0); void AddArc(const QSharedPointer<VArc> &arc, const quint32 &arcId, const quint32 &parentId = 0);
void AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, void AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id,
const quint32 &parentId = NULL_ID); quint32 parentId = NULL_ID);
void AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
quint32 parentId = NULL_ID);
template <typename T> template <typename T>
void AddVariable(const QString& name, T *var); void AddVariable(const QString& name, T *var);

View File

@ -366,20 +366,21 @@ void VTranslateVars::InitPatternMakingSystems()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTranslateVars::InitVariables() void VTranslateVars::InitVariables()
{ {
variables.insert(line_, translate("VTranslateVars", "Line_", "Left symbol _ in name")); variables.insert(line_, translate("VTranslateVars", "Line_", "Left symbol _ in the name"));
variables.insert(angleLine_, translate("VTranslateVars", "AngleLine_", "Left symbol _ in name")); variables.insert(angleLine_, translate("VTranslateVars", "AngleLine_", "Left symbol _ in the name"));
variables.insert(arc_, translate("VTranslateVars", "Arc_", "Left symbol _ in name")); variables.insert(arc_, translate("VTranslateVars", "Arc_", "Left symbol _ in the name"));
variables.insert(spl_, translate("VTranslateVars", "Spl_", "Left symbol _ in name")); variables.insert(spl_, translate("VTranslateVars", "Spl_", "Left symbol _ in the name"));
variables.insert(splPath, translate("VTranslateVars", "SplPath", "Do not add symbol _ to the end of name")); variables.insert(splPath, translate("VTranslateVars", "SplPath", "Do not add symbol _ to the end of the name"));
variables.insert(radiusArc_, translate("VTranslateVars", "RadiusArc_", "Left symbol _ in name")); variables.insert(radiusArc_, translate("VTranslateVars", "RadiusArc_", "Left symbol _ in the name"));
variables.insert(angle1Arc_, translate("VTranslateVars", "Angle1Arc_", "Left symbol _ in name")); variables.insert(angle1Arc_, translate("VTranslateVars", "Angle1Arc_", "Left symbol _ in the name"));
variables.insert(angle2Arc_, translate("VTranslateVars", "Angle2Arc_", "Left symbol _ in name")); variables.insert(angle2Arc_, translate("VTranslateVars", "Angle2Arc_", "Left symbol _ in the name"));
variables.insert(angle1Spl_, translate("VTranslateVars", "Angle1Spl_", "Left symbol _ in name")); variables.insert(angle1Spl_, translate("VTranslateVars", "Angle1Spl_", "Left symbol _ in the name"));
variables.insert(angle2Spl_, translate("VTranslateVars", "Angle2Spl_", "Left symbol _ in name")); variables.insert(angle2Spl_, translate("VTranslateVars", "Angle2Spl_", "Left symbol _ in the name"));
variables.insert(angle1SplPath, translate("VTranslateVars", "Angle1SplPath", variables.insert(angle1SplPath, translate("VTranslateVars", "Angle1SplPath",
"Do not add symbol _ to the end of name")); "Do not add symbol _ to the end of the name"));
variables.insert(angle2SplPath, translate("VTranslateVars", "Angle2SplPath", variables.insert(angle2SplPath, translate("VTranslateVars", "Angle2SplPath",
"Do not add symbol _ to the end of name")); "Do not add symbol _ to the end of the name"));
variables.insert(seg_, translate("VTranslateVars", "Seg_", "Segment. Left symbol _ in the name"));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -92,12 +92,12 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
{ {
id = data->AddGObject(path); id = data->AddGObject(path);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id); data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
} }
else else
{ {
data->UpdateGObject(id, path); data->UpdateGObject(id, path);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id); data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
if (parse != Document::FullParse) if (parse != Document::FullParse)
{ {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);

View File

@ -166,12 +166,12 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
{ {
id = data->AddGObject(path); id = data->AddGObject(path);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id); data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
} }
else else
{ {
data->UpdateGObject(id, path); data->UpdateGObject(id, path);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id); data->AddCurveWithSegments(data->GeometricObject<VAbstractCubicBezierPath>(id), id);
if (parse != Document::FullParse) if (parse != Document::FullParse)
{ {
doc->UpdateToolData(id, data); doc->UpdateToolData(id, data);

View File

@ -648,6 +648,7 @@ void TST_MeasurementRegExp::CheckUnderlineExists() const
data.insert(angle2Spl_, true); data.insert(angle2Spl_, true);
data.insert(angle1SplPath, false); data.insert(angle1SplPath, false);
data.insert(angle2SplPath, false); data.insert(angle2SplPath, false);
data.insert(seg_, true);
//Catch case when new internal variable appears. //Catch case when new internal variable appears.
QCOMPARE(data.size(), builInVariables.size()); QCOMPARE(data.size(), builInVariables.size());