gef/src/GEFView.i3


Copyright (C) 1994, Digital Equipment Corp.

INTERFACE GEFView;

IMPORT Algorithm, Bundle, RefList, Thread, View AS ZeusView;
The simplest way to get a mentor algorithm is to create a pair of of SLisp programs. One implements the algorithm, the other the view. Call the procedure Create in your main program

PROCEDURE Create(sessionName: TEXT; views, algs, codeViews: RefList.T := NIL);
  (* Creates a zeus session named "sessionName" with algorithms, views and
     codeviews.

     "views" is an association list of view names and GEF view file names.
     "algs" is an association list of algorithm names and GEF algorithm file names.
     "codeview" is an association list of codeview names and code view file names.

     All of the files (algorithm, view and codeview) are looked for as
     resources.

     There will also be a transcript view for the session.
  *)

TYPE
  ViewClass <: ZeusView.T;
  View <: ViewPublic;
  ViewPublic = ViewClass OBJECT
  METHODS
    init(): View;
  END;

TYPE
  AlgClass <: Algorithm.T;
  Alg <: AlgPublic;
  AlgPublic = AlgClass OBJECT
  METHODS
    init(algFile: TEXT; viewFiles: RefList.T): Alg;

    (* Initializes the algorithm to run using "algFile" and the views
       to use "viewFiles".

       "viewFiles" is an association list of view name, view file name pairs.
       Each view looks up its name in the list and initializes itself from
       the associated GEF file.

       Each view file is SLisp with the following  extensions:

       (get element FieldName) Returns the value of the field "FieldName"
                               of the GEF "element".

       (set element FieldName value) Sets the value of the field "FieldName"
                               of GEF "element" to "value".

       (delete element) Deletes the GEF "element" from the view.

       (Feedback name args) calls a function named "name" in the algorithm's
                            SLisp code with "args".  "Feedback" can only
                            be called from the view's MouseFeedback function.
                            "Feedback" produces a Zeus "FEEDBACK" event.

       A view file can also include a number of graphics elements and
       animation actions as defined in GEF.i3

       If a view has a function named "MouseFeedback" it is called whenever
       the user selects in the view with the mouse.  It takes 5 arguments.

       pos - the world coordinate position of the selection (a list of
             two real values, the horizontal and vertical positions)
       vertices   - A list of the graphical elements (a different list for
       highlights   each type) that are at the selected position.  If the
       edges        list is NIL, then there are no elements of that type
       polygons     at the selected point.

       "algFile" must be a GEF algorithm file, which is SLisp with the following
       extensions:

       (Event name args)  call the event "name" with "args".
       (Update name args) "name" is a string giving the name of a function
                          defined in the file given to "Init".
                          "args" is a list which is passed to the function.
                          "Event" is a Zeus "OUTPUT" event while "Update"
                          is a Zeus "UPDATE" event.  Their only difference
                          is in the Zeus locking level.

                          Note: each top-level element in args is evaluated
                               before being passed
                         ex: (Event "growbox" ("BoxA" (+ 3.3 i)))

       (Pause)           call the event "Pause" which is a null event
                         that is provided as a convenient stepping point

       (CodeViewEvent line) display "line" (an integer) in the code view
       (CodeViewProc proc)  display procedure "proc" (a string) in the code view
       (CodeViewExit)       exit the current procedure in the code view

       (StartFeedback)  calls the Zeus StartFeedback and EndFeedbac procedures
       (EndFeedback)    so the algorithm can prompt the user for input.
    *)
  END;

 PROCEDURE Init (alg: AlgClass; file: TEXT) RAISES {Thread.Alerted};
Initialize the GEFView with file (must be a file in gef format

PROCEDURE Event (alg: AlgClass; name: TEXT; data: RefList.T)
  RAISES {Thread.Alerted};
    (*Invoke the event "name" with "data" in the GEFView *)

PROCEDURE Update (alg: AlgClass; name: TEXT; data: RefList.T)
  RAISES {Thread.Alerted};
 (* Invoke the update event "name" with "data" in the GEFView *)

PROCEDURE Pause(alg: AlgClass) RAISES {Thread.Alerted};
 (* Invoke the "pause" event, a null event convenient for stepping *)

PROCEDURE GetBundle(): Bundle.T;
 (* Returns a bundle containing GEF resources *)

PROCEDURE RegisterSession();
 (* Initialization code *)

END GEFView.