KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ifsg_shape.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 SGSHAPE( nullptr );
42
43 m_node->AssociateWrapper( &m_node );
44}
45
46
48{
49 m_node = new SGSHAPE( 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#ifdef DEBUG
71 if( !pp )
72 {
73 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
74 BadParent );
75 }
76#endif
77
78 m_node = new SGSHAPE( nullptr );
79
80 if( !m_node->SetParent( pp ) )
81 {
82 delete m_node;
83 m_node = nullptr;
84
85 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
87
88 return;
89 }
90
91 m_node->AssociateWrapper( &m_node );
92}
93
94
96{
97 if( m_node )
98 m_node->DisassociateWrapper( &m_node );
99
100 m_node = nullptr;
101
102 if( !aNode )
103 return false;
104
105 if( S3D::SGTYPE_SHAPE != aNode->GetNodeType() )
106 {
107 return false;
108 }
109
110 m_node = aNode;
111 m_node->AssociateWrapper( &m_node );
112
113 return true;
114}
115
116
118{
119 if( m_node )
120 m_node->DisassociateWrapper( &m_node );
121
122 m_node = new SGSHAPE( aParent );
123
124 if( aParent != m_node->GetParent() )
125 {
126 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SGSHAPE" ),
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}
SGNODE * GetRawPtr(void) noexcept
Return the raw internal SGNODE pointer.
Definition ifsg_node.cpp:61
SGNODE * m_node
Definition ifsg_node.h:47
IFSG_SHAPE(bool create)
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.
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
Define a complex 3D shape for a scenegraph object.
Definition sg_shape.h:39
char BadParent[]
Definition ifsg_node.cpp:34
char WrongParent[]
Definition ifsg_node.cpp:35
defines the wrapper for the SGSHAPE class
@ SGTYPE_SHAPE
Definition sg_types.h:41