KiCad PCB EDA Suite
Loading...
Searching...
No Matches
x3d_base.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2016 Cirilo Bernardo <[email protected]>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20
25
26
27#ifndef X3D_BASE_H
28#define X3D_BASE_H
29
30#include <list>
31#include <map>
32#include <string>
33#include <vector>
34#include <wx/string.h>
35
36class X3DNODE;
37class SGNODE;
38class wxXmlNode;
39
40typedef std::vector< wxXmlNode* > NODE_LIST;
41
42
43// a class to hold the dictionary of node DEFs
45{
46public:
47 bool AddName( const wxString& aName, X3DNODE* aNode );
48 bool DelName( const wxString& aName, X3DNODE* aNode );
49 X3DNODE* FindName( const wxString& aName );
50
51private:
52 std::map< wxString, X3DNODE* > reg;
53};
54
66
71{
72public:
73
80 virtual void unlinkChildNode( const X3DNODE* aNode );
81
88 virtual void unlinkRefNode( const X3DNODE* aNode );
89
98 void addNodeRef( X3DNODE* aNode );
99
105 void delNodeRef( X3DNODE* aNode );
106
107 X3DNODE();
108 virtual ~X3DNODE();
109
110 // read data and return TRUE on success
111 virtual bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) = 0;
112
116 X3DNODES GetNodeType( void ) const;
117
122 X3DNODE* GetParent( void ) const;
123
127 wxString GetName( void ) const;
128
137 virtual bool SetParent( X3DNODE* aParent, bool doUnlink = true ) = 0;
138
139 virtual bool AddChildNode( X3DNODE* aNode ) = 0;
140
141 virtual bool AddRefNode( X3DNODE* aNode ) = 0;
142
143 std::string GetError( void );
144
152 virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
153
154protected:
155 X3DNODE* m_Parent; // pointer to parent node; may be NULL for top level node
156 X3DNODES m_Type; // type of node
157 X3D_DICT* m_Dict; // reference to dictionary
158
159 std::list< X3DNODE* > m_BackPointers; // nodes which hold a reference to this
160 std::list< X3DNODE* > m_Children; // nodes owned by this node
161 std::list< X3DNODE* > m_Refs; // nodes referenced by this node
162 std::string m_error;
163
164 wxString m_Name; // name to use for referencing the node by name
165 SGNODE* m_sgNode; // the SGNODE representation of the display data
166};
167
168#endif // X3D_BASE_H
The base class of all Scene Graph nodes.
Definition sg_node.h:71
The base class of all X3D nodes.
Definition x3d_base.h:71
X3DNODES m_Type
Definition x3d_base.h:156
void addNodeRef(X3DNODE *aNode)
Add a pointer to a node which references, but does not own, this node.
Definition x3d_base.cpp:138
std::list< X3DNODE * > m_Children
Definition x3d_base.h:160
SGNODE * m_sgNode
Definition x3d_base.h:165
std::list< X3DNODE * > m_BackPointers
Definition x3d_base.h:159
X3DNODE * m_Parent
Definition x3d_base.h:155
virtual ~X3DNODE()
Definition x3d_base.cpp:89
wxString GetName(void) const
Return the name of this object.
Definition x3d_base.cpp:192
virtual bool AddChildNode(X3DNODE *aNode)=0
std::list< X3DNODE * > m_Refs
Definition x3d_base.h:161
X3DNODES GetNodeType(void) const
Return the type of this node instance.
Definition x3d_base.cpp:180
X3DNODE * GetParent(void) const
Return a pointer to the parent node of this object or NULL if the object has no parent (ie.
Definition x3d_base.cpp:186
wxString m_Name
Definition x3d_base.h:164
virtual SGNODE * TranslateToSG(SGNODE *aParent)=0
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
virtual bool Read(wxXmlNode *aNode, X3DNODE *aTopNode, X3D_DICT &aDict)=0
virtual void unlinkRefNode(const X3DNODE *aNode)
Remove pointers to a referenced node; it is invoked by the referenced node upon destruction to ensure...
Definition x3d_base.cpp:118
std::string GetError(void)
Definition x3d_base.cpp:198
virtual bool SetParent(X3DNODE *aParent, bool doUnlink=true)=0
Set the parent X3DNODE of this object.
virtual bool AddRefNode(X3DNODE *aNode)=0
void delNodeRef(X3DNODE *aNode)
Remove a pointer to a node which references, but does not own, this node.
Definition x3d_base.cpp:161
virtual void unlinkChildNode(const X3DNODE *aNode)
Remove references to an owned child; it is invoked by the child upon destruction to ensure that the p...
Definition x3d_base.cpp:98
std::string m_error
Definition x3d_base.h:162
X3D_DICT * m_Dict
Definition x3d_base.h:157
bool DelName(const wxString &aName, X3DNODE *aNode)
Definition x3d_base.cpp:47
std::map< wxString, X3DNODE * > reg
Definition x3d_base.h:52
bool AddName(const wxString &aName, X3DNODE *aNode)
Definition x3d_base.cpp:31
X3DNODE * FindName(const wxString &aName)
Definition x3d_base.cpp:64
X3DNODES
Definition x3d_base.h:56
@ X3D_END
Definition x3d_base.h:64
@ X3D_TRANSFORM
Definition x3d_base.h:57
@ X3D_SWITCH
Definition x3d_base.h:58
@ X3D_APPEARANCE
Definition x3d_base.h:60
@ X3D_SHAPE
Definition x3d_base.h:59
@ X3D_COORDINATE
Definition x3d_base.h:62
@ X3D_INVALID
Definition x3d_base.h:63
@ X3D_INDEXED_FACE_SET
Definition x3d_base.h:61
std::vector< wxXmlNode * > NODE_LIST
Definition x3d_base.h:40