KiCad PCB EDA Suite
IFSG_TRANSFORM Class Reference

IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH. More...

#include <ifsg_transform.h>

Inheritance diagram for IFSG_TRANSFORM:
IFSG_NODE

Public Member Functions

 IFSG_TRANSFORM (bool create)
 
 IFSG_TRANSFORM (SGNODE *aParent)
 
bool Attach (SGNODE *aNode) override
 Function Attach associates a given SGNODE* with this wrapper. More...
 
bool NewNode (SGNODE *aParent) override
 Function NewNode creates a new node to associate with this wrapper. More...
 
bool NewNode (IFSG_NODE &aParent) override
 
bool SetScaleOrientation (const SGVECTOR &aScaleAxis, double aAngle)
 
bool SetRotation (const SGVECTOR &aRotationAxis, double aAngle)
 
bool SetScale (const SGPOINT &aScale) noexcept
 
bool SetScale (double aScale)
 
bool SetCenter (const SGPOINT &aCenter) noexcept
 
bool SetTranslation (const SGPOINT &aTranslation) noexcept
 
void Destroy (void)
 Function Destroy deletes the object held by this wrapper. More...
 
SGNODEGetRawPtr (void) noexcept
 Function GetRawPtr() returns the raw internal SGNODE pointer. More...
 
S3D::SGTYPES GetNodeType (void) const
 Function GetNodeType returns the type of this node instance. More...
 
SGNODEGetParent (void) const
 Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie. More...
 
bool SetParent (SGNODE *aParent)
 Function SetParent sets the parent SGNODE of this object. More...
 
const char * GetName (void)
 Function GetName returns a pointer to the node name (NULL if no name assigned) More...
 
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. More...
 
const char * GetNodeTypeName (S3D::SGTYPES aNodeType) const
 Function GetNodeTypeName returns the text representation of the node type or NULL if the node somehow has an invalid type. More...
 
SGNODEFindNode (const char *aNodeName)
 Function FindNode searches the tree of linked nodes and returns a reference to the first node found with the given name. More...
 
bool AddRefNode (SGNODE *aNode)
 Function AddRefNode adds a reference to an existing node which is not owned by (not a child of) this node. More...
 
bool AddRefNode (IFSG_NODE &aNode)
 
bool AddChildNode (SGNODE *aNode)
 Function AddChildNode adds a node as a child owned by this node. More...
 
bool AddChildNode (IFSG_NODE &aNode)
 

Protected Attributes

SGNODEm_node
 

Detailed Description

IFSG_TRANSFORM is the wrapper for the VRML compatible TRANSFORM block class SCENEGRAPH.

Definition at line 40 of file ifsg_transform.h.

Constructor & Destructor Documentation

◆ IFSG_TRANSFORM() [1/2]

IFSG_TRANSFORM::IFSG_TRANSFORM ( bool  create)

Definition at line 37 of file ifsg_transform.cpp.

38{
39 m_node = nullptr;
40
41 if( !create )
42 return;
43
44 m_node = new SCENEGRAPH( nullptr );
45
47}
SGNODE * m_node
Definition: ifsg_node.h:57
Define the basic data set required to represent a 3D model.
Definition: scenegraph.h:45
void AssociateWrapper(SGNODE **aWrapperRef) noexcept
Associate this object with a handle to itself.
Definition: sg_node.cpp:207

References SGNODE::AssociateWrapper(), and IFSG_NODE::m_node.

◆ IFSG_TRANSFORM() [2/2]

IFSG_TRANSFORM::IFSG_TRANSFORM ( SGNODE aParent)

Definition at line 50 of file ifsg_transform.cpp.

51{
52 m_node = new SCENEGRAPH( nullptr );
53
54 if( !m_node->SetParent( aParent ) )
55 {
56 delete m_node;
57 m_node = nullptr;
58
59 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d %s" ), __FILE__, __FUNCTION__, __LINE__,
61
62 return;
63 }
64
66}
virtual bool SetParent(SGNODE *aParent, bool notify=true)=0
Set the parent SGNODE of this object.
char WrongParent[]
Definition: ifsg_node.cpp:39

References SGNODE::AssociateWrapper(), IFSG_NODE::m_node, SGNODE::SetParent(), and WrongParent.

Member Function Documentation

