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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
31#ifndef X3D_BASE_H
32#define X3D_BASE_H
33
34#include <list>
35#include <map>
36#include <string>
37#include <vector>
38#include <wx/string.h>
39
40class X3DNODE;
41class SGNODE;
42class wxXmlNode;
43
44typedef std::vector< wxXmlNode* > NODE_LIST;
45
46
47// a class to hold the dictionary of node DEFs
49{
50public:
51 bool AddName( const wxString& aName, X3DNODE* aNode );
52 bool DelName( const wxString& aName, X3DNODE* aNode );
53 X3DNODE* FindName( const wxString& aName );
54
55private:
56 std::map< wxString, X3DNODE* > reg;
57};
58
60{
61 X3D_TRANSFORM = 0, // Transform or Group node
69};
70
75{
76public:
77
84 virtual void unlinkChildNode( const X3DNODE* aNode );
85
92 virtual void unlinkRefNode( const X3DNODE* aNode );
93
102 void addNodeRef( X3DNODE* aNode );
103
109 void delNodeRef( X3DNODE* aNode );
110
111 X3DNODE();
112 virtual ~X3DNODE();
113
114 // read data and return TRUE on success
115 virtual bool Read( wxXmlNode* aNode, X3DNODE* aTopNode, X3D_DICT& aDict ) = 0;
116
120 X3DNODES GetNodeType( void ) const;
121
126 X3DNODE* GetParent( void ) const;
127
131 wxString GetName( void ) const;
132
141 virtual bool SetParent( X3DNODE* aParent, bool doUnlink = true ) = 0;
142
143 virtual bool AddChildNode( X3DNODE* aNode ) = 0;
144
145 virtual bool AddRefNode( X3DNODE* aNode ) = 0;
146
147 std::string GetError( void );
148
156 virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
157
158protected:
159 X3DNODE* m_Parent; // pointer to parent node; may be NULL for top level node
160 X3DNODES m_Type; // type of node
161 X3D_DICT* m_Dict; // reference to dictionary
162
163 std::list< X3DNODE* > m_BackPointers; // nodes which hold a reference to this
164 std::list< X3DNODE* > m_Children; // nodes owned by this node
165 std::list< X3DNODE* > m_Refs; // nodes referenced by this node
166 std::string m_error;
167
168 wxString m_Name; // name to use for referencing the node by name
169 SGNODE* m_sgNode; // the SGNODE representation of the display data
170};
171
172#endif // X3D_BASE_H
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
The base class of all X3D nodes.
Definition: x3d_base.h:75
X3DNODES m_Type
Definition: x3d_base.h:160
void addNodeRef(X3DNODE *aNode)
Add a pointer to a node which references, but does not own, this node.
Definition: x3d_base.cpp:142
std::list< X3DNODE * > m_Children
Definition: x3d_base.h:164
SGNODE * m_sgNode
Definition: x3d_base.h:169
std::list< X3DNODE * > m_BackPointers
Definition: x3d_base.h:163
X3DNODE * m_Parent
Definition: x3d_base.h:159
virtual ~X3DNODE()
Definition: x3d_base.cpp:93
wxString GetName(void) const
Return the name of this object.
Definition: x3d_base.cpp:196
X3DNODE()
Definition: x3d_base.cpp:82
virtual bool AddChildNode(X3DNODE *aNode)=0
std::list< X3DNODE * > m_Refs
Definition: x3d_base.h:165
X3DNODES GetNodeType(void) const
Return the type of this node instance.
Definition: x3d_base.cpp:184
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:190
wxString m_Name
Definition: x3d_base.h:168
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:122
std::string GetError(void)
Definition: x3d_base.cpp:202
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:165
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:102
std::string m_error
Definition: x3d_base.h:166
X3D_DICT * m_Dict
Definition: x3d_base.h:161
bool DelName(const wxString &aName, X3DNODE *aNode)
Definition: x3d_base.cpp:51
std::map< wxString, X3DNODE * > reg
Definition: x3d_base.h:56
bool AddName(const wxString &aName, X3DNODE *aNode)
Definition: x3d_base.cpp:35
X3DNODE * FindName(const wxString &aName)
Definition: x3d_base.cpp:68
X3DNODES
Definition: x3d_base.h:60
@ X3D_END
Definition: x3d_base.h:68
@ X3D_TRANSFORM
Definition: x3d_base.h:61
@ X3D_SWITCH
Definition: x3d_base.h:62
@ X3D_APPEARANCE
Definition: x3d_base.h:64
@ X3D_SHAPE
Definition: x3d_base.h:63
@ X3D_COORDINATE
Definition: x3d_base.h:66
@ X3D_INVALID
Definition: x3d_base.h:67
@ X3D_INDEXED_FACE_SET
Definition: x3d_base.h:65
std::vector< wxXmlNode * > NODE_LIST
Definition: x3d_base.h:44