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