◆ AddChildNode() [1/2]

bool IFSG_NODE::AddChildNode ( IFSG_NODE aNode)
inherited

Definition at line 156 of file ifsg_node.cpp.

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}
SGNODE * GetRawPtr(void) noexcept
Function GetRawPtr() returns the raw internal SGNODE pointer.
Definition: ifsg_node.cpp:65
The base class of all Scene Graph nodes.
Definition: sg_node.h:75
virtual bool AddChildNode(SGNODE *aNode)=0

References SGNODE::AddChildNode(), IFSG_NODE::GetRawPtr(), and IFSG_NODE::m_node.

◆ AddChildNode() [2/2]

bool IFSG_NODE::AddChildNode ( SGNODE aNode)
inherited

Function AddChildNode adds a node as a child owned by this node.

Returns
true on success

Definition at line 148 of file ifsg_node.cpp.

149{
150 wxCHECK( m_node, false );
151
152 return m_node->AddChildNode( aNode );
153}

References SGNODE::AddChildNode(), and IFSG_NODE::m_node.

Referenced by SHAPE::CalcShape(), EXPORTER_PCB_VRML::create_vrml_plane(), EXPORTER_PCB_VRML::create_vrml_shell(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), and makeComponents().

◆ AddRefNode() [1/2]

bool IFSG_NODE::AddRefNode ( IFSG_NODE aNode)
inherited

Definition at line 136 of file ifsg_node.cpp.

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}
virtual bool AddRefNode(SGNODE *aNode)=0

References SGNODE::AddRefNode(), IFSG_NODE::GetRawPtr(), and IFSG_NODE::m_node.

◆ AddRefNode() [2/2]

bool IFSG_NODE::AddRefNode ( SGNODE aNode)
inherited

Function AddRefNode adds a reference to an existing node which is not owned by (not a child of) this node.

Returns
true on success

Definition at line 128 of file ifsg_node.cpp.

129{
130 wxCHECK( m_node, false );
131
132 return m_node->AddRefNode( aNode );
133}

References SGNODE::AddRefNode(), and IFSG_NODE::m_node.

Referenced by SHAPE::CalcShape(), EXPORTER_PCB_VRML::create_vrml_plane(), EXPORTER_PCB_VRML::create_vrml_shell(), EXPORTER_PCB_VRML::ExportVrmlFootprint(), makeComponents(), and vrmlToSG().

◆ Attach()

bool IFSG_TRANSFORM::Attach ( SGNODE aNode)
overridevirtual

Function Attach associates a given SGNODE* with this wrapper.

Implements IFSG_NODE.

Definition at line 69 of file ifsg_transform.cpp.

70{
71 if( m_node )
73
74 m_node = nullptr;
75
76 if( !aNode )
77 return false;
78
79 if( S3D::SGTYPE_TRANSFORM != aNode->GetNodeType() )
80 {
81 return false;
82 }
83
84 m_node = aNode;
86
87 return true;
88}
S3D::SGTYPES GetNodeType(void) const noexcept
Return the type of this node instance.
Definition: sg_node.cpp:104
void DisassociateWrapper(SGNODE **aWrapperRef) noexcept
Remove the association between an IFSG* wrapper object and this object.
Definition: sg_node.cpp:225
@ SGTYPE_TRANSFORM
Definition: sg_types.h:36

References SGNODE::AssociateWrapper(), SGNODE::DisassociateWrapper(), SGNODE::GetNodeType(), IFSG_NODE::m_node, and S3D::SGTYPE_TRANSFORM.

Referenced by makeComponents(), and EXPORTER_PCB_VRML::~EXPORTER_PCB_VRML().

◆ Destroy()

◆ FindNode()

SGNODE * IFSG_NODE::FindNode ( const char *  aNodeName)
inherited

Function FindNode searches the tree of linked nodes and returns a reference to the first node found with the given name.

The reference is then typically added to another node via AddRefNode().

Parameters
aNodeNameis the name of the node to search for
Returns
is a valid node pointer on success, otherwise NULL

Definition at line 120 of file ifsg_node.cpp.

121{
122 wxCHECK( m_node, nullptr );
123
124 return m_node->FindNode( aNodeName, nullptr );
125}
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.

References SGNODE::FindNode(), and IFSG_NODE::m_node.

