File: ifsg_node.h

package info (click to toggle)
kicad 9.0.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 771,448 kB
  • sloc: cpp: 969,355; ansic: 121,001; xml: 66,428; python: 18,387; sh: 1,010; awk: 301; asm: 292; makefile: 228; javascript: 167; perl: 10
file content (150 lines) | stat: -rw-r--r-- 4,621 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
 *
 * 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
 */

/**
 * @file ifsg_node.h
 * defines the wrapper of the base class SG_NODE
 */

#ifndef IFSG_NODE_H
#define IFSG_NODE_H

#include "plugins/3dapi/sg_base.h"
#include "plugins/3dapi/sg_types.h"

class SGNODE;

/**
 * The base class of all DLL-safe Scene Graph nodes.
 *
 * @note The IFSG wrapper classes shall be aimed at creating a VRML-like intermediate scenegraph
 *       representation. Although objects are readily created and added to the structure, no
 *       provision shall be made to inspect the structures in detail. For example the #SCENEGRAPH
 *       class may contain various #SGSHAPE and #SCENEGRAPH nodes but there shall be no provision
 *       to extract those nodes.  This was done because in principle all the detailed data shall
 *       only be handled within the SG* classes and only data processed via GetRenderData() shall
 *       be available via the wrappers.
 */
class SGLIB_API IFSG_NODE
{
protected:
    SGNODE* m_node;

public:
    IFSG_NODE();
    virtual ~IFSG_NODE();

    // deleted operators
    IFSG_NODE( const IFSG_NODE& aParent ) = delete;
    IFSG_NODE& operator= ( const IFSG_NODE& ) = delete;

    /**
     * Delete the object held by this wrapper.
     */
    void Destroy( void );

    /**
     * Associate a given SGNODE* with this wrapper.
     */
    virtual bool Attach( SGNODE* aNode ) = 0;

    /**
     * Create a new node to associate with this wrapper.
     */
    virtual bool NewNode( SGNODE* aParent ) = 0;
    virtual bool NewNode( IFSG_NODE& aParent ) = 0;

    /**
     * Return the raw internal SGNODE pointer.
     */
    SGNODE* GetRawPtr( void ) noexcept;

    /**
     * Return the type of this node instance.
     */
    S3D::SGTYPES GetNodeType( void ) const;

    /**
     * Return a pointer to the parent SGNODE of this object or NULL if the object has no
     * parent (ie. top level transform).
     */
    SGNODE* GetParent( void ) const;

    /**
     * Set the parent SGNODE of this object.
     *
     * @param[in] aParent is the desired parent node.
     * @return true if the operation succeeds; false if the given node is not allowed to be a
     *              parent to the derived object.
     */
    bool SetParent( SGNODE* aParent );

    /**
     * Return a pointer to the node name (NULL if no name assigned).
     */
    const char* GetName( void );

    /**
     * Set the node's name.
     *
     * If the pointer passed is NULL, the node's name is erased.
     *
     * @return true on success.
     */
    bool SetName( const char *aName );

    /**
     * Return the text representation of the node type or NULL if the node somehow has an
     * invalid type.
     */
    const char * GetNodeTypeName( S3D::SGTYPES aNodeType ) const;

    /**
     * Search 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().
     *
     * @param aNodeName is the name of the node to search for.
     * @return is a valid node pointer on success, otherwise NULL.
     */
    SGNODE* FindNode( const char *aNodeName );

    /**
     * Add a reference to an existing node which is not owned by (not a child of) this node.
     *
     * @return true on success.
     */
    bool AddRefNode( SGNODE* aNode );
    bool AddRefNode( IFSG_NODE& aNode );

    /**
     * Add a node as a child owned by this node.
     *
     * @return true on success.
     */
    bool AddChildNode( SGNODE* aNode );
    bool AddChildNode( IFSG_NODE& aNode );
};

#endif  // IFSG_NODE_H