KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ifsg_node.cpp
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) 2015 Cirilo Bernardo <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
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
21
22#include <iostream>
23#include <sstream>
24#include <wx/log.h>
25
27#include "3d_cache/sg/sg_node.h"
29
30
31// collection of common error strings used by the wrappers
32char BadObject[] = " * [BUG] operating on an invalid wrapper (object may have been deleted)";
33char BadOperand[] = " * [BUG] parameter aNode is an invalid wrapper; its data may have been deleted";
34char BadParent[] = " * [BUG] invalid parent node (data may have been deleted)";
35char WrongParent[] = " * [BUG] parent node type is incompatible";
36
37
39{
40 m_node = nullptr;
41}
42
43
45{
46 if( m_node )
47 m_node->DisassociateWrapper( &m_node );
48}
49
50
52{
53 if( m_node )
54 m_node->DisassociateWrapper( &m_node );
55
56 delete m_node;
57 m_node = nullptr;
58}
59
60
62{
63 return m_node;
64}
65
66
68{
69 wxCHECK( m_node, S3D::SGTYPE_END );
70
71 return m_node->GetNodeType();
72}
73
74
76{
77 wxCHECK( m_node, nullptr );
78
79 return m_node->GetParent();
80}
81
82
84{
85 wxCHECK( m_node, false );
86
87 return m_node->SetParent( aParent );
88}
89
90
91const char* IFSG_NODE::GetName( void )
92{
93 wxCHECK( m_node, nullptr );
94
95 return m_node->GetName();
96}
97
98
99bool IFSG_NODE::SetName( const char* aName )
100{
101 wxCHECK( m_node, false );
102
103 m_node->SetName( aName );
104 return true;
105}
106
107
108const char* IFSG_NODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
109{
110 wxCHECK( m_node, nullptr );
111
112 return m_node->GetNodeTypeName( aNodeType );
113}
114
115
116SGNODE* IFSG_NODE::FindNode( const char* aNodeName )
117{
118 wxCHECK( m_node, nullptr );
119
120 return m_node->FindNode( aNodeName, nullptr );
121}
122
123
125{
126 wxCHECK( m_node, false );
127
128 return m_node->AddRefNode( aNode );
129}
130
131
133{
134 wxCHECK( m_node, false );
135
136 SGNODE* np = aNode.GetRawPtr();
137
138 wxCHECK( np, false );
139
140 return m_node->AddRefNode( np );
141}
142
143
145{
146 wxCHECK( m_node, false );
147
148 return m_node->AddChildNode( aNode );
149}
150
151
153{
154 wxCHECK( m_node, false );
155
156 SGNODE* np = aNode.GetRawPtr();
157
158 wxCHECK( np, false );
159
160 return m_node->AddChildNode( np );
161}
const char * GetNodeTypeName(S3D::SGTYPES aNodeType) const
Return the text representation of the node type or NULL if the node somehow has an invalid type.
SGNODE * GetParent(void) const
Return a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.
Definition ifsg_node.cpp:75
bool SetParent(SGNODE *aParent)
Set the parent SGNODE of this object.
Definition ifsg_node.cpp:83
SGNODE * GetRawPtr(void) noexcept
Return the raw internal SGNODE pointer.
Definition ifsg_node.cpp:61
SGNODE * FindNode(const char *aNodeName)
Search the tree of linked nodes and returns a reference to the first node found with the given name.
const char * GetName(void)
Return a pointer to the node name (NULL if no name assigned).
Definition ifsg_node.cpp:91
void Destroy(void)
Delete the object held by this wrapper.
Definition ifsg_node.cpp:51
SGNODE * m_node
Definition ifsg_node.h:47
bool AddChildNode(SGNODE *aNode)
Add a node as a child owned by this node.
bool AddRefNode(SGNODE *aNode)
Add a reference to an existing node which is not owned by (not a child of) this node.
bool SetName(const char *aName)
Set the node's name.
Definition ifsg_node.cpp:99
virtual ~IFSG_NODE()
Definition ifsg_node.cpp:44
S3D::SGTYPES GetNodeType(void) const
Return the type of this node instance.
Definition ifsg_node.cpp:67
The base class of all Scene Graph nodes.
Definition sg_node.h:71
defines the API calls for the manipulation of SG* classes
char BadParent[]
Definition ifsg_node.cpp:34
char WrongParent[]
Definition ifsg_node.cpp:35
char BadObject[]
Definition ifsg_node.cpp:32
char BadOperand[]
Definition ifsg_node.cpp:33
defines the wrapper of the base class SG_NODE
SGTYPES
Definition sg_types.h:32
@ SGTYPE_END
Definition sg_types.h:42