New internal variable "Length to spline control point".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-09-24 20:44:06 +03:00
parent eee2144483
commit 3bb657ea1a
37 changed files with 515 additions and 72 deletions

View File

@ -84,6 +84,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par
FillLengthsLines();
FillLengthLinesAngles();
FillLengthsCurves();
FillCurvesCLengths();
FillRadiusesArcs();
FillAnglesCurves();
@ -232,6 +233,12 @@ void DialogIncrements::FillLengthsCurves()
FillTable(data->DataLengthCurves(), ui->tableWidgetSplines);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::FillCurvesCLengths()
{
FillTable(data->DataCurvesCLength(), ui->tableWidgetCLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::FillRadiusesArcs()
{
@ -254,6 +261,7 @@ void DialogIncrements::ShowUnits()
ShowHeaderUnits(ui->tableWidgetLines, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetSplines, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetCLength, 1, unit);// lengths
ShowHeaderUnits(ui->tableWidgetLinesAngles, 1, degreeSymbol);// angle
ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit);// radius
ShowHeaderUnits(ui->tableWidgetAnglesCurves, 1, degreeSymbol);// angle
@ -445,6 +453,7 @@ void DialogIncrements::FullUpdateFromFile()
FillLengthsLines();
FillLengthLinesAngles();
FillLengthsCurves();
FillCurvesCLengths();
FillRadiusesArcs();
FillAnglesCurves();

View File

@ -98,6 +98,7 @@ private:
void FillLengthsLines();
void FillLengthLinesAngles();
void FillLengthsCurves();
void FillCurvesCLengths();
void FillRadiusesArcs();
void FillAnglesCurves();

View File

@ -273,8 +273,7 @@
</property>
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
@ -288,8 +287,7 @@
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
@ -572,6 +570,45 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Curves control point lengths</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTableWidget" name="tableWidgetCLength">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>137</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Curve</string>
</property>
</column>
<column>
<property name="text">
<string>Length</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Angles curves</string>

View File

@ -3356,6 +3356,7 @@ void VPattern::PrepareForParse(const Document &parse)
data->ClearVariables(VarType::LineAngle);
data->ClearVariables(VarType::LineLength);
data->ClearVariables(VarType::CurveLength);
data->ClearVariables(VarType::CurveCLength);
data->ClearVariables(VarType::ArcRadius);
data->ClearVariables(VarType::CurveAngle);
}

View File

@ -162,6 +162,8 @@ const QString radius_V = QStringLiteral("Radius");
const QString radiusArc_ = radius_V + arc_;
const QString angle1_V = QStringLiteral("Angle1");
const QString angle2_V = QStringLiteral("Angle2");
const QString c1Length_V = QStringLiteral("C1Length");
const QString c2Length_V = QStringLiteral("C2Length");
const QString angle1Arc_ = angle1_V + arc_;
const QString angle2Arc_ = angle2_V + arc_;
const QString angle1Spl_ = angle1_V + spl_;

View File

@ -168,6 +168,8 @@ extern const QString radius_V;
extern const QString radiusArc_;
extern const QString angle1_V;
extern const QString angle2_V;
extern const QString c1Length_V;
extern const QString c2Length_V;
extern const QString angle1Arc_;
extern const QString angle2Arc_;
extern const QString angle1Spl_;

View File

@ -0,0 +1,57 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 24 9, 2016
**
** @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) 2016 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 "vabstractbezier.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::VAbstractBezier(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractCurve(type, idObject, mode)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::VAbstractBezier(const VAbstractBezier &curve)
: VAbstractCurve(curve)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier &VAbstractBezier::operator=(const VAbstractBezier &curve)
{
if ( &curve == this )
{
return *this;
}
VAbstractCurve::operator=(curve);
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractBezier::~VAbstractBezier()
{
}

View File

@ -0,0 +1,48 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 24 9, 2016
**
** @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) 2016 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 VABSTRACTBEZIER_H
#define VABSTRACTBEZIER_H
#include <QtGlobal>
#include "vabstractcurve.h"
class VAbstractBezier : public VAbstractCurve
{
public:
VAbstractBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
VAbstractBezier(const VAbstractBezier &curve);
VAbstractBezier& operator= (const VAbstractBezier &curve);
virtual ~VAbstractBezier();
virtual qreal GetC1Length() const =0;
virtual qreal GetC2Length() const =0;
};
#endif // VABSTRACTBEZIER_H

