Seamly2D
Code documentation
vnodespline.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 vnodespline.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 "vnodespline.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 VNodeSpline::ToolType = QStringLiteral("modelingSpline");
66 
67 //---------------------------------------------------------------------------------------------------------------------
68 /**
69  * @brief VNodeSpline 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 id node.
76  * @param qoParent QObject parent.
77  */
78 VNodeSpline::VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline,
79  const Source &typeCreation, const QString &blockName, const quint32 &idTool, QObject *qoParent)
80  :VAbstractNode(doc, data, id, idSpline, blockName, idTool, qoParent)
81 {
82  ToolCreation(typeCreation);
83 }
84 
85 //---------------------------------------------------------------------------------------------------------------------
86 /**
87  * @brief Create help create tool.
88  * @param doc dom document container.
89  * @param data container with variables.
90  * @param id object id in container.
91  * @param idSpline object id in containerSpline.
92  * @param parse parser file mode.
93  * @param typeCreation way we create this tool.
94  * @param idTool id node.
95  * @return pointer to node.
96  */
98  quint32 idSpline, const Document &parse,
99  const Source &typeCreation, const QString &blockName, const quint32 &idTool)
100 {
101  VNodeSpline *spl = nullptr;
102  if (parse == Document::FullParse)
103  {
105  spl = new VNodeSpline(doc, data, id, idSpline, typeCreation, blockName, idTool, doc);
106 
107  VAbstractPattern::AddTool(id, spl);
108  if (idTool != NULL_ID)
109  {
110  //Some nodes we don't show on scene. Tool that create this nodes must free memory.
112  SCASSERT(tool != nullptr)
113  spl->setParent(tool);// Adopted by a tool
114  }
115  else
116  {
117  // Help to delete the node before each FullParse
118  doc->AddToolOnRemove(spl);
119  }
120  }
121  else
122  {
123  doc->UpdateToolData(id, data);
124  }
125  return spl;
126 }
127 
128 //---------------------------------------------------------------------------------------------------------------------
129 QString VNodeSpline::getTagName() const
130 {
132 }
133 
134 //---------------------------------------------------------------------------------------------------------------------
135 void VNodeSpline::AllowHover(bool enabled)
136 {
137  Q_UNUSED(enabled)
138  // do nothing
139 }
140 
141 //---------------------------------------------------------------------------------------------------------------------
142 void VNodeSpline::AllowSelecting(bool enabled)
143 {
144  Q_UNUSED(enabled)
145  // do nothing
146 }
147 
148 //---------------------------------------------------------------------------------------------------------------------
149 /**
150  * @brief AddToFile add tag with Information about tool into file.
151  */
153 {
154  QDomElement domElement = doc->createElement(getTagName());
155 
156  doc->SetAttribute(domElement, VDomDocument::AttrId, m_id);
157  doc->SetAttribute(domElement, AttrType, ToolType);
158  doc->SetAttribute(domElement, AttrIdObject, idNode);
159  if (idTool != NULL_ID)
160  {
161  doc->SetAttribute(domElement, AttrIdTool, idTool);
162  }
163 
164  AddToModeling(domElement);
165 }
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 VNodeSpline class spline detail node.
Definition: vnodespline.h:70
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
virtual QString getTagName() const Q_DECL_OVERRIDE
static VNodeSpline * 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.
Definition: vnodespline.cpp:97
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
static const QString ToolType
Definition: vnodespline.h:78
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
VNodeSpline(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0, QObject *qoParent=nullptr)
VNodeSpline constructor.
Definition: vnodespline.cpp:78
#define SCASSERT(cond)
Definition: def.h:317
@ NodeSpline
Source
Definition: def.h:106
const QString AttrType
Definition: ifcdef.cpp:73
const QString AttrIdObject
Definition: ifcdef.cpp:148
#define NULL_ID
Definition: ifcdef.h:76
Document