2014-08-20 15:02:41 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vspline_p.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 20 8, 2014
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2014-08-20 15:02:41 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2014-08-20 15:02:41 +02:00
|
|
|
**
|
|
|
|
** 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 VSPLINE_P_H
|
|
|
|
#define VSPLINE_P_H
|
|
|
|
|
|
|
|
#include <QSharedData>
|
|
|
|
#include <QLineF>
|
|
|
|
|
2016-02-26 15:38:42 +01:00
|
|
|
#include "vpointf.h"
|
2020-10-15 17:05:21 +02:00
|
|
|
#include "../vmisc/vabstractvalapplication.h"
|
2016-08-16 18:57:32 +02:00
|
|
|
#include "../vmisc/vmath.h"
|
2016-02-26 15:38:42 +01:00
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
2017-05-30 17:44:16 +02:00
|
|
|
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
2014-08-23 08:18:07 +02:00
|
|
|
|
2021-09-25 10:43:05 +02:00
|
|
|
class VSplineData final : public QSharedData
|
2014-08-20 15:02:41 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-02-24 20:47:39 +01:00
|
|
|
VSplineData();
|
|
|
|
VSplineData(const VSplineData &spline);
|
|
|
|
VSplineData(VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve);
|
2016-02-27 15:49:10 +01:00
|
|
|
VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4);
|
2016-02-24 20:47:39 +01:00
|
|
|
VSplineData(VPointF p1, VPointF p4, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
|
2016-02-27 15:49:10 +01:00
|
|
|
qreal c1Length, const QString &c1LengthF, qreal c2Length, const QString &c2LengthF);
|
2014-09-11 18:52:02 +02:00
|
|
|
virtual ~VSplineData();
|
2014-08-20 15:02:41 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
static qreal GetL(const QPointF &p1, const QPointF &p4, qreal kCurve);
|
2014-08-20 15:02:41 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
/** @brief p1 first spline point. */
|
|
|
|
VPointF p1;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
/** @brief p4 fourth spline point. */
|
|
|
|
VPointF p4;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
|
|
|
/** @brief angle1 first angle control line. */
|
2016-02-24 20:47:39 +01:00
|
|
|
qreal angle1;
|
|
|
|
|
|
|
|
/** @brief angle1F the first control point angle formula*/
|
|
|
|
QString angle1F;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
|
|
|
/** @brief angle2 second angle control line. */
|
2016-02-24 20:47:39 +01:00
|
|
|
qreal angle2;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
/** @brief angle2F the second control point angle formula*/
|
|
|
|
QString angle2F;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
/** @brief c1Length the length from the first spline point to the first control point. */
|
|
|
|
qreal c1Length;
|
|
|
|
|
|
|
|
/** @brief c1LengthF the formula from the first spline point to the first control point. */
|
|
|
|
QString c1LengthF;
|
|
|
|
|
|
|
|
/** @brief c2Length the length from the fourth spline point to the second control point. */
|
|
|
|
qreal c2Length;
|
|
|
|
|
|
|
|
/** @brief c2LengthF the formula length from the fourth spline point to the second control point. */
|
|
|
|
QString c2LengthF;
|
2014-08-20 15:02:41 +02:00
|
|
|
|
|
|
|
/** @brief kCurve coefficient of curvature spline. */
|
2016-02-24 20:47:39 +01:00
|
|
|
qreal kCurve;
|
2015-10-31 13:56:28 +01:00
|
|
|
|
|
|
|
private:
|
2019-07-01 10:33:29 +02:00
|
|
|
Q_DISABLE_ASSIGN(VSplineData)
|
2014-08-20 15:02:41 +02:00
|
|
|
};
|
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSplineData::VSplineData()
|
|
|
|
: p1(),
|
|
|
|
p4(),
|
|
|
|
angle1(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
angle1F('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
angle2(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
angle2F('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
c1Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c1LengthF('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
c2Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c2LengthF('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
kCurve(1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSplineData::VSplineData(const VSplineData &spline)
|
|
|
|
: QSharedData(spline),
|
|
|
|
p1(spline.p1),
|
|
|
|
p4(spline.p4),
|
|
|
|
angle1(spline.angle1),
|
|
|
|
angle1F(spline.angle1F),
|
|
|
|
angle2(spline.angle2),
|
|
|
|
angle2F(spline.angle2F),
|
|
|
|
c1Length(spline.c1Length),
|
|
|
|
c1LengthF(spline.c1LengthF),
|
|
|
|
c2Length(spline.c2Length),
|
|
|
|
c2LengthF(spline.c2LengthF),
|
|
|
|
kCurve(spline.kCurve)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSplineData::VSplineData(VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve)
|
|
|
|
: p1(p1),
|
|
|
|
p4(p4),
|
|
|
|
angle1(angle1),
|
|
|
|
angle1F(QString().number(angle1)),
|
|
|
|
angle2(angle2),
|
|
|
|
angle2F(QString().number(angle2)),
|
|
|
|
c1Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c1LengthF('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
c2Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c2LengthF('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
kCurve(kCurve)
|
|
|
|
{
|
2017-03-31 16:04:11 +02:00
|
|
|
const qreal L = GetL(static_cast<QPointF>(p1), static_cast<QPointF>(p4), kCurve);
|
2016-02-24 20:47:39 +01:00
|
|
|
|
|
|
|
QLineF p1p2(p1.x(), p1.y(), p1.x() + L * kAsm1, p1.y());
|
|
|
|
p1p2.setAngle(angle1);
|
|
|
|
c1Length = p1p2.length();
|
2021-02-06 14:52:21 +01:00
|
|
|
c1LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c1Length));
|
2016-02-24 20:47:39 +01:00
|
|
|
|
|
|
|
QLineF p4p3(p4.x(), p4.y(), p4.x() + L * kAsm2, p4.y());
|
|
|
|
p4p3.setAngle(angle2);
|
|
|
|
c2Length = p4p3.length();
|
2021-02-06 14:52:21 +01:00
|
|
|
c2LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c2Length));
|
2016-02-24 20:47:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2016-02-27 15:49:10 +01:00
|
|
|
VSplineData::VSplineData(VPointF p1, QPointF p2, QPointF p3, VPointF p4)
|
2016-02-24 20:47:39 +01:00
|
|
|
: p1(p1),
|
|
|
|
p4(p4),
|
|
|
|
angle1(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
angle1F('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
angle2(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
angle2F('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
c1Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c1LengthF('0'),
|
2016-02-24 20:47:39 +01:00
|
|
|
c2Length(0),
|
2018-04-12 12:13:19 +02:00
|
|
|
c2LengthF('0'),
|
2016-02-27 15:49:10 +01:00
|
|
|
kCurve(1)
|
2016-02-24 20:47:39 +01:00
|
|
|
{
|
2017-03-31 16:04:11 +02:00
|
|
|
QLineF p1p2(static_cast<QPointF>(p1), static_cast<QPointF>(p2));
|
2016-02-24 20:47:39 +01:00
|
|
|
|
|
|
|
angle1 = p1p2.angle();
|
|
|
|
angle1F = QString().number(angle1);
|
|
|
|
|
|
|
|
c1Length = p1p2.length();
|
2021-02-06 14:52:21 +01:00
|
|
|
c1LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c1Length));
|
2016-02-24 20:47:39 +01:00
|
|
|
|
2017-03-31 16:04:11 +02:00
|
|
|
QLineF p4p3(static_cast<QPointF>(p4), static_cast<QPointF>(p3));
|
2016-02-24 20:47:39 +01:00
|
|
|
|
|
|
|
angle2 = p4p3.angle();
|
|
|
|
angle2F = QString().number(angle2);
|
|
|
|
|
|
|
|
c2Length = p4p3.length();
|
2021-02-06 14:52:21 +01:00
|
|
|
c2LengthF = QString().number(VAbstractValApplication::VApp()->fromPixel(c2Length));
|
2016-02-24 20:47:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VSplineData::VSplineData(VPointF p1, VPointF p4, qreal angle1, const QString &angle1F, qreal angle2,
|
|
|
|
const QString &angle2F, qreal c1Length, const QString &c1LengthF,
|
2016-02-27 15:49:10 +01:00
|
|
|
qreal c2Length, const QString &c2LengthF)
|
2016-02-24 20:47:39 +01:00
|
|
|
: p1(p1),
|
|
|
|
p4(p4),
|
|
|
|
angle1(angle1),
|
|
|
|
angle1F(angle1F),
|
|
|
|
angle2(angle2),
|
|
|
|
angle2F(angle2F),
|
|
|
|
c1Length(c1Length),
|
|
|
|
c1LengthF(c1LengthF),
|
|
|
|
c2Length(c2Length),
|
|
|
|
c2LengthF(c2LengthF),
|
2016-02-27 15:49:10 +01:00
|
|
|
kCurve(1)
|
2016-02-24 20:47:39 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-09-11 18:52:02 +02:00
|
|
|
VSplineData::~VSplineData()
|
|
|
|
{}
|
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
qreal VSplineData::GetL(const QPointF &p1, const QPointF &p4, qreal kCurve)
|
|
|
|
{
|
|
|
|
static const qreal angle = 90;
|
2022-03-16 16:43:09 +01:00
|
|
|
qreal length = VFuzzyComparePoints(p1, p4) ? accuracyPointOnLine*2 : QLineF(p1, p4).length();
|
|
|
|
const qreal radius = length/M_SQRT2;
|
2016-02-24 20:47:39 +01:00
|
|
|
return kCurve * radius * 4 / 3 * qTan( angle * M_PI_4 / 180.0 );
|
|
|
|
}
|
|
|
|
|
2016-08-06 20:42:40 +02:00
|
|
|
QT_WARNING_POP
|
2014-08-20 15:02:41 +02:00
|
|
|
|
|
|
|
#endif // VSPLINE_P_H
|