The tool Cut Spline now supports Cubic Bezier Path curve.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-22 17:14:53 +02:00
parent baddba9e43
commit 2e0bf11261
12 changed files with 234 additions and 222 deletions

View File

@ -35,6 +35,7 @@
class VPointF;
class VSpline;
class VSplinePoint;
class VAbstractCubicBezierPath : public VAbstractCurve
{
@ -50,6 +51,7 @@ public:
virtual qint32 CountPoints() const =0;
virtual void Clear() =0;
virtual VSpline GetSpline(qint32 index) const =0;
virtual QVector<VSplinePoint> GetSplinePath() const =0;
virtual QPainterPath GetPath(PathDirection direction = PathDirection::Hide) const Q_DECL_OVERRIDE;
virtual QVector<QPointF> GetPoints() const Q_DECL_OVERRIDE;

View File

@ -30,6 +30,8 @@
#include "vcubicbezierpath_p.h"
#include "vspline.h"
#include "../ifc/exception/vexception.h"
#include "vsplinepoint.h"
#include "../vmisc/vabstractapplication.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
# include "../vmisc/vmath.h"
@ -39,7 +41,7 @@
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::VCubicBezierPath(quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
: VAbstractCubicBezierPath(GOType::CubicBezierPath, idObject, mode),
d(new VCubicBezierPathData())
{
}
@ -53,7 +55,7 @@ VCubicBezierPath::VCubicBezierPath(const VCubicBezierPath &curve)
//---------------------------------------------------------------------------------------------------------------------
VCubicBezierPath::VCubicBezierPath(const QVector<VPointF> &points, quint32 idObject, Draw mode)
: VAbstractCubicBezierPath(GOType::SplinePath, idObject, mode),
: VAbstractCubicBezierPath(GOType::CubicBezierPath, idObject, mode),
d(new VCubicBezierPathData())
{
if (points.isEmpty())
@ -184,7 +186,36 @@ qreal VCubicBezierPath::GetEndAngle() const
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VPointF> VCubicBezierPath::GetSplinePath() const
QVector<VSplinePoint> VCubicBezierPath::GetSplinePath() const
{
const int size = CountSubSpl();
QVector<VSplinePoint> splPoints(size+1);
for (qint32 i = 1; i <= size; ++i)
{
const VSpline spl = GetSpline(i);
{
VSplinePoint p = splPoints.at(i-1);
p.SetP(spl.GetP1());
p.SetAngle2(spl.GetStartAngle(), spl.GetStartAngleFormula());
p.SetLength2(spl.GetC1Length(), spl.GetC1LengthFormula());
splPoints[i-1] = p;
}
{
VSplinePoint p = splPoints.at(i);
p.SetP(spl.GetP4());
p.SetAngle1(spl.GetEndAngle(), spl.GetEndAngleFormula());
p.SetLength1(spl.GetC2Length(), spl.GetC2LengthFormula());
splPoints[i] = p;
}
}
return splPoints;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VPointF> VCubicBezierPath::GetCubicPath() const
{
return d->path;
}

View File

@ -60,7 +60,8 @@ public:
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
QVector<VPointF> GetSplinePath() const;
virtual QVector<VSplinePoint> GetSplinePath() const Q_DECL_OVERRIDE;
QVector<VPointF> GetCubicPath() const;
static qint32 CountSubSpl(qint32 size);
static qint32 SubSplOffset(qint32 subSplIndex);

View File

@ -32,7 +32,7 @@
#include <QString>
enum class Draw : char { Calculation, Modeling, Layout };
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, Unknown };
enum class GOType : char { Point, Arc, EllipticalArc, Spline, SplinePath, CubicBezier, CubicBezierPath, Unknown };
enum class SplinePointPosition : char { FirstPoint, LastPoint };
#endif // VGEOMETRYDEF_H

View File

@ -62,7 +62,7 @@ public:
virtual void Clear() Q_DECL_OVERRIDE;
virtual VSpline GetSpline(qint32 index) const Q_DECL_OVERRIDE;
QVector<VSplinePoint> GetSplinePath() const;
virtual QVector<VSplinePoint> GetSplinePath() const Q_DECL_OVERRIDE;
QVector<VFSplinePoint> GetFSplinePath() const;
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;

View File

@ -61,7 +61,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
flagFormula = false;
CheckState();
FillComboBoxSimpleSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2);
FillComboBoxSplines(ui->comboBoxSpline, FillComboBox::NoChildren, ch1, ch2);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogCutSpline::FXLength);

View File

@ -134,19 +134,43 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule, const quint
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule, const quint32 &ch1, const quint32 &ch2) const
{
FillCombo<VAbstractCurve>(box, GOType::Spline, rule, ch1, ch2);
SCASSERT(box != nullptr);
box->blockSignals(true);
const auto objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (rule == FillComboBox::NoChildren)
{
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
{
if (IsSpline(i.value()))
{
PrepareList<VAbstractCurve>(list, i.key());
}
}
}
else
{
if (i.key() != toolId)
{
if (IsSpline(i.value()))
{
PrepareList<VAbstractCurve>(list, i.key());
}
}
}
}
FillList(box, list);
box->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule, const quint32 &ch1,
const quint32 &ch2) const
{
FillCombo<VAbstractCurve>(box, GOType::SplinePath, rule, ch1, ch2);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxSimpleSplines(QComboBox *box, FillComboBox rule, const quint32 &ch1,
const quint32 &ch2) const
{
SCASSERT(box != nullptr);
box->blockSignals(true);
@ -160,22 +184,9 @@ void DialogTool::FillComboBoxSimpleSplines(QComboBox *box, FillComboBox rule, co
{
if (i.key() != toolId && i.key() != ch1 && i.key() != ch2)
{
QSharedPointer<VGObject> obj = i.value();
if ((obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) &&
obj->getMode() == Draw::Calculation)
if (IsSplinePath(i.value()))
{
const auto curve = data->GeometricObject<VAbstractCurve>(i.key());
QString newName = curve->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, curve->name(), bias))
{
list[newName] = i.key();
}
else
{
list[curve->name()] = i.key();
}
PrepareList<VAbstractCurve>(list, i.key());
}
}
}
@ -183,22 +194,9 @@ void DialogTool::FillComboBoxSimpleSplines(QComboBox *box, FillComboBox rule, co
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if ((obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) &&
obj->getMode() == Draw::Calculation)
if (IsSplinePath(i.value()))
{
const auto curve = data->GeometricObject<VAbstractCurve>(i.key());
QString newName = curve->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, curve->name(), bias))
{
list[newName] = i.key();
}
else
{
list[curve->name()] = i.key();
}
PrepareList<VAbstractCurve>(list, i.key());
}
}
}
@ -221,21 +219,10 @@ void DialogTool::FillComboBoxCurves(QComboBox *box) const
{
QSharedPointer<VGObject> obj = i.value();
if ((obj->getType() == GOType::Arc || obj->getType() == GOType::Spline ||
obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezier) &&
obj->getMode() == Draw::Calculation)
obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezier ||
obj->getType() == GOType::CubicBezierPath) && obj->getMode() == Draw::Calculation)
{
const auto curve = data->GeometricObject<VAbstractCurve>(i.key());
QString newName = curve->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, curve->name(), bias))
{
list[newName] = i.key();
}
else
{
list[curve->name()] = i.key();
}
PrepareList<VAbstractCurve>(list, i.key());
}
}
}
@ -390,6 +377,13 @@ quint32 DialogTool::DNumber(const QString &baseName) const
return num;
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::IsSplinePath(const QSharedPointer<VGObject> &obj) const
{
return (obj->getType() == GOType::SplinePath || obj->getType() == GOType::CubicBezierPath) &&
obj->getMode() == Draw::Calculation;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ValFormulaChanged handle change formula
@ -676,6 +670,32 @@ void DialogTool::FillList(QComboBox *box, const QMap<QString, quint32> &list) co
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void DialogTool::PrepareList(QMap<QString, quint32> &list, quint32 id) const
{
const auto obj = data->GeometricObject<T>(id);
SCASSERT(obj != nullptr);
QString newName = obj->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, obj->name(), bias))
{
list[newName] = id;
}
else
{
list[obj->name()] = id;
}
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogTool::IsSpline(const QSharedPointer<VGObject> &obj) const
{
return (obj->getType() == GOType::Spline || obj->getType() == GOType::CubicBezier) &&
obj->getMode() == Draw::Calculation;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CheckState enable, when all is correct, or disable, when something wrong, button ok
@ -937,18 +957,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
QString newName = arc->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, arc->name(), bias))
{
list[newName] = i.key();
}
else
{
list[arc->name()] = i.key();
}
PrepareList<GObject>(list, i.key());
}
}
}
@ -959,18 +968,7 @@ void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule, cons
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
QString newName = arc->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, arc->name(), bias))
{
list[newName] = i.key();
}
else
{
list[arc->name()] = i.key();
}
PrepareList<GObject>(list, i.key());
}
}
}

