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