KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ifsg_coordindex.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
28
29
30extern char BadParent[];
31extern char WrongParent[];
32
33
35{
36 m_node = nullptr;
37
38 if( !create )
39 return;
40
41 m_node = new SGCOORDINDEX( nullptr );
42
43 m_node->AssociateWrapper( &m_node );
44}
45
46
48{
49 m_node = new SGCOORDINDEX( nullptr );
50
51 if( !m_node->SetParent( aParent ) )
52 {
53 delete m_node;
54 m_node = nullptr;
55
56 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
58
59 return;
60 }
61
62 m_node->AssociateWrapper( &m_node );
63}
64
65
67{
68 SGNODE* pp = aParent.GetRawPtr();
69
70 if( !pp )
71 {
72 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
73 BadParent );
74
75 return;
76 }
77
78 m_node = new SGCOORDINDEX( nullptr );
79
80 if( !m_node->SetParent( pp ) )
81 {
82 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
84
85 delete m_node;
86 m_node = nullptr;
87 return;
88 }
89
90 m_node->AssociateWrapper( &m_node );
91}
92
93
95{
96 if( m_node )
97 m_node->DisassociateWrapper( &m_node );
98
99 m_node = nullptr;
100
101 if( !aNode )
102 return false;
103
104 if( S3D::SGTYPE_COORDINDEX != aNode->GetNodeType() )
105 {
106 return false;
107 }
108
109 m_node = aNode;
110 m_node->AssociateWrapper( &m_node );
111
112 return true;
113}
114
115
117{
118 if( m_node )
119 m_node->DisassociateWrapper( &m_node );
120
121 m_node = new SGCOORDINDEX( aParent );
122
123 if( aParent != m_node->GetParent() )
124 {
125 wxLogTrace( MASK_3D_SG,
126 wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGCOORDINDEX" ),
127 __FILE__, __FUNCTION__, __LINE__,
128 aParent->GetNodeTypeName( aParent->GetNodeType() ) );
129
130 delete m_node;
131 m_node = nullptr;
132 return false;
133 }
134
135 m_node->AssociateWrapper( &m_node );
136
137 return true;
138}
139
140
142{
143 SGNODE* np = aParent.GetRawPtr();
144
145 wxCHECK( np, false );
146
147 return NewNode( np );
148}
bool NewNode(SGNODE *aParent) override
Create a new node to associate with this wrapper.
bool Attach(SGNODE *aNode) override
Associate a given SGNODE* with this wrapper.
IFSG_COORDINDEX(bool create)
SGNODE * GetRawPtr(void) noexcept
Return the raw internal SGNODE pointer.
Definition ifsg_node.cpp:61
SGNODE * m_node
Definition ifsg_node.h:47
An object to maintain a coordinate index list.
The base class of all Scene Graph nodes.
Definition sg_node.h:71
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
Definition sg_node.cpp:100
const char * GetNodeTypeName(S3D::SGTYPES aNodeType) const noexcept
Definition sg_node.cpp:160
char BadParent[]
Definition ifsg_node.cpp:34
char WrongParent[]
Definition ifsg_node.cpp:35
defines the CoordIndex node wrapper
@ SGTYPE_COORDINDEX
Definition sg_types.h:39