1 /************************************************************************
2  **
3  **  @file   vtoolarcwithlength.h
4  **  @author Roman Telezhynskyi <dismine(at)gmail.com>
5  **  @date   9 6, 2015
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) 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 VTOOLARCWITHLENGTH_H
30 #define VTOOLARCWITHLENGTH_H
31 
32 #include <qcompilerdetection.h>
33 #include <QGraphicsItem>
34 #include <QMetaObject>
35 #include <QObject>
36 #include <QString>
37 #include <QtGlobal>
38 
39 #include "../ifc/xml/vabstractpattern.h"
40 #include "../vmisc/def.h"
41 #include "vabstractspline.h"
42 
43 class VFormula;
44 template <class T> class QSharedPointer;
45 
46 struct VToolArcWithLengthInitData : VAbstractSplineInitData
47 {
VToolArcWithLengthInitDataVToolArcWithLengthInitData48     VToolArcWithLengthInitData()
49         : VAbstractSplineInitData(),
50           center(NULL_ID),
51           radius('0'),
52           f1('0'),
53           length('0')
54     {}
55 
56     quint32 center;
57     QString radius;
58     QString f1;
59     QString length;
60 };
61 
62 class VToolArcWithLength : public VToolAbstractArc
63 {
64     Q_OBJECT
65 public:
66     virtual void     setDialog() override;
67     static VToolArcWithLength* Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene  *scene,
68                                       VAbstractPattern *doc, VContainer *data);
69     static VToolArcWithLength* Create(VToolArcWithLengthInitData &initData);
70 
71     static const QString ToolType;
type()72     virtual int      type() const override {return Type;}
73     enum { Type = UserType + static_cast<int>(Tool::ArcWithLength)};
74     virtual QString  getTagName() const override;
75 
76     VFormula         GetFormulaRadius() const;
77     void             SetFormulaRadius(const VFormula &value);
78 
79     VFormula         GetFormulaF1() const;
80     void             SetFormulaF1(const VFormula &value);
81 
82     VFormula         GetFormulaLength() const;
83     void             SetFormulaLength(const VFormula &value);
84 
85     qreal            GetApproximationScale() const;
86     void             SetApproximationScale(qreal value);
87 
88     virtual void     ShowVisualization(bool show) override;
89 protected slots:
90     virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
91 protected:
92     virtual void    RemoveReferens() override;
93     virtual void    SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
94                                QList<quint32> &newDependencies) override;
95     virtual void    SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
96     virtual void    SetVisualization() override;
97     virtual QString MakeToolTip() const override;
98 private:
99     Q_DISABLE_COPY(VToolArcWithLength)
100 
101     VToolArcWithLength(const VToolArcWithLengthInitData &initData, QGraphicsItem *parent = nullptr);
102     virtual ~VToolArcWithLength()=default;
103 };
104 
105 #endif // VTOOLARCWITHLENGTH_H
106