View File

@ -39,13 +39,13 @@
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::VAbstractCubicBezier(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractCurve(type, idObject, mode)
: VAbstractBezier(type, idObject, mode)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezier::VAbstractCubicBezier(const VAbstractCubicBezier &curve)
: VAbstractCurve(curve)
: VAbstractBezier(curve)
{
}
@ -56,7 +56,7 @@ VAbstractCubicBezier &VAbstractCubicBezier::operator=(const VAbstractCubicBezier
{
return *this;
}
VAbstractCurve::operator=(curve);
VAbstractBezier::operator=(curve);
return *this;
}

View File

@ -36,13 +36,13 @@
#include <QtGlobal>
#include "../ifc/ifcdef.h"
#include "vabstractcurve.h"
#include "vabstractbezier.h"
#include "vgeometrydef.h"
class QPointF;
class VPointF;
class VAbstractCubicBezier : public VAbstractCurve
class VAbstractCubicBezier : public VAbstractBezier
{
public:
VAbstractCubicBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);

View File

@ -40,13 +40,13 @@ class QPointF;
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezierPath::VAbstractCubicBezierPath(const GOType &type, const quint32 &idObject, const Draw &mode)
: VAbstractCurve(type, idObject, mode)
: VAbstractBezier(type, idObject, mode)
{
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractCubicBezierPath::VAbstractCubicBezierPath(const VAbstractCubicBezierPath &curve)
: VAbstractCurve(curve)
: VAbstractBezier(curve)
{
}
@ -57,7 +57,7 @@ VAbstractCubicBezierPath &VAbstractCubicBezierPath::operator=(const VAbstractCub
{
return *this;
}
VAbstractCurve::operator=(curve);
VAbstractBezier::operator=(curve);
return *this;
}

View File

@ -36,7 +36,7 @@
#include <QVector>
#include <QtGlobal>
#include "vabstractcurve.h"
#include "vabstractbezier.h"
#include "vgeometrydef.h"
class QPainterPath;
@ -45,7 +45,7 @@ class VPointF;
class VSpline;
class VSplinePoint;
class VAbstractCubicBezierPath : public VAbstractCurve
class VAbstractCubicBezierPath : public VAbstractBezier
{
Q_DECLARE_TR_FUNCTIONS(VAbstractCubicBezierPath)
public:

View File

@ -175,6 +175,18 @@ QVector<QPointF> VCubicBezier::GetPoints() const
return GetCubicBezierPoints(GetP1(), GetP2(), GetP3(), GetP4());
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezier::GetC1Length() const
{
return QLineF(GetP1(), GetP2()).length();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezier::GetC2Length() const
{
return QLineF(GetP4(), GetP3()).length();
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VCubicBezier::GetControlPoint1() const
{

View File

@ -73,6 +73,9 @@ public:
virtual qreal GetLength() const Q_DECL_OVERRIDE;
virtual QVector<QPointF> GetPoints() const Q_DECL_OVERRIDE;
virtual qreal GetC1Length() const Q_DECL_OVERRIDE;
virtual qreal GetC2Length() const Q_DECL_OVERRIDE;
protected:
virtual QPointF GetControlPoint1() const Q_DECL_OVERRIDE;
virtual QPointF GetControlPoint2() const Q_DECL_OVERRIDE;

View File

@ -210,6 +210,33 @@ qreal VCubicBezierPath::GetEndAngle() const
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezierPath::GetC1Length() const
{
if (CountSubSpl() > 0)
{
return GetSpline(1).GetC1Length();
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VCubicBezierPath::GetC2Length() const
{
const qint32 count = CountSubSpl();
if (count > 0)
{
return GetSpline(count).GetC2Length();
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VSplinePoint> VCubicBezierPath::GetSplinePath() const
{

View File

@ -72,6 +72,9 @@ public:
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
virtual qreal GetC1Length() const Q_DECL_OVERRIDE;
virtual qreal GetC2Length() const Q_DECL_OVERRIDE;
virtual QVector<VSplinePoint> GetSplinePath() const Q_DECL_OVERRIDE;
QVector<VPointF> GetCubicPath() const;

View File

@ -14,7 +14,8 @@ SOURCES += \
$$PWD/vabstractcubicbezier.cpp \
$$PWD/vabstractcubicbezierpath.cpp \
$$PWD/vcubicbezierpath.cpp \
$$PWD/vabstractarc.cpp
$$PWD/vabstractarc.cpp \
$$PWD/vabstractbezier.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -44,4 +45,5 @@ HEADERS += \
$$PWD/vcubicbezierpath.h \
$$PWD/vcubicbezierpath_p.h \
$$PWD/vabstractarc.h \
$$PWD/vabstractarc_p.h
$$PWD/vabstractarc_p.h \
$$PWD/vabstractbezier.h

View File

@ -85,8 +85,8 @@ public:
void SetStartAngle(qreal angle, const QString &formula);
void SetEndAngle(qreal angle, const QString &formula);
qreal GetC1Length() const;
qreal GetC2Length() const;
virtual qreal GetC1Length() const Q_DECL_OVERRIDE;
virtual qreal GetC2Length() const Q_DECL_OVERRIDE;
QString GetC1LengthFormula() const;
QString GetC2LengthFormula() const;

View File

@ -317,6 +317,32 @@ qreal VSplinePath::GetEndAngle() const
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSplinePath::GetC1Length() const
{
if (CountPoints() > 0)
{
return GetSplinePath().first().Length2();
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VSplinePath::GetC2Length() const
{
if (CountPoints() > 0)
{
return GetSplinePath().last().Length1();
}
else
{
return 0;
}
}
//---------------------------------------------------------------------------------------------------------------------
VPointF VSplinePath::FirstPoint() const
{

View File

@ -80,6 +80,9 @@ public:
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
virtual qreal GetC1Length() const Q_DECL_OVERRIDE;
virtual qreal GetC2Length() const Q_DECL_OVERRIDE;
void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point);
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const;

View File

@ -157,8 +157,8 @@ enum class Vis : ToolVisHolderType
ToolFlippingByAxis
};
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, LineAngle, CurveAngle, ArcRadius,
Unknown };
enum class VarType : char { Measurement, Increment, LineLength, CurveLength, CurveCLength, LineAngle, CurveAngle,
ArcRadius, Unknown };
enum class GHeights : unsigned char { ALL,
H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134,

View File

@ -37,5 +37,6 @@
#include "variables/vlineangle.h"
#include "variables/varcradius.h"
#include "variables/vcurveangle.h"
#include "variables/vcurveclength.h"
#endif // VARIABLES_H

View File

@ -0,0 +1,105 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 24 9, 2016
**
** @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) 2016 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 "vcurveclength.h"
#include <QLatin1String>
#include <QMessageLogger>
#include "../vmisc/def.h"
#include "../ifc/ifcdef.h"
#include "../vgeometry/vabstractcurve.h"
#include "../vgeometry/vspline.h"
#include "vcurvevariable.h"
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::VCurveCLength()
: VCurveVariable()
{
SetType(VarType::CurveCLength);
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *curve,
CurveCLength cType, Unit patternUnit)
: VCurveVariable(id, parentId)
{
SetType(VarType::CurveCLength);
SCASSERT(curve != nullptr);
if (cType == CurveCLength::C1)
{
SetValue(FromPixel(curve->GetC1Length(), patternUnit));
SetName(c1Length_V + curve->name());
}
else
{
SetValue(FromPixel(curve->GetC2Length(), patternUnit));
SetName(c2Length_V + curve->name());
}
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName,
const VSpline &spl, CurveCLength cType, Unit patternUnit, qint32 segment)
: VCurveVariable(id, parentId)
{
SetType(VarType::CurveCLength);
if (cType == CurveCLength::C1)
{
SetValue(FromPixel(spl.GetC1Length(), patternUnit));
SetName(c1Length_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
}
else
{
SetValue(FromPixel(spl.GetC2Length(), patternUnit));
SetName(c2Length_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
}
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::VCurveCLength(const VCurveCLength &var)
: VCurveVariable(var)
{
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength &VCurveCLength::operator=(const VCurveCLength &var)
{
if ( &var == this )
{
return *this;
}
VCurveVariable::operator=(var);
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::~VCurveCLength()
{
}

View File

@ -0,0 +1,56 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 24 9, 2016
**
** @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) 2016 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 VCURVECLENGTH_H
#define VCURVECLENGTH_H
#include <qcompilerdetection.h>
#include <QString>
#include <QtGlobal>
#include "vcurvevariable.h"
enum class CurveCLength : char { C1, C2 };
class VAbstractBezier;
class VSpline;
class VCurveCLength : public VCurveVariable
{
public:
VCurveCLength();
VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *curve, CurveCLength cType,
Unit patternUnit);
VCurveCLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
CurveCLength cType, Unit patternUnit, qint32 segment);
VCurveCLength(const VCurveCLength &var);
VCurveCLength &operator=(const VCurveCLength &var);
virtual ~VCurveCLength() Q_DECL_OVERRIDE;
};
#endif // VCURVECLENGTH_H

View File

@ -46,6 +46,7 @@
#include "variables/varcradius.h"
#include "variables/vcurveangle.h"
#include "variables/vcurvelength.h"
#include "variables/vcurveclength.h"
#include "variables/vincrement.h"
#include "variables/vlineangle.h"
#include "variables/vlinelength.h"
@ -276,6 +277,7 @@ void VContainer::ClearForFullParse()
ClearVariables(VarType::LineAngle);
ClearVariables(VarType::LineLength);
ClearVariables(VarType::CurveLength);
ClearVariables(VarType::CurveCLength);
ClearVariables(VarType::ArcRadius);
ClearVariables(VarType::CurveAngle);
ClearGObjects();
@ -407,11 +409,23 @@ void VContainer::AddCurve(const QSharedPointer<VAbstractCurve> &curve, const qui
AddVariable(endAngle->GetName(), endAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId)
{
AddCurve(curve, id, parentId);
VCurveCLength *c1Length = new VCurveCLength(id, parentId, curve.data(), CurveCLength::C1, *GetPatternUnit());
AddVariable(c1Length->GetName(), c1Length);
VCurveCLength *c2Length = new VCurveCLength(id, parentId, curve.data(), CurveCLength::C2, *GetPatternUnit());
AddVariable(c2Length->GetName(), c2Length);
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
quint32 parentId)
{
AddCurve(curve, id, parentId);
AddSpline(curve, id, parentId);
for (qint32 i = 1; i <= curve->CountSubSpl(); ++i)
{
@ -425,6 +439,14 @@ void VContainer::AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierP
VCurveAngle *endAngle = new VCurveAngle(id, parentId, curve->name(), spl, CurveAngle::EndAngle, i);
AddVariable(endAngle->GetName(), endAngle);
VCurveCLength *c1Length = new VCurveCLength(id, parentId, curve->name(), spl, CurveCLength::C1,
*GetPatternUnit(), i);
AddVariable(c1Length->GetName(), c1Length);
VCurveCLength *c2Length = new VCurveCLength(id, parentId, curve->name(), spl, CurveCLength::C2,
*GetPatternUnit(), i);
AddVariable(c2Length->GetName(), c2Length);
}
}
@ -524,6 +546,12 @@ const QMap<QString, QSharedPointer<VCurveLength> > VContainer::DataLengthCurves(
return DataVar<VCurveLength>(VarType::CurveLength);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, QSharedPointer<VCurveCLength> > VContainer::DataCurvesCLength() const
{
return DataVar<VCurveCLength>(VarType::CurveCLength);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() const
{

View File

@ -140,9 +140,8 @@ public:
quint32 AddGObject(VGObject *obj);
quint32 AddDetail(const VDetail &detail);
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
void AddArc(const QSharedPointer<VArc> &arc, const quint32 &arcId, const quint32 &parentId = 0);
void AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id,
quint32 parentId = NULL_ID);
void AddArc(const QSharedPointer<VArc> &arc, const quint32 &arcId, const quint32 &parentId = NULL_ID);
void AddSpline(const QSharedPointer<VAbstractBezier> &curve, quint32 id, quint32 parentId = NULL_ID);
void AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierPath> &curve, const quint32 &id,
quint32 parentId = NULL_ID);
@ -176,13 +175,14 @@ public:
const QHash<quint32, VDetail> *DataDetails() const;
const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const;
const QMap<QString, QSharedPointer<VMeasurement> > DataMeasurements() const;
const QMap<QString, QSharedPointer<VIncrement> > DataIncrements() const;
const QMap<QString, QSharedPointer<VLengthLine> > DataLengthLines() const;
const QMap<QString, QSharedPointer<VCurveLength> > DataLengthCurves() const;
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
const QMap<QString, QSharedPointer<VMeasurement> > DataMeasurements() const;
const QMap<QString, QSharedPointer<VIncrement> > DataIncrements() const;
const QMap<QString, QSharedPointer<VLengthLine> > DataLengthLines() const;
const QMap<QString, QSharedPointer<VCurveLength> > DataLengthCurves() const;
const QMap<QString, QSharedPointer<VCurveCLength> > DataCurvesCLength() const;
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
const QMap<QString, QSharedPointer<VCurveAngle> > DataAnglesCurves() const;
const QHash<QString, qreal *> PlainVariables() const;
@ -203,6 +203,8 @@ private:
QSharedDataPointer<VContainerData> d;
void AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId = NULL_ID);
template <class T>
uint qHash( const QSharedPointer<T> &p );

View File

@ -19,7 +19,8 @@ SOURCES += \
$$PWD/variables/vvariable.cpp \
$$PWD/vformula.cpp \
$$PWD/vpatternpiecedata.cpp \
$$PWD/vpatterninfogeometry.cpp
$$PWD/vpatterninfogeometry.cpp \
$$PWD/variables/vcurveclength.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -53,4 +54,5 @@ HEADERS += \
$$PWD/variables/vvariable_p.h \
$$PWD/vformula.h \
$$PWD/vpatternpiecedata.h \
$$PWD/vpatterninfogeometry.h
$$PWD/vpatterninfogeometry.h \
$$PWD/variables/vcurveclength.h

View File

@ -297,6 +297,13 @@ void DialogEditWrongFormula::LengthCurves()
ShowVariable(data->DataLengthCurves());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::CurvesCLength()
{
ui->checkBoxHideEmpty->setEnabled(false);
ShowVariable(data->DataCurvesCLength());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::AngleLines()
{
@ -399,6 +406,7 @@ void DialogEditWrongFormula::InitVariables()
connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements);
connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, &DialogEditWrongFormula::RadiusArcs);
connect(ui->radioButtonAnglesCurves, &QRadioButton::clicked, this, &DialogEditWrongFormula::AnglesCurves);
connect(ui->radioButtonCLength, &QRadioButton::clicked, this, &DialogEditWrongFormula::CurvesCLength);
connect(ui->radioButtonFunctions, &QRadioButton::clicked, this, &DialogEditWrongFormula::Functions);
}

View File

@ -88,6 +88,7 @@ public slots:
void RadiusArcs();
void AnglesCurves();
void LengthCurves();
void CurvesCLength();
void AngleLines();
void Increments();
void Functions();

View File

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>453</height>
<width>448</width>
<height>425</height>
</rect>
</property>
<property name="windowTitle">
@ -329,6 +329,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonCLength">
<property name="text">
<string>Lengths to control points</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonFunctions">
<property name="sizePolicy">

View File

@ -103,7 +103,7 @@ DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, quint32 idItem, c
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
data->AddCurve(data->GeometricObject<Item>(item.id), item.id);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -135,7 +135,7 @@ void VAbstractFlipping::UpdateCurve(quint32 idTool, quint32 idItem, const QPoint
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
data->AddCurve(data->GeometricObject<Item>(id), id);
data->AddSpline(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -390,7 +390,7 @@ DestinationItem VToolRotation::CreateCurve(quint32 idTool, quint32 idItem, const
const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, origin, angle, suffix, data);
data->AddCurve(data->GeometricObject<Item>(item.id), item.id);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
@ -429,7 +429,7 @@ void VToolRotation::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &or
//---------------------------------------------------------------------------------------------------------------------
void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data, quint32 id)
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<VArc>(idTool, idItem, origin, angle, suffix, data, id);
data->AddArc(data->GeometricObject<VArc>(id), id);
@ -438,16 +438,16 @@ void VToolRotation::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &ori
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolRotation::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data, quint32 id)
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
data->AddCurve(data->GeometricObject<Item>(id), id);
data->AddSpline(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VToolRotation::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &origin, qreal angle,
const QString &suffix, VContainer *data, quint32 id)
const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, origin, angle, suffix, data, id);
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);

View File

@ -117,12 +117,12 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(spline);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id);
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
}
else
{
data->UpdateGObject(id, spline);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id);
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);

View File

@ -196,12 +196,12 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(spline);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id);
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
}
else
{
data->UpdateGObject(id, spline);
data->AddCurve(data->GeometricObject<VAbstractCurve>(id), id);
data->AddSpline(data->GeometricObject<VAbstractBezier>(id), id);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);

View File

@ -150,20 +150,20 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa
quint32 id = _id;
VPointF *p = new VPointF(point, pointName, mx, my);
auto spline1 = QSharedPointer<VAbstractCurve>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
auto spline2 = QSharedPointer<VAbstractCurve>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(p);
data->AddCurve(spline1, NULL_ID, id);
data->AddCurve(spline2, NULL_ID, id);
data->AddSpline(spline1, NULL_ID, id);
data->AddSpline(spline2, NULL_ID, id);
}
else
{
data->UpdateGObject(id, p);
data->AddCurve(spline1, NULL_ID, id);
data->AddCurve(spline2, NULL_ID, id);
data->AddSpline(spline1, NULL_ID, id);
data->AddSpline(spline2, NULL_ID, id);
if (parse != Document::FullParse)
{

View File

@ -166,15 +166,15 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
{
id = data->AddGObject(p);
data->AddCurve(QSharedPointer<VAbstractCurve>(splPath1), NULL_ID, id);
data->AddCurve(QSharedPointer<VAbstractCurve>(splPath2), NULL_ID, id);
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
}
else
{
data->UpdateGObject(id, p);
data->AddCurve(QSharedPointer<VAbstractCurve>(splPath1), NULL_ID, id);
data->AddCurve(QSharedPointer<VAbstractCurve>(splPath2), NULL_ID, id);
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, id);
data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, id);
if (parse != Document::FullParse)
{

View File

@ -378,8 +378,8 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
case GOType::CubicBezier:
case GOType::Spline:
{
QSharedPointer<VAbstractCurve> spline1;
QSharedPointer<VAbstractCurve> spline2;
QSharedPointer<VAbstractBezier> spline1;
QSharedPointer<VAbstractBezier> spline2;
const auto spl = data->GeometricObject<VAbstractCubicBezier>(curveId);
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
@ -397,13 +397,13 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
if (not VFuzzyComparePossibleNulls(segLength, -1))
{
spline1 = QSharedPointer<VAbstractCurve>(spl1);
spline2 = QSharedPointer<VAbstractCurve>(spl2);
spline1 = QSharedPointer<VAbstractBezier>(spl1);
spline2 = QSharedPointer<VAbstractBezier>(spl2);
}
else
{
spline1 = QSharedPointer<VAbstractCurve>(new VSpline());
spline2 = QSharedPointer<VAbstractCurve>(new VSpline());
spline1 = QSharedPointer<VAbstractBezier>(new VSpline());
spline2 = QSharedPointer<VAbstractBezier>(new VSpline());
// Take names for empty splines from donors.
spline1->setName(spl1->name());
@ -413,15 +413,15 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
delete spl2;
}
data->AddCurve(spline1, NULL_ID, p->id());
data->AddCurve(spline2, NULL_ID, p->id());
data->AddSpline(spline1, NULL_ID, p->id());
data->AddSpline(spline2, NULL_ID, p->id());
break;
}
case GOType::CubicBezierPath:
case GOType::SplinePath:
{
QSharedPointer<VAbstractCurve> splP1;
QSharedPointer<VAbstractCurve> splP2;
QSharedPointer<VAbstractBezier> splP1;
QSharedPointer<VAbstractBezier> splP2;
const auto splPath = data->GeometricObject<VAbstractCubicBezierPath>(curveId);
VSplinePath *splPath1 = nullptr;
@ -442,13 +442,13 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
if (not VFuzzyComparePossibleNulls(segLength, -1))
{
splP1 = QSharedPointer<VAbstractCurve>(splPath1);
splP2 = QSharedPointer<VAbstractCurve>(splPath2);
splP1 = QSharedPointer<VAbstractBezier>(splPath1);
splP2 = QSharedPointer<VAbstractBezier>(splPath2);
}
else
{
splP1 = QSharedPointer<VAbstractCurve>(new VSplinePath());
splP2 = QSharedPointer<VAbstractCurve>(new VSplinePath());
splP1 = QSharedPointer<VAbstractBezier>(new VSplinePath());
splP2 = QSharedPointer<VAbstractBezier>(new VSplinePath());
// Take names for empty spline paths from donors.
splP1->setName(splPath1->name());
@ -458,8 +458,8 @@ void VToolCurveIntersectAxis::InitSegments(const GOType &curveType, qreal segLen
delete splPath2;
}
data->AddCurve(splP1, NULL_ID, p->id());
data->AddCurve(splP2, NULL_ID, p->id());
data->AddSpline(splP1, NULL_ID, p->id());
data->AddSpline(splP2, NULL_ID, p->id());
break;
}
case GOType::EllipticalArc: