next up previous contents index
Next: Matrix_Edit Up: Classes and Methods Previous: Layer

Manager

  (subclass of Root)

The manager is the connection between the user's actions, the mathematical objects, the hardware drivers and the graphical view. A longer description can be found in section 9.1.1.1 and in section 4.

The manager has got a new concept for long numerical processes, which will show the progress and enable the user to stop or abort the numerics. To do so, you have to create a wait layer, as it is shown in the following example:

An example wait layer:

void numerics (void)
{
  MANAGER *mgr;
  int i;
  
  mgr = (MANAGER *) GRAPE (Manager, "get-stdmgr")();

  /* inactivate everything, open a layer containing a percent bar
   * which shown the current state of i, 0 on the left side, 1000
   * on the right side */

  GRAPE (mgr, "disable-menu")(&i, 0.0, 1000.0, dfInt);
  for (i = 0; i < 1000; i++) {
    ...; /* numerics */

    /* Let the Manager process the pending events, allow the user
     * to press "pause" to pause, update the percent bar.
     * if "abort" is pressed we have to terminate the loop
     */
    if (!GRAPE (mgr, "process-events")(NULL))
      break;
  }
  GRAPE (mgr, "enable-menu")();
}

void g_ctl_draw_procedure (MANAGER *mgr); Redraw the standard GraphicDevice. That is: draw the current object.

   GRAPE(manager, "add-cross-depend")(instance, method)
MANAGER * manager
INSTANCE * instance
char * method
Every time "recalc-cross" is called in manager it will call the following: GRAPE (instance, method)(current_object).
   GRAPE(manager, "add-inter")(item)
MANAGER *manager
ITEM *item
Tries to add the item to the first opt-menu. This method will do the same as GRAPE(manager, "add-inter-for-opt")(item, 0)
   GRAPE(manager, "add-inter-for-opt")(item, nr)
MANAGER *manager
ITEM *item
int nr
Tries to add the item to the option-menu nr. If the item doesn't fit in this opt-menu it will be automatically put into the next one, which has enough place for it (see also 9.1.1.2). If there is no space left for this item in any opt-menu, NULL will be returned.
   GRAPE(manager, "add-layer")(layer)
MANAGER *manager
LAYER *layer
Add the layer as the new top-layer to the manager.
   GRAPE(manager, "check-refresh")()
MANAGER *manager
Redraw all Items which redraw flag in ON and reset the redraw flag.
   GRAPE(manager, "delete-item")(item)
MANAGER *manager ITEM *item
Add the item to a list of items, which will be removed at the next possible time. This method is the only way to delete an item which is still in use. For example: A Button wants to delete the Layer is is part of, if you press the button. If the Button sends in its action method a "delete" method to the layer, the layer and all its items will be deleted at that moment. After that GRAPE will try to continue the action- and the cause-action method of the button, but the button is deleted. Doing it this way GRAPE will crash when the next method call for button is executed. So the only way is to add the layer to the delete list of the manager and the manager will delete it, being sure, that no more method calls for these objects are still in process.

   (LAYER * ) GRAPE(manager, "disable-menu")(value, min_value, max_value, vtype)
MANAGER *manager
void *value
double min_value, max_value
DECLARATION_FORMAT vtype
Disables the whole Manager and adds a new Layer, which only contains a "abort" and a "pause" Button and a Slider, which shows the actual value of value. The type of the variable should be selected using the vtype parameter. The Slider will be scaled using the min_value and the max_value.

This method initializes the support of long numeric processes, which is described with an example at the top of this section. After the call of this method the numeric process has to call the method "process-events" periodically to enable the usage of the Button and to update the Slider, which should show the progress of the numerics. After the numeric is finished or aborted, the method "enable-menu" must be called to delete the layer and enable the manager again. The usage of this mechanism can be used recursively to enable depending numeric processes.

   GRAPE(manager, "enable-all-layers")()
MANAGER *manager
This will enable all layers, which were disabled by a call to "disable-menu". Calling this method will enable you to use the whole manager, while the numeric is in progress. This is very dangerous, because it is possible to remove methods, which are necessary for the numeric, while the numeric is still in progress.
   GRAPE(manager, "enable-layer")(name)
MANAGER *manager
char *name
Enables the layer with the name name after he has be disabled by a call of "disable-menu". This is useful to enable some special layers, while the numeric is in progress.
   GRAPE(manager, "enable-menu")()
MANAGER *manager
Restore the general manager activity state a before the last "disable-menu".
   (INSTANCE * ) GRAPE(manager, "get-current-object")()
MANAGER *manager
Returns the current object.
   GRAPE(manager, "get-display-method")(display_method)
MANAGER *manager
char **display_method
Replace the string pointed to by display_method by a g_strdup copy of the currently chosen display method.
   (INSTANCE * ) GRAPE(manager, "get-mark-instance")()
MANAGER * manager
Return the marked instance, i.e. the instance marked in the manag-menu. This instance can change without notice, so be careful not to assume its validity across method calls.
   GRAPE(Manager, "get-stdmgr")()
CLASS *Manager
Returns the standard Manager. If there is no standard manager, it will be created together with a Graphicdevice and a ControlDevice.
   (SCENE * ) GRAPE(mgr, "goto-instance")(object)
MANAGER *mgr
INSTANCE * object
Find an go the shortest "click"-path between the current object and object in the scene tree.
   GRAPE(manager, "handle")(inst)
