Seamly2D
Code documentation
vnodesplinepath.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 vnodesplinepath.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 "vnodesplinepath.h"
53 
54 #include <QDomElement>
55 #include <QStaticStringData>
56 #include <QStringData>
57 #include <QStringDataPtr>
58 
59 #include "../ifc/xml/vdomdocument.h"
60 #include "../ifc/ifcdef.h"
61 #include "../vabstracttool.h"
62 #include "../vdatatool.h"
63 #include "vabstractnode.h"
64 
65 const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath");
66 
67 //---------------------------------------------------------------------------------------------------------------------
68 /**
69  * @brief VNodeSplinePath constructor.
70  * @param doc dom document container.
71  * @param data container with variables.
72  * @param id object id in container.
73  * @param idSpline object id in containerSpline.
74  * @param typeCreation way we create this tool.
75  * @param idTool tool id.
76  * @param qoParent QObject parent.
77  */
78 VNodeSplinePath::VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
79  const Source &typeCreation, const QString &blockName, const quint32 &idTool,
80  QObject *qoParent)
81  :VAbstractNode(doc, data, id, idSpline, blockName, idTool, qoParent)
82 {
83  ToolCreation(typeCreation);
84 }
85 
86 //---------------------------------------------------------------------------------------------------------------------
87 /**
88  * @brief Create help create tool.
89  * @param doc dom document container.
90  * @param data container with variables.
91  * @param id object id in container.
92  * @param idSpline object id in containerSpline.
93  * @param parse parser file mode.
94  * @param typeCreation way we create this tool.
95  * @param idTool tool id.
96  */
98  quint32 idSpline, const Document &parse, const Source &typeCreation,
99  const QString &blockName, const quint32 &idTool)
100 {
101  if (parse == Document::FullParse)
102  {
104  VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, blockName, idTool, doc);
105 
107  if (idTool != NULL_ID)
108  {
109  //Some nodes we don't show on scene. Tool that create this nodes must free memory.
111  SCASSERT(tool != nullptr)
112  splPath->setParent(tool);// Adopted by a tool
113  }
114  else
115  {
116  // Help to delete the node before each FullParse
118  }
119  }
120  else
121  {
122  doc->UpdateToolData(id, data);
123  }
124 }
125 
126 //---------------------------------------------------------------------------------------------------------------------
128 {
130 }
131 
132 //---------------------------------------------------------------------------------------------------------------------
133 void VNodeSplinePath::AllowHover(bool enabled)
134 {
135  Q_UNUSED(enabled)
136  // do nothing
137 }
138 
139 //---------------------------------------------------------------------------------------------------------------------
141 {
142  Q_UNUSED(enabled)
143  // do nothing
144 }
145 
146 //---------------------------------------------------------------------------------------------------------------------
147 /**
148  * @brief AddToFile add tag with Information about tool into file.
149  */
151 {
152  QDomElement domElement = doc->createElement(getTagName());
153 
154  doc->SetAttribute(domElement, VDomDocument::AttrId, m_id);
155  doc->SetAttribute(domElement, AttrType, ToolType);
156  doc->SetAttribute(domElement, AttrIdObject, idNode);
157  if (idTool != 0)
158  {
159  doc->SetAttribute(domElement, AttrIdTool, idTool);
160  }
161 
162  AddToModeling(domElement);
163 }
The VAbstractNode class parent class for all detail node.
Definition: vabstractnode.h:71
static const QString AttrIdTool
Definition: vabstractnode.h:77
quint32 idTool
idTool id tool.
Definition: vabstractnode.h:97
quint32 idNode
idNodenode id.
Definition: vabstractnode.h:94
virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE
void AddToModeling(const QDomElement &domElement)
AddToModeling add tag to modeling tag current pattern peace.
static const QString TagSpline
void AddToolOnRemove(VDataTool *tool)
virtual void UpdateToolData(const quint32 &id, VContainer *data)=0
static void AddTool(quint32 id, VDataTool *tool)
AddTool add tool to list tools.
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
VAbstractPattern * doc
doc dom document container
static void AddRecord(const quint32 id, const Tool &toolType, VAbstractPattern *doc)
AddRecord add record about tool in history.
const quint32 m_id
id object id.
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VDataTool class need for getting access to data container of tool.
Definition: vdatatool.h:71
VContainer data
data container with data
Definition: vdatatool.h:84
void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
SetAttribute set attribute in pattern file. Replace "," by ".".
Definition: vdomdocument.h:185
static const QString AttrId
Definition: vdomdocument.h:108
The VNodeSplinePath class spline path detail node.
static const QString ToolType
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
virtual QString getTagName() const Q_DECL_OVERRIDE
VNodeSplinePath(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0, QObject *qoParent=nullptr)
VNodeSplinePath constructor.
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0)
Create help create tool.
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
#define SCASSERT(cond)
Definition: def.h:317
@ NodeSplinePath
Source
Definition: def.h:106
const QString splPath
Definition: ifcdef.cpp:419
const QString AttrType
Definition: ifcdef.cpp:73
const QString AttrIdObject
Definition: ifcdef.cpp:148
#define NULL_ID
Definition: ifcdef.h:76
Document