kicad/3d-viewer/3d_cache/sg/ifsg_node.cpp

166 lines
3.5 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
2020-12-16 18:19:28 +00:00
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <iostream>
#include <sstream>
#include <wx/log.h>
#include "plugins/3dapi/ifsg_node.h"
#include "3d_cache/sg/sg_node.h"
#include "plugins/3dapi/ifsg_api.h"
2020-12-16 18:19:28 +00:00
// collection of common error strings used by the wrappers
char BadObject[] = " * [BUG] operating on an invalid wrapper (object may have been deleted)";
char BadOperand[] = " * [BUG] parameter aNode is an invalid wrapper; its data may have been deleted";
char BadParent[] = " * [BUG] invalid parent node (data may have been deleted)";
char WrongParent[] = " * [BUG] parent node type is incompatible";
2020-12-16 18:19:28 +00:00
IFSG_NODE::IFSG_NODE()
{
2020-12-16 18:19:28 +00:00
m_node = nullptr;
}
IFSG_NODE::~IFSG_NODE()
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
}
void IFSG_NODE::Destroy( void )
{
if( m_node )
m_node->DisassociateWrapper( &m_node );
delete m_node;
2020-12-16 18:19:28 +00:00
m_node = nullptr;
}
SGNODE* IFSG_NODE::GetRawPtr( void ) noexcept
{
return m_node;
}
S3D::SGTYPES IFSG_NODE::GetNodeType( void ) const
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, S3D::SGTYPE_END );
return m_node->GetNodeType();
}
SGNODE* IFSG_NODE::GetParent( void ) const
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, nullptr );
return m_node->GetParent();
}
bool IFSG_NODE::SetParent( SGNODE* aParent )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
return m_node->SetParent( aParent );
}
const char* IFSG_NODE::GetName( void )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, nullptr );
return m_node->GetName();
}
2020-12-16 18:19:28 +00:00
bool IFSG_NODE::SetName( const char* aName )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
m_node->SetName( aName );
return true;
}
2020-12-16 18:19:28 +00:00
const char* IFSG_NODE::GetNodeTypeName( S3D::SGTYPES aNodeType ) const
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, nullptr );
return m_node->GetNodeTypeName( aNodeType );
}
2020-12-16 18:19:28 +00:00
SGNODE* IFSG_NODE::FindNode( const char* aNodeName )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, nullptr );
return m_node->FindNode( aNodeName, nullptr );
}
bool IFSG_NODE::AddRefNode( SGNODE* aNode )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
return m_node->AddRefNode( aNode );
}
bool IFSG_NODE::AddRefNode( IFSG_NODE& aNode )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
SGNODE* np = aNode.GetRawPtr();
2020-12-16 18:19:28 +00:00
wxCHECK( np, false );
return m_node->AddRefNode( np );
}
bool IFSG_NODE::AddChildNode( SGNODE* aNode )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
return m_node->AddChildNode( aNode );
}
bool IFSG_NODE::AddChildNode( IFSG_NODE& aNode )
{
2020-12-16 18:19:28 +00:00
wxCHECK( m_node, false );
SGNODE* np = aNode.GetRawPtr();
2020-12-16 18:19:28 +00:00
wxCHECK( np, false );
return m_node->AddChildNode( np );
}