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