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
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/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-06-08 20:10:57 +02:00
|
|
|
class QPainterPath;
|
2016-08-08 13:44:49 +02:00
|
|
|
class QPointF;
|
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
|
|
|
*/
|
2016-03-08 18:48:10 +01:00
|
|
|
class VSpline :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-03-08 18:48:10 +01:00
|
|
|
virtual ~VSpline();
|
2014-06-08 20:10:57 +02:00
|
|
|
VSpline &operator=(const VSpline &spl);
|
2016-02-27 11:28:15 +01:00
|
|
|
|
2016-03-08 18:48:10 +01:00
|
|
|
virtual VPointF GetP1 () const Q_DECL_OVERRIDE;
|
|
|
|
void SetP1 (const VPointF &p);
|
2016-02-27 11:28:15 +01:00
|
|
|
|
2016-06-30 15:02:59 +02:00
|
|
|
virtual VPointF GetP2 () const Q_DECL_OVERRIDE;
|
|
|
|
virtual VPointF GetP3 () const Q_DECL_OVERRIDE;
|
2016-02-27 11:28:15 +01:00
|
|
|
|
2016-03-08 18:48:10 +01:00
|
|
|
virtual VPointF GetP4 () const Q_DECL_OVERRIDE;
|
|
|
|
void SetP4 (const VPointF &p);
|
2015-06-02 15:53:19 +02:00
|
|
|
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
|
|
|
|
virtual qreal GetEndAngle() const Q_DECL_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);
|
|
|
|
|
2016-02-24 20:47:39 +01:00
|
|
|
qreal GetC1Length() const;
|
|
|
|
qreal GetC2Length() const;
|
|
|
|
|
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);
|
|
|
|
|
2016-03-08 18:48:10 +01:00
|
|
|
virtual qreal GetLength () const Q_DECL_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
|
|
|
|
2016-03-08 18:48:10 +01:00
|
|
|
virtual QVector<QPointF> GetPoints () const Q_DECL_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,
|
|
|
|
qreal kAsm2, qreal kCurve);
|
2015-02-12 11:55:09 +01:00
|
|
|
qreal ParamT(const QPointF &pBt) const;
|
2016-03-10 17:09:38 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual QPointF GetControlPoint1() const Q_DECL_OVERRIDE;
|
|
|
|
virtual QPointF GetControlPoint2() const Q_DECL_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
|