Seamly2D
Code documentation
union_tool.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file union_tool.h
3  ** @author Douglas S Caskey
4  ** @date Dec 27, 2022
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2022 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25 /************************************************************************
26  **
27  ** @file vtooluniondetails.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 26 12, 2013
30  **
31  ** @brief
32  ** @copyright
33  ** This source code is part of the Valentina project, a pattern making
34  ** program, whose allow create and modeling patterns of clothing.
35  ** Copyright (C) 2013-2015 Valentina project
36  ** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
37  **
38  ** Valentina is free software: you can redistribute it and/or modify
39  ** it under the terms of the GNU General Public License as published by
40  ** the Free Software Foundation, either version 3 of the License, or
41  ** (at your option) any later version.
42  **
43  ** Valentina is distributed in the hope that it will be useful,
44  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
45  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  ** GNU General Public License for more details.
47  **
48  ** You should have received a copy of the GNU General Public License
49  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
50  **
51  *************************************************************************/
52 
53 #ifndef UNION_TOOL_H
54 #define UNION_TOOL_H
55 
56 #include <qcompilerdetection.h>
57 #include <QDomElement>
58 #include <QDomNode>
59 #include <QMetaObject>
60 #include <QObject>
61 #include <QPointF>
62 #include <QString>
63 #include <QVector>
64 #include <QtGlobal>
65 
66 #include "vabstracttool.h"
67 #include "../ifc/ifcdef.h"
68 #include "../ifc/xml/vabstractpattern.h"
69 #include "../vmisc/def.h"
70 #include "../vpatterndb/vpiece.h"
71 
72 class DialogTool;
73 
75 {
77  : piece1_Id(NULL_ID),
81  scene(nullptr),
82  doc(nullptr),
83  data(nullptr),
86  retainPieces(false)
87  {}
88 
89  quint32 piece1_Id;
90  quint32 piece2_Id;
91  quint32 piece1_Index;
92  quint32 piece2_Index;
99 };
100 
101 /**
102  * @brief The UnionTool class tool union details.
103  */
104 class UnionTool : public VAbstractTool
105 {
106  Q_OBJECT
107 public:
110  static UnionTool *Create(const quint32 _id, const UnionToolInitData &initData);
111 
112  static const QString ToolType;
113  static const QString TagUnionPiece;
114  static const QString TagNode;
115  static const QString TagChildren;
116  static const QString TagChild;
117  static const QString AttrIndexD1;
118  static const QString AttrIndexD2;
119  static const QString AttrIdObject;
120  static const QString AttrNodeType;
121  static const QString NodeTypeContour;
122  static const QString NodeTypeModeling;
123 
124  virtual QString getTagName() const Q_DECL_OVERRIDE;
125  virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
126  virtual void incrementReferens() Q_DECL_OVERRIDE;
127  virtual void decrementReferens() Q_DECL_OVERRIDE;
128  virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE;
129 
130 public slots:
131  /**
132  * @brief FullUpdateFromFile update tool data form file.
133  */
134  virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {}
135  virtual void AllowHover(bool) Q_DECL_OVERRIDE {}
136  virtual void AllowSelecting(bool) Q_DECL_OVERRIDE {}
137 
138 protected:
139  virtual void AddToFile() Q_DECL_OVERRIDE;
140  virtual void SetVisualization() Q_DECL_OVERRIDE {}
141 
142 private:
143  Q_DISABLE_COPY(UnionTool)
144 
145  quint32 piece1_Id; /** @brief d1 first detail id. */
146  quint32 piece2_Id; /** @brief d2 second detail id. */
147  quint32 piece1_Index; /** @brief piece1_Index index edge in first detail. */
148  quint32 piece2_Index; /** @brief piece2_Index index edge in second detail. */
149 
150  UnionTool(quint32 id, const UnionToolInitData &initData, QObject *parent = nullptr);
151 
152  void addPiece(QDomElement &domElement, const VPiece &d) const;
153  void AddToModeling(const QDomElement &domElement);
154  QVector<quint32> GetReferenceObjects() const;
155  QVector<quint32> ReferenceObjects(const QDomElement &root, const QString &tag, const QString &attribute) const;
156 };
157 
158 #endif // UNION_TOOL_H
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
The UnionTool class tool union details.
Definition: union_tool.h:105
static const QString AttrIndexD2
Definition: union_tool.h:118
QVector< quint32 > GetReferenceObjects() const
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE
FullUpdateFromFile update tool data form file.
Definition: union_tool.h:134
virtual void incrementReferens() Q_DECL_OVERRIDE
incrementReferens increment referens.
virtual void decrementReferens() Q_DECL_OVERRIDE
decrementReferens decrement referens.
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE
quint32 piece2_Index
piece1_Index index edge in first detail.
Definition: union_tool.h:148
static const QString TagNode
Definition: union_tool.h:114
quint32 piece1_Id
Definition: union_tool.h:145
virtual QString getTagName() const Q_DECL_OVERRIDE
void AddToModeling(const QDomElement &domElement)
AddToModeling add tool to xml tree.
static const QString NodeTypeContour
Definition: union_tool.h:121
virtual void AddToFile() Q_DECL_OVERRIDE
AddToFile add tag with Information about tool into file.
static const QString TagChild
Definition: union_tool.h:116
void addPiece(QDomElement &domElement, const VPiece &d) const
addPiece add piece to xml file.
static const QString TagUnionPiece
Definition: union_tool.h:113
virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE
virtual void AllowHover(bool) Q_DECL_OVERRIDE
Definition: union_tool.h:135
static const QString ToolType
Definition: union_tool.h:112
static const QString TagChildren
Definition: union_tool.h:115
QVector< quint32 > ReferenceObjects(const QDomElement &root, const QString &tag, const QString &attribute) const
virtual void SetVisualization() Q_DECL_OVERRIDE
Definition: union_tool.h:140
static UnionTool * Create(QSharedPointer< DialogTool > dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
Create help create tool from GUI.
static const QString NodeTypeModeling
Definition: union_tool.h:122
static const QString AttrIdObject
Definition: union_tool.h:119
quint32 piece1_Index
d2 second detail id.
Definition: union_tool.h:147
quint32 piece2_Id
d1 first detail id.
Definition: union_tool.h:146
static const QString AttrIndexD1
Definition: union_tool.h:117
static const QString AttrNodeType
Definition: union_tool.h:120
virtual void AllowSelecting(bool) Q_DECL_OVERRIDE
Definition: union_tool.h:136
The VAbstractTool abstract class for all tools.
Definition: vabstracttool.h:80
VAbstractPattern * doc
doc dom document container
The VContainer class container of all variables.
Definition: vcontainer.h:141
VContainer data
data container with data
Definition: vdatatool.h:84
The VMainGraphicsScene class main scene.
Definition: vpiece.h:88
Source
Definition: def.h:106
#define NULL_ID
Definition: ifcdef.h:76
Source typeCreation
Definition: union_tool.h:97
VAbstractPattern * doc
Definition: union_tool.h:94
Document parse
Definition: union_tool.h:96
VContainer * data
Definition: union_tool.h:95
quint32 piece1_Index
Definition: union_tool.h:91
quint32 piece2_Id
Definition: union_tool.h:90
VMainGraphicsScene * scene
Definition: union_tool.h:93
quint32 piece1_Id
Definition: union_tool.h:89
quint32 piece2_Index
Definition: union_tool.h:92
Document