Seamly2D
Code documentation
vsplinepath.h
Go to the documentation of this file.
1 /******************************************************************************
2  * @file vsplinepath.h
3  ** @author Douglas S Caskey
4  ** @date 22 Mar, 2023
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly2D project, a pattern making
9  ** program to create and model patterns of clothing.
10  ** Copyright (C) 2017-2023 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** You should have received a copy of the GNU General Public License
15  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
16  **
17  *****************************************************************************/
18 
19 /************************************************************************
20  **
21  ** @file vsplinepath.h
22  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
23  ** @date November 15, 2013
24  **
25  ** @brief
26  ** @copyright
27  ** This source code is part of the Valentine project, a pattern making
28  ** program, whose allow create and modeling patterns of clothing.
29  ** Copyright (C) 2013-2015 Seamly2D project
30  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
31  **
32  ** Seamly2D is free software: you can redistribute it and/or modify
33  ** it under the terms of the GNU General Public License as published by
34  ** the Free Software Foundation, either version 3 of the License, or
35  ** (at your option) any later version.
36  **
37  ** Seamly2D is distributed in the hope that it will be useful,
38  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
39  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40  ** GNU General Public License for more details.
41  **
42  ** You should have received a copy of the GNU General Public License
43  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
44  **
45  *************************************************************************/
46 
47 #ifndef VSPLINEPATH_H
48 #define VSPLINEPATH_H
49 
50 #include <qcompilerdetection.h>
51 #include <QCoreApplication>
52 #include <QPainterPath>
53 #include <QPointF>
54 #include <QSharedDataPointer>
55 #include <QString>
56 #include <QTypeInfo>
57 #include <QVector>
58 #include <QtGlobal>
59 
61 #include "vgeometrydef.h"
62 #include "vpointf.h"
63 #include "vspline.h"
64 #include "vsplinepoint.h"
65 
66 class VSplinePathData;
67 
68 /**
69  * @brief The VSplinePath class keep information about splinePath.
70  */
72 {
73  Q_DECLARE_TR_FUNCTIONS(VSplinePath)
74 
75 public:
76  explicit VSplinePath(quint32 idObject = 0, Draw mode = Draw::Calculation);
77 
78  VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve = 1,
79  quint32 idObject = 0, Draw mode = Draw::Calculation);
80  VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject = 0,
81  Draw mode = Draw::Calculation);
83 
84  VSplinePath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
85  VSplinePath Flip(const QLineF &axis, const QString &prefix = QString()) const;
86  VSplinePath Move(qreal length, qreal angle, const QString &prefix = QString()) const;
87  virtual ~VSplinePath() Q_DECL_OVERRIDE;
88 
89  VSplinePoint &operator[](int indx);
90  VSplinePath &operator=(const VSplinePath &path);
91 
92 #ifdef Q_COMPILER_RVALUE_REFS
93  VSplinePath &operator=(VSplinePath &&path) Q_DECL_NOTHROW;
94 #endif
95 
96  void Swap(VSplinePath &path) Q_DECL_NOTHROW;
97 
98  void append(const VSplinePoint &point);
99 
100  virtual qint32 CountSubSpl() const Q_DECL_OVERRIDE;
101  virtual qint32 CountPoints() const Q_DECL_OVERRIDE;
102  virtual void Clear() Q_DECL_OVERRIDE;
103  virtual VSpline GetSpline(qint32 index) const Q_DECL_OVERRIDE;
104 
105  virtual QVector<VSplinePoint> GetSplinePath() const Q_DECL_OVERRIDE;
107 
108  virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
109  virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
110 
111  virtual qreal GetC1Length() const Q_DECL_OVERRIDE;
112  virtual qreal GetC2Length() const Q_DECL_OVERRIDE;
113 
114  void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point);
115  VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const;
116 
117  const VSplinePoint &at(int indx) const;
118 
119  virtual VPointF FirstPoint() const Q_DECL_OVERRIDE;
120  virtual VPointF LastPoint() const Q_DECL_OVERRIDE;
121 
122 private:
123  QSharedDataPointer<VSplinePathData> d;
124 };
125 
127 
128 #endif // VSPLINEPATH_H
The VPointF class keep data of point.
Definition: vpointf.h:75
The VSplinePath class keep information about splinePath.
Definition: vsplinepath.h:72
virtual qreal GetC2Length() const Q_DECL_OVERRIDE
VSplinePath Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
const VSplinePoint & at(int indx) const
at return spline point by index.
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
virtual VSpline GetSpline(qint32 index) const Q_DECL_OVERRIDE
GetSpline return spline by index.
virtual qint32 CountPoints() const Q_DECL_OVERRIDE
CountPoints return count of points.
VSplinePath Flip(const QLineF &axis, const QString &prefix=QString()) const
void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point)
UpdatePoint update spline point in list.
VSplinePath & operator=(const VSplinePath &path)
operator = assignment operator.
virtual void Clear() Q_DECL_OVERRIDE
Clear clear list of points.
virtual QVector< VSplinePoint > GetSplinePath() const Q_DECL_OVERRIDE
GetSplinePath return list with spline points.
virtual VPointF FirstPoint() const Q_DECL_OVERRIDE
VSplinePath(quint32 idObject=0, Draw mode=Draw::Calculation)
VSplinePath constructor.
Definition: vsplinepath.cpp:74
QSharedDataPointer< VSplinePathData > d
Definition: vsplinepath.h:123
virtual qint32 CountSubSpl() const Q_DECL_OVERRIDE
CountSubSpl return count of simple splines.
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
QVector< VFSplinePoint > GetFSplinePath() const
virtual VPointF LastPoint() const Q_DECL_OVERRIDE
VSplinePoint & operator[](int indx)
operator [] return spline point by index.
VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const
GetSplinePoint return spline point from list.
virtual ~VSplinePath() Q_DECL_OVERRIDE
VSplinePath Move(qreal length, qreal angle, const QString &prefix=QString()) const
void Swap(VSplinePath &path) Q_DECL_NOTHROW
Definition: vsplinepath.cpp:65
void append(const VSplinePoint &point)
append add point in the end of list points.
virtual qreal GetC1Length() const Q_DECL_OVERRIDE
The VSplinePoint class keep information about point in spline path. Each point have two angles and tw...
Definition: vsplinepoint.h:108
VSpline class that implements the spline.
Definition: vspline.h:75
const QString splPath
Definition: ifcdef.cpp:419
Draw
Definition: vgeometrydef.h:55
@ Calculation
SplinePointPosition
Definition: vgeometrydef.h:58
Q_DECLARE_TYPEINFO(VSplinePath, Q_MOVABLE_TYPE)