◆ GetName()

const char * IFSG_NODE::GetName ( void  )
inherited

Function GetName returns a pointer to the node name (NULL if no name assigned)

Definition at line 95 of file ifsg_node.cpp.

96{
97 wxCHECK( m_node, nullptr );
98
99 return m_node->GetName();
100}
const char * GetName(void)
Definition: sg_node.cpp:146

References SGNODE::GetName(), and IFSG_NODE::m_node.

◆ GetNodeType()

S3D::SGTYPES IFSG_NODE::GetNodeType ( void  ) const
inherited

Function GetNodeType returns the type of this node instance.

Definition at line 71 of file ifsg_node.cpp.

72{
73 wxCHECK( m_node, S3D::SGTYPE_END );
74
75 return m_node->GetNodeType();
76}
@ SGTYPE_END
Definition: sg_types.h:45

References SGNODE::GetNodeType(), IFSG_NODE::m_node, and S3D::SGTYPE_END.

◆ GetNodeTypeName()

const char * IFSG_NODE::GetNodeTypeName ( S3D::SGTYPES  aNodeType) const
inherited

Function GetNodeTypeName returns the text representation of the node type or NULL if the node somehow has an invalid type.

Definition at line 112 of file ifsg_node.cpp.

113{
114 wxCHECK( m_node, nullptr );
115
116 return m_node->GetNodeTypeName( aNodeType );
117}
const char * GetNodeTypeName(S3D::SGTYPES aNodeType) const noexcept
Definition: sg_node.cpp:164

References SGNODE::GetNodeTypeName(), and IFSG_NODE::m_node.

◆ GetParent()

SGNODE * IFSG_NODE::GetParent ( void  ) const
inherited

Function GetParent returns a pointer to the parent SGNODE of this object or NULL if the object has no parent (ie.

top level transform).

Definition at line 79 of file ifsg_node.cpp.

80{
81 wxCHECK( m_node, nullptr );
82
83 return m_node->GetParent();
84}
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

References SGNODE::GetParent(), and IFSG_NODE::m_node.

Referenced by makeComponents().

◆ GetRawPtr()

◆ NewNode() [1/2]

bool IFSG_TRANSFORM::NewNode ( IFSG_NODE aParent)
overridevirtual

Implements IFSG_NODE.

Definition at line 115 of file ifsg_transform.cpp.

116{
117 SGNODE* np = aParent.GetRawPtr();
118
119 wxCHECK( np, false );
120
121 return NewNode( np );
122}
bool NewNode(SGNODE *aParent) override
Function NewNode creates a new node to associate with this wrapper.

References IFSG_NODE::GetRawPtr(), and NewNode().

◆ NewNode() [2/2]

bool IFSG_TRANSFORM::NewNode ( SGNODE aParent)
overridevirtual

Function NewNode creates a new node to associate with this wrapper.

Implements IFSG_NODE.

Definition at line 91 of file ifsg_transform.cpp.

92{
93 if( m_node )
95
96 m_node = new SCENEGRAPH( aParent );
97
98 if( aParent != m_node->GetParent() )
99 {
100 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] invalid SGNODE parent (%s) to SCENEGRAPH" ),
101 __FILE__, __FUNCTION__, __LINE__,
102 aParent->GetNodeTypeName( aParent->GetNodeType() ) );
103
104 delete m_node;
105 m_node = nullptr;
106 return false;
107 }
108
110
111 return true;
112}

References SGNODE::AssociateWrapper(), SGNODE::DisassociateWrapper(), SGNODE::GetNodeType(), SGNODE::GetNodeTypeName(), SGNODE::GetParent(), and IFSG_NODE::m_node.

Referenced by NewNode().

◆ SetCenter()

bool IFSG_TRANSFORM::SetCenter ( const SGPOINT aCenter)
noexcept

Definition at line 185 of file ifsg_transform.cpp.

186{
187 wxCHECK( m_node, false );
188
189 ( (SCENEGRAPH*) m_node )->center = aCenter;
190
191 return true;
192}

Referenced by WRL2TRANSFORM::TranslateToSG(), and X3DTRANSFORM::TranslateToSG().

◆ SetName()

bool IFSG_NODE::SetName ( const char *  aName)
inherited

Function SetName sets the node's name; if the pointer passed is NULL then the node's name is erased.

