7.10. PyramidKit

The next two examples show PyramidKit, a new subclass of SoShapeKit( C++ | Java | .NET ) that uses the Pyramid node created in Chapter 2. By making it a subclass of SoShapeKit( C++ | Java | .NET ), this new kit inherits all the parts, such as “appearance,” “transform,” and “units,” used by all the other shape kits. This class changes the type and defaultType of one of the parts in the parent class, SoShapeKit( C++ | Java | .NET ).

Example 7.3, “ PyramidKit.h ” shows the header file for PyramidKit. Example 7.4, “ PyramidKit.c++ shows the source code for this new node-kit class.

Example 7.3.  PyramidKit.h


C++
#include <Inventor/nodekits/SoShapeKit.h>

class PyramidKit : public SoShapeKit {
   SO_KIT_HEADER(PyramidKit);
  public:
   PyramidKit();
   static void initClass();
   static void exitClass();
  private:
   virtual ~PyramidKit();
};

Example 7.4.  PyramidKit.c++


C++
#include <Inventor/SoDB.h>

// Include files for new classes
#include "Pyramid.h"
#include "PyramidKit.h"

SO_KIT_SOURCE(PyramidKit);

void
PyramidKit::initClass()
{
   SO_KIT_INIT_CLASS(PyramidKit, SoShapeKit, "ShapeKit");
}

void
PyramidKit::exitClass()
{
   SO__KIT_EXIT_CLASS(PyramidKit);
}

PyramidKit::PyramidKit()
{
   SO_KIT_CONSTRUCTOR(PyramidKit);

   // Change the 'shape' part to be a Pyramid node.
   SO_KIT_CHANGE_ENTRY_TYPE(shape, Pyramid, Pyramid );

   SO_KIT_INIT_INSTANCE();

}

PyramidKit::~PyramidKit()
{
}