Seamly2D
Code documentation
vsplinepoint.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vsplinepoint.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date November 15, 2013
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "vsplinepoint.h"
53 
54 #include <QLineF>
55 
56 #include "../qmuparser/qmutokenparser.h"
57 #include "vsplinepoint_p.h"
58 
59 #ifdef Q_COMPILER_RVALUE_REFS
61 { Swap(point); return *this; }
62 #endif
63 
64 void VFSplinePoint::Swap(VFSplinePoint &point) Q_DECL_NOTHROW
65 { std::swap(d, point.d); }
66 
67 //---------------------------------------------------------------------------------------------------------------------
68 /**
69  * @brief VFSplinePoint default constructor.
70  */
72  :d(new VFSplinePointData)
73 {}
74 
75 //---------------------------------------------------------------------------------------------------------------------
76 /**
77  * @brief VFSplinePoint constructor.
78  * @param pSpline spline point.
79  * @param kAsm1 coefficient of length first control line.
80  * @param angle1 first angle control line.
81  * @param kAsm2 coefficient of length second control line.
82  * @param angle2 second angle control line.
83  */
84 VFSplinePoint::VFSplinePoint(const VPointF &pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
85  :d(new VFSplinePointData(pSpline, kAsm1, angle1, kAsm2, angle2))
86 {}
87 
88 //---------------------------------------------------------------------------------------------------------------------
89 /**
90  * @brief VFSplinePoint copy constructor
91  * @param point point
92  */
94  :d(point.d)
95 {}
96 
97 //---------------------------------------------------------------------------------------------------------------------
99 {
100  if ( &point == this )
101  {
102  return *this;
103  }
104  d = point.d;
105  return *this;
106 }
107 
108 //---------------------------------------------------------------------------------------------------------------------
110 {}
111 
112 //---------------------------------------------------------------------------------------------------------------------
113 /**
114  * @brief SetAngle1 set first angle of spline.
115  * @param value angle.
116  */
117 void VFSplinePoint::SetAngle1(const qreal &value)
118 {
119  QLineF line(0, 0, 100, 0);
120  line.setAngle(value);
121  d->angle1 = line.angle();
122 
123  line.setAngle(d->angle1+180);
124  d->angle2 = line.angle();
125 }
126 
127 //---------------------------------------------------------------------------------------------------------------------
128 /**
129  * @brief SetAngle2 set second angle of spline.
130  * @param value angle.
131  */
132 void VFSplinePoint::SetAngle2(const qreal &value)
133 {
134  QLineF line(0, 0, 100, 0);
135  line.setAngle(value);
136  d->angle2 = line.angle();
137 
138  line.setAngle(d->angle2+180);
139  d->angle1 = line.angle();
140 }
141 
142 //---------------------------------------------------------------------------------------------------------------------
143 /**
144  * @brief P return point.
145  * @return point.
146  */
148 {
149  return d->pSpline;
150 }
151 
152 //---------------------------------------------------------------------------------------------------------------------
153 /**
154  * @brief SetP set point.
155  * @param value point.
156  */
157 void VFSplinePoint::SetP(const VPointF &value)
158 {
159  d->pSpline = value;
160 }
161 
162 //---------------------------------------------------------------------------------------------------------------------
163 /**
164  * @brief Angle1 return first angle of spline.
165  * @return angle.
166  */
168 {
169  return d->angle1;
170 }
171 
172 //---------------------------------------------------------------------------------------------------------------------
173 /**
174  * @brief Angle2 return second angle of spline.
175  * @return angle.
176  */
178 {
179  return d->angle2;
180 }
181 
182 //---------------------------------------------------------------------------------------------------------------------
183 /**
184  * @brief KAsm1 return coefficient of length first control line.
185  * @return coefficient.
186  */
187 qreal VFSplinePoint::KAsm1() const
188 {
189  return d->kAsm1;
190 }
191 
192 //---------------------------------------------------------------------------------------------------------------------
193 /**
194  * @brief SetKAsm1 set coefficient of length first control line.
195  * @param value coefficient.
196  */
197 void VFSplinePoint::SetKAsm1(const qreal &value)
198 {
199  d->kAsm1 = value;
200 }
201 
202 //---------------------------------------------------------------------------------------------------------------------
203 /**
204  * @brief KAsm2 return coefficient of length second control line.
205  * @return coefficient.
206  */
207 qreal VFSplinePoint::KAsm2() const
208 {
209  return d->kAsm2;
210 }
211 
212 //---------------------------------------------------------------------------------------------------------------------
213 /**
214  * @brief SetKAsm2 set coefficient of length second control line.
215  * @param value coefficient.
216  */
217 void VFSplinePoint::SetKAsm2(const qreal &value)
218 {
219  d->kAsm2 = value;
220 }
221 
222 //---------------------------------------------------------------------------------------------------------------------
223 #ifdef Q_COMPILER_RVALUE_REFS
224 VSplinePoint &VSplinePoint::operator=(VSplinePoint &&point) Q_DECL_NOTHROW
225 { Swap(point); return *this; }
226 #endif
227 
228 void VSplinePoint::Swap(VSplinePoint &point) Q_DECL_NOTHROW
229 { std::swap(d, point.d); }
230 //------------------------------------------VSplinePoint---------------------------------------------------------------
232  : d(new VSplinePointData)
233 {
234 }
235 
236 //---------------------------------------------------------------------------------------------------------------------
237 VSplinePoint::VSplinePoint(const VPointF &pSpline, qreal angle1, const QString &angle1F, qreal angle2,
238  const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
239  const QString &length2F)
240  : d(new VSplinePointData(pSpline, angle1, angle1F, angle2, angle2F, length1, length1F, length2, length2F))
241 {
242 }
243 
244 //---------------------------------------------------------------------------------------------------------------------
246  : d(point.d)
247 {
248 }
249 
250 //---------------------------------------------------------------------------------------------------------------------
252 {
253  if ( &point == this )
254  {
255  return *this;
256  }
257  d = point.d;
258  return *this;
259 }
260 
261 //---------------------------------------------------------------------------------------------------------------------
263 {
264 }
265 
266 //---------------------------------------------------------------------------------------------------------------------
268 {
269  return d->pSpline;
270 }
271 
272 //---------------------------------------------------------------------------------------------------------------------
273 void VSplinePoint::SetP(const VPointF &value)
274 {
275  d->pSpline = value;
276 }
277 
278 //---------------------------------------------------------------------------------------------------------------------
279 qreal VSplinePoint::Angle1() const
280 {
281  return d->angle1;
282 }
283 
284 //---------------------------------------------------------------------------------------------------------------------
286 {
287  return d->angle1F;
288 }
289 
290 //---------------------------------------------------------------------------------------------------------------------
291 void VSplinePoint::SetAngle1(const qreal &value, const QString &angle1F)
292 {
293  d->angle1F = angle1F;
294 
295  QLineF line(0, 0, 100, 0);
296  line.setAngle(value);
297  d->angle1 = line.angle();
298 
299  line.setAngle(d->angle1+180);
300  d->angle2 = line.angle();
301  d->angle2F = QString().number(d->angle2);
302 }
303 
304 //---------------------------------------------------------------------------------------------------------------------
305 qreal VSplinePoint::Angle2() const
306 {
307  return d->angle2;
308 }
309 
310 //---------------------------------------------------------------------------------------------------------------------
312 {
313  return d->angle2F;
314 }
315 
316 //---------------------------------------------------------------------------------------------------------------------
317 void VSplinePoint::SetAngle2(const qreal &value, const QString &angle2F)
318 {
319  d->angle2F = angle2F;
320 
321  QLineF line(0, 0, 100, 0);
322  line.setAngle(value);
323  d->angle2 = line.angle();
324 
325  line.setAngle(d->angle2+180);
326  d->angle1 = line.angle();
327  d->angle1F = QString().number(d->angle1);
328 }
329 
330 //---------------------------------------------------------------------------------------------------------------------
332 {
333  return d->length1;
334 }
335 
336 //---------------------------------------------------------------------------------------------------------------------
338 {
339  return d->length1F;
340 }
341 
342 //---------------------------------------------------------------------------------------------------------------------
343 void VSplinePoint::SetLength1(const qreal &value, const QString &length1F)
344 {
345  d->length1 = value;
346  d->length1F = length1F;
347 }
348 
349 //---------------------------------------------------------------------------------------------------------------------
351 {
352  return d->length2;
353 }
354 
355 //---------------------------------------------------------------------------------------------------------------------
357 {
358  return d->length2F;
359 }
360 
361 //---------------------------------------------------------------------------------------------------------------------
362 void VSplinePoint::SetLength2(const qreal &value, const QString &length2F)
363 {
364  d->length2 = value;
365  d->length2F = length2F;
366 }
367 
368 //---------------------------------------------------------------------------------------------------------------------
370 {
371  return qmu::QmuTokenParser::IsSingle(d->angle1F) && qmu::QmuTokenParser::IsSingle(d->angle2F) &&
373 }
The VFSplinePoint class keep information about point in spline path. Each point have two angles and t...
Definition: vsplinepoint.h:70
void SetKAsm1(const qreal &value)
SetKAsm1 set coefficient of length first control line.
void Swap(VFSplinePoint &point) Q_DECL_NOTHROW
VPointF P() const
P return point.
void SetP(const VPointF &value)
SetP set point.
void SetAngle2(const qreal &value)
SetAngle2 set second angle of spline.
void SetKAsm2(const qreal &value)
SetKAsm2 set coefficient of length second control line.
VFSplinePoint & operator=(const VFSplinePoint &point)
VFSplinePoint()
VFSplinePoint default constructor.
qreal Angle1() const
Angle1 return first angle of spline.
void SetAngle1(const qreal &value)
SetAngle1 set first angle of spline.
QSharedDataPointer< VFSplinePointData > d
Definition: vsplinepoint.h:95
qreal KAsm1() const
KAsm1 return coefficient of length first control line.
qreal Angle2() const
Angle2 return second angle of spline.
qreal KAsm2() const
KAsm2 return coefficient of length second control line.
The VPointF class keep data of point.
Definition: vpointf.h:75
The VSplinePoint class keep information about point in spline path. Each point have two angles and tw...
Definition: vsplinepoint.h:108
QString Length1Formula() const
void SetAngle1(const qreal &value, const QString &angle1F)
qreal Length2() const
QSharedDataPointer< VSplinePointData > d
Definition: vsplinepoint.h:144
qreal Angle2() const
QString Angle2Formula() const
VSplinePoint & operator=(const VSplinePoint &point)
void SetP(const VPointF &value)
void SetLength1(const qreal &value, const QString &length1F)
QString Length2Formula() const
QString Angle1Formula() const
void SetLength2(const qreal &value, const QString &length2F)
void Swap(VSplinePoint &point) Q_DECL_NOTHROW
qreal Angle1() const
void SetAngle2(const qreal &value, const QString &angle2F)
bool IsMovable() const
VPointF P() const
qreal Length1() const
static bool IsSingle(const QString &formula)
IsSingle test formula and return true if it contain only one number.