Returns
true on success

Definition at line 103 of file ifsg_node.cpp.

104{
105 wxCHECK( m_node, false );
106
107 m_node->SetName( aName );
108 return true;
109}
void SetName(const char *aName)
Definition: sg_node.cpp:155

References IFSG_NODE::m_node, and SGNODE::SetName().

◆ SetParent()

bool IFSG_NODE::SetParent ( SGNODE aParent)
inherited

Function SetParent sets the parent SGNODE of this object.

Parameters
aParent[in] is the desired parent node
Returns
true if the operation succeeds; false if the given node is not allowed to be a parent to the derived object

Definition at line 87 of file ifsg_node.cpp.

88{
89 wxCHECK( m_node, false );
90
91 return m_node->SetParent( aParent );
92}

References IFSG_NODE::m_node, and SGNODE::SetParent().

Referenced by processFace(), and EXPORTER_PCB_VRML::~EXPORTER_PCB_VRML().

◆ SetRotation()

bool IFSG_TRANSFORM::SetRotation ( const SGVECTOR aRotationAxis,
double  aAngle 
)

Definition at line 125 of file ifsg_transform.cpp.

126{
127 wxCHECK( m_node, false );
128
129 ( (SCENEGRAPH*) m_node )->rotation_axis = aRotationAxis;
130 ( (SCENEGRAPH*) m_node )->rotation_angle = aAngle;
131
132 return true;
133}

References IFSG_NODE::m_node.

Referenced by EXPORTER_PCB_VRML::ExportVrmlFootprint(), makeComponents(), processLabel(), WRL2TRANSFORM::TranslateToSG(), and X3DTRANSFORM::TranslateToSG().

◆ SetScale() [1/2]

bool IFSG_TRANSFORM::SetScale ( const SGPOINT aScale)
noexcept

Definition at line 136 of file ifsg_transform.cpp.

137{
138 wxCHECK( m_node, false );
139
140 ( (SCENEGRAPH*) m_node )->scale = aScale;
141
142 return true;
143}

Referenced by EXPORTER_PCB_VRML::ExportVrmlFootprint(), EXPORTER_PCB_VRML::SetScale(), WRL2TRANSFORM::TranslateToSG(), and X3DTRANSFORM::TranslateToSG().

◆ SetScale() [2/2]

bool IFSG_TRANSFORM::SetScale ( double  aScale)

Definition at line 146 of file ifsg_transform.cpp.

147{
148 wxCHECK( m_node, false );
149
150 if( aScale < 1e-8 && aScale > -1e-8 )
151 {
152 wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [BUG] |scale| is < 1e-8 - this seems strange" ),
153 __FILE__, __FUNCTION__, __LINE__ );
154
155 return false;
156 }
157
158 ( (SCENEGRAPH*) m_node )->scale = SGPOINT( aScale, aScale, aScale );
159
160 return true;
161}

References IFSG_NODE::m_node.

◆ SetScaleOrientation()

bool IFSG_TRANSFORM::SetScaleOrientation ( const SGVECTOR aScaleAxis,
double  aAngle 
)

Definition at line 174 of file ifsg_transform.cpp.

175{
176 wxCHECK( m_node, false );
177
178 ( (SCENEGRAPH*) m_node )->scale_axis = aScaleAxis;
179 ( (SCENEGRAPH*) m_node )->scale_angle = aAngle;
180
181 return true;
182}

References IFSG_NODE::m_node.

Referenced by WRL2TRANSFORM::TranslateToSG(), and X3DTRANSFORM::TranslateToSG().

◆ SetTranslation()

bool IFSG_TRANSFORM::SetTranslation ( const SGPOINT aTranslation)
noexcept

Definition at line 164 of file ifsg_transform.cpp.

165{
166 wxCHECK( m_node, false );
167
168 ( (SCENEGRAPH*) m_node )->translation = aTranslation;
169
170 return true;
171}

Referenced by EXPORTER_PCB_VRML::ExportVrmlFootprint(), makeComponents(), processLabel(), WRL2TRANSFORM::TranslateToSG(), and X3DTRANSFORM::TranslateToSG().

Member Data Documentation

◆ m_node

SGNODE* IFSG_NODE::m_node
protectedinherited

The documentation for this class was generated from the following files: