Seamly2D
Code documentation
vellipticalarc.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vellipticalarc.h
4  ** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
5  ** @date February 1, 2016
6  **
7  ** @brief
8  ** @copyright
9  ** This source code is part of the Valentine project, a pattern making
10  ** program, whose allow create and modeling patterns of clothing.
11  ** Copyright (C) 2013-2015 Seamly2D project
12  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
13  **
14  ** Seamly2D is free software: you can redistribute it and/or modify
15  ** it under the terms of the GNU General Public License as published by
16  ** the Free Software Foundation, either version 3 of the License, or
17  ** (at your option) any later version.
18  **
19  ** Seamly2D is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  ** GNU General Public License for more details.
23  **
24  ** You should have received a copy of the GNU General Public License
25  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VELLIPTICALARC_H
30 #define VELLIPTICALARC_H
31 
32 #include <qcompilerdetection.h>
33 #include <QCoreApplication>
34 #include <QPointF>
35 #include <QSharedDataPointer>
36 #include <QString>
37 #include <QTypeInfo>
38 #include <QVector>
39 #include <QtGlobal>
40 
41 #include "vabstractarc.h"
42 #include "vgeometrydef.h"
43 #include "vpointf.h"
44 
45 class VEllipticalArcData;
46 
48 {
49  Q_DECLARE_TR_FUNCTIONS(VEllipticalArc)
50 
51 public:
53  VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, const QString &formulaRadius1,
54  const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
55  const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle,
56  quint32 idObject = 0, Draw mode = Draw::Calculation);
57 
58  VEllipticalArc(const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
59 
60  VEllipticalArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius1, qreal radius2,
61  const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1,
62  qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0,
63  Draw mode = Draw::Calculation);
64 
65  VEllipticalArc(qreal length, const VPointF &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
66 
67  VEllipticalArc(const VEllipticalArc &arc);
68 
69  VEllipticalArc Rotate(QPointF originPoint, qreal degrees, const QString &prefix = QString()) const;
70  VEllipticalArc Flip(const QLineF &axis, const QString &prefix = QString()) const;
71  VEllipticalArc Move(qreal length, qreal angle, const QString &prefix = QString()) const;
72 
73  virtual ~VEllipticalArc() Q_DECL_OVERRIDE;
74 
76 
77 #ifdef Q_COMPILER_RVALUE_REFS
78  VEllipticalArc &operator=(VEllipticalArc &&arc) Q_DECL_NOTHROW;
79 #endif
80 
81  void Swap(VEllipticalArc &arc) Q_DECL_NOTHROW;
82 
83  QString GetFormulaRotationAngle () const;
84  void SetFormulaRotationAngle (const QString &formula, qreal value);
85  qreal GetRotationAngle() const;
86 
87  QString GetFormulaRadius1 () const;
88  void SetFormulaRadius1 (const QString &formula, qreal value);
89  qreal GetRadius1 () const;
90 
91  QString GetFormulaRadius2 () const;
92  void SetFormulaRadius2 (const QString &formula, qreal value);
93  qreal GetRadius2 () const;
94 
95  virtual qreal GetLength () const Q_DECL_OVERRIDE;
96 
97  QPointF GetP1() const;
98  QPointF GetP2() const;
99 
100  QTransform getTransform() const;
101  void setTransform(const QTransform &matrix, bool combine = false);
102 
103  virtual VPointF GetCenter () const Q_DECL_OVERRIDE;
104  virtual QVector<QPointF> getPoints() const Q_DECL_OVERRIDE;
105  virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
106  virtual qreal GetEndAngle () const Q_DECL_OVERRIDE;
107 
108  QPointF CutArc (const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const;
109  QPointF CutArc (const qreal &length) const;
110 
111  static qreal normalizeAngle(qreal angle);
112 
113 protected:
114  virtual void CreateName() Q_DECL_OVERRIDE;
115  virtual void FindF2(qreal length) Q_DECL_OVERRIDE;
116 
117 private:
118  QSharedDataPointer<VEllipticalArcData> d;
119  qreal MaxLength() const;
120  QPointF getPoint (qreal angle) const;
121  qreal getRealEndAngle() const;
122 };
123 
124 Q_DECLARE_METATYPE(VEllipticalArc)
126 
127 //---------------------------------------------------------------------------------------------------------------------
128 inline qreal VEllipticalArc::normalizeAngle(qreal angle)
129 {
130  return angle - 360.*qFloor(angle/360.);
131 }
132 #endif // VELLIPTICALARC_H
VEllipticalArc Flip(const QLineF &axis, const QString &prefix=QString()) const
qreal GetRadius2() const
GetRadius2 return elliptical arc minor radius.
QString GetFormulaRadius2() const
GetFormulaRadius2 return formula for minor radius.
VEllipticalArc Rotate(QPointF originPoint, qreal degrees, const QString &prefix=QString()) const
VEllipticalArc & operator=(const VEllipticalArc &arc)
operator = assignment operator
virtual qreal GetStartAngle() const Q_DECL_OVERRIDE
static qreal normalizeAngle(qreal angle)
QPointF GetP1() const
GetP1 return point associated with start angle.
VEllipticalArc Move(qreal length, qreal angle, const QString &prefix=QString()) const
QString GetFormulaRadius1() const
GetFormulaRadius1 return formula for major radius.
virtual VPointF GetCenter() const Q_DECL_OVERRIDE
void SetFormulaRadius1(const QString &formula, qreal value)
VEllipticalArc()
VEllipticalArc default constructor.
virtual ~VEllipticalArc() Q_DECL_OVERRIDE
QPointF CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2) const
CutArc cut arc into two arcs.
qreal GetRadius1() const
GetRadius1 return elliptical arc major radius.
QSharedDataPointer< VEllipticalArcData > d
virtual QVector< QPointF > getPoints() const Q_DECL_OVERRIDE
GetPoints return list of points needed for drawing arc.
virtual void FindF2(qreal length) Q_DECL_OVERRIDE
void setTransform(const QTransform &matrix, bool combine=false)
QString GetFormulaRotationAngle() const
GetFormulaRotationAngle return formula for rotation angle.
void SetFormulaRotationAngle(const QString &formula, qreal value)
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE
QPointF getPoint(qreal angle) const
GetPoint return point associated with angle.
QPointF GetP2() const
GetP2 return point associated with end angle.
qreal MaxLength() const
qreal GetRotationAngle() const
GetRotationAngle return rotation angle.
QTransform getTransform() const
virtual qreal GetLength() const Q_DECL_OVERRIDE
GetLength return arc length.
void SetFormulaRadius2(const QString &formula, qreal value)
qreal getRealEndAngle() const
void Swap(VEllipticalArc &arc) Q_DECL_NOTHROW
virtual void CreateName() Q_DECL_OVERRIDE
The VPointF class keep data of point.
Definition: vpointf.h:75
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE)
Draw
Definition: vgeometrydef.h:55
@ Calculation