MANAGER *manager
INSTANCE *inst
Set inst as the current object, enter the interactive mode.
   (SCENE * ) GRAPE(mgr, "insert-object")(object, bury, at_head, skip_first)
MANAGER * mgr
INSTANCE * object
int bury, at_head, skip_first
Insert object into the scene tree in a legal way.

The first (or second, if skip_first is set) Scene above or equal the current instance is found. If this does not exist or at_head is set, a Scene with the whole scene tree as object is created. After that object is passed to the Scene using "insert-object", which ASSIGNs object as scene-> tex2html_wrap44180 object to itself or one of its next_scenes, if an empty one is found. If bury is set, the next_scene chain is searched to the end, otherwise a new Scene as direct next_scene is created. The return value is the Scene, object has been assigned to.

   GRAPE(manager, "new-handle")(f, count)
MANAGER *manager
void (*f)()
int count
This method checks if the manager has got count items registered as dependent upon the display-method f. If the items are already registered and added, it will return NULL. If the items are not registered, they MUST be added, using GRAPE (mgr, "add-inter")() or GRAPE (mgr, "add-inter-for-opt")(), directly after the call of "new-handle". This method may only be used inside a display-method or inside a function, which is called directly from a display method. The usage outside a display method will cause an error message.

This method is used to add display dependent interactives, which are removed automatically when the display method isn't used any more.

   (ITEM * ) GRAPE(manager, "path-to-item")(path)
MANAGER *manager
char * path
Return the first Item matching path. See the method "path-to-item" on class Item.
   GRAPE(manager, "pop-instance")()
MANAGER *manager
Restore the previous current object after "push-instance".
   GRAPE(manager, "pop-layer")(layer)
MANAGER *manager
LAYER *layer
Pop layer to top position.
   GRAPE(manager, "pop-message")()
MANAGER *manager
Restore the main message state after a "push-message".
   GRAPE(manager, "process-events")(pause_flag)
MANAGER *manager
int *pause_flag
Process pending events. Part of the wait layer mechanism. If "abort" is pressed this method returns NULL. If "pause" is pressed the method will return if the pause state is released.

Always pass NULL as pause_flag.

   GRAPE(manager, "push-instance")(inst, type)
MANAGER *manager
INSTANCE *inst
char type
Set inst as the new current object. Valid values for type are
#define G_CROSS_EMPTY   ' '  /* no instance */
#define G_CROSS_PUSHED  'p'  /* instance is pushed, pop it to go there */
#define G_CROSS_DOWN    'd'  /* go down: current instance has to move left */
#define G_CROSS_NEXT    'n'  /* like next_scene: curr inst has to move up */
#define G_CROSS_CHAINED 'c'  /* next element in a doubly linked list,
                              * like timesteps. since this instance will
                              * show curr inst in its follow, don't push
                              * current instance */
. This method is called to set the instance when a button in the manag-menu is clicked. type is the value that was set in the "follow" method of the (previous) current object.

Normally you will use G_CROSS_DOWN for sub-instances.

An follow method example can be found in section 5.4.6.

   GRAPE(manager, "push-message")(line1, line2, line3)
MANAGER *manager
char *line1, *line2, *line3
Set a three line message. The previous state of the message field is saved to be restored via "pop-message".
   GRAPE(manager, "recalc-cross")()
MANAGER *manager
Recalculate the viewable part of the scene tree. After calling "follow" on the current object the cross buttons are correctly labeled and cross dependent objects are updated.
   GRAPE(manager, "remove-cross-depend")(instance, method)
MANAGER * manager
INSTANCE * instance
char * method
Remove a dependency added with "add-cross-depend". If method is passed as NULL every method added with instance instance is removed.
   GRAPE(manager, "remove-inter")(item)
MANAGER *manager
ITEM *item
Remove item from the containing option menu. If item is a layer it will be hidden by calling "remove-layer".
   GRAPE(manager, "remove-layer")(layer)
MANAGER *manager
LAYER *layer
Hide layer by removing it from the Manager's list of active layers.
   GRAPE(manager, "remove-message")()
MANAGER *manager
Clear the main message. Better use "push-message" and "pop-message".
   GRAPE(manager, "send-to-layers")(method)
MANAGER *manager
char *method
Send a send-method (an arbitrary method without parameters) to all active Layers.
   GRAPE(manager, "send-display-method")(method)
MANAGER *manager
char *method
Set the display method to method.
   GRAPE(manager, "set-graphic-redraw")(new_status)
MANAGER *manager
REDRAW_FLAG new_status
Set the kind of graphic redraw to be done. If an object changes that is seen in the graphic window someone, e. g. the pressed button, has to set rfOn.
   GRAPE(manager, "set-message")(str0, str1, str2)
MANAGER *manager
char *str0, *str1, *str2
Set a three line message, the old message is discarded. Better use "push-message" and "pop-message".
   GRAPE(manager, "set-standard-message")()
MANAGER *manager
Set the standard message you see at startup.
   GRAPE(manager, "set-stdmgr")()
MANAGER *manager
Set manager as standard manager. It will be returned by "get-stdmgr".
   GRAPE(manager, "update")()
MANAGER *manager
"update" the main menu.


next up previous contents index
Next: Matrix_Edit Up: Classes and Methods Previous: Layer

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.