1 /************************************************************************
2  **
3  **  @file   vpointf.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 VPOINTF_H
30 #define VPOINTF_H
31 
32 #include <qcompilerdetection.h>
33 #include <QMetaType>
34 #include <QSharedDataPointer>
35 #include <QString>
36 #include <QTypeInfo>
37 #include <QtGlobal>
38 
39 #include "../vmisc/diagnostic.h"
40 #include "vgeometrydef.h"
41 #include "vgobject.h"
42 
43 class VPointFData;
44 
45 QT_WARNING_PUSH
46 QT_WARNING_DISABLE_INTEL(2304)
47 
48 /**
49  * @brief The VPointF class keep data of point.
50  */
51 class VPointF:public VGObject
52 {
53 public:
54     VPointF ();
55     VPointF (const VPointF &point );
56     explicit VPointF (const QPointF &point );
57     VPointF (qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject = 0,
58              const Draw &mode = Draw::Calculation);
59     VPointF (const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0,
60              const Draw &mode = Draw::Calculation);
61     virtual ~VPointF() override;
62 
63     VPointF &operator=(const VPointF &point);
64 #ifdef Q_COMPILER_RVALUE_REFS
65     VPointF(const VPointF &&point) Q_DECL_NOTHROW;
66     VPointF &operator=(VPointF &&point) Q_DECL_NOTHROW;
67 #endif
68 
69     explicit operator QPointF() const;
70     VPointF Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const;
71     VPointF Flip(const QLineF &axis, const QString &prefix = QString()) const;
72     VPointF Move(qreal length, qreal angle, const QString &prefix = QString()) const;
73     qreal   mx() const;
74     qreal   my() const;
75     void    setMx(qreal mx);
76     void    setMy(qreal my);
77     QPointF toQPointF()const;
78     qreal   x() const;
79     void    setX(const qreal &value);
80     qreal   y() const;
81     void    setY(const qreal &value);
82 
83     bool IsShowLabel() const;
84     void SetShowLabel(bool hide);
85 
86     virtual QJsonObject ToJson() const override;
87 
88     virtual void SetAlias(const QString &alias) override;
89     virtual void SetAliasSuffix(const QString &aliasSuffix) override;
90 
91     static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
92     static QPointF FlipPF(const QLineF &axis, const QPointF &point);
93     static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);
94 private:
95     QSharedDataPointer<VPointFData> d;
96 };
97 
98 Q_DECLARE_METATYPE(VPointF)
99 Q_DECLARE_TYPEINFO(VPointF, Q_MOVABLE_TYPE);
100 
101 QT_WARNING_POP
102 
103 #endif // VPOINTF_H
104