Seamly2D
Code documentation
varc.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 varc.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
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) 2013-2015 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 VARC_H
53 #define VARC_H
54 
55 #include <qcompilerdetection.h>
56 #include <QCoreApplication>
57 #include <QPointF>
58 #include <QSharedDataPointer>
59 #include <QString>
60 #include <QTypeInfo>
61 #include <QVector>
62 #include <QtGlobal>
63 
64 #include "vabstractarc.h"
65 #include "vgeometrydef.h"
66 #include "vpointf.h"
67 
68 class VArcData;
69 
70 /**
71  * @brief VArc class for anticlockwise arc.
72  */
73 class VArc: public VAbstractArc
74 {
75  Q_DECLARE_TR_FUNCTIONS(VArc)
76 public:
77  VArc();
78  VArc(const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
79  qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
80  VArc(const VPointF &center, qreal radius, qreal f1, qreal f2);
81  VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
82  qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
83  VArc(qreal length, const VPointF &center, qreal radius, qreal f1);
84  VArc(const VArc &arc);
85 
86  VArc Rotate(const QPointF &originPoint, qreal degrees,
87  const QString &prefix = QString()) const;
88  VArc Flip(const QLineF &axis, const QString &prefix = QString()) const;
89  VArc Move(qreal length, qreal angle, const QString &prefix = QString()) const;
90  virtual ~VArc() Q_DECL_OVERRIDE;
91 
92  VArc &operator= (const VArc &arc);
93 #ifdef Q_COMPILER_RVALUE_REFS
94  VArc &operator=(VArc &&arc) Q_DECL_NOTHROW;
95 #endif
96 
97  void Swap(VArc &arc) Q_DECL_NOTHROW;
98 
99  QString GetFormulaRadius () const;
100  void SetFormulaRadius (const QString &formula, qreal value);
101  qreal GetRadius () const;
102 
103  virtual qreal GetLength () const Q_DECL_OVERRIDE;
104 
105  QPointF GetP1() const;
106  QPointF GetP2 () const;
107 
108  virtual QVector<QPointF> getPoints() const Q_DECL_OVERRIDE;
110 
111  QPointF CutArc (qreal length, VArc &segment1, VArc &segment2) const;
112  QPointF CutArc (qreal length) const;
113 
114 protected:
115  virtual void CreateName() Q_DECL_OVERRIDE;
116  virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
117 
118 private:
119  QSharedDataPointer<VArcData> d;
120 
121  qreal MaxLength() const;
122 };
123 
124 Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE);
125 
126 #endif // VARC_H
VArc class for anticlockwise arc.
Definition: varc.h:74
QPointF GetP2() const
GetP2 return point associated with end angle.
Definition: varc.cpp:249
virtual void FindF2(qreal length) Q_DECL_OVERRIDE
Definition: varc.cpp:432
VArc()
VArc default constructor.
Definition: varc.cpp:68
virtual ~VArc() Q_DECL_OVERRIDE
Definition: varc.cpp:212
QPointF CutArc(qreal length, VArc &segment1, VArc &segment2) const
CutArc cut arc into two segments.
Definition: varc.cpp:357
virtual void CreateName() Q_DECL_OVERRIDE
Definition: varc.cpp:414
VArc Move(qreal length, qreal angle, const QString &prefix=QString()) const
Definition: varc.cpp:192
QVector< QLineF > getSegments() const
Definition: varc.cpp:331
virtual qreal GetLength() const Q_DECL_OVERRIDE
GetLength return arc length.
Definition: varc.cpp:220
VArc Flip(const QLineF &axis, const QString &prefix=QString()) const
Definition: varc.cpp:172
QString GetFormulaRadius() const
GetRadius return arc radius.
Definition: varc.cpp:465
VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix=QString()) const
Definition: varc.cpp:152
VArc & operator=(const VArc &arc)
operator = assignment operator
Definition: varc.cpp:140
qreal MaxLength() const
Definition: varc.cpp:455
qreal GetRadius() const
GetRadius return formula for radius.
Definition: varc.cpp:482
void Swap(VArc &arc) Q_DECL_NOTHROW
VArc constructor.
Definition: varc.cpp:87
QPointF GetP1() const
GetP1 return point associated with start angle.
Definition: varc.cpp:236
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list of points needed for drawing arc.
Definition: varc.cpp:262
void SetFormulaRadius(const QString &formula, qreal value)
Definition: varc.cpp:471
QSharedDataPointer< VArcData > d
Definition: varc.h:119
The VPointF class keep data of point.
Definition: vpointf.h:75
Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE)
Draw
Definition: vgeometrydef.h:55
@ Calculation