1 /************************************************************************
2 **
3 ** @file vsplinepoint_p.h
4 ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5 ** @date 20 8, 2014
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 VSPLINEPOINT_P_H
30 #define VSPLINEPOINT_P_H
31
32 #include <QLineF>
33 #include <QSharedData>
34 #include <QtDebug>
35
36 #include "vpointf.h"
37 #include "../vmisc/def.h"
38 #include "../qmuparser/qmutokenparser.h"
39
40 QT_WARNING_PUSH
41 QT_WARNING_DISABLE_GCC("-Weffc++")
42 QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
43
44 class VFSplinePointData : public QSharedData
45 {
46 public:
47
VFSplinePointData()48 VFSplinePointData()
49 : pSpline(VPointF()),
50 angle1(0),
51 angle2(180),
52 kAsm1(1),
53 kAsm2(1)
54 {}
55
VFSplinePointData(VPointF pSpline,qreal kAsm1,qreal angle1,qreal kAsm2,qreal angle2)56 VFSplinePointData(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
57 : pSpline(pSpline),
58 angle1(angle1),
59 angle2(angle2),
60 kAsm1(kAsm1),
61 kAsm2(kAsm2)
62 {
63 if (VFuzzyComparePossibleNulls(angle1, angle2) || not qFuzzyCompare(qAbs(angle1-angle2), 180) )
64 {
65 this->angle2 = this->angle1 + 180;
66 }
67 }
68
VFSplinePointData(const VFSplinePointData & point)69 VFSplinePointData(const VFSplinePointData &point)
70 : QSharedData(point),
71 pSpline(point.pSpline),
72 angle1(point.angle1),
73 angle2(point.angle2),
74 kAsm1(point.kAsm1),
75 kAsm2(point.kAsm2)
76 {}
77
78 virtual ~VFSplinePointData();
79
80 /** @brief pSpline point. */
81 VPointF pSpline;
82
83 /** @brief angle1 first angle spline. */
84 qreal angle1;
85
86 /** @brief angle2 second angle spline. */
87 qreal angle2;
88
89 /** @brief kAsm1 coefficient of length first control line. */
90 qreal kAsm1;
91
92 /** @brief kAsm2 coefficient of length second control line. */
93 qreal kAsm2;
94
95 private:
96 Q_DISABLE_ASSIGN(VFSplinePointData)
97 };
98
~VFSplinePointData()99 VFSplinePointData::~VFSplinePointData()
100 {}
101
102 //--------------------------------------VSplinePointData---------------------------------------------------------------
103
104 class VSplinePointData : public QSharedData
105 {
106 public:
VSplinePointData()107 VSplinePointData()
108 : pSpline(),
109 angle1(0),
110 angle1F('0'),
111 angle2(180),
112 angle2F("180"),
113 length1(ToPixel(0.01, Unit::Mm)),
114 length1F('0'),
115 length2(ToPixel(0.01, Unit::Mm)),
116 length2F('0')
117 {}
118
119 VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
120 qreal length1, const QString &length1F, qreal length2, const QString &length2F);
121
VSplinePointData(const VSplinePointData & point)122 VSplinePointData(const VSplinePointData &point)
123 : QSharedData(point),
124 pSpline(point.pSpline),
125 angle1(point.angle1),
126 angle1F(point.angle1F),
127 angle2(point.angle2),
128 angle2F(point.angle2F),
129 length1(point.length1),
130 length1F(point.length1F),
131 length2(point.length2),
132 length2F(point.length2F)
133 {
134 if (qFuzzyIsNull(this->length1))
135 {
136 this->length1 = ToPixel(0.01, Unit::Mm);
137 }
138
139 if (qFuzzyIsNull(this->length2))
140 {
141 this->length2 = ToPixel(0.01, Unit::Mm);
142 }
143 }
144
145 virtual ~VSplinePointData();
146
147 /** @brief pSpline point. */
148 VPointF pSpline;
149
150 /** @brief angle1 first angle spline. */
151 qreal angle1;
152 QString angle1F;
153
154 /** @brief angle2 second angle spline. */
155 qreal angle2;
156 QString angle2F;
157
158 /** @brief length1 length a first control line. */
159 qreal length1;
160 QString length1F;
161
162 /** @brief length2 length a second control line. */
163 qreal length2;
164 QString length2F;
165
166 private:
167 Q_DISABLE_ASSIGN(VSplinePointData)
168 };
169
170 //---------------------------------------------------------------------------------------------------------------------
VSplinePointData(VPointF pSpline,qreal angle1,const QString & angle1F,qreal angle2,const QString & angle2F,qreal length1,const QString & length1F,qreal length2,const QString & length2F)171 VSplinePointData::VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2,
172 const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
173 const QString &length2F)
174 : pSpline(pSpline),
175 angle1(angle1),
176 angle1F(angle1F),
177 angle2(angle2),
178 angle2F(angle2F),
179 length1(length1),
180 length1F(length1F),
181 length2(length2),
182 length2F(length2F)
183 {
184 if (not VFuzzyComparePossibleNulls(qAbs(angle1-angle2), 180))
185 {
186 QLineF line (0, 0, 100, 0);
187
188 if (not qmu::QmuTokenParser::IsSingle(angle1F) || qmu::QmuTokenParser::IsSingle(angle2F))
189 {
190 line.setAngle(angle1 + 180);
191 this->angle2 = line.angle();
192 this->angle2F = QString().number(line.angle());
193 }
194 else
195 {
196 line.setAngle(angle2 + 180);
197 this->angle1 = line.angle();
198 this->angle1F = QString().number(line.angle());
199 }
200 }
201
202 if (qFuzzyIsNull(this->length1))
203 {
204 this->length1 = ToPixel(0.01, Unit::Mm);
205 }
206
207 if (qFuzzyIsNull(this->length2))
208 {
209 this->length2 = ToPixel(0.01, Unit::Mm);
210 }
211 }
212
213 //---------------------------------------------------------------------------------------------------------------------
~VSplinePointData()214 VSplinePointData::~VSplinePointData()
215 {}
216
217 QT_WARNING_POP
218
219 #endif // VSPLINEPOINT_P_H
220