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
26
#include "
plugins/3dapi/ifsg_shape.h
"
27
#include "
3d_cache/sg/sg_shape.h
"
28
29
30
extern
char
BadParent
[];
31
extern
char
WrongParent
[];
32
33
34
IFSG_SHAPE::IFSG_SHAPE
(
bool
create )
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
47
IFSG_SHAPE::IFSG_SHAPE
(
SGNODE
* aParent )
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__,
57
WrongParent
);
58
59
return
;
60
}
61
62
m_node
->AssociateWrapper( &
m_node
);
63
}
64
65
66
IFSG_SHAPE::IFSG_SHAPE
(
IFSG_NODE
& aParent )
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__,
86
WrongParent
);
87
88
return
;
89
}
90
91
m_node
->AssociateWrapper( &
m_node
);
92
}
93
94
95
bool
IFSG_SHAPE::Attach
(
SGNODE
* aNode )
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
117
bool
IFSG_SHAPE::NewNode
(
SGNODE
* aParent )
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
141
bool
IFSG_SHAPE::NewNode
(
IFSG_NODE
& aParent )
142
{
143
SGNODE
* np = aParent.
GetRawPtr
();
144
145
wxCHECK( np,
false
);
146
147
return
NewNode
( np );
148
}
IFSG_NODE::GetRawPtr
SGNODE * GetRawPtr(void) noexcept
Return the raw internal SGNODE pointer.
Definition
ifsg_node.cpp:61
IFSG_NODE::IFSG_NODE
IFSG_NODE()
Definition
ifsg_node.cpp:38
IFSG_NODE::m_node
SGNODE * m_node
Definition
ifsg_node.h:47
IFSG_SHAPE::IFSG_SHAPE
IFSG_SHAPE(bool create)
Definition
ifsg_shape.cpp:34
IFSG_SHAPE::NewNode
bool NewNode(SGNODE *aParent) override
Create a new node to associate with this wrapper.
Definition
ifsg_shape.cpp:117
IFSG_SHAPE::Attach
bool Attach(SGNODE *aNode) override
Associate a given SGNODE* with this wrapper.
Definition
ifsg_shape.cpp:95
SGNODE
The base class of all Scene Graph nodes.
Definition
sg_node.h:71
SGNODE::GetNodeType
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
Definition
sg_node.cpp:100
SGNODE::GetNodeTypeName
const char * GetNodeTypeName(S3D::SGTYPES aNodeType) const noexcept
Definition
sg_node.cpp:160
SGSHAPE
Define a complex 3D shape for a scenegraph object.
Definition
sg_shape.h:39
BadParent
char BadParent[]
Definition
ifsg_node.cpp:34
WrongParent
char WrongParent[]
Definition
ifsg_node.cpp:35
ifsg_shape.h
defines the wrapper for the SGSHAPE class
S3D::SGTYPE_SHAPE
@ SGTYPE_SHAPE
Definition
sg_types.h:41
sg_shape.h
src
3d-viewer
3d_cache
sg
ifsg_shape.cpp
Generated on Fri Jun 26 2026 00:05:31 for KiCad PCB EDA Suite by
1.13.2