You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
5.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Cirilo Bernardo <cirilo.bernardo@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file ifsg_node.h
  25. * defines the wrapper of the base class SG_NODE
  26. */
  27. /*
  28. * NOTES:
  29. * 1. The IFSG wrapper classes shall be aimed at creating a VRML-like
  30. * intermediate scenegraph representation. Although objects are
  31. * readily created and added to the structure, no provision shall
  32. * be made to inspect the structures in detail. For example the
  33. * SCENEGRAPH class may contain various SGSHAPE and SCENEGRAPH
  34. * nodes but there shall be no provision to extract those nodes.
  35. * This was done because in principle all the detailed data shall
  36. * only be handled within the SG* classes and only data processed
  37. * via GetRenderData() shall be available via the wrappers.
  38. */
  39. #ifndef IFSG_NODE_H
  40. #define IFSG_NODE_H
  41. #include "plugins/3dapi/sg_base.h"
  42. #include "plugins/3dapi/sg_types.h"
  43. class SGNODE;
  44. /**
  45. * Class IFSG_NODE
  46. * represents the base class of all DLL-safe Scene Graph nodes
  47. */
  48. class SGLIB_API IFSG_NODE
  49. {
  50. protected:
  51. SGNODE* m_node;
  52. public:
  53. IFSG_NODE();
  54. virtual ~IFSG_NODE();
  55. // deleted operators
  56. IFSG_NODE( const IFSG_NODE& aParent ) = delete;
  57. IFSG_NODE( IFSG_NODE& aParent ) = delete;
  58. IFSG_NODE( volatile const IFSG_NODE& aParent ) = delete;
  59. IFSG_NODE( volatile IFSG_NODE& aParent ) = delete;
  60. IFSG_NODE& operator= ( const IFSG_NODE& ) = delete;
  61. /**
  62. * Function Destroy
  63. * deletes the object held by this wrapper
  64. */
  65. void Destroy( void );
  66. /**
  67. * Function Attach
  68. * associates a given SGNODE* with this wrapper
  69. */
  70. virtual bool Attach( SGNODE* aNode ) = 0;
  71. /**
  72. * Function NewNode
  73. * creates a new node to associate with this wrapper
  74. */
  75. virtual bool NewNode( SGNODE* aParent ) = 0;
  76. virtual bool NewNode( IFSG_NODE& aParent ) = 0;
  77. /**
  78. * Function GetRawPtr()
  79. * returns the raw internal SGNODE pointer
  80. */
  81. SGNODE* GetRawPtr( void );
  82. /**
  83. * Function GetNodeType
  84. * returns the type of this node instance
  85. */
  86. S3D::SGTYPES GetNodeType( void ) const;
  87. /**
  88. * Function GetParent
  89. * returns a pointer to the parent SGNODE of this object
  90. * or NULL if the object has no parent (ie. top level transform).
  91. */
  92. SGNODE* GetParent( void ) const;
  93. /**
  94. * Function SetParent
  95. * sets the parent SGNODE of this object.
  96. *
  97. * @param aParent [in] is the desired parent node
  98. * @return true if the operation succeeds; false if
  99. * the given node is not allowed to be a parent to
  100. * the derived object
  101. */
  102. bool SetParent( SGNODE* aParent );
  103. /**
  104. * Function GetName
  105. * returns a pointer to the node name (NULL if no name assigned)
  106. */
  107. const char* GetName( void );
  108. /**
  109. * Function SetName
  110. * sets the node's name; if the pointer passed is NULL
  111. * then the node's name is erased
  112. *
  113. * @return true on success
  114. */
  115. bool SetName( const char *aName );
  116. /**
  117. * Function GetNodeTypeName
  118. * returns the text representation of the node type
  119. * or NULL if the node somehow has an invalid type
  120. */
  121. const char * GetNodeTypeName( S3D::SGTYPES aNodeType ) const;
  122. /**
  123. * Function FindNode searches the tree of linked nodes and returns a
  124. * reference to the first node found with the given name. The reference
  125. * is then typically added to another node via AddRefNode().
  126. *
  127. * @param aNodeName is the name of the node to search for
  128. * @param aCaller is a pointer to the node invoking this function
  129. * @return is a valid node pointer on success, otherwise NULL
  130. */
  131. SGNODE* FindNode( const char *aNodeName );
  132. /**
  133. * Function AddRefNode
  134. * adds a reference to an existing node which is not owned by
  135. * (not a child of) this node.
  136. *
  137. * @return true on success
  138. */
  139. bool AddRefNode( SGNODE* aNode );
  140. bool AddRefNode( IFSG_NODE& aNode );
  141. /**
  142. * Function AddChildNode
  143. * adds a node as a child owned by this node.
  144. *
  145. * @return true on success
  146. */
  147. bool AddChildNode( SGNODE* aNode );
  148. bool AddChildNode( IFSG_NODE& aNode );
  149. };
  150. #endif // IFSG_NODE_H