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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
25
26/*
27 * Notes on deleting unsupported entities:
28 * 1. PROTO: PROTO ProtoName [parameter list] {body}
29 * the parameter list will always have '[]'. So the items
30 * to delete are: String, List, Body
31 * 2. EXTERNPROTO: EXTERNPROTO extern protoname [] MFstring
32 * delete: string, string, string, list, list
33 * 3. Unsupported node types: NodeName (Optional DEF RefName) {body}
34 * This scheme should also apply to PROTO'd node types.
35 * 4. ROUTE: ROUTE nodename1.event to nodename2.event
36 * Delete a String 3 times
37 * 5. Script: Script { ... }
38 */
39
40#ifndef VRML2_NODE_H
41#define VRML2_NODE_H
42
43#include <list>
44#include <string>
45
46#include "wrlproc.h"
47
48class WRL2BASE;
49class SGNODE;
50
52{
53public:
54 WRL2NODE();
55 virtual ~WRL2NODE();
56
57 // read data via the given file processor and WRL2BASE object
58 virtual bool Read( WRLPROC& proc, WRL2BASE* aTopNode ) = 0;
59
63 WRL2NODES GetNodeType( void ) const;
64
69 WRL2NODE* GetParent( void ) const;
70
79 virtual bool SetParent( WRL2NODE* aParent, bool doUnlink = true );
80
81 virtual std::string GetName( void );
82 virtual bool SetName( const std::string& aName );
83
84 const char* GetNodeTypeName( WRL2NODES aNodeType ) const;
85
94 virtual WRL2NODE* FindNode( const std::string& aNodeName, const WRL2NODE *aCaller );
95
96 virtual bool AddChildNode( WRL2NODE* aNode );
97
98 virtual bool AddRefNode( WRL2NODE* aNode );
99
100 std::string GetError( void );
101
109 virtual SGNODE* TranslateToSG( SGNODE* aParent ) = 0;
110
115 WRL2NODES getNodeTypeID( const std::string& aNodeName );
116
125 virtual void unlinkChildNode( const WRL2NODE* aNode );
126
135 virtual void unlinkRefNode( const WRL2NODE* aNode );
136
145 void addNodeRef( WRL2NODE* aNode );
146
152 void delNodeRef( WRL2NODE* aNode );
153
162 virtual bool isDangling( void ) = 0;
163
164protected:
165 WRL2NODE* m_Parent; // pointer to parent node; may be NULL for top level node
166 WRL2NODES m_Type; // type of VRML node
167 std::string m_Name; // name to use for referencing the node by name
168
169 std::list< WRL2NODE* > m_BackPointers; // nodes which hold a reference to this
170 std::list< WRL2NODE* > m_Children; // nodes owned by this node
171 std::list< WRL2NODE* > m_Refs; // nodes referenced by this node
172 std::string m_error;
173
174 SGNODE* m_sgNode; // the SGNODE representation of the display data
175};
176
177#endif // VRML2_NODE_H
The base class of all Scene Graph nodes.
Definition sg_node.h:71
The top node of a VRML2 model.
Definition vrml2_base.h:56
void addNodeRef(WRL2NODE *aNode)
Add a pointer to a node which references but does not own this node.
virtual bool SetName(const std::string &aName)
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:174
WRL2NODES getNodeTypeID(const std::string &aNodeName)
virtual ~WRL2NODE()
std::list< WRL2NODE * > m_BackPointers
Definition vrml2_node.h:169
WRL2NODE * GetParent(void) const
virtual std::string GetName(void)
virtual bool SetParent(WRL2NODE *aParent, bool doUnlink=true)
Set the parent WRL2NODE of this object.
virtual void unlinkChildNode(const WRL2NODE *aNode)
Remove references to an owned child.
std::string GetError(void)
WRL2NODE * m_Parent
Definition vrml2_node.h:165
std::string m_Name
Definition vrml2_node.h:167
std::list< WRL2NODE * > m_Children
Definition vrml2_node.h:170
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.
WRL2NODES m_Type
Definition vrml2_node.h:166
virtual bool AddRefNode(WRL2NODE *aNode)
void delNodeRef(WRL2NODE *aNode)
Remove a pointer to a node which references but does not own this node.
virtual void unlinkRefNode(const WRL2NODE *aNode)
Remove pointers to a referenced node.
const char * GetNodeTypeName(WRL2NODES aNodeType) const
WRL2NODES GetNodeType(void) const
std::list< WRL2NODE * > m_Refs
Definition vrml2_node.h:171
virtual bool AddChildNode(WRL2NODE *aNode)
virtual bool Read(WRLPROC &proc, WRL2BASE *aTopNode)=0
std::string m_error
Definition vrml2_node.h:172
defines the basic input class for VRML
WRL2NODES
Definition wrltypes.h:121