2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vspline.h
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2013-11-15 13:41:26 +01: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.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
2013-08-05 10:37:56 +02:00
|
|
|
#ifndef VSPLINE_H
|
|
|
|
#define VSPLINE_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QLineF>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QMetaType>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QPointF>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QSharedDataPointer>
|
|
|
|
#include <QString>
|
|
|
|
#include <QTypeInfo>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
#include "vabstractcubicbezier.h"
|
|
|
|
#include "vgeometrydef.h"
|
|
|
|
#include "vpointf.h"
|
2013-08-05 10:37:56 +02:00
|
|
|
|
2014-08-20 15:02:41 +02:00
|
|
|
class VSplineData;
|
2013-11-12 13:48:45 +01:00
|
|
|
|
2013-08-05 10:37:56 +02:00
|
|
|
/**
|
2013-12-18 12:13:32 +01:00
|
|
|
* @brief VSpline class that implements the spline.
|
2013-08-05 10:37:56 +02:00
|
|
|
*/
|
2021-09-25 16:18:33 +02:00
|
|
|
class VSpline final :public VAbstractCubicBezier
|
2013-11-04 21:35:15 +01:00
|
|
|
{
|
2013-08-05 10:37:56 +02:00
|
|
|
public:
|
2013-12-18 12:13:32 +01:00
|
|
|
VSpline();
|
|
|
|
VSpline (const VSpline &spline );
|
2016-08-21 18:45:16 +02:00
|
|
|
VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
|
2014-06-12 09:22:29 +02:00
|
|
|
quint32 idObject = 0, Draw mode = Draw::Calculation);
|
2016-08-21 18:45:16 +02:00
|
|
|
VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, quint32 idObject = 0,
|
2014-06-12 09:22:29 +02:00
|
|
|
Draw mode = Draw::Calculation);
|
2016-08-21 18:45:16 +02:00
|
|
|
VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, const QString &angle1Formula, qreal angle2,
|
2016-02-24 20:47:39 +01:00
|
|
|
const QString &angle2Formula, qreal c1Length, const QString &c1LengthFormula, qreal c2Length,
|
2016-02-27 15:49:10 +01:00
|
|
|
const QString &c2LengthFormula, quint32 idObject = 0, Draw mode = Draw::Calculation);
|
2016-04-10 17:03:15 +02:00
|
|
|
VSpline Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
|
2016-09-10 20:40:30 +02:00
|
|
|
VSpline Flip(const QLineF &axis, const QString &prefix = QString()) const;
|
2016-10-04 16:34:37 +02:00
|
|
|
VSpline Move(qreal length, qreal angle, const QString &prefix = QString()) const;
|
2016-03-08 18:48:10 +01:00
|
|
|
virtual ~VSpline();
|
2017-04-19 12:27:17 +02:00
|
|
|
|
2017-04-06 14:50:15 +02:00
|
|
|
VSpline &operator=(const VSpline &spline);
|
2017-04-19 12:27:17 +02:00
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
2019-12-30 16:13:18 +01:00
|
|
|
VSpline(const VSpline &&spline) Q_DECL_NOTHROW;
|
2019-12-30 12:00:57 +01:00
|
|
|
VSpline &operator=(VSpline &&spline) Q_DECL_NOTHROW;
|
2017-04-19 12:27:17 +02:00
|
|
|
#endif
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual VPointF GetP1 () const override;
|
2016-03-08 18:48:10 +01:00
|
|
|
void SetP1 (const VPointF &p);
|
2016-02-27 11:28:15 +01:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual VPointF GetP2 () const override;
|
|
|
|
virtual VPointF GetP3 () const override;
|
2016-02-27 11:28:15 +01:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual VPointF GetP4 () const override;
|
2016-03-08 18:48:10 +01:00
|
|
|
void SetP4 (const VPointF &p);
|
2015-06-02 15:53:19 +02:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual qreal GetStartAngle () const override;
|
|
|
|
virtual qreal GetEndAngle() const override;
|
2015-06-02 15:53:19 +02:00
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
QString GetStartAngleFormula () const;
|
|
|
|
QString GetEndAngleFormula() const;
|
|
|
|
|
2016-02-27 11:28:15 +01:00
|
|
|
void SetStartAngle(qreal angle, const QString &formula);
|
|
|
|
void SetEndAngle(qreal angle, const QString &formula);
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual qreal GetC1Length() const override;
|
|
|
|
virtual qreal GetC2Length() const override;
|
2016-02-24 20:47:39 +01:00
|
|
|
|
2016-02-25 20:23:16 +01:00
|
|
|
QString GetC1LengthFormula() const;
|
|
|
|
QString GetC2LengthFormula() const;
|
2016-02-24 20:47:39 +01:00
|
|
|
|
2016-02-27 11:28:15 +01:00
|
|
|
void SetC1Length(qreal length, const QString &formula);
|
|
|
|
void SetC2Length(qreal length, const QString &formula);
|
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual qreal GetLength () const override;
|
2014-02-26 09:18:59 +01:00
|
|
|
qreal GetKasm1() const;
|
|
|
|
qreal GetKasm2() const;
|
|
|
|
qreal GetKcurve() const;
|
2016-03-10 17:09:38 +01:00
|
|
|
|
|
|
|
using VAbstractCubicBezier::CutSpline;
|
2014-10-23 10:38:57 +02:00
|
|
|
QPointF CutSpline ( qreal length, VSpline &spl1, VSpline &spl2) const;
|
2016-03-10 17:09:38 +01:00
|
|
|
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual QVector<QPointF> GetPoints () const override;
|
2014-05-11 20:15:32 +02:00
|
|
|
// cppcheck-suppress unusedFunction
|
2013-11-07 15:40:39 +01:00
|
|
|
static QVector<QPointF> SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1,
|
2017-10-11 12:51:06 +02:00
|
|
|
qreal kAsm2, qreal kCurve, qreal approximationScale);
|
2015-02-12 11:55:09 +01:00
|
|
|
qreal ParamT(const QPointF &pBt) const;
|
2016-03-10 17:09:38 +01:00
|
|
|
|
2019-08-29 14:01:27 +02:00
|
|
|
virtual QJsonObject ToJson() const override;
|
|
|
|
|
2016-03-10 17:09:38 +01:00
|
|
|
protected:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual QPointF GetControlPoint1() const override;
|
|
|
|
virtual QPointF GetControlPoint2() const override;
|
2013-08-05 10:37:56 +02:00
|
|
|
private:
|
2014-08-20 15:02:41 +02:00
|
|
|
QSharedDataPointer<VSplineData> d;
|
2015-02-12 11:55:09 +01:00
|
|
|
QVector<qreal> CalcT(qreal curveCoord1, qreal curveCoord2, qreal curveCoord3, qreal curveCoord4,
|
|
|
|
qreal pointCoord) const;
|
2015-03-02 18:54:33 +01:00
|
|
|
static qint32 Cubic(QVector<qreal> &x, qreal a, qreal b, qreal c);
|
|
|
|
static int Sign(long double ld);
|
2013-08-05 10:37:56 +02:00
|
|
|
};
|
|
|
|
|
2016-04-02 13:59:43 +02:00
|
|
|
Q_DECLARE_METATYPE(VSpline)
|
2015-11-25 19:56:17 +01:00
|
|
|
Q_DECLARE_TYPEINFO(VSpline, Q_MOVABLE_TYPE);
|
|
|
|
|
2013-08-05 10:37:56 +02:00
|
|
|
#endif // VSPLINE_H
|