1 /************************************************************************
2  **
3  **  @file   vabstractnode.h
4  **  @author Roman Telezhynskyi <dismine(at)gmail.com>
5  **  @date   November 15, 2013
6  **
7  **  @brief
8  **  @copyright
9  **  This source code is part of the Valentina project, a pattern making
10  **  program, whose allow create and modeling patterns of clothing.
11  **  Copyright (C) 2013-2015 Valentina project
12  **  <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13  **
14  **  Valentina is free software: you can redistribute it and/or modify
15  **  it under the terms of the GNU General Public License as published by
16  **  the Free Software Foundation, either version 3 of the License, or
17  **  (at your option) any later version.
18  **
19  **  Valentina is distributed in the hope that it will be useful,
20  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  **  GNU General Public License for more details.
23  **
24  **  You should have received a copy of the GNU General Public License
25  **  along with Valentina.  If not, see <http://www.gnu.org/licenses/>.
26  **
27  *************************************************************************/
28 
29 #ifndef VABSTRACTNODE_H
30 #define VABSTRACTNODE_H
31 
32 #include <qcompilerdetection.h>
33 #include <QColor>
34 #include <QDomElement>
35 #include <QMetaObject>
36 #include <QObject>
37 #include <QString>
38 #include <QtGlobal>
39 
40 #include "../vabstracttool.h"
41 
42 enum class ParentType : bool {Scene, Item};
43 
44 struct VAbstractNodeInitData : VAbstractToolInitData
45 {
VAbstractNodeInitDataVAbstractNodeInitData46     VAbstractNodeInitData()
47         : VAbstractToolInitData(),
48           idObject(NULL_ID),
49           drawName(),
50           idTool(NULL_ID)
51     {}
52 
53     quint32 idObject;
54     QString drawName;
55     quint32 idTool;
56 };
57 
58 /**
59  * @brief The VAbstractNode class parent class for all detail node.
60  */
61 class VAbstractNode : public VAbstractTool
62 {
63     Q_OBJECT
64 public:
65     VAbstractNode(VAbstractPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode,
66                   const QString &drawName = QString(), const quint32 &idTool = 0, QObject *parent = nullptr);
67     virtual      ~VAbstractNode() Q_DECL_EQ_DEFAULT;
68     static const QString AttrIdTool;
69     virtual void ShowVisualization(bool show) override;
70     virtual void incrementReferens() override;
71     virtual void decrementReferens() override;
72 
73     ParentType GetParentType() const;
74     void       SetParentType(const ParentType &value);
75 
76     quint32 GetIdTool() const;
77 
78     virtual void GroupVisibility(quint32 object, bool visible) override;
79 
80     bool IsExluded() const;
81     void SetExluded(bool exluded);
82 
83 protected:
84     ParentType parentType;
85 
86     /** @brief idNodenode id. */
87     quint32       idNode;
88 
89     /** @brief idTool id tool. */
90     quint32       idTool;
91 
92     QString       m_drawName;
93 
94     bool          m_exluded;
95 
96     void         AddToModeling(const QDomElement &domElement);
97     virtual void ToolCreation(const Source &typeCreation) override;
SetVisualization()98     virtual void SetVisualization() override {}
99 
100     virtual void ShowNode()=0;
101     virtual void HideNode()=0;
102 private:
103     Q_DISABLE_COPY(VAbstractNode)
104 };
105 
106 //---------------------------------------------------------------------------------------------------------------------
GetIdTool()107 inline quint32 VAbstractNode::GetIdTool() const
108 {
109     return idTool;
110 }
111 
112 #endif // VABSTRACTNODE_H
113