KiCad PCB EDA Suite
Loading...
Searching...
No Matches
vrml2_node.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 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
4 *
5 * Copyright (C) 2015-2016 Cirilo Bernardo <[email protected]>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
30/*
31 * Notes on deleting unsupported entities:
32 * 1. PROTO: PROTO ProtoName [parameter list] {body}
33 * the parameter list will always have '[]'. So the items
34 * to delete are: String, List, Body
35 * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
36 * delete: string, string, string, list, list
37 * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
38 * This scheme should also apply to PROTO'd node types.
39 * 4. ROUTE: ROUTE nodename1.event to nodename2.event
40 * Delete a String 3 times
41 * 5. Script: Script { ... }
42 */
43
44#ifndef VRML2_NODE_H
45#define VRML2_NODE_H
46
47#include <list>
48#include <string>
49
50#include "wrlproc.h"
51
52class WRL2BASE;
53class SGNODE;
54
56{
57public:
58 WRL2NODE();
59 virtual ~WRL2NODE();
60
61 // read data via the given file processor and WRL2BASE object
62 virtual bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) = 0;
63
67 WRL2NODES GetNodeType( void ) const;
68
73 WRL2NODE* GetParent( void ) const;
74
83 virtual bool SetParent( WRL2NODE* aParent, bool doUnlink = true );
84
85 virtual std::string GetName( void );
86 virtual bool SetName( const std::string& aName );
87
88 const char* GetNodeTypeName( WRL2NODES aNodeType ) const;
89
98 virtual WRL2NODE* FindNode( const std::string& aNodeName, const WRL2NODE *aCaller );
99
100 virtual bool AddChildNode( WRL2NODE* aNode );
101
102 virtual bool AddRefNode( WRL2NODE* aNode );
103
104 std::string GetError( void );
105
113 virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
114
119 WRL2NODES getNodeTypeID( const std::string& aNodeName );
120
129 virtual void unlinkChildNode( const WRL2NODE* aNode );
130
139 virtual void unlinkRefNode( const WRL2NODE* aNode );
140
149 void addNodeRef( WRL2NODE* aNode );
150
156 void delNodeRef( WRL2NODE* aNode );
157
166 virtual bool isDangling( void ) = 0;
167
168protected:
169 WRL2NODE* m_Parent; // pointer to parent node; may be NULL for top level node
170 WRL2NODES m_Type; // type of VRML node
171 std::string m_Name; // name to use for referencing the node by name
172
173 std::list< WRL2NODE* > m_BackPointers; // nodes which hold a reference to this
174 std::list< WRL2NODE* > m_Children; // nodes owned by this node
175 std::list< WRL2NODE* > m_Refs; // nodes referenced by this node
176 std::string m_error;
177
178 SGNODE* m_sgNode; // the SGNODE representation of the display data
179};
180
181#endif // VRML2_NODE_H
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
The top node of a VRML2 model.
Definition: vrml2_base.h:60
void addNodeRef(WRL2NODE *aNode)
Add a pointer to a node which references but does not own this node.
Definition: vrml2_node.cpp:171
virtual bool SetName(const std::string &aName)
Definition: vrml2_node.cpp:222
virtual bool isDangling(void)=0
Determine whether an object should be moved to a different parent during the VRML to SG* translation.
SGNODE * m_sgNode
Definition: vrml2_node.h:178
WRL2NODES getNodeTypeID(const std::string &aNodeName)
Definition: vrml2_node.cpp:288
virtual ~WRL2NODE()
Definition: vrml2_node.cpp:133
std::list< WRL2NODE * > m_BackPointers
Definition: vrml2_node.h:173
WRL2NODE * GetParent(void) const
Definition: vrml2_node.cpp:210
virtual std::string GetName(void)
Definition: vrml2_node.cpp:216
virtual bool SetParent(WRL2NODE *aParent, bool doUnlink=true)
Set the parent WRL2NODE of this object.
Definition: vrml2_node.cpp:339
virtual void unlinkChildNode(const WRL2NODE *aNode)
Remove references to an owned child.
Definition: vrml2_node.cpp:407
std::string GetError(void)
Definition: vrml2_node.cpp:299
WRL2NODE * m_Parent
Definition: vrml2_node.h:169
std::string m_Name
Definition: vrml2_node.h:171
std::list< WRL2NODE * > m_Children
Definition: vrml2_node.h:174
virtual SGNODE * TranslateToSG(SGNODE *aParent)=0
Produce a representation of the data using the intermediate scenegraph structures of the kicad_3dsg l...
virtual WRL2NODE * FindNode(const std::string &aNodeName, const WRL2NODE *aCaller)
Search the tree of linked nodes and returns a reference to the first node found with the given name.
Definition: vrml2_node.cpp:305
WRL2NODES m_Type
Definition: vrml2_node.h:170
virtual bool AddRefNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:383
void delNodeRef(WRL2NODE *aNode)
Remove a pointer to a node which references but does not own this node.
Definition: vrml2_node.cpp:187
virtual void unlinkRefNode(const WRL2NODE *aNode)
Remove pointers to a referenced node.
Definition: vrml2_node.cpp:425
const char * GetNodeTypeName(WRL2NODES aNodeType) const
Definition: vrml2_node.cpp:273
WRL2NODES GetNodeType(void) const
Definition: vrml2_node.cpp:204
std::list< WRL2NODE * > m_Refs
Definition: vrml2_node.h:175
virtual bool AddChildNode(WRL2NODE *aNode)
Definition: vrml2_node.cpp:356
virtual bool Read(WRLPROC &proc, WRL2BASE *aTopNode)=0
std::string m_error
Definition: vrml2_node.h:176
defines the basic input class for VRML
WRL2NODES
Definition: wrltypes.h:125