Seamly2D
Code documentation
vpiecenode_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
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 3 11, 2016
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) 2016 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 VPIECENODE_P_H
53 #define VPIECENODE_P_H
54 
55 #include <QSharedData>
56 #include <QDataStream>
57 #include "../ifc/ifcdef.h"
58 #include "../vmisc/def.h"
59 #include "../vmisc/diagnostic.h"
60 #include "../vmisc/vabstractapplication.h"
61 #include "../vmisc/vcommonsettings.h"
62 
63 QT_WARNING_PUSH
64 QT_WARNING_DISABLE_GCC("-Weffc++")
65 QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
66 
67 class VPieceNodeData : public QSharedData
68 {
69 public:
71  : m_id(NULL_ID)
72  , m_typeTool(Tool::NodePoint)
73  , m_reverse(false)
74  , m_excluded(false)
75  , m_isNotch(false)
76  , m_isMainPathNode(true)
77  , m_beforeWidthFormula(currentSeamAllowance)
78  , m_afterWidthFormula(currentSeamAllowance)
79  , m_angleType(PieceNodeAngle::ByLength)
80  , m_notchType(stringToNotchType(qApp->Settings()->getDefaultNotchType()))
81  , m_notchSubType(NotchSubType::Straightforward)
82  , m_showNotch(qApp->Settings()->showSeamAllowanceNotch())
83  , m_showSeamlineNotch(qApp->Settings()->showSeamlineNotch())
84  , m_notchLength(qApp->Settings()->getDefaultNotchLength())
85  , m_notchWidth(qApp->Settings()->getDefaultNotchWidth())
86  , m_notchAngle(.000)
87  , m_notchCount(1)
88  {}
89 
90  VPieceNodeData(quint32 id, Tool typeTool, bool reverse)
91  : m_id(id)
92  , m_typeTool(typeTool)
93  , m_reverse(reverse)
94  , m_excluded(false)
95  , m_isNotch(false)
96  , m_isMainPathNode(true)
97  , m_beforeWidthFormula(currentSeamAllowance)
98  , m_afterWidthFormula(currentSeamAllowance)
99  , m_angleType(PieceNodeAngle::ByLength)
100  , m_notchType(stringToNotchType(qApp->Settings()->getDefaultNotchType()))
101  , m_notchSubType(NotchSubType::Straightforward)
102  , m_showNotch(qApp->Settings()->showSeamAllowanceNotch())
103  , m_showSeamlineNotch(qApp->Settings()->showSeamlineNotch())
104  , m_notchLength(qApp->Settings()->getDefaultNotchLength())
105  , m_notchWidth(qApp->Settings()->getDefaultNotchWidth())
106  , m_notchAngle(.000)
107  , m_notchCount(1)
108  {
109  if (m_typeTool == Tool::NodePoint)
110  {
111  m_reverse = false;
112  }
113  }
114 
116  : QSharedData(node)
117  , m_id(node.m_id)
118  , m_typeTool(node.m_typeTool)
119  , m_reverse(node.m_reverse)
120  , m_excluded(node.m_excluded)
121  , m_isNotch(node.m_isNotch)
122  , m_isMainPathNode(node.m_isMainPathNode)
123  , m_beforeWidthFormula(node.m_beforeWidthFormula)
124  , m_afterWidthFormula(node.m_afterWidthFormula)
125  , m_angleType(node.m_angleType)
126  , m_notchType(node.m_notchType)
127  , m_notchSubType(node.m_notchSubType)
128  , m_showNotch(node.m_showNotch)
129  , m_showSeamlineNotch(node.m_showSeamlineNotch)
130  , m_notchLength(node.m_notchLength)
131  , m_notchWidth(node.m_notchWidth)
132  , m_notchAngle(node.m_notchAngle)
133  , m_notchCount(node.m_notchCount)
134  {}
135 
136  ~VPieceNodeData() Q_DECL_EQ_DEFAULT;
137 
138  friend QDataStream& operator<<(QDataStream& out, const VPieceNodeData& p);
139  friend QDataStream& operator>>(QDataStream& in, VPieceNodeData& p);
140 
141  quint32 m_id; //! @brief id object id.
142  Tool m_typeTool; //! @brief typeTool type of tool
143  bool m_reverse; //! @brief reverse true if need reverse points list for node.
144  bool m_excluded; //! @brief m_excluded true if item excluded from main path. Excluded item is
145  //! not visible and also will not has affect on main path. Also include to exist
146  //! path items automatically setted excluded. */
147  bool m_isNotch; //! @brief m_isNotch has sense only for points. If true to seam allowance should
148  //! a notch should be added.
149  bool m_isMainPathNode; //! @brief m_isMainPathNode need fin know if allowed for this notch to be double.
150 
151  QString m_beforeWidthFormula;
152  QString m_afterWidthFormula;
153 
154  PieceNodeAngle m_angleType;
155 
156  NotchType m_notchType;
157  NotchSubType m_notchSubType;
158  bool m_showNotch;
159  bool m_showSeamlineNotch;
160  qreal m_notchLength;
161  qreal m_notchWidth;
162  qreal m_notchAngle;
163  int m_notchCount;
164 
165 private:
166  VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE;
167 };
168 
169 // Friend functions
170 //---------------------------------------------------------------------------------------------------------------------
171 QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p)
172 {
173  out << p.m_id
174  << static_cast<int>(p.m_typeTool)
175  << p.m_reverse
176  << p.m_excluded
177  << p.m_isNotch
178  << p.m_beforeWidthFormula
179  << p.m_afterWidthFormula
180  << static_cast<int>(p.m_angleType)
181  << static_cast<int>(p.m_notchType)
182  << static_cast<int>(p.m_notchSubType)
183  << p.m_showNotch
184  << p.m_showSeamlineNotch
185  << p.m_notchLength
186  << p.m_notchWidth
187  << p.m_notchAngle
188  << p.m_notchCount;
189  return out;
190 }
191 
192 //---------------------------------------------------------------------------------------------------------------------
193 QDataStream &operator>>(QDataStream &in, VPieceNodeData &p)
194 {
195  int typeTool = 0;
196  int angleType = 0;
197  int notchType = 0;
198  int notchSubType = 0;
199 
200  in >> p.m_id
201  >> typeTool
202  >> p.m_reverse
203  >> p.m_excluded
204  >> p.m_isNotch
207  >> angleType
208  >> notchType
209  >> notchSubType
210  >> p.m_showNotch
212  >> p.m_notchLength
213  >> p.m_notchWidth
214  >> p.m_notchAngle
215  >> p.m_notchCount;
216 
217  p.m_typeTool = static_cast<Tool>(typeTool);
218  p.m_angleType = static_cast<PieceNodeAngle>(angleType);
219  p.m_notchType = static_cast<NotchType>(notchType);
220  p.m_notchSubType = static_cast<NotchSubType>(notchSubType);
221 
222  return in;
223 }
224 
226 
227 #endif // VPIECENODE_P_H
bool m_isNotch
m_excluded true if item excluded from main path. Excluded item is not visible and also will not has a...
Definition: vpiecenode_p.h:147
VPieceNodeData(const VPieceNodeData &node)
Definition: vpiecenode_p.h:115
bool m_showSeamlineNotch
Definition: vpiecenode_p.h:159
QString m_afterWidthFormula
Definition: vpiecenode_p.h:152
PieceNodeAngle m_angleType
Definition: vpiecenode_p.h:154
NotchSubType m_notchSubType
Definition: vpiecenode_p.h:157
QString m_beforeWidthFormula
m_isMainPathNode need fin know if allowed for this notch to be double.
Definition: vpiecenode_p.h:151
Tool m_typeTool
id object id.
Definition: vpiecenode_p.h:142
VPieceNodeData(quint32 id, Tool typeTool, bool reverse)
Definition: vpiecenode_p.h:90
bool m_excluded
reverse true if need reverse points list for node.
Definition: vpiecenode_p.h:144
NotchType m_notchType
Definition: vpiecenode_p.h:156
~VPieceNodeData() Q_DECL_EQ_DEFAULT
bool m_reverse
typeTool type of tool
Definition: vpiecenode_p.h:143
NotchType stringToNotchType(const QString &value)
Definition: def.cpp:600
NotchType
Definition: def.h:123
PieceNodeAngle
Definition: def.h:113
NotchSubType
Definition: def.h:137
Tool
Definition: def.h:161
@ NodePoint
const QString currentSeamAllowance
Definition: ifcdef.cpp:442
#define NULL_ID
Definition: ifcdef.h:76
#define qApp
Definition: vapplication.h:67
QDataStream & operator>>(QDataStream &in, VPieceNodeData &p)
Definition: vpiecenode_p.h:193