Seamly2D
Code documentation
vsplinepoint_p.h
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_p.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 20 8, 2014
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 #ifndef VSPLINEPOINT_P_H
53 #define VSPLINEPOINT_P_H
54 
55 #include <QLineF>
56 #include <QSharedData>
57 #include <QtDebug>
58 
59 #include "vpointf.h"
60 #include "../vmisc/def.h"
61 #include "../qmuparser/qmutokenparser.h"
62 
63 QT_WARNING_PUSH
64 QT_WARNING_DISABLE_GCC("-Weffc++")
65 QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
66 
67 class VFSplinePointData : public QSharedData
68 {
69 public:
70 
72  : pSpline(VPointF()),
73  angle1(0),
74  angle2(180),
75  kAsm1(1),
76  kAsm2(1)
77  {}
78 
79  VFSplinePointData(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
80  : pSpline(pSpline),
81  angle1(angle1),
82  angle2(angle2),
83  kAsm1(kAsm1),
84  kAsm2(kAsm2)
85  {
86  if (VFuzzyComparePossibleNulls(angle1, angle2) || not qFuzzyCompare(qAbs(angle1-angle2), 180) )
87  {
88  qDebug()<<"Make angle1 and angle2 correct.";
89  this->angle2 = this->angle1 + 180;
90  }
91  }
92 
94  : QSharedData(point),
95  pSpline(point.pSpline),
96  angle1(point.angle1),
97  angle2(point.angle2),
98  kAsm1(point.kAsm1),
99  kAsm2(point.kAsm2)
100  {}
101 
102  virtual ~VFSplinePointData();
103 
104  /** @brief pSpline point. */
106 
107  /** @brief angle1 first angle spline. */
108  qreal angle1;
109 
110  /** @brief angle2 second angle spline. */
111  qreal angle2;
112 
113  /** @brief kAsm1 coefficient of length first control line. */
114  qreal kAsm1;
115 
116  /** @brief kAsm2 coefficient of length second control line. */
117  qreal kAsm2;
118 
119 private:
120  VFSplinePointData &operator=(const VFSplinePointData &) Q_DECL_EQ_DELETE;
121 };
122 
124 {}
125 
126 //--------------------------------------VSplinePointData---------------------------------------------------------------
127 
128 class VSplinePointData : public QSharedData
129 {
130 public:
132  : pSpline(),
133  angle1(0),
134  angle1F("0"),
135  angle2(180),
136  angle2F("180"),
137  length1(0),
138  length1F("0"),
139  length2(0),
140  length2F("0")
141  {}
142 
143  VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2, const QString &angle2F,
144  qreal length1, const QString &length1F, qreal length2, const QString &length2F);
145 
147  : QSharedData(point),
148  pSpline(point.pSpline),
149  angle1(point.angle1),
150  angle1F(point.angle1F),
151  angle2(point.angle2),
152  angle2F(point.angle2F),
153  length1(point.length1),
154  length1F(point.length1F),
155  length2(point.length2),
156  length2F(point.length2F)
157  {}
158 
159  virtual ~VSplinePointData();
160 
161  /** @brief pSpline point. */
163 
164  /** @brief angle1 first angle spline. */
165  qreal angle1;
166  QString angle1F;
167 
168  /** @brief angle2 second angle spline. */
169  qreal angle2;
170  QString angle2F;
171 
172  /** @brief length1 length a first control line. */
173  qreal length1;
174  QString length1F;
175 
176  /** @brief length2 length a second control line. */
177  qreal length2;
178  QString length2F;
179 
180 private:
181  VSplinePointData &operator=(const VSplinePointData &) Q_DECL_EQ_DELETE;
182 };
183 
184 //---------------------------------------------------------------------------------------------------------------------
185 VSplinePointData::VSplinePointData(VPointF pSpline, qreal angle1, const QString &angle1F, qreal angle2,
186  const QString &angle2F, qreal length1, const QString &length1F, qreal length2,
187  const QString &length2F)
188  : pSpline(pSpline),
189  angle1(angle1),
190  angle1F(angle1F),
191  angle2(angle2),
192  angle2F(angle2F),
193  length1(length1),
194  length1F(length1F),
195  length2(length2),
196  length2F(length2F)
197 {
198  if (not VFuzzyComparePossibleNulls(qAbs(angle1-angle2), 180))
199  {
200  qDebug()<<"Make angle1 and angle2 correct.";
201 
202  QLineF line (0, 0, 100, 0);
203 
205  {
206  line.setAngle(angle1 + 180);
207  this->angle2 = line.angle();
208  this->angle2F = QString().number(line.angle());
209  }
210  else
211  {
212  line.setAngle(angle2 + 180);
213  this->angle1 = line.angle();
214  this->angle1F = QString().number(line.angle());
215  }
216  }
217 }
218 
219 //---------------------------------------------------------------------------------------------------------------------
221 {}
222 
224 
225 #endif // VSPLINEPOINT_P_H
VFSplinePointData & operator=(const VFSplinePointData &) Q_DECL_EQ_DELETE
VFSplinePointData(VPointF pSpline, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2)
qreal kAsm1
kAsm1 coefficient of length first control line.
VFSplinePointData(const VFSplinePointData &point)
qreal angle2
angle2 second angle spline.
virtual ~VFSplinePointData()
VPointF pSpline
pSpline point.
qreal kAsm2
kAsm2 coefficient of length second control line.
qreal angle1
angle1 first angle spline.
The VPointF class keep data of point.
Definition: vpointf.h:75
qreal length1
length1 length a first control line.
qreal length2
length2 length a second control line.
qreal angle2
angle2 second angle spline.
qreal angle1
angle1 first angle spline.
VSplinePointData & operator=(const VSplinePointData &) Q_DECL_EQ_DELETE
VSplinePointData(const VSplinePointData &point)
virtual ~VSplinePointData()
VPointF pSpline
pSpline point.
static bool IsSingle(const QString &formula)
IsSingle test formula and return true if it contain only one number.
static Q_REQUIRED_RESULT bool VFuzzyComparePossibleNulls(double p1, double p2)
Definition: def.h:490