next up previous contents index
Next: The Rotate Init-Method Up: Project Rotate Previous: The Rotate Setup-Method

The Rotate Add-Method

 

A new Rot2d instance should be added to the data hierarchy each time the user adds our project, therefore we provide an add-method:

PROJECT *project_rotate_add()
{
  PROJECT *self;
  ROT2D *rot;

  self = (PROJECT *)START_METHOD(G_INSTANCE);
  ASSURE(self, "", END_METHOD(NULL));

  /*
   * This method is called when a project is added from the project list
   * in the manager menu or when g_project_add is called. We just create
   * a Rot2d instance like it was done in the main program.
   */
  rot = (ROT2D *)GRAPE(Rot2d, "new-instance")("rot");
  ASSURE(rot, "project_rotate_add: can't create instance", END_METHOD(NULL));

  /*
   * We set the instance as the project's object. The project will
   * put it into the data hierarchy for us, creating a scene if
   * necessary. By added the project several time we can get any
   * number of Rot2d instances.
   */
   GRAPE(self, "set-object")(rot);

  END_METHOD(self);
}


SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.