1 /************************************************************************
2  **
3  **  @file   varc.h
4  **  @author Roman Telezhynskyi <dismine(at)gmail.com>
5  **  @date   November 15, 2013
6  **
7  **  @brief
8  **  @copyright
9  **  This source code is part of the Valentina project, a pattern making
10  **  program, whose allow create and modeling patterns of clothing.
11  **  Copyright (C) 2013-2015 Valentina project
12  **  <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13  **
14  **  Valentina 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  **  Valentina 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 Valentina.  If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VARC_H
30 #define VARC_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 VArcData;
46 
47 /**
48  * @brief VArc class for anticlockwise arc.
49  */
50 class VArc: public VAbstractArc
51 {
52     Q_DECLARE_TR_FUNCTIONS(VArc)
53 public:
54     VArc ();
55     VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
56           qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
57     VArc (const VPointF &center, qreal radius, qreal f1, qreal f2);
58     VArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
59           qreal f1, const QString &formulaF1,  quint32 idObject = 0, Draw mode = Draw::Calculation);
60     VArc (qreal length, const VPointF &center, qreal radius, qreal f1);
61     VArc(const VArc &arc);
62     VArc Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
63     VArc Flip(const QLineF &axis, const QString &prefix = QString()) const;
64     VArc Move(qreal length, qreal angle, const QString &prefix = QString()) const;
65     virtual ~VArc() override;
66 
67     VArc& operator= (const VArc &arc);
68 #ifdef Q_COMPILER_RVALUE_REFS
69     VArc(VArc &&arc) Q_DECL_NOTHROW;
70     VArc &operator=(VArc &&arc) Q_DECL_NOTHROW;
71 #endif
72 
73     QString GetFormulaRadius () const;
74     void    SetFormulaRadius (const QString &formula, qreal value);
75     qreal   GetRadius () const;
76 
77     virtual qreal GetLength () const override;
78 
79     QPointF GetP1() const;
80     QPointF GetP2 () const;
81 
82     virtual QVector<QPointF> GetPoints () const override;
83 
84     QPointF CutArc (qreal length, VArc &arc1, VArc &arc2) const;
85     QPointF CutArc (qreal length) const;
86 protected:
87     virtual void CreateName() override;
88     virtual void CreateAlias() override;
89     virtual void FindF2(qreal length) override;
90 private:
91     QSharedDataPointer<VArcData> d;
92 
93     qreal MaxLength() const;
94 };
95 
96 Q_DECLARE_TYPEINFO(VArc, Q_MOVABLE_TYPE);
97 
98 #endif // VARC_H
99