Computer Programs in Biomedicine 8 (1978) 115-120 © Elsevier/North-Holland Biomedical Press
INTERACTIVE
CONTROL OF GRAPHIC OUTPUT DEVICES
W. KYNAST and H.P. MEINZER Institute of Documentation, Information and Statistics of the German Cancer Research Center, Deutsches Krebsforschungszentrum, Ira Neuenheimer Feld 280, 6900 Heidelberg, West Germany A software package for the support of graphic output was developed. The main feature is the capability to draw graphs in a Cartesian coordinate system. With up to 60 variable parameters, it is problematic to change them interactively. Classical program languages do not support interaction. Subroutines for various kinds of input had to be written. Most important are other subroutines for reading, writing or erasing datasets at runtime, the name of which need not be known before starting a program. According to the problems, different appropriate methods of dialogue were used: the simple sequential dialogue, command languages and, for more complex input, a syntax analyser. The resulting dialogue is very simple and self-explanatory. The users need not have previous experience with computers; the package was accepted quickly and is now in extensive use. Graphic output
Interactive use
1. Introduction
which should be able to support the creation of a graphic output interactively. The intention was to help those people who know little about a computer and computer languages. The system should be easy to learn and easy to use. Furthermore, it should be flexible in its capabilities and able to fulfil as many different tasks as possible. From the system designer's and programmer's point of view, it should be easily extendable and changeable according to the users' wishes.
In a research center, a great amount of data is obtained from measuring devices. These data have to be evaluated and it has been shown that a computer can be very helpful in this respect. For this purpose, many different software packages have been developed supporting, for example, the storage, retrieval and manipulation of data. The output is mostly produced in the form o f lists and tables. The lists tend to be voluminous and difficult to read. A graphic display of results is generally easier to understand and contains more information in a compact form. Graphs are usually drawn by hand, which is time-consuming and expensive. Of course, the computer can plot pictures, if a package of graphic subroutines is implemented. Such packages are available from different sources, like CALCOMP or TEKTRONIX. To create pictures, the subroutines are embedded in programs that are usually written in FORTRAN. The user has to know a programming language plus the subroutines that control a picture. If a picture has to be changed even slightly, the program has to be rewritten and compiled again. When the problem for which the program was written is abandoned, the expensive programs are not used any longer, Our idea was to combine a package of graphic subroutines with an advanced dialogue system. We decided to write a plot-oriented software package
2. Different techniques for m a n - m a c h i n e dialogue Different possibilities to control a man-machine dialogue will be described. First, there is the simple, sequential dialogue. The program asks and the user responds. Example
Program: HOW LONG IS THE X-AXIS? (Default = 16.0 cm) User : 12 This kind of dialogue is very popular with inexperienced users. The input is either a number (or array), a textstring or a yes/no decision. To make programming easier, modules for these different kinds of input were developed. 115
W. Kynast, H.P. Meinzer, Interactive control of graphic output devices
116
The program for the input o f numbers accepts unformatted arrays of digits, because normally users do not know the difference between integer and real numbers. For them 1 , 1 . 0 and 001 are the same. The analysis is done b y a scanner which marks erroneous input with an asterisk under the first wrong input symbol. In addition, this program sends an error message if the input value is out o f range o f a predefined minimum and maximum. The input routine for text strings evaluates the length o f a text which is important for the further internal handling of that string, The routine for yes/no decisions simply branches internally to a predefined label, Another valuable subroutine deals with the connection and disconnection o f a dataset to a program at runtime. For users it is n o t necessary to specify the dataset names they intend to read or write when the system is initialized.
Example*
Name of the graphic dataset? (GDS. - - -) - lolo OUTPUT DATASET Dataset already exists ERROR MESSAGE GDS. LOLO '%E' or input of a new name (Default: old dataset will be erased) EMPTY INPUT Name of input dataset? (DATA. - - -) - lolo0 Dataset does not exist ERROR MESSAGE DATA. LOLO0 '%E' or input of a new name data. 1olol one more dataset? (DEF = Y) (Y/N) EMPTY INPUT Name of input dataset? (DATA. - - -) - 10102 one more dataset? (DEF = Y) (Y/N) -
--
To simplify a sequential dialogue, as many answers as possible are defaulted (DEF indicates the default values). If a user does not interfere, the machine assumes a reasonable input. A disadvantage of this dialogue is its inflexibility. The sequence of questions and answers is strict, and this might be unsatisfactory for a more experienced user. Furthermore, it is difficult to restart the dialogue at any level if an already existing parameter has to be changed. Another conceptual difficulty is the creation of user-specific default lists, where private defaults are stored. The second possibility for a dialogue are command languages. At a certain point o f a dialogue, a user can choose between several possible commands;
Example %INP %P %SEND %END
Input of data Creation of a plot dataset Send the graphic dataset to the plotter End program
This technique has most of the advantages o f the sequential dialogue, but avoids its inflexibility at least partially. A menue can only be of a certain size because only a certain number of possible commands can be displayed. To avoid unintelligible lists o f commantis, it is necessary to create submenues which are called by superior menues on higher levels. The input is analyzed by a scanner which detects a member o f a set o f possible commands and initializes the execution o f the indicated program. The interaction might be continued with a sequential dialogue. Commands can also be followed by a list o f parameters.
Example
n
PRINT DSNAME,,,EDIT,YES *
( - indicates input to make it easier to red the
example) This routine includes an extensive handling o f error messages. The most c o m m o n errors are that a dataset which is to be read does not exist or that a dataset which is to be created already exists. In this case, a user can either choose a different name or erase the already existing version o f that dataset. If a user does not know what to do at all, he can type '%HELP' which causes the display o f explanations,
This command prints a dataset in a special way and erases it afterwards. If commands with parameter lists are used, a user has first to read a manual which is not popular. As long as a user does not work with a computer regularly, he will have great difficulties in taking full advantage of its possibilities. Especially the parameter lists are not easily remembered. Wrong or misplaced parameters can cause severe errors, individual parameter checks are necessary before initializing
I¢. Kynast, H.P. Meinzer, Interactive control o f graphic output devices
the execution. The programming for error checking is complicated and time-consuming, Presently a third possibility o f controlling a dialogue is becoming more popular. The possible input is defined by formal languages. Syntax analyzers (parsers) for formal languages can be generated automatically,
117
Example
This approach is not suitable for problems which deal with direct picture interaction (i.e., computeraided design). Our dialogue consists of a mixture of the above-mentioned techniques of interactive programming. All possible routines are embedded in a monitor which uses the menue technique. To enter the monitor level, a user has to enter a command which consists of one word only ('plot'). Then the menue of all routines is displayed.
TABULATE AGE VERSUS SEX FROM DATASET ALPHA
%L
LIST OF FUNCTIONS AVAILABLE
%E
End of program
%INP %M %F %PAP %S
Input of a basic dataset Manipulation of datasets Function creation Read papertape Survival and death rate of animals
%B %T %P %PM
Bargraphs - Histograms Texts and legends Several curves from one dataset Several curves, one from each of several datasets Plot of datasets from a tablet with calculation of lengths and areas
An input which can be very close to natural language is analysed and the respective actions initialized. Usually the lexical analysis is performed by a scanner. At all levels a user is free to put in whatever he likes, as long as the sentence is known to the compurer. The parser performs checks of the syntax very efficiently and the execution o f a program will not be started unless the syntax is correct. Such languages are easier to learn than commands. To minimize the initial amount of knowledge required to use this kind of input, special user-assisting routines are generated together with the parser. The flexibility o f languages that are analysed by parsers is obvious and can be compared only to that of command languages.
%TAB
%SYS %SEND
Input of a system command Send a graphic dataset (GDS. - - -) to the plotter
Function? 3. Description of the plot package Fig. 1. The main menue of the plot package. Our software package allows the interactive construction of graphic output. As graphic output devices are expensive, especially those which support interactive programming, we did not expect them to be available in sufficient numbers. For the dialogue we use simple alpha-numerical terminals which are unable to show the picture which was created. Furthermore, the interaction does not take place with the picture itself, as there is no cheap device at hand, but with a dialogue system to which a user may explain the picture he wishes. The dialogue can be done with any usual computer terminal and only the totally finished picture is shown on a graphic terminal, drawn by a plotter or printed on a printer plotter, If a user does not like the result of his efforts, he has to restart the procedure, which is not wasteful as the dialogue takes only a few minutes,
There are various routines for the input o f data. All data necessary for a plot (i.e., an array o f points) are stored in a standarized dataset. Data may be typed by hand at a terminal, or a papertape is read, produced by any kind of measuring device where the columns of interest are selected. This routine uses a scanner for nurnbers, as information on papertape tends to be distorted. Another possibility for the input of data is a tablet. With this tablet, a user can input an already existing picture by following a line with a pencil, the position of which is recorded constantly. This routine is used mostly for the evaluation of lengths of curves and the size of areas. Of course, the standardized dataset can also be the output of any other program, as for example tables
118
I¢. Kynast, H.P. Meinzer, Interactive control of graphic output devices SAMPLE TR£ATFO !4ITH
First value on the axis: 2.50cpm Log. distance between 2 tickmarks: 2.50 cpm Phys. distance between 2 tickmarks: 0.75 cm
TRITIUM
~: ss so-
// !
~s -
~
/ \
Alter? (DEF = N) (Y/N)
~,
First value? (DEF = 2.50 cpm) -0 ,
Log. distance? (DEF = 2.50 cpm)
~20
}~
1S
'
~
Phys. distance? (0.75-1.25 cm, DEF = 0.75 cm)
0 5-
0
.... ~
t o
With these values the length of the axis is 14.0 cm
~/%~-~
Alter? (DEF = N)(Y/N) -
I
I
4
a
I
~12
lf6 LENGTH
~
2o
I
24
i
I
~_8
I
[~M]
s~
Fig. 2. Example of a plot. and other statistical or sorting algorithms. Such a dataset can contain the data for one or several graphs, plus labels for the (x a n d y ) axes and the legend. The format of the dataset is chosen to be easily accessible for an editing system, to give users the possibility to correct or change their data, if necessary, A further routine controls some simple mathematical operations on these datasets, according to the special requirements o f some o f our users. Then, by special request, a graph generator was implemented, The user types only the mathematical description o f a graph (including the information about the domain and step width) and the corresponding array o f points is written into a dataset. The formula is analyzed by a parser. Once the data is stored in a dataset, another routine transfers the information into a picture. The resulting graphic dataset, a pseudo-picture code, is stored as well. Within the plotting routine the size o f the picture, many features o f the axes, the scaling, features o f the graphs and so on can be controlled.
EMPTY INPUT Repeat input? (DEF = N) (Y/N)
-
EMPTY INPUT
Label? - cpm Legend? Sample treated with tritium ( - indicates input) Arrays o f points might be connected by solid lines or dashed and/or smoothed and/or marked b y 9 different symbols. This routine, like most o f the others, uses a sequential dialogue, a sequence of questions. If the answer is an e m p t y string, a reasonable assumption is made by the program. Of course, certain questions cannot have a preset default, i.e., the names of datasets to be read or written.
Example for the dialogue to define graphs Smooth? (N = No, Y = Yes) Default for curve No. 1 2 3...N is: N N _ y y
Example for the dialogue for an axis
Dash length? 9 = solid 1-8 = dashed with mm 0 = curve omitted
Y- A X I S
Default for curve No. 1
-
-
Units? (to be written at the end of the axis) cpm Axis length? (Def = 10.0 cm) EMPTY INPUT
is:
2
3...N
9 1
-
EMPTY INPUT Point indication? 0 = unmarked
W. Kynast, H.P. Meinzer, Interactive control of graphic output devices
1 = cross 2 = plus 3 = square vertical 4 = square horizontal 5 = triangle
6 = dash 7 = octogon 8 = arrow 9 = square type 3 10 = star
Default for curve No. 1 2 3 ... N is: 1 2 - 1 5 Colour? l = black 2 = green 3 = red Default for curve No. 1 2 3 ... N is: 1 1 -
-
EMPTY INPUT (The picture is ready and the menue is displayed again) Function? %E
(To leave the plot package)
( - indicates input) As the dialogue should not be too long, and as there are very many parameters that could vary for one picture (approx. 60!), a certain amount of parameters is fixed with no possibility of changing them except of rewriting the program. For a programmer these restrictions are not desirable. To overcome these restrictions, another method of dialogue is needed, either commands or parser-analyzed input, The disadvantage of these methods for an inexperienced user has already been discussed. In a sequential dialogue it is also difficult to implement an intelligent restart mechanism. Some kind of help is delivered by a submenue technique. A question may be answered by several different inputs. The analysis of such an input is usually done by a scanner. From the programmer's point of view, a menue technique is rather convenient. The implementation of new routines is simple. The resulting graphic dataset which was nroduced by the plot routine can now be given to different output devices. For every output device an interface from the pseudo-picture code in the graphic dataset into a device-dependent code has to be written, i.e., plotter, graphic displays etc. The basic idea that data is kept in datasets and
119
programs transfer information from one dataset to another is understood by inexperienced users without difficulty. A user need only know the names of datasets; he need not deal with formats or data control blocks. Internally the datasets have a fixed structure. After having it on the system, we realized that a fixed data structure is an unnecessary restriction. If the structure would be more flexible, it could be used for more purposes, i.e., storage of more general information about a certain experiment and not only for keeping the results plus a legend. However, these datasets were not planned to be a general database. The system can communicate with other software packages more or less easily. The appearance of a dataset, in order to be accepted by the routines implemented, is clearly defined.
4. The implementation of the package The programming was done in FORTRAN and PL/I, whatever seemed to be more adequate. The monitor and the plot routines are in FORTRAN because the plot subroutines were available in FORTRAN. Most of the plot subroutines, especially those of more complex capabilities (i.e., axes), had to be rewritten completely. The computer used is an IBM 370/158 with the time-sharing operating system TSS, which supports the dataset management very efficiently. It proved to be very helpful in giving system commands out of a program at runtime. One of the most inconvenient restrictions of the package is that we cannot set special defaults for every user. There is not only the problem of storing and changing these defaults at runtime, but also of saving them subsequently. Implementation of the package requires a FORTRAN IV and a PL/I Compiler. The following requirements must also be fulfilled: (i) The operating system must support conversational tasks. (ii) The fundamental graphic software must support a vector-oriented output device. (ii~) An automatic dataset management must be provided. (iv) System commands must be executable at runtime from a program.
120
14}.Kynast, H.P. Meinzer, Interactive control o f graphic output devices
This is necessary for subroutines which create a connection to a dataset to be read, written or erased, Some routines should be implemented in ASSEMBLER, i.e., transfer and search of character strings. The package is used by more than 60 scientists in the German Cancer Research Center. Most of them have no experience with data processing machinery. The package was developed in cooperation with the users. About 2500 pictures/year are created. Some routines are dedicated to special problems but most of them can be used very generally. The dialogue for the picture is embedded in the test. It is not complete and should only give a general impression of the system. As all questions, except those for dataset names, are defaulted, a user can step
through the program quickly. Usually a dialogue for the controlled creation of a picture takes approx. 3 min, if the data which is to be plotted is available.
References [1 ] W.M. Newman and R.F. Sproull, Principles of Interactive Computer Graphics (McGraw Hill, New York, 1973). [2] A.V. Aho and J.D. Ullmann, The Theory of Parsing, Translation and Compiling, Vol. 1 and 2 (Prentice Hall, Englewood Cliffs, NJ, 1972). [31 H. Hahne, DKFGRAF, Tech. Rep. (DKFZ, Heidelberg, 1973). [41 G. Osterburg and K. Schadewaldt, LL-1 Parsergenerator, Tech. Rep. (DKFZ, Heidelberg, 1977).