View File

@ -192,8 +192,6 @@ protected:
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
void FillComboBoxSimpleSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
void FillComboBoxCurves(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
void FillComboBoxLineColors(QComboBox *box)const;
@ -262,9 +260,17 @@ protected:
private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
template <typename T>
void PrepareList(QMap<QString, quint32> &list, quint32 id) const;
bool IsSpline(const QSharedPointer<VGObject> &obj) const;
bool IsSplinePath(const QSharedPointer<VGObject> &obj) const;
template <typename GObject>
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole,
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -123,17 +123,24 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId);
const auto splPath = data->GeometricObject<VAbstractCubicBezierPath>(splinePathId);
SCASSERT(splPath != nullptr);
const qreal result = CheckFormula(_id, formula, data);
quint32 id = _id;
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
VSplinePath *splPath1 = nullptr;
VSplinePath *splPath2 = nullptr;
VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(result), splPath, &splPath1, &splPath2);
SCASSERT(splPath1 != nullptr);
SCASSERT(splPath2 != nullptr);
SCASSERT(p != nullptr);
p->setName(pointName);
p->setMx(mx);
p->setMy(my);
const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
VPointF *p = new VPointF(point, pointName, mx, my);
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(p);
@ -146,64 +153,6 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
quint32 splPath1id = id + 1;
quint32 splPath2id = id + 2;
VSplinePoint splP1 = splPath->at(p1);
VSplinePoint splP2 = splPath->at(p2);
const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p);
const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P());
VSplinePath *splPath1 = new VSplinePath();
VSplinePath *splPath2 = new VSplinePath();
for (qint32 i = 0; i < splPath->CountPoints(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
const qreal angle1 = spl1.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
splPath1->append(VSplinePoint(splP1.P(), angle1, angle1F, spl1.GetStartAngle(),
spl1.GetStartAngleFormula(), splP1.Length1(), splP1.Length1Formula(),
spl1.GetC1Length(), spl1.GetC1LengthFormula()));
const qreal angle2 = spl1.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
const auto cutPoint = VSplinePoint(*p, spl1.GetEndAngle(), spl1.GetEndAngleFormula(), angle2, angle2F,
spl1.GetC2Length(), spl1.GetC2LengthFormula(), spl2.GetC1Length(),
spl2.GetC1LengthFormula());
splPath1->append(cutPoint);
continue;
}
splPath1->append(splPath->at(i));
}
else
{
if (i == p2)
{
const qreal angle1 = spl2.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
const auto cutPoint = VSplinePoint(*p, angle1, angle1F, spl2.GetStartAngle(),
spl2.GetStartAngleFormula(), spl1.GetC2Length(),
spl1.GetC2LengthFormula(), spl2.GetC1Length(),
spl2.GetC1LengthFormula());
splPath2->append(cutPoint);
const qreal angle2 = spl2.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
splPath2->append(VSplinePoint(splP2.P(), spl2.GetEndAngle(), spl2.GetEndAngleFormula(), angle2, angle2F,
spl2.GetC2Length(), spl2.GetC2LengthFormula(), splP2.Length2(),
splP2.Length2Formula()));
continue;
}
splPath2->append(splPath->at(i));
}
}
if (typeCreation == Source::FromGui)
{
splPath1id = data->AddGObject(splPath1);
@ -252,6 +201,81 @@ void VToolCutSplinePath::ShowVisualization(bool show)
ShowToolVisualization<VisToolCutSplinePath>(show);
}
//---------------------------------------------------------------------------------------------------------------------
VPointF *VToolCutSplinePath::CutSplinePath(qreal length, const QSharedPointer<VAbstractCubicBezierPath> &splPath,
VSplinePath **splPath1, VSplinePath **splPath2)
{
SCASSERT(splPath != nullptr);
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
const QPointF point = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
VPointF *p = new VPointF(point);
const QVector<VSplinePoint> points = splPath->GetSplinePath();
const VSplinePoint splP1 = points.at(p1);
const VSplinePoint splP2 = points.at(p2);
const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p);
const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P());
*splPath1 = new VSplinePath();
*splPath2 = new VSplinePath();
for (qint32 i = 0; i < points.size(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
const qreal angle1 = spl1.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
(*splPath1)->append(VSplinePoint(splP1.P(), angle1, angle1F, spl1.GetStartAngle(),
spl1.GetStartAngleFormula(), splP1.Length1(), splP1.Length1Formula(),
spl1.GetC1Length(), spl1.GetC1LengthFormula()));
const qreal angle2 = spl1.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
const auto cutPoint = VSplinePoint(*p, spl1.GetEndAngle(), spl1.GetEndAngleFormula(), angle2, angle2F,
spl1.GetC2Length(), spl1.GetC2LengthFormula(), spl2.GetC1Length(),
spl2.GetC1LengthFormula());
(*splPath1)->append(cutPoint);
continue;
}
(*splPath1)->append(points.at(i));
}
else
{
if (i == p2)
{
const qreal angle1 = spl2.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
const auto cutPoint = VSplinePoint(*p, angle1, angle1F, spl2.GetStartAngle(),
spl2.GetStartAngleFormula(), spl1.GetC2Length(),
spl1.GetC2LengthFormula(), spl2.GetC1Length(),
spl2.GetC1LengthFormula());
(*splPath2)->append(cutPoint);
const qreal angle2 = spl2.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
(*splPath2)->append(VSplinePoint(splP2.P(), spl2.GetEndAngle(), spl2.GetEndAngleFormula(), angle2,
angle2F, spl2.GetC2Length(), spl2.GetC2LengthFormula(),
splP2.Length2(), splP2.Length2Formula()));
continue;
}
(*splPath2)->append(points.at(i));
}
}
return p;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -31,6 +31,9 @@
#include "vtoolcut.h"
class VAbstractCubicBezierPath;
class VSplinePath;
/**
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
* two.
@ -56,6 +59,9 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CutSplinePath)};
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
static VPointF *CutSplinePath(qreal length, const QSharedPointer<VAbstractCubicBezierPath> &splPath,
VSplinePath **splPath1, VSplinePath **splPath2);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;

View File

@ -56,7 +56,7 @@ VisToolCubicBezierPath::~VisToolCubicBezierPath()
//---------------------------------------------------------------------------------------------------------------------
void VisToolCubicBezierPath::RefreshGeometry()
{
const QVector<VPointF> pathPoints = path.GetSplinePath();
const QVector<VPointF> pathPoints = path.GetCubicPath();
const int size = pathPoints.size();
if (size > 0)
{

View File

@ -27,8 +27,9 @@
*************************************************************************/
#include "vistoolcutsplinepath.h"
#include "../../vpatterndb/vcontainer.h"
#include "../../vgeometry/vsplinepath.h"
#include "../vpatterndb/vcontainer.h"
#include "../vgeometry/vsplinepath.h"
#include "../tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
//---------------------------------------------------------------------------------------------------------------------
VisToolCutSplinePath::VisToolCutSplinePath(const VContainer *data, QGraphicsItem *parent)
@ -53,83 +54,26 @@ void VisToolCutSplinePath::RefreshGeometry()
{
if (object1Id > NULL_ID)
{
const QSharedPointer<VSplinePath> splPath = Visualization::data->GeometricObject<VSplinePath>(object1Id);
const auto splPath = Visualization::data->GeometricObject<VAbstractCubicBezierPath>(object1Id);
DrawPath(this, splPath->GetPath(PathDirection::Show), supportColor, Qt::SolidLine, Qt::RoundCap);
if (qFuzzyCompare(1 + length, 1 + 0) == false)
if (not qFuzzyIsNull(length))
{
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
qint32 p1 = 0, p2 = 0;
VSplinePath *spPath1 = nullptr;
VSplinePath *spPath2 = nullptr;
VPointF *p = VToolCutSplinePath::CutSplinePath(length, splPath, &spPath1, &spPath2);
SCASSERT(p != nullptr);
SCASSERT(spPath1 != nullptr);
SCASSERT(spPath2 != nullptr);
// TODO make refactoring. CutSplPath repeat twice. Here and in VToolCutSpline.
const QPointF cutPoint = splPath->CutSplinePath(length, p1, p2, spl1p2, spl1p3, spl2p2, spl2p3);
VPointF p = VPointF(cutPoint);
DrawPoint(point, p->toQPointF(), mainColor);
delete p;
VSplinePoint splP1 = splPath->at(p1);
VSplinePoint splP2 = splPath->at(p2);
const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, p);
const VSpline spl2 = VSpline(p, spl2p2, spl2p3, splP2.P());
DrawPath(splPath1, spPath1->GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
DrawPath(splPath2, spPath2->GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap);
VSplinePath spPath1 = VSplinePath();
VSplinePath spPath2 = VSplinePath();
for (qint32 i = 0; i < splPath->CountPoints(); i++)
{
if (i <= p1 && i < p2)
{
if (i == p1)
{
const qreal angle1 = spl1.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
spPath1.append(VSplinePoint(splP1.P(), angle1, angle1F, spl1.GetStartAngle(),
spl1.GetStartAngleFormula(), splP1.Length1(),
splP1.Length1Formula(), spl1.GetC1Length(),
spl1.GetC1LengthFormula()));
const qreal angle2 = spl1.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
const auto cutPoint = VSplinePoint(p, spl1.GetEndAngle(), spl1.GetEndAngleFormula(), angle2,
angle2F, spl1.GetC2Length(), spl1.GetC2LengthFormula(),
spl2.GetC1Length(), spl2.GetC1LengthFormula());
spPath1.append(cutPoint);
continue;
}
spPath1.append(splPath->at(i));
}
else
{
if (i == p2)
{
const qreal angle1 = spl2.GetStartAngle()+180;
const QString angle1F = QString().number(angle1);
const auto cutPoint = VSplinePoint(p, angle1, angle1F, spl2.GetStartAngle(),
spl2.GetStartAngleFormula(), spl1.GetC2Length(),
spl1.GetC2LengthFormula(), spl2.GetC1Length(),
spl2.GetC1LengthFormula());
spPath2.append(cutPoint);
const qreal angle2 = spl2.GetEndAngle()+180;
const QString angle2F = QString().number(angle2);
spPath2.append(VSplinePoint(splP2.P(), spl2.GetEndAngle(), spl2.GetEndAngleFormula(), angle2,
angle2F, spl2.GetC2Length(), spl2.GetC2LengthFormula(),
splP2.Length2(), splP2.Length2Formula()));
continue;
}
spPath2.append(splPath->at(i));
}
}
DrawPoint(point, cutPoint, mainColor);
DrawPath(splPath1, spPath1.GetPath(PathDirection::Show), Qt::darkGreen, Qt::SolidLine, Qt::RoundCap);
DrawPath(splPath2, spPath2.GetPath(PathDirection::Show), Qt::darkRed, Qt::SolidLine, Qt::RoundCap);
delete spPath1;
delete spPath2;
}
}
}