Seamly2D
Code documentation
vabstractcubicbezier.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vabstractcubicbezier.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 8 3, 2016
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2016 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #ifndef VABSTRACTCUBICBEZIER_H
53 #define VABSTRACTCUBICBEZIER_H
54 
55 #include <qcompilerdetection.h>
56 #include <QPointF>
57 #include <QString>
58 #include <QVector>
59 #include <QtGlobal>
60 
61 #include "../ifc/ifcdef.h"
62 #include "vabstractbezier.h"
63 #include "vgeometrydef.h"
64 
65 class VPointF;
66 
68 {
69 public:
70  VAbstractCubicBezier(const GOType &type, const quint32 &idObject = NULL_ID, const Draw &mode = Draw::Calculation);
73  virtual ~VAbstractCubicBezier();
74 
75  virtual VPointF GetP1 () const =0;
76  virtual VPointF GetP2 () const =0;
77  virtual VPointF GetP3 () const =0;
78  virtual VPointF GetP4 () const =0;
79 
80  QPointF CutSpline ( qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const;
81 
82  virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE;
83 
84  qreal GetParmT(qreal length) const;
85  qreal LengthT(qreal t) const;
86 
87 protected:
88  virtual void CreateName() Q_DECL_OVERRIDE;
89 
90  static qreal CalcSqDistance(qreal x1, qreal y1, qreal x2, qreal y2);
91  static void PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4,
92  qreal y4, qint16 level, QVector<qreal> &px, QVector<qreal> &py);
93  static QVector<QPointF> GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
94  const QPointF &p4);
95  static qreal LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4);
96 
97  virtual QPointF GetControlPoint1() const =0;
98  virtual QPointF GetControlPoint2() const =0;
99 };
100 
101 #endif // VABSTRACTCUBICBEZIER_H
VAbstractCubicBezier & operator=(const VAbstractCubicBezier &curve)
virtual VPointF GetP1() const =0
qreal LengthT(qreal t) const
VAbstractCubicBezier(const GOType &type, const quint32 &idObject=null_id, const Draw &mode=Draw::Calculation)
static qreal LengthBezier(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
LengthBezier return spline length using 4 spline point.
virtual void CreateName() Q_DECL_OVERRIDE
virtual VPointF GetP3() const =0
qreal GetParmT(qreal length) const
QPointF CutSpline(qreal length, QPointF &spl1p2, QPointF &spl1p3, QPointF &spl2p2, QPointF &spl2p3) const
CutSpline cut spline.
static qreal CalcSqDistance(qreal x1, qreal y1, qreal x2, qreal y2)
CalcSqDistance calculate squared distance.
virtual QPointF GetControlPoint2() const =0
virtual VPointF GetP2() const =0
static QVector< QPointF > GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4)
GetCubicBezierPoints return list with cubic bezier curve points.
virtual QPointF GetControlPoint1() const =0
static void PointBezier_r(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4, qint16 level, QVector< qreal > &px, QVector< qreal > &py)
PointBezier_r find spline point using four point of spline.
virtual QString NameForHistory(const QString &toolName) const Q_DECL_OVERRIDE
virtual VPointF GetP4() const =0
The VPointF class keep data of point.
Definition: vpointf.h:75
#define NULL_ID
Definition: ifcdef.h:76
GOType
Definition: vgeometrydef.h:56
Draw
Definition: vgeometrydef.h:55
@ Calculation