next up previous contents index
Next: A User-Interface for Rot2d Up: Interactive Elements Previous: Adding Items to the

Display Methods Using Items

 

Parameters for a display method can be provided with interactives, in most cases by variables that are controlled by rulers. An example for this was already given in section 5.4.6: the display method of class Rot2d draws an icosahedron around the point that is currently edited, to control the radius of the icosahedron a double variable controlled by a ruler is used.

Of course items in display methods also have to be added to the manager with "add-inter" or "add-inter-for-opt", but for these methods this only has to be done when the method is active, and the items have to be removed when the method is no longer used. To control adding and removing these display method dependent items the method

GRAPE(mgr, "new-handle")(display_method_function, number_of_items)
is used. display_method_function is the pointer to the function that implements the display method and number_of_items is the number of items that are added to the manager by this method. The method returns TRUE (a pointer that is not NULL) if the items have to be added and FALSE (a NULL pointer) if they were already added.

In the Rot2d example the lines to insert the ruler look like this:

if(GRAPE(mgr, "new-handle")(rot2d_display, 1))
  GRAPE(mgr, "add-inter")(radius);
When the display method gets active the "new-handle" method returns TRUE and the ruler is added. Now while it is active "new-handle" always returns NULL and nothing happens. When the method is no longer used the manager automatically removes all items that belonged to that method, therefore they can be added again the next time the method is activated.

Of course all kinds of items can be used with "new-handle", even groups and layers. Items that belong together should be put into a group, then they always appear in the same option menu. Layers added by display methods are not restricted to one of the option menus, they are visible in all manager menus.


next up previous contents index
Next: A User-Interface for Rot2d Up: Interactive Elements Previous: Adding Items to the

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.