Seamly2D
Code documentation
vnodeellipticalarc.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
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 20 12, 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 #include "vnodeellipticalarc.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 VNodeEllipticalArc::ToolType = QStringLiteral("modeling");
66 
67 //---------------------------------------------------------------------------------------------------------------------
68 void VNodeEllipticalArc::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc,
69  const Document &parse, const Source &typeCreation, const QString &blockName,
70  const quint32 &idTool)
71 {
72  if (parse == Document::FullParse)
73  {
75  VNodeEllipticalArc *arc = new VNodeEllipticalArc(doc, data, id, idArc, typeCreation, blockName, idTool, doc);
76 
78  if (idTool != NULL_ID)
79  {
80  //Some nodes we don't show on scene. Tool that create this nodes must free memory.
82  SCASSERT(tool != nullptr)
83  arc->setParent(tool);// Adopted by a tool
84  }
85  else
86  {
87  // Help to delete the node before each FullParse
88  doc->AddToolOnRemove(arc);
89  }
90  }
91  else
92  {
93  doc->UpdateToolData(id, data);
94  }
95 }
96 
97 //---------------------------------------------------------------------------------------------------------------------
99 {
101 }
102 
103 //---------------------------------------------------------------------------------------------------------------------
105 {
106  Q_UNUSED(enabled)
107  // do nothing
108 }
109 
110 //---------------------------------------------------------------------------------------------------------------------
112 {
113  Q_UNUSED(enabled)
114  // do nothing
115 }
116 
117 //---------------------------------------------------------------------------------------------------------------------
119 {
120  QDomElement domElement = doc->createElement(getTagName());
121 
122  doc->SetAttribute(domElement, VDomDocument::AttrId, m_id);
123  doc->SetAttribute(domElement, AttrType, ToolType);
124  doc->SetAttribute(domElement, AttrIdObject, idNode);
125  if (idTool != NULL_ID)
126  {
127  doc->SetAttribute(domElement, AttrIdTool, idTool);
128  }
129 
130  AddToModeling(domElement);
131 }
132 
133 //---------------------------------------------------------------------------------------------------------------------
135  const Source &typeCreation, const QString &blockName, const quint32 &idTool,
136  QObject *qoParent)
137  :VAbstractNode(doc, data, id, idArc, blockName, idTool, qoParent)
138 {
139  ToolCreation(typeCreation);
140 }
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.
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 const QString TagElArc
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
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE
virtual QString getTagName() const Q_DECL_OVERRIDE
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=NULL_ID)
VNodeEllipticalArc(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, const QString &blockName=QString(), const quint32 &idTool=0, QObject *qoParent=nullptr)
static const QString ToolType
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE
#define SCASSERT(cond)
Definition: def.h:317
@ NodeElArc
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