UBC Theses and Dissertations

UBC Theses Logo

UBC Theses and Dissertations

Design and implementation of a high-level language for interactive computer graphics Pieké, Albertus Jacobus 1973

Your browser doesn't seem to have a PDF viewer, please download the PDF to view this item.

Item Metadata

Download

Media
831-UBC_1973_A7 P53_5.pdf [ 3.55MB ]
Metadata
JSON: 831-1.0101250.json
JSON-LD: 831-1.0101250-ld.json
RDF/XML (Pretty): 831-1.0101250-rdf.xml
RDF/JSON: 831-1.0101250-rdf.json
Turtle: 831-1.0101250-turtle.txt
N-Triples: 831-1.0101250-rdf-ntriples.txt
Original Record: 831-1.0101250-source.json
Full Text
831-1.0101250-fulltext.txt
Citation
831-1.0101250.ris

Full Text

DESIGN AND IMPLEMENTATION OF A HIGH-LEVEL LANGUAGE FOR INTERACTIVE COMPUTER GRAPHICS by Albertus Jacobus (Bert) Pieke* Diplom in E.E., ETH-Ziirich 1969 A THESIS SUBMITTED IN PARTIAL FULFILMENT OF THE REQUIREMENTS FOR THE DEGREE OF MASTER OF APPLIED SCIENCE in the Department of E l e c t r i c a l Engineering We accept this thesis as conforming to the required standard THE UNIVERSITY OF BRITISH COLUMBIA July 1973 In p r e s e n t i n g t h i s t h e s i s i n p a r t i a l f u l f i l m e n t o f the requirements f o r an advanced degree a t the U n i v e r s i t y o f B r i t i s h Columbia, I agree t h a t the L i b r a r y s h a l l make i t f r e e l y a v a i l a b l e f o r r e f e r e n c e and study. I f u r t h e r agree t h a t p e r m i s s i o n f o r e x t e n s i v e c o p y i n g o f t h i s t h e s i s by h i s r e p r e s e n t a t i v e s . I t i s understood t h a t c o p y i n g or p u b l i c a t i o n of t h i s t h e s i s f o r f i n a n c i a l g a i n s h a l l not be allowed without my w r i t t e n p e r m i s s i o n . Department o f ^L€y>. C A L /€AJ<S-IM^B^T/iC-The U n i v e r s i t y o f B r i t i s h Columbia Vancouver 8, Canada f o r s c h o l a r l y purposes may be gran t e d by the Head o f my Department or ABSTRACT The design and implementation of the interactive graphics language IGL is described. This language not only allows the definition and display of line drawings but also has f u l l f a c i l i t i e s for manipula-ting, naming, identifying and interacting with such drawings. The lan-guage has been implemented as an extension to Fortran IV using the XPL compiler generator system. The experience gained so far i n the use of the language has already proven a number of advantages over present-day graphics systems. The language i s readily learned by users with previous high-level language experience. As no extensive testing and documenta-tion i s necessary due to the readability of the program, the time re-quired for the completion of a project i s greatly reduced. i TABLE OF CONTENTS Page ABSTRACT i TABLE OF CONTENTS i i LIST OF FIGURES i i i ACKNOWLEDGEMENT i v 1. INTRODUCTION 1 2. COMPUTER GRAPHICS, A SHORT SURVEY 3 3. GRAPHIC LANGUAGES 6 4. THE LANGUAGE IGL 10 5. IGLCOM, AN IGL COMPILER 19 6. IGLRUNLIB, AN IGL RUNTIME LIBRARY 21 7. IMPLEMENTATION OF IGL ON A DATA GENERAL SUPERNOVA MINI COMPUTER 29 8. EXPERIENCE WITH THE IMPLEMENTED IGL SYSTEM 35 9. BIBLIOGRAPHY 36 REFERENCES 37 APPENDICES: A IGL users' guide 40 B I l l u s t r a t i o n s from IGL programs 58 C L i s t i n g s : IGL-Syntax, IGLCOM . . 62 D Device Dependent Support Routines 73 i i LIST OF FIGURES Page 1 Sample IGL program. 16 2 Display algorithm 26 i i i ACKNOWLEDGEMENT The author wishes to thank his supervisor, Dr. G.F. Schrack and also Dr. F. Nake (formerly of the Dept. of Computer Science, U.B.C.) f o r t h e i r i n t e r e s t , advice, and encouragement throughout the period of t h i s research. Thanks are also due for the many h e l p f u l suggestions by the people i n t h i s department who have used the IGL language i n i t s i n i t i a l stages and to Miss Norma Duggan f o r typing the t h e s i s . F i n a n c i a l support for t h i s research was provided by the National Research Council of Canada as a Research A s s i s t a n t s h i p and a Bursary to the author. iv 1. INTRODUCTION Over the l a s t years, an i n c r e a s i n g need has been f e l t i n the E l e c t r i c a l Engineering Department at t h i s U n i v e r s i t y f o r a computer f a c i l i t y to permit computer aided design. A f i r s t attempt was made i n the summer of 1970. A program was w r i t t e n to enable a user to enter the topology of an e l e c t r o n i c c i r c u i t diagram to a PDP-9 computer, using a display screen and l i g h t pen as communication i n t e r f a c e [19]. This program had a number of remarkable features such as an elegant windowing f a c i l i t y and automatic l a b e l l i n g of elements. I t was reasonably w e l l documented and tested and yet proved to be less useful than hoped f o r . The reason was simple. Some a d d i t i o n a l features were needed, some inconsistencies s t i l l e x i s t e d and the i n t e r f a c i n g to a c i r c u i t ana-l y s i s program had not been included. So changes had to be made to the program and the author was no longer a v a i l a b l e . The program was w r i t t e n i n assembler and was quite complex. The e f f o r t needed f o r somebody else to f a m i l i a r i z e himself with the programming techniques used was considerable and the p r o j e c t was never completed. This example shows c l e a r l y that the design of complex software systems should occur on a more general l e v e l i f the systems are to be used by many d i f f e r e n t users and i f they are to be expandable to future needs. This i s p a r t i c u 1 a r l y true i n a u n i v e r s i t y environment where a regular turnover of students using and updating an e x i s t i n g system takes place. This thesis describes, a f t e r an i n t r o d u c t i o n to the f i e l d of computer graphics, the design and implementation of a h i g h - l e v e l 1 2 language for interactive graphics, the resulting graphics system, and the experience gained with i t . 3 2. COMPUTER GRAPHICS, A SHORT SURVEY Int e r a c t i v e techniques are widely used i n problem s o l v i n g by computers. The purpose of these techniques i s to make e f f i c i e n t use of both man and machine. The computer i s used to carry out those actions that can be s p e c i f i e d i n advance and human reasoning i s c a l l e d upon to d i r e c t the course of those actions. To be able to do t h i s , the user must have a cl e a r understanding of the state of h i s computations and he must have a means of i n d i c a t i n g h i s commands to the computer. A graphics display provides a n a t u r a l way of communicating information to the user. Lihe : drawings and graphs are much eas i e r understood than tables of num-bers. Also a graphical input device such as a l i g h t pen or j o y s t i c k allows the user to transmit h i s wishes with a maximum of convenience. This kind of i n t e r a c t i v e computing i s c a l l e d i n t e r a c t i v e computer gra-phics. The e a r l i e s t attempt at computer graphics was made i n 1962 when Ivan Sutherland implemented the now famous "Sketchpad" system on the TX-2 computer at Li n c o l n Laboratory at MIT [20]. The p u b l i c a t i o n of h i s work triggered research i n th i s f i e l d by many others and l e d companies•like General Motors, Boeing and Lockheed to set up graphics systems f o r computer aided design (CAD) [18]. A l l these systems used expensive display terminals (such as the IBM 2250) and required a huge computer to monitor the i n t e r a c t i o n . Their cost effectiveness has been hi g h l y disputed and the economic de-c l i n e i n the aerospace industry has caused the development of many new CAD projects to be abandoned. In the meantime, a new generation of computer hardware has A appeared and with i t many new concepts i n computer software [2]. The high cost of computer graphics had been determined by two f a c t o r s : - the high cost of the terminal and main computer hardware - the high cost of developing the necessary programs. The cost of computer hardware has decreased sharply over the l a s t decade and the a v a i l a b i l i t y of mini computers and time-sharing systems has further reduced the cost of i n t e r a c t i v e computing. Storage tube d i s -plays have eliminated the necessity of continuous re f r e s h i n g of the display screen and thereby made economical terminals for computer graphics a r e a l i t y . A great e f f o r t has been made to match t h i s progress i n hard-ware with a s i m i l a r cost cutt i n g progress i n software. As the hardware gets l e s s expensive, the software development costs are becoming an ever more dominating f a c t o r i n any v e r s a t i l e computer system. The previous approach where a l l software was w r i t t e n i n assembly language f o r maximum runtime e f f i c i e n c y i s now being overtaken by an e f f o r t to provide the programmer with easy to use computer languages that enable him to write h i s programs with a maximum of programming time e f f i c i e n c y . A number of s p e c i a l purpose languages have recently appeared i n the l i t e r a t u r e that attempt to make the programming of graphics a p p l i c a t i o n s as easy f o r the programmer as programming numerical programs i n con-ventio n a l algorithmic languages such as Fortran and A l g o l . The f i r s t "Graphic Languages" were published i n 1968 [5,10,13] and the development of such languages has since been the subject of a s p e c i a l conference [8]. The advantage of a powerful graphic language i s obvious. I t allows the user of a graphics system to write the programs necessary 5 for h i s s p e c i a l a p p l i c a t i o n himself. He can experiment with ideas and make changes to h i s programs without having to r e l y on a programmer to do t h i s work for him. Thus he has control over and can be made respon-s i b l e for h i s own graphics programs. What i s equally important i s the r e a d a b i l i t y of programs written i n graphic languages. I t not only re-duces the t e s t i n g and documentation time considerably, but (as most programs usually end up with inadequate documentation) i t allows changes to be made to the program by consulting j u s t a program l i s t i n g . The next chapter w i l l describe the nature of graphic languages and attempt to i d e n t i f y some of the points that are important to a p p l i -cations i n computer aided design. 6 3. GRAPHIC LANGUAGES The v a r i a b l e s i n graphic languages that are manipulated are p i c t u r e s , two-dimensional structures. One of the most d i f f i c u l t pro-blems i n computer graphics i s to f i n d a concise d e s c r i p t i o n f o r such p i c t u r e s . Even the simplest of two-dimensional drawings contains a great amount of i m p l i c i t information. For example, a drawing c o n s i s t i n g of only two l i n e s contains information about the lengths, the p o s i t i o n s , and the angles of the l i n e s r e l a t i v e to a frame of reference and r e l a t i v e to each other; also whether they are s o l i d , dotted, dashed, i n t e r s e c t i n g , e t c . The more complicated the drawing, the greater the amount of such i m p l i c i t information becomes. Even more confusing i s the case where pictu r e s are considered to include grey-levels and raster s i z e s , common factors where pictures are d i g i t i z e d f o r processing. To s i m p l i f y the d e s c r i p t i o n , we w i l l look at only generation, not recognition, of p i c t u r e s and consider a l l p i c t u r e s to be l i n e drawings c o n s i s t i n g of s o l i d l i n e s of equal thickness. 3.1 P r i m i t i v e s The p r i m i t i v e s of a language are the constants defined i n the language that can be broken down no further. In Fortran these are the r e a l , integer, and l o g i c a l constants, i n a graphic language they are the basic p i c t u r e constants. Line drawings consist of l i n e s , or rather l i n e segments. The dot can be treated e i t h e r as a l i n e segment of length zero or as a s p e c i a l symbol. Defining only DOT and LINE as the p r i m i t i v e s of a graphic language i s s u f f i c i e n t , but t r e a t i n g p i c t u r e s d i r e c t l y at t h i s p r i m i t i v e l e v e l i s rather bothersome and so usually some a d d i t i o n a l p r i m i t i v e s 7 are defined i n the language as a help f o r the programmer. A set could consist of elementary geometric symbols l i k e : DOT, LINE, SQUARE, CIRCLE, TRIANGLE, ARC, e t c . The representation of the numbers and the characters of the alphabet are also often defined i n the language as p i c t u r e p r i m i t i v e s . Depending on the display hardware other characters may be included. 3.2 Operators The operators of a language are the symbols that stand f o r manipulations to be performed on variables and constants. Here our i n -complete understanding of pictures becomes evident. We are able to define b a s i c mathematical operators l i k e +, -, * for manipulating numbers without trouble, as we are so f a m i l i a r with using these symbols i n c a l -culus where they are w e l l defined. A b a s i c set of operators f o r p i c t u r e s , however, i s not as e a s i l y extracted from geometry, the mathematical d i s c i p l i n e which studies manipulation of two dimensional s t r u c t u r e s . Even i n c l u d i n g other relevant d i s c i p l i n e s , as Graph Theory and Set Theory, does not b r i n g us much cl o s e r to understanding pi c t u r e s yet. Research i s being done i n t h i s d i r e c t i o n , however [8]. The e a s i e s t way of f i n d i n g a useful set of operators i s by comparing e x i s t i n g graphic languages and p i c k i n g out features that seem desira b l e . As an example we s h a l l consider the process of b u i l d i n g up p i c t u r e s : One operator should allow us to add subimages together to form a p i c t u r e . This operation can be done as a superposition of two pictures or as a concatenation of two p i c t u r e s . (a) In the case of superposition some coordinate system must be known 8 for both subpictures. This leads to considering each subpicture to be defined i n a "frame" [10],and superposition involves superimposing the two frames, b) In the case of concatenation, the p i c t u r e s must contain some s p e c i a l l y designated points at which they can be j o i n e d together. This leads to considering each subpicture as having a "head" and a " t a i l " and concatenating pictures head to t a i l only [13]. Both approaches have t h e i r l i m i t a t i o n s , i n (a) i t i s d i f f i c u l t to keep track of what i s now connected to what and i n (b) each subpicture i s l i m i t e d to one head and one t a i l . Further operators should allow us to delete p i c t u r e s or parts of p i c t u r e s , to move p i c t u r e s , to scale p i c t u r e s and maybe to display p i c t u r e s . As no arithmetic operators, apart from + f o r adding and -f o r d e l e t i n g , seem to apply to p i c t u r e s i n a n a t u r a l manner, most other forms of manipulation are described as functions. Giving these func-tions mnemonic names makes them easy to remember. Examples: SCALE, MOVE TO, ROTATE, WINDOW, DISPLAY ... or b u i l t i n constraints l i k e : PARALLEL, VERTICAL, POINT ON LINE ... 3.3 Assignments In b u i l d i n g pictures i t must be possible to give names to subpictures, i n order to use these names for b u i l d i n g up more compli-cated p i c t u r e s . Most languages include the assignment statement i n one way or another. The symbol used i s the same as i n arithmetic assign-ments (=, : = , •«-) . Some published languages use instead a procedure oriented approach. Instead of assigning a p i c t o r i a l expression 9 to a v a r i a b l e , they assign a procedure to a v a r i a b l e . This procedure i s executed whenever the va r i a b l e i s referenced i n the program and causes the corresponding picture to be drawn. The d e c i s i o n f o r or against display procedures w i l l most l i k e l y be influenced strongly by the programming language a v a i l a b l e f o r the implementation. Procedure oriented languages such as Euler have been used s u c c e s f u l l y for designing graphic languages [16] and s i m i l a r r e s u l t s have been achieved using APL and APL-like structures [4,6], The reason that the language used f o r the im-plementation shows through so strongly i n the design of a graphic language i s the following. The creation of a complete, v e r s a t i l e computer language can be a huge task i f c a r r i e d out from b a s i c s . However, i f the graphic language i s defined as an extention of an e x i s t i n g algorithmic language, only those constants, operators, and functions that are not already a v a i l -able need to be included. Features such as, e.g. branching, c o n d i t i o n a l and arithmetic statements and the complete I/O handling f a c i l i t y can be used d i r e c t l y as defined i n the algorithmic language which now takes the place of "host-language" for the graphics language. Thus a graphics program i s r e a l l y a mixture of graphics statements and host-language statements, and the designer of such a language w i l l usually choose h i s graphics syntax d e f i n i t i o n s to f i t i n with the o v e r a l l syntax structure of the host-language. 10 4. THE LANGUAGE IGL The acronym IGL stands f o r I n t e r a c t i v e Graphics Language, a computer language for handling l i n e drawings. This language not only allows the d e f i n i t i o n and display of l i n e drawings but also has f u l l f a c i l i t i e s for manipulating, naming, i d e n t i f y i n g and i n t e r a c t i n g with such drawings. Through the use of windowing techniques, parts of the drawing can be magnified f o r closer inspection or scaled down for greater display density. Commands are further provided for saving and re s t o r i n g drawings on secondary storage. An ap p l i c a t i o n s program written i n IGL appears to be a mixture of statements f o r graphical manipulations and host-language statements. The d i s t i n c t i o n between the two i s made on a card-by-card b a s i s , the graphical statements having a s p e c i a l character (*) i n the f i r s t column of each card. The compilation i s executed i n two stages: f i r s t a compilation from IGL i n t o host-language, secondly a compilation of the host-language i n t o machine language. Because of i t s widespread use and support, Fortran IV was chosen both as host-language for IGL and as programming language f o r the routines i n the IGL runtime l i b r a r y . This one-language approach provides almost complete p o r t a b i l i t y from one computer i n s t a l l a t i o n to another. 4.1 Syntax The graphical aspects of the syntax of IGL are based on the work of F. Nake [14]. In addition to e x i s t i n g types of constants and variables i n the host-language (e.g. integer, r e a l , e t c . ) , the new type IMAGE i s introduced. Image constants are e i t h e r elements from the set 11 {BLANK, DOT, LINE, SQUARE, TRIANGLE, CIRCLE, HALFCIRCLE} or s t r i n g s of l i t e r a l s (keyboard characters). Image variables are defined with the aid of the image assignment operation (:=) by image expressions which are s t r i n g s of image constants and/or va r i a b l e s j o i n e d by d i a d i c image operators. Image constants and variables are i n i t i a l l y defined on the unit square.as follows: BLANK LINE DOT SQUARE TRIANGLE CIRCLE HCIRCLE For each use of an image v a r i a b l e , a set. of a t t r i b u t e s i s attached de-f i n i n g coordinates, scale, and angle of r o t a t i o n of the p i c t u r e which the v a r i a b l e represents. These a t t r i b u t e s can be redefined with the use of unary image operators, hence a f f i n e transformations such as t r a n s l a t i o n , s c a l i n g , r o t a t i o n and mirroring can be applied. For i l l u s t r a t i o n , the following image assignment statements define an image v a r i a b l e to represent the symbol " r e s i s t o r " . * HR:= LINE FROM 0,.5 TO .4,.5 + LINE FROM .4,.5 TO .425,1 * + LINE FROM .425,1 TO .5,0; * R:= HR + HR VSYM .5; The r i g h t hand sides of both statements employ the di a d i c image operator + (superposition). The f i r s t , statement defines a temporary image v a r i a b l e HR by superimposing the image constant LINE three times, each time modified with the image operator FROM ... TO ... i n the desired manner. 12 HR R The second statement defines the v a r i a b l e R as a superposition of HR and the r e f l e c t i o n of HR on the v e r t i c a l at x = .5, thus completing the symbol " r e s i s t o r " . The numeric operands of image operators may be not only numeric constants but can be numerical v a r i a b l e s of the host-language as w e l l . Therefore, complicated p i c t u r e s can be defined with image assign-ment statements imbedded i n statements of the host language, e.g. i n loops. For example, the following program portion: S = .25*SQRT(2.) SC = 2.*S ALPHA = P I / A . * BRIDGE:= BLANK; DO 100 I = 1, A XI = .5 + S * SIN(ALPHA) Y l = .5 - S * COS(ALPHA) * BRIDGE:= BRIDGE + R AT XI,Yl SCALE SC,.l ANGLE ALPHA; 100 ALPHA = ALPHA + PI/2. * DISPLAY BRIDGE; would display a r e s i s t o r bridge: 13 The f a c i l i t i e s described above allow the creation and naming of items c a l l e d image v a r i a b l e s . For most a p p l i c a t i o n s , however, an a d d i t i o n a l f a c i l i t y i s needed to group into l o g i c a l groupings, items that do not n e c e s s a r i l y look a l i k e . As an example consider an e l e c t r o n i c c i r c u i t diagram. At f i r s t glance i t may seem to be composed of a l i m i t e d set of i d e n t i c a l symbols. Apart from being i n d i f f e r e n t places i n a c i r c u i t , two r e s i s t o r s , e.g., may seem to be duplicates of each other. A c l o s e r examination, however, shows that the. leads of the f i r s t have d i f f e r e n t lengths than the leads of the second and that the l a b e l s d i f f e r from one another. Such d e t a i l s as the length of the leads and the l a b e l are properties of the p i c t u r e s representing the i n d i v i d u a l r e s i s t o r s and must be taken i n t o account. A second category of v a r i a b l e s , sub-s c r i p t e d image v a r i a b l e s , i s therefore defined i n the syntax. Subscripted v a r i a b l e s names are names of items that are not n e c e s s a r i l y a f f i n e trans-formations of one another, but that are l o g i c a l l y members of the same set. A l l network elements i n a c i r c u i t can thus be named, e.g., ELEMENT(I) regardless of whether they are r e s i s t o r s , capacitors e t c . A l t e r -n a t i v e l y , i f t h i s d i s t i n c t i o n i s important, a l l r e s i s t o r s i n a c i r c u i t can be named RESISTOR (I) regardless of the length of t h e i r leads or 14 the l e t t e r s i n t h e i r l a b e l . Example: * RESISTOR (3): = R AT X,Y SCALE S l +.LEAD FROM XI,Yl TO X2,Y2 + * LEAD FROM X3,Y3 TO . X4 ,Y4 + 'R' AT X5,Y5 + VALUE(3) AT X6,Y6; * CIRCUIT:= CIRCUIT + RESISTOR(3); The function VALUE, used i n this example, allows the conversion of an integer value to an image value. A s i m i l a r function, TEXT, accepts a v a r i a b l e containing a text s t r i n g f o r conversion. For a more d e t a i l e d d e s c r i p t i o n of the IGL syntax and semantics, the reader i s r e f e r r e d to the IGL Users' Guide i n Appendix A of t h i s t h e s i s . 4.2 I n t e r a c t i o n Describing the i n t e r a c t i v e process means defi n i n g the response of the system to each input. The response i s not only dependent on the type of input, but also on the state of the system at the time the input occurred. W.H. Newman [15] has proposed to treat the system as a f i n i t e -state automaton where the response i s determined by the state of the program as w e l l as by the action. The actions are inputs to the auto-maton, which cause i t to change i t s s t a t e ; reactions are the outputs. The i n t e r a c t i o n i s then best described i n the form of a state diagram, which i s used as a guide when w r i t i n g the program. To f a c i l i -tate this process, the syntax of IGL allows a close correspondence be-tween the state diagram notation and the formulation i n the program. This aspect of the IGL-system i s based on the work of P. B o u l l i e r et a l . [1]. The program i s divided i n t o states which correspond to the states 15 i n the diagram. For each input (e.g. a h i t on a menu symbol on the screen) a decision i s made within the current state of the program as to which state i s to be executed next. For an i l l u s t r a t i o n , see Figure 1. The d i v i s i o n into states also provides a p h y s i c a l segmentation of the program which can be used f o r paging or overlaying at computer i n s t a l l a t i o n s with i n s u f f i c i e n t core storage for the e n t i r e program, this w i l l be discussed i n greater d e t a i l i n Chapter 7. Control s t a t e -ments are defined i n the language to allow v a r i a b l e s to be displayed on the screen, to turn on the cursor or cross-hairs (which can be p o s i -tioned by the user with the help of some graphical input device such as a j o y - s t i c k , tracker b a l l or l i g h t pen) and to detect an i n t e r r u p t from the user, s i g n a l l i n g that he has chosen an item on the screen. A s p e c i a l v a r i a b l e : IHIT i s used i n the program to i n d i c a t e the s u b s c r i p t of the item l a s t i d e n t i f i e d on the screen. This subscript allows the programmer to r e f e r to items that are pointed at by the user when he i s i n t e r a c t i n g with the program. For example the sequence: * DISPLAY 'IDENTIFY RESISTOR TO BE DELETED' AT .2,.9; * . CURSOR ON; WAIT FOR INTERRUPT; * FOR HIT ON RESISTOR: CIRCUIT:= CIRCUIT - RESISTOR (IHIT); would prompt the user to s e l e c t the r e s i s t o r to be deleted and would execute the d e l e t i o n . 4.3 Semantics and Data Structure The semantics are defined i n the routines i n the runtime l i b r a r y that perform the actions s p e c i f i e d by the statements w r i t t e n i n the program. The c o n t r o l and i n t e r a c t i o n routines a f f e c t the sequence of the execution and the communication with the graphics terminal, 16 Fig. 1 Sample IGL program * STATE 15 C C —» DEFINE ELEMENTS AND MENUSYMBQLS C * ?« C f»«'cAPACITOR * HALFC LEAD t LINE FROM , 4 , 0 TO , 4,t? * C »s HALFC + HALFC VSYM , 5 • MARKER? 9 * « ? 9 U C MENUC0MMAND3 * DELETE? = 'DELETE'? SAVE:='SAVE'J ROTATE: = 'ROT ATEt5 t t t * GOTO STATE 2; * END STATE If * STATE 38 C C • STATE 3 8 PICKING FROM THE MENU C * DISPLAY 'CHOOSE FROM MENU' AT « l r „ 9 ; * CURSOR ON? WAIT FOR INTERRUPT? * FOR HIT ON M E N U S * FOR HIT ON DELETE! GOTO STATE. 4? END; * FOR HIT ON ROTATE: GOTO STATE 5 ; END? * FOR HIT ON SAVE; GOTO STATE 6? END? R « 8 fi « S * END f 1 1 1 9 9 t * END STATE 3 ? * STATE 51 C C STATE 5 I ROTATING AN ELEMENT C * DISPLAY 'PICK ELEMENT TO BE REVERSED' AT ,1,,2| * CURSOR ON? WAIT FOR INTERRUPT? * FOR HIT ON MENU! GOTO STATE 3 ? END? * FOR HIT OM ELEMENT: * AN s ANGLE (ELEMENT UHIT) ) ? PI = 3 , 1 M 5 9 3 AN=AN+PI * ANGLFCELEMENTCIHIT)) = AN? * ERASE SCREEN? DISPLAY CIRCUIT? * END? GOTO STATE 3 ? * END STATE 5 ? 17 whereas the assignment routines operate on a data structure that represents the current state of the p i c t o r i a l information. The display i s derived a l g o r i t h m i c a l l y from t h i s s tructure and no separate display f i l e i s needed. The correspondence between the v a r i a b l e names used i n the program and the locati o n s i n the data structure i s kept through a hash-coded directory where a l l names are stored together with pointers to the st r u c t u r e . (For a d e s c r i p t i o n of hash-coding see [11]). The data structure i s implemented as a l i n k e d l i s t [9,21] with "brother"-pointers l i n k i n g items that are connected by the (+) operator and "son"-pointers l i n k i n g downwards through the structure to subitems and p r i m i t i v e s that are used i n the d e f i n i t i o n of items. No "father"-pointers are kept l i n k i n g upwards through the s t r u c t u r e , so i t would not be possible to say e.g. i n which items the p r i m i t i v e LINE i s referenced. This means that the cursor i d e n t i f i c a t i o n on the screen does not follow the usual pattern of determining which l i n e i s c l o s e s t to the l o c a t i o n of the cursor and then determining to which item this l i n e belongs. Instead, the syntax of the i d e n t i f i c a t i o n statement: FOR HIT ON <variablename>: <statementlist> END; allows a scan of a l l items with the name <variablename>, which are l i n k e d by a d d i t i o n a l "buddy"-pointers, to determine whether any of those items were wit h i n a tolerance region ( s p e c i f i e d by the x and y-scale of the item) around the cursor l o c a t i o n . 4.4 System Configuration Two implementations are used at t h i s u n i v e r s i t y . One runs under the MTS timesharing system on an IBM 360/67 with an Adage/10 graphics terminal, Calcomp and l i n e - p r i n t e r p l o t t e r s . This system i s used mainly for debugging new programs. The other system runs under 18 .DOS on a Data General 20k Supernova with a Tektronix 4010 graphics terminal. Graphics programs can be run on e i t h e r system without mo f i c a t i o n . 19 5. IGLCOM, AN IGL COMPILER IGLCOM, the IGL compiler used i n t h i s implementation was w r i t t e n using the XPL compiler w r i t i n g system [12]. This i s a w e l l documented and easy to use program package w r i t -ten i n the XPL d i a l e c t of PL/I. To b u i l d a compiler using the XPL system, the language syntax i n Backus Naur notation (BNF) and the corresponding semantics i n XPL must be supplied. These two user components are pro-cessed as follows. The syntax i s read i n , p r i n t e d , analyzed and a parser i s punched out by the XPL program ANALYZER. ANALYZER w i l l check that the grammar i s unambiguous and w i l l attempt to modify the grammar i f that i s not the case. The produced parser i s i n a format that allows i t to be d i r e c t l y i n s e r t e d i n t o a compiler framework c a l l e d SKELETON. SKELETON i t s e l f i s w r i t t e n i n XPL and has two open s l o t s , one f o r accepting the parser from ANALYZER and one f o r acepting the se-mantics. When these two components have been added, SKELETON can be compiled by the XPL compiler producing f o r the input grammar a compiler i n object code. The semantics are written as an XPL procedure named SYNTHESIZE. This procedure i s c a l l e d i n SKELETON each time a grammar ru l e i s applied by the parser for reducing the input s t r i n g . The number of the p a r t i -cular rule applied i s passed along as an argument. In SYNTHESIZE the output language i s generated. I f the output i s i n a high l e v e l language, the output statements w i l l usually consist of c a l l s to semantic routines. I f the output i s i n assembly language, the actions can be generated d i r e c t l y . For passing names from, the input to the output language, SYNTHESIZE has access to the contents of the parsing stacks. Pointers 20 are kept by SKELETON to show the current state of these stacks. This automation of the compiler-writing process allows changes to the language to be c a r r i e d out e a s i l y when needed. The syntax and the corresponding semantics can be updated independently of one another. Compilers generated by the XPL system provide good e r r o r checking f a c i l i -t i e s and have proven to be quite e f f i c i e n t . Complete l i s t i n g s of the IGL syntax d e s c r i p t i o n i n BNF and of the SYNTHESIZE routines can be found i n Appendix C of t h i s t h e s i s . 21 6. IGLRUNLIB, AN IGL RUNTIME LIBRARY The routines i n IGLRUNLIB maintain a datastructure, represen-t i n g the p i c t o r i a l information created by the executing IGL program, and handle the communication with the graphics terminal. 6.1 Datastructure The o v e r a l l datastructure has been introduced i n Chapter 4. I t consists of a l i n k e d l i s t of datablocks, addressable through a hash-coded d i r e c t o r y . The d i r e c t o r y contains the name, the l o c a t i o n of the f i r s t d e f i n i t i o n datablock and the l o c a t i o n of the f i r s t datablock that references that d e f i n i t i o n f or every named item. The p r i m i t i v e s , de-f i n e d i n the language, are flagged i n the d i r e c t o r y to prevent t h e i r a l t e r a t i o n by the program. Datablocks The datablocks contain the l o c a t i o n (xloc, yloc), s c a l i n g (xscale, y s c a l e ) , r o t a t i o n (angle), and subscript (tag) of a p i c t u r e item, aid three pointers as l i n k s to other items. 22 xloc, y l o c xscale,yscale angle, tag BROTHER BUDDY SON A datablock The son-pointer l i n k s the datablock to i t s d e f i n i t i o n block(s) i n the stru c t u r e . It i s a one-way pointer; no pointers l i n k "sons" back to "fathers". The datablocks for the p r i m i t i v e s have son-pointers that point to t h e i r graphical d e s c r i p t i o n i n an array of (x,y,ipen) t r i p l e s . To d i s t i n g u i s h t h i s pointer from normal son-pointers, a value of 10,000 i s added to i t s correct value. Example: * A:= SQUARE SCALE .1; B:= A ANGLE 45; A X SQUARE / B 0 X Y i SQUARE i s here a son of A, who i s i n turn a son of B. 23 The brother pointer l i n k s together datablocks that are l o g i -c a l l y connected by the (+) operator. The end of the l i n k i s i n d i c a t e d by a zero entry. Brother pointers e x i s t on two l e v e l s : "stronger" l i n k s within the d e f i n i t i o n of subscripted v a r i a b l e s and "weaker" l i n k s within the d e f i n i t i o n of unsubscripted v a r i a b l e s . This allows a two l e v e l hierarchy within a l i n e a r l i s t . Example: * E(2):= A + B; C:= E(2) + A; C The statement: * C:= C-E(2); would now cause the de l e t i o n of both of the f i r s t two blocks i n C, as they are l i n k e d by the stronger l i n k s . The t h i r d block, however, w i l l be retained as i t i s l i n k e d by a weaker l i n k , meaning that although i t i s part of C, i t i s not a part of E ( 2 ) . The buddy pointer l i n k s together datablocks that have the same name. They are e s s e n t i a l f o r access to any item given by name and 24 su b s c r i p t . This access i s accomplished as follows: The name i s looked up i n the di r e c t o r y , where the l o c a t i o n of the f i r s t d e f i n i t i o n and refer-encing block i s found. A sequential search of a l l blocks with that name i s made by following the buddy pointers. A comparison between the stored "tag" i n the datablock and the subscript given allows the item to be i d e n t i f i e d . As the buddy pointers are l i n k e d i n a closed r i n g , the end of an unsuccessful search i s determined when returning to the f i r s t block. Example: * C:= E ( l ) + E(2) ; D:= E(3); C E(2) 1 brother \ son son \ D ' buddy / son 6.2 Display Algorithm For d i s p l a y i n g a p i c t u r e , the information i n the data struc-ture has to be transformed into a l i n e a r sequence of beam or pen move-ments on the display device. * In the following the terms father, son and brother are de-fin e d as shown: 25 B A x ^ A i s the f a t h e r of B and C • B i s the f i r s t son of A / i \ 1 1 C i s B's brother The a l g o r i t h m i s the f o l l o w i n g : S t a r t i n g a t the image to be d i s p l a y e d , the f i r s t son (subimage) i s taken and the v a l u a t i o n of the f a t h e r ap-p l i e d . The v a l u a t i o n i s the set of a t t r i b u t e s : (XLOC, YLOC, XSCALE, YSCALE, ANGLE). This i s c a r r i e d out r e p e t i t i v e l y u n t i l a p r i m i t i v e i s encountered, the intermediate steps being saved i n a push-down stack. Then the p r i m i t i v e i s d i s p l a y e d using the accumulated t r a n s f o r m a t i o n s . A f t e r t h i s , the top item i n the push-down stack i s popped up and i t i s t r e a t e d as a new s t a r t i n g image. This process i s stopped when the s t a c k i s empty and a l l brothers of the o r i g i n a l f a t h e r have been considered. The process i s i l l u s t r a t e d by the f l o w c h a r t i n F i g . 2. In order to be able to apply a f a t h e r ' s v a l u a t i o n to h i s son we must consider the f o l l o w i n g : The v a l u a t i o n i n v o l v e s a SCALING, ROTATION and TRANSLATION of some p o i n t P (X,Y) i n a coordinate system. The equations f o r t h i s t r a n s f o r m a t i o n are: X = (X - 0.5) XSCALE ' COSa - (Y - 0.5) YSCALE • ' SINct + XLOC Y = (X - 0.5) XSCALE • SINa + (Y - 0.5) YSCALE * COSa + YLOC or: P = [A] ' P + [B] where: XSCALE • COSa [A] = XSCALE ' SINa -YSCALE • SINa YSCALE * COSa DISPLAY 'NAME' Get pointer to 'NAME*' Push down into stack Get f i r s t son Figure 2: DISPLAY algorithm 27 [B] = Storing the valuation as ([A], [B]) rather than as (XLOC, YLOC, XSCALE, YSCALE, a) allows us to apply one v a l u a t i o n (A^, B^) to another (A g, B g ) . P = A, P + B. = A„ (A P + B ) + B.. f f f v s s f = A. A P + A. B + B = A P + B f s f s f ->- A = A £ • A f s B = A£ B + B £  f s f For t h i s reason the i n t e r n a l representation of the v a l u a t i o n components i s a sextuplet (A^^, A^^, A^> -^22' B l ' B2^ r a t n e r t n a n the quintuplet used i n the IGL-syntax. 6.3 Terminal Interface The communication with the graphics terminal takes place on a l o g i c a l l e v e l , using a coordinate system of 1.0 by 1.0 as defined i n the language. Keeping this i n t e r f a c e on a l o g i c a l l e v e l , rather than on a p h y s i c a l l e v e l , makes i t r e l a t i v e l y easy to i n t e r f a c e to d i f f e r e n t terminals. The l o g i c a l terminal i s assumed to be capable of four things: - erase the screen - move the beam or draw a vector from the current beam p o s i t i o n to l o c a t i o n X,Y - display a t e x t s t r i n g of n characters, s t a r t i n g at l o c a t i o n X,Y - display a cursor on the screen, wait for the user to p o s i t i o n the cursor, return the X,Y coordinates of the cursor, and the vrnr J. YSCALE • SINa - XSCALE • COSa  XSCALE • SINa + YSCALE • COSa 28 charactercode of the button pushed by the user to in d i c a t e his i n t e r r u p t . The c a l l i n g sequences are: CALL ERASE IPEN = 0: move beam CALL VECTOR (X,Y,IPEN) IPEN = 1: draw vector CALL DISPS (ITEXT, X.Y.N) CALL WAITIN COMMON/CURSOR/IDUMMY, X,Y, KEYHIT Any other input/output can be programmed using conventional Fortran WRITE and READ statements. 29 7. IMPLEMENTATION OF IGL ON A DATA GENERAL SUPERNOVA MINICOMPUTER Although, during the implementation phase, every effort was made to keep the programs hardware independent, i t was unavoidable that the particular computer system used had some influence on the decisions that were made. The most far-reaching decision was made in choosing Fortran as programming language for the runtime library. Although the language Fortran IV was standardized by ASA i n 1964 [7], a combination of practical considerations and the ambiguities in the published description of the language have led to the present situation, where the Fortran compilers supplied by computer manufacturers include most ( i f not a l l ) features of ASA Fortran and, to make up for any deficiencies, usually offer added on special features not found i n ASA Fortran. The average user of such a compiler w i l l tend to regard his particular expanded subset of ASA Fortran as the "only Fortran" and distrust any other implementa-tions of the language. This i s particularly the case i f the implementa-tion used is the IBM Fortran IV G-level compiler, regarded by many as the ultimate definition of the Fortran language. The runtime library was written in a subset of Fortran common to the IBM and Data General compilers. These routines can thus be executed on either computer without modification. This fact does not insure, however, that these routines w i l l execute on any computer due to the above reasons. Only the routines that communicate with the graphics terminal differ in the two implementations. The routines for the Tektronix 4010 terminal are written in assembler. They were supplied with the terminal 30 and are documented by Tektronix. The routines for the Adage/10 terminal are written i n Fortran using the UBC AGT:BASIC support package and can be found i n Appendix D of this t h e s i s . The same r e s t r i c t i o n s that apply to the runtime l i b r a r y apply to any user program written i n IGL. A program that w i l l execute c o r r e c t l y on the IBM 360 may not do so on the Supernova. The Users' Guide l i s t s some of the points to be watched when w r i t i n g a program, most of which need not concern us here. There are a few points, though, that are of more general i n t e r e s t and may apply to a number of computers. Wordlength - Many t h i r d generation computers have followed the example of the IBM 360 system, using a wordlength of 32 b i t s (4 bytes), divided i n t o 2 halfwords of 16 b i t s (2 bytes). Fortran compilers on these machines t y p i c a l l y allow integer wordlengths of one word (INTEGER*4) or of one halfword (INTEGERS) . For numerical algorithms t h i s f a c t i s of no great s i g n i f i c a n c e as long as i t i s kept i n mind that the l a r g e s t allowable INTEGER*2 value i s 32767, which may be quite low f o r many problems. More noticeable i s the e f f e c t on the character handling c a p a b i l i t i e s , which i n Fortran are l i n k e d to the integer wordlength. Many minicomputers are organized around a wordlength of 16 b i t s , which leaves them with the r e s t r i c t i o n of allowing only INTEGER*2 values. The Supernova i s an example. To be compatible between the two machines, only 16 b i t integers should be used f o r character manipulation. These facts n a t u r a l l y l i m i t the p o r t a b i l i t y of any Fortran program from one computer i n s t a l l a t i o n to another, but i n t e r a c t i v e programs e s p e c i a l l y are dependent on character handling for evaluating responses and values typed i n by the user. 31 Storage - 16 b i t machines are designed to use two computer words for s t o r i n g a f l o a t i n g point value. One word would not permit s u f f i c i e n t accuracy. This means that the storage of REAL values uses twice the amount of space needed for s t o r i n g the same number of INTEGER values. For t h i s reason, a l l arrays representing the IGL datastructure are stored as integer values. This i s at a cost i n accuracy (4-5 versus 7 decimal p l a c e s ) , a cost i n conversion f o r arithmetic operations, and at the r i s k of integer overflow i f unexpected large values should occur. Another problem i n storage on a minicomputer i s the very f i n i t e s i z e of the main memory. Designers of operating systems and programmers of large programs have resorted to various techniques of using a v a i l a b l e external storage space ( f i x e d or moving head disk) to augment the power of the main (core or semiconductor) memory. The simplest technique i s to keep part of the data used on external storage and read i t i n every time i t i s to be used. Another p o s s i b i l i t y i s to keep part of the program to be executed on external storage and read i t i n t o the main memory when needed; t h i s scheme i s generally r e f e r r e d to as overlaying. The Data General disk operating system allows up to 6 l e v e l s of overlays and i n addition allows chaining of segments. To understand the difference between these two methods, we consider the following example. 32 1) Routine A - T - A 2) Routine A CALL B CALL C A CALL B B END END Routine B __ C B CALL C END C We assume that any of the routines A-D w i l l f i t i n t o the main memory separately, but no two routines w i l l f i t i n together. Each routine i s now considered a separate program segment. In case 1), the execution of segment A must be suspended f o r segment B to be brought i n t o core. When B has f i n i s h e d , A can continue. As A, however, would be over-w r i t t e n by B, i t must f i r s t be saved. An overlay thus i n v o l v e s : - saving the current segment A - loading the needed segment B - s t a r t i n g the execution of B. A return from overlay involves: - reloading the previous segment A - r e s t a r t i n g the execution of A at the l o c a t i o n where the In case 2), the execution of segment A i s f i n i s h e d when segment B i s needed. There i s thus no need to save A, and B can be loaded d i r e c t l y . This process i s c a l l e d chaining. A chaining involves: - loading the needed segment B execution was suspended. 33 - s t a r t i n g the execution of B. A r e t u r n from ch a i n i n g does not e x i s t . The communication between segments i s only p o s s i b l e through the BLANK COMMON area, the only p a r t of core that i s n e i t h e r saved nor r e s t o r e d when executing an overlay. (Communication by saving r e l e v a n t data on e x t e r n a l storage i s of course always p o s s i b l e ) . The present v e r s i o n of DOS (r e l e a s e 5) w i l l , however (contr a r y to i t s d e s c r i p t i o n ) , s t o r e and l o a d a l l of core, i n c l u d i n g blank common. This can be pre-vented by c a l l i n g the i n i t i a l i z a t i o n r o u t i n e INCOM, des c r i b e d i n Ap-pendix D. T h e . d i v i s i o n of an IGL program i n t o s t a t e s makes an automatic o v e r l a y i n g scheme f e a s i b l e . Each s t a t e corresponds to a separate ov e r l a y segment. As no r e t u r n to a previous s t a t e i s provided f o r i n the IGL syntax, segments can be chained. Apart from savin g time ( c h a i n i n g : 3 s e c , o v e r l a y : 7 sec. i n our system), the c h a i n i n g allows the execution to proceed at the same l e v e l i n DOS, thus s e t t i n g no l i m i t to the number of s t a t e s to be executed. The IGL compiler t r a n s -l a t e s the goto statement: GOTO STATE n i n t o : CALL CHAIN ('STAT n.SV'), where n i s the number of the s t a t e to be executed. (n = n f o r n > 9, ii = 0 n f o r n $ 9) . Because of the l i m i t e d storage s i z e of 20k words main memory, i t was i n i t i a l l y found t h a t the runtime l i b r a r y was t a k i n g up too much space, l e a v i n g only a m i n i s c u l e amount f o r the user program. The s o l u -t i o n has been t o move the d i s p l a y and e r r o r r o u t i n e s to separate o v e r l a y segments. This i s r e g r e t t a b l e , as the d i s p l a y r o u t i n e s are c a l l e d o f t e n , and executing an overlay f o r each d i s p l a y command causes a very n o t i c e a b l e pause i n the i n t e r a c t i o n . 34 For an analysis of th i s situation., i t i s useful to examine the storage a l l o c a t i o n within the main memory and see which parameters can be varied. With an IGL program executing, the main memory of the computer i s roughly divided up as follows: Page zero and Fortran addresses .5 k IGL user program 1.5 k * IGLRUNLIB 4.5k(*) Fortran runtime l i b r a r y 4 k DOS stacks 1 k BLANK COMMON 2.5 k * DOS SYSTEM 6 k 20 k Of these sections, only the s t a r r e d values are v a r i a b l e , a l l others -are f i x e d , regardless of program s i z e . What would now be the e f f e c t of increasing the memory s i z e by 4k to 24 k words? The following changes could be made to the current implementation: - The display routines are added to the main segment (1.5 k) - The BLANK COMMON area and user program are allowed an a d d i t i o n a l 2.5 k. This would mean instant response to a display command, more data storage and la r g e r (and hopefully more i n t e r e s t i n g ) a p p l i c a t i o n s . The present implementation i s s u c c e s s f u l , i n as f a r as i t proves that an IGL system can be implemented and used on a moderately small machine. For the system to be t r u l y convenient and s u f f i c i e n t l y powerful f o r r e a l world a p p l i c a t i o n s , however, a minimum storage s i z e of 24 k words i s absolutely necessary. 35 8. EXPERIENCE WITH USING THE IMPLEMENTED IGL SYSTEM The f l e x i b i l i t y and ease of use make the language IGL i d e a l f o r experimenting with new graphics techniques and ideas. To gain ex-perience with the system, se v e r a l applications were programmed by d i f -ferent users. (See Appendix B). F i r s t p rojects were a program for drawing e l e c t r o n i c c i r c u i t s and a load flow program f o r the analysis of power systems [3]. In two 12 week systems lab p r o j e c t s , groups of fourth year students i n this department implemented complete i n t e r -a c t i v e systems; one for i n t e r a c t i v e p r o j e c t scheduling using CPM methods and one f o r i n t e r a c t i v e nonlinear c i r c u i t a n a l y s i s , [17]. Both systems run on a minicomputer i n t h i s department and i n t e r f a c e to analysis programs on the IBM 360 i n s t a l l a t i o n i n the Computer Centre. A voice grade data l i n k i s used for transmitting data from one computer to another. The experience gained so f a r i n the use of the language has already proven a number of advantages over present-day graphics systems. Due to the d e f i n i t i o n of the syntax and the semantics, changes of these are e a s i l y incorporated as experience i s gained i n the use of the language. The system has been found f a r easier to use than the graphical subroutine packages found on most computer i n s t a l l a t i o n s . The language i s r e a d i l y learned by users with previous h i g h - l e v e l language experience. As no extensive t e s t i n g and.documentation i s necessary due to the r e a d a b i l i t y of the program, the time required for the completion of a project i s greatly reduced. Furthermore, the a v a i l a b i l i t y of a new powerful t o o l stimulates the imagination of the user to tackle pro-blems previously considered out of reach. 36 9. BIBLIOGRAPHY U n t i l recently, l i t t l e i n t e r a c t i o n has taken place between the d i f f e r e n t workers i n the f i e l d of Computer Graphics. No textbooks e x i s -ted on graphics and a r t i c l e s were scattered throughout various p u b l i c a -tions such as Communications of the ACM, Computing Surveys, AFIPS con-ference proceedings etc. However, i n 1970 a f i r s t conference was held on Computer Graphics at Brunei University. In 19 72, the jou r n a l "Computer Graphics and Image Processing" appeared and a working conference on Graphic Languages was held by IFIPS at the Un i v e r s i t y of B.C. F i n a l l y , an excel l e n t textbook has appeared i n 1973, " P r i n c i p l e s of I n t e r a c t i v e Computer Graphics", by W.H. Newman, that contains the essence of a way of thinking about computer graphics that was developed over the l a s t 10 years. 37 REFERENCES 1. P. B o u l l i e r et a l . , "METAVISU, A general purpose graphic system", i n F. Nake,. A. Rosenfeld, Eds., Graphic Languages, Amsterdam: North-Holland Publ. Co., 1972. 2. I.W. Cotton, R.S. Greatorex, "Data structures and techniques f o r re-mote computer graphics", AFIPS Proc. FJCC, 1968. 3. B.A. Dixon, "Interactive Graphical Load Flow", submitted to: I n t e r -n a t i o n a l E l e c t r i c a l , E l e c t r o n i c s Conference and Exposition, Toronto, Oct. 1973. 4. J.D. Duf f i n , "A language f o r l i n e drawing", Tech. Rep. #20, Comp. Sc. Dept., U. of Toronto, May 1970. 5. A.J. Frank, " B - l i n e , B e l l l i n e draining language", AFIPS Proc. FJCC, 1968. 6. "Grapple - Graphical Programming Language Reference Manual", B e l l -Northern Research, Feb. 19 72. 7. "History and Summary of FORTRAN standardization development f o r the ASA". Comm. ACM, Oct. 1964. 8. IFIP Working Conference on Graphic Languages, i n F. Nake, A. Rosen-f e l d Eds., Graphic Languages, Amsterdam: North-Holland Publ. Co., 1972. 9. D.E. Knuth, The Art of Computer Programming, V o l . 1, Addison-Wesley, 1969. 10. H.E. Kulsrud, "A general purpose Graphic Language", Comm. ACM, A p r i l 1968. 11. W.D. Maurer, "An improved Hash Code f or s c a t t e r storage", Comm. ACM, January 1968. 12. W.M. McKeeman et a l . , A Compiler Generator, P r e n t i c e - H a l l , 1970. 13. W.F. M i l l e r , A.C. Shaw, " L i n g u i s t i c methods i n p i c t u r e processing -A survey", AFIPS Proc. FJCC, 1968. *• 14. F. Nake, "A proposed language f o r the d e f i n i t i o n of a r b i t r a r y two-dimensional signs" i n 0.1. Grusser, R. Klinke, Eds., Zeichenerkennung  i n biologischen und technischen Systemen. B e r l i n : Springer, 19 71. 15. W.M. Newman, "A system for i n t e r a c t i v e graphical programming", AFIPS  Proc. SJCC, 1968. 16. W.M. Newman, R.F. S p r o u l l , P r i n c i p l e s of Int e r a c t i v e Computer Graphics, McGraw-Hill, 19 73. 38 17. B. Pieke, G.F. Schrack, "I n t e r a c t i v e c i r c u i t analysis using a high-l e v e l graphics language", 16th Midwest Symposium on C i r c u i t Theory, Waterloo, 1973. 18. M.D. Prince, I n t e r a c t i v e Graphics for_Computer-Aided Design, Addison-Wesley, 1971. 19. S. Semrau, "PDP-9 c i r c u i t input program", E.E. Dept., U. of B r i t i s h Columbia, 19 71. 20. I.E. Sutherland, "SKETCHPAD - A man-machine graphical communication system", AFIPS Proc. SJCC, 1963. 21. R. Williams, "Asurvey of data structures f o r computer graphics systems", Computing Surveys, March 1971. APPENDICES 40 APPENDIX A: IGL USERS' GUIDE 1. Introduction IGL i s an acronym f or In t e r a c t i v e Graphics Language, a com-puter language for w r i t i n g programs for handling l i n e drawings. This language not only allows the d e f i n i t i o n and display of l i n e drawings, but also has f u l l f a c i l i t i e s f o r manipulating, naming, i d e n t i f y i n g and i n t e r a c t i n g with such drawings. The IGL system consists of IGLCOM, the IGL compiler, and IGLRUNLIB, the IGL runtime l i b r a r y . 2. The IGL Language The d e f i n i t i o n of the IGL language has been formally given i n BNF notation, but t h i s d e f i n i t i o n should not be required reading f o r the average user. Instead, this users' guide w i l l attempt to introduce the language i n a less formal manner, using examples to explain the use of IGL statements. IGL has been implemented as an extension to Fortran IV, allow-ing the user to mix Fortran IV and IGL statements i n the same program. IGL statements are recognized by the IGL compiler by examining the f i r s t column of each l i n e . The characters . {_, 0, 1...9, C, A, X} i n d i -cate a Fortran statement, any other character an IGL statement. In a l l examples i n t h i s manual, the character * w i l l be used to i n d i c a t e IGL statements. The rules f o r the coding of IGL statements do not follow the Fortran convention. IGL statements can be w r i t t e n i n free format, with no regard f o r card boundaries. One rule should be followed, however. Keywords i n e i t h e r Fortran or IGL are considered to be reserved words. 41 They cannot be used as var i a b l e names and must be written without im-bedded blanks. Keywords should be separated by at l e a s t one blank. Example: RE~AD, which i s l e g a l i n IBM Fortran IV i s not l e g a l i n an IGL program. 3. Writing an IGL Program An IGL program i s divided up into s t a t e s , each state corres-ponds to a l o g i c a l state i n the i n t e r a c t i o n . Consider the following example: A 'rubber-band' l i n e can be created by means of a joy-s t i c k and a push-button i n a sequence of f i v e operations. 1) press button to turn on cursor; . 2) move cursor, using j o y s t i c k , to s t a r t i n g point of l i n e ; 3) press button to f i x s t a r t i n g point; 4) move cursor to end point of l i n e ; 5) press button to f i x end point. A state diagram might look as seen on the next page. Here a feature i s added to allow d e l e t i o n of l i n e s and to continue drawing l i n e s from the l a s t endpoint. Each of the 5 states shown represents a d i f f e r e n t stage i n the i n t e r a c t i o n . This can be seen by the meaning of the push-button i n each s t a t e . i n state 2 i t means: F i x the s t a r t i n g point of a new l i n e , and the end point of the l i n e i n s t ate 4 : Execute a command from the menu i n state 5 : Delete the l i n e that i s pointed to An IGL program that corresponds to t h i s state diagram would look as follows: 42 STATE DIAGRAM (creating a 'rubber-band' drawing) f INITIALISATIONS I press button f o r d e l e t i o n 43 * STATE H C C — IN IT IALISATIONS ' C COMMON X i , X ? , Y l , Y 2 , I * NEWLINE J = 'Nf;w L INE>; DELETE J = I DELETE I ; * DRAWING»=NEWLINE SCALE , 1 , , 1 AT 1 , 1 5 , , 8 + DELETE SCALE , 1 # , 1 AT 1 , 1 5 , , 6 ; 1 = 0 X1 = 0 , Y1 = 0, PAUSE 'PRESS BUTTON I * ERASE SCREEN? DISPLAY DRAWING; GOTO STATE 2 ; END STATE 1; * STATE 2J C C —«» STORING STARTING AND ENDING POINT OF A LINE C COMMON X 1 , X 2 , Y 1 , Y 2 , I * CURSOR ON; WAIT FOR INTERRUPT; X1=XHIT Y1=YHIT * DISPLAY DOT AT X I , Y l ; * CURSOR ON; WAIT FOR INTERRUPT; X2=XHIT Y2=YHIT * GOTO STATE 3; END STATE 2; * STATE 3j C . . . . . . . . . . . C - ~ * ADDING LINE TO DRAWING C COMMON X l , X 2 , Y i , Y 2 , I 1 = 1 + 1 * L C I ) : = L I N b FROM X I , Y l TO X 2 , Y 2 ; DISPLAY L U ) ; * DRAWING:=DRAWING + L C I ) ; * GOTO STATE 4; ENU STATE 3; * STATE 4 : C C — CHOOSING FROM MENU C COMMON X 1 , X 2 , Y 1 , Y 2 , I * CURSOR ON; WAIT FOR INTERRUPT; * FOR HIT ON NEWLINE: GOTO STATE 2; END; * FOR HIT ON D E L E T E : GOTO STATE 5; END; X1=X2 Y1=Y2 X2=XHIT Y2=YHIT * GOTO STATE 3; END STATE 4; * STATE 5 : C C — - DELETING A LINE C COMMON XI , X 2 , Y 1 , Y 2 , I * DISPLAY 'CHOOSE LINES TO BE DELETED' AT , 2 , , 9 ; 1 CONTINUE * CURSOR ON; WAIT FOR INTERRUPT; * FOR HIT ON L l DRAWING f= DRAW1NG-L(I HIT) ; GOTO 1 * END; * ERASE SCREEN; DISPLAY DRAWING; GOTO STATE 2> * END STATE 5; * EOF EOF EOF 44 This example shows how the i n t e r a c t i o n can be programmed i n IGL and already uses most of the statement types to be described below. A number of points should be noted here, however. - The program i s divided i n t o states of which the f i r s t to be executed must be STATE 1. - Fortran variables can be passed between states using BLANK COMMON only. The length of BLANK COMMON areas must be declared equal i n a l l s t a t e s . - Fortran statement numbers are l o c a l to st a t e s . - A l l statements i n IGL are terminated using a semicolon (;). Cons tants There are.two types of image constants i n IGL: p i c t u r e con-stants and l i t e r a l constants. Picture constants form the set {BLANK, LINE, DOT, SQUARE, TRIANGLE, CIRCLE, HCIRCLE} and are defined as shown below. BLANK LINE DOT SQUARE TRIANGLE CIRCLE HCIRCLE L i t e r a l constants are t e x t s t r i n g s , delimited by quotemarks. They can have a maximum length of 10 characters. Functions are provided to convert Fortran values to corres-ponding IGL image values. 45 VALUE converts an integer value TEXT converts an integer v a r i a b l e containing a t e x t s t r i n g . (The s t r i n g i s assumed to be 10 characters long). Example: 'DELETE', 'HI, THERE', VALUE (3) or TEXT (ITEXT) are l i t e r a l constants. Variables Image va r i a b l e s stand f o r p i c t u r e s and/or l i t e r a l s and can be assigned image values. They are named according to the Fortran rules f o r v a r i a b l e names, but can have up to 8 characters. Example: DELETE or RESISTOR are l e g a l v a r i a b l e names. Assignments ] Image variables are assigned values using an assignment s t a t e -ment. The image assignment operator i s the (:=). A l l values on the ri g h t hand side of the assignment must have been previously defined. Example: * DELETE:= 'DELETE'; A:= SQUARE; B:= VALUE (13); Modifiers Constants and variables can be modified, using v a l u a t i o n modifiers. A l l a f f i n e transformations can be applied. The modifiers are: - t r a n s l a t i o n : AT x,y - s c a l i n g : SCALE xs , ys or SCALE s - r o t a t i o n : ANGLE alpha - mirroring: VSYM axis or HSYM axis (the lower case names stand f o r Fortran REAL values) 46 Any combination of these can be s p e c i f i e d and w i l l be applied i n the following order: Scaling, r o t a t i o n , t r a n s l a t i o n , mirroring As a l l p i c t u r e v a r i a b les are defined within a unit square, i t helps to v i s u a l i s e what happens to t h i s square when the modifiers are applied. Example: * A:= TRIANGLE SCALE dx, dy ANGLE alpha AT x,y; * B:= A VSYM ax; I ax TRIANGLE Pi* B For l i n e segments, the modifiers as given are akward to use. The f o l l o w -i n g can be used: -FROM x l , x l TO y2, y2 This corresponds to: SCALE xs , ys ANGLE alpha AT x,y where: XS = SQRT ((X2-X1) 2 + (Y2 - Y l ) 2 ) YS = .1 * XS ALPHA = ARCTAN ((Y2 - Y1)/(X2-X1)) * 180/ir X = (XI + X2)/2 Y = (Y l + Y2)/2 Example: * HORIZON:= LINE FROM 0,.3 TO 1,.3; LINE HORIZON Note: A t r a i l i n g decimal point need not be w r i t t e n . No value l a r g e r than 3.0 should be used. (Larger values may produce integer overflow at runtime). I f the s c a l i n g factors f o r X and Y are i d e n t i c a l , only one value need be given. Example: * SUN: = CIRCLE SCALE .1; CIRCLE SUN Default values are assigned f o r any modifiers that are not s p e c i f i e d . The default values are: SCALE 1,1 ANGLE 0 AT .5,.5 Expressions The right hand side of an assignment can be an image expression. The operators are (+) for superposition and (—) for d e l e t i o n . Example: •* SUNSET:= HORIZON + SUN AT .6,.6; * M00N:= HCIRCLE SCALE .1 + HCIRCLE SCALE .05,.1; * NIGHT:= SUNSET - SUN + MOON AT .A,.8; 48 0 SUNSET MOON NIGHT Subscripted variables It may be useful to assign the same v a r i a b l e name to p i c t u r e s that are not a f f i n e transformations of one another. Assume that R and C are defined as follows: R C Both may be r e f e r r e d to as ELEMENTS (E): * E ( l ) : = R; E(2):= C; * DIAGRAM: = E ( l ) SCALE dx, dy AT xl.'yl + E(2) SCALE dx,dy AT x2, y2; or a l t e r n a t i v e l y : * E ( l ) : = R SCALE dx, dy AT x l , y l ; * E(2):= C SCALE dx, dy AT x2, y l ; ' • * DIAGRAM:= E ( l ) + E(2); I d e n t i f i c a t i o n and Hitarea An important feature of each p i c t u r e item i s the s i z e of the area surrounding i t which i s i d e n t i f i e d on the screen as being part of the item. This area i s c a l l e d the h i t a r e a of the item. The s i z e of 4 9 the h i t a r e a i s defined by the XSCALE and YSCALE a t t r i b u t e s of the item. This means that the h i t a r e a corresponds to the o r i g i n a l u n i t square i n which the item was defined. A d i s t i n c t i o n must be made between item d e f i n i t i o n s and uses of items: A d e f i n i t i o n : P:= TRIANGLE SCALE .5; defines the item P. Every time the item p i s referenced i n def i n i n g other items, a use of the item P i s created. Its h i t a r e a i s the s i z e of the unit square of P, modified according.to the a t t r i b u t e s of this use of P. Example: * PICTURE:= P SCALE .2,.6 AT .7,.6; TRIANGLE P PICTURE The dotted square of s i z e .2 by .6 i s the h i t a r e a of P. Because P was defined as a t r i a n g l e , scaled by a f a c t o r - j , the h i t a r e a of a l l uses of P w i l l be rectangles double the siz e of the t r i a n g l e displayed. Note: For h i t a r e a s i z e , the modifiers applied to subscripted v a r i a b l e s are cumulative. 5 • Example: *Q(3):= SQUARE SCALE .5; PICTURE:= Q(3) SCALE .2,.6; The h i t a r e a f o r Q ( 3 ) i s .5'(.2 by .6) = . 1 by .3. The reason for t h i s i s that there i s only one item Q(3). I f i t i s modified, i t s at t r i b u t e s are changed. In constrast, there may appear, many uses of P, 50 each with i t s own h i t a r e a . Interaction I d e n t i f i c a t i o n on the screen i s accomplished as follows: The statements: CURSOR ON; WAIT FOR INTERRUPT; cause the cursor (crosshairs) to be displayed on the screen and cause the program to wait for a key to-be pressed on the keyboard. When a key i s pressed, the X and Y coordinates of the cursor are stored i n the global Fortran v a r i a b l e s XHIT and YHIT and the l i t e r a l code of the key i n KEYHIT. (On the Nova: ASCII code of key i n l e f t byte, r i g h t byte = n u l l j o n the 360: EBCDIC code of key i s l e f t byte, r i g h t bytes = blanks). The statement: FOR HIT ON <variable>: <statement l i s t > END; allows the user to determine whether the cursor was within the h i t a r e a of any item named <variable>. Is th i s the case, the statements i n <statement l i s t > are executed and the subscript of the item h i t i s stored i n the Fortran v a r i a b l e IHIT. I f there was no h i t , the program w i l l branch to the statement following the END. For-statements can be nested but the nesting has to close within each s t a t e . I f an unsubscripted v a r i a b l e i s i d e n t i f i e d on the screen, the v a r i a b l e IHIT contains the value 0. Example: •* * FOR HIT ON MENUAREA: * FOR HIT ON DELETE: GOTO STATE 5; END: * FOR HIT ON ROTATE: GOTO STATE 4; END; « * END; 51 *-'-FOR HIT ON E: * CIRCUIT:= CIRCUIT - E(IHIT); * END * CURSOR ON; WAIT FOR INTERRUPT; * CIRCUIT:= CIRCUIT + NODE SCALE .03 AT XHIT, YHIT; A t t r i b u t e functions The functions XLOC, YLOC, XSCALE, YSCALE, ANGLE and TAG allow access to the a t t r i b u t e s given to any pi c t u r e item. Note the use of the equal sign (=). Example: * XI = XLOC (ELEMENT (IHIT)); * ANGLE (E(IHIT)) = ALPHA2; * TAG (Q(3)) = 4; The l a s t statement w i l l cause the item p r e v i o u s l y c a l l e d Q(3) to be renamed Q(4). Q(3) now no longer e x i s t s . Jumps The GOTO STATE n statement i s used to tr a n s f e r c o n t r o l to the beginning of another s t a t e . Within a sta t e , Fortran.GOTO's and labels (statement numbers) should be used. Example: * GOTO STATE 2; or GOTO STATE 2; 52 Display Statements A number of commands allow the user c o n t r o l over the graphics terminal. A display statement causes an item to be displayed on the screen. Example: * DISPLAY CIRCUIT; DISPLAY R AT XI, Y l ; * DISPLAY 'GOOD MORNING' AT .7,-8; The erase statement: ERASE SCREEN w i l l cause the screen to be erased. P a r t i a l erasure of the screen i s not p o s s i b l e . The Tektronix 4010 screen The unit square i s mapped onto the rectangular screen as f o l -lows : 1.3,1 1.3,0 The screen i s p h y s i c a l l y addressable by 781 x 1024 points, corresponding to a 1 x 1.3 r a t i o . The character s i z e on the screen i s f i x e d (approx. 14 x 22 p o i n t s ) . Textstrings are neit h e r scaled nor rotated. Such values, i f given, are ignored for display purposes. Writing to and reading from the terminal can furth e r be pro-grammed i n Fortran. The terminal i s addressed as. a teletype (output: WRITE (10), input: READ (11)). Vectors can be drawn on the screen using the IGL statement: DRAW FROM x l , y l to x2, y2. Such vectors are not stored i n the data s t r u c t u r e . T I I I 53 Example: C DRAW A GRID, RASTER SIZE = .05 .. DO 1 I = 1, 21 V = 0.5 * (1-1) * DRAW FROM 0, V to 1, V; DRAW FROM V,0 TO V , l ; 1 CONTINUE Windowing The display command allows a window to be set to show only part of a pic t u r e on the screen. Example: * DISPLAY CIRCUIT WITHIN XI, Y l DXl, DY1 ONTO X2, Y2 DX2, DY2; Y l ( v i r t u a l picture) DXl (screen) Y2 Saving and re s t o r i n g on secondary storage The statement: * STORE nm,n; w i l l cause the complete IGL data structure and i n a d d i t i o n a following blank common area of n words to be stored on a disk f i l e with the name as s p e c i f i e d i n the v a r i a b l e nm. This f i l e w i l l be created i f i t does not already e x i s t . The corresponding statement: * RESTORE nm,n; w i l l cause the f i l e as s p e c i f i e d i n nm to be read n and used as the current data s t r u c t u r e . 54 Differences between the IBM 360 version and the Data General Supernova  version of IGL The differences between the two implementations are twofold: 1) The procedure for compiling and running IGL i s d i f f e r e n t , 2) The two Fortran implementations are d i f f e r e n t . Procedures f o r compiling and executing IGL programs IBM 360 Datagen Supernova F i r s t card i n program: * 360 VERSION * NOVA VERSION Compiling program: $R ELEC:XPL 0 = ELEC:.IGLCOM 2 = -OUT SCARDS = igl - s o u r c e SPRINT = i g l - l i s t i n g ' Compiling intermediate Fortran program $R * FORTRAN SCARDS = -OUT SPUNCH = i g l - o b j e c t or $R*'WATFIV PAR=SIZE=40 SCARDS= -OUT+ELEC:IGLRUNLIB.S Execute Program $R igl-object+ELEC:IGLRUNLIB 9 = p l o t f i l e (plots go to p l o t f i l e ) or $R igl-object+ELEC:IGLAGTLIB ( i n t e r a c t i o n through Adage terminal) Transfer -OUT to Supernova, s p l i t up X into i n d i v i d u a l programs, one f o r each state, named STAT01...STATn FORT STAT01; FORT STAT02 ... RLDR STAT01 IGLRUNLIB; ... IGLGO^ ( i n t e r a c t i o n through Tek-t r o n i x 4010 terminal). 55 Differences i n the Fortran implementation on the IBM 360 and the Data- gen Supernova Below, a l i s t i s given of the major v a r i a t i o n s of Datagen;.For-tran from the IBM Fortran IV d e f i n i t i o n . - A l l variables not stored i n COMMON are placed on a run-time stack. Any program that does not a l t e r COMMON storage i s therefore a reentrant program. (Variables i n subroutines (or states) are not saved from one c a l l to the next!) - Program units must be ordered as follows: FUNCTION, SUBROUTINE statement. - Declaration statements. These begin with the keywords COMMON, COMPLEX, DIMENSION, DOUBLE, EQUIVALENCE, EXTERNAL, INTEGER, LOGICAL or REAL. .- Statement functions and i n t e r n a l subprograms (FORMAT statements .and DATA i n i t i a l i z a t i o n statements may be given i n t h i s area). - Executable statements. (FORMAT statements and DATA i n i t i a l i -zations may be given i n this area). - Imbedded blanks are s i g n i f i c a n t except when they appear i n the name of a program v a r i a b l e or i n the statement i d e n t i f i e r GOTO (GO TO) . - Statement i d e n t i f i e r s , operator names, and names of l i b r a r y functions are reserved and cannot be used as program v a r i a b l e s . The reserved names are: 56 . A N D . ASSIGN D A T A N D R E A L L O G I C A L . E O T . A T A N D A T A N 2 DSIGN M A X 0 . E Q . A T A N 2 D A T N 2 DSIN M A X 1 . F A L S E . B A C K S P A C E D B L E D S Q R T MIN0 . G E . BINARY D C ABS - D T A N MINI . G T . B L O C K D A T A D C C O S D T A N H M O D . L E . DABS D C E X P E N D F I L E P A R A M E T E R . L T . C A L L D C L O G E N T R Y P A U S E . N E . C C O S D C M P L X E Q U I V A L E N C E R E A D . N O T . C E X P D C O S E X P R E A L . OR. C L O G DCSIN E X T E R N A L R E T U R N . T R U E . C M P L X D C S Q R T F L O A T R E W I N D ABS C O M M O N D E X P F O R M A T SIGN A C C E P T C O M P I L E R D E X O A T F U N C T I O N SIN A I M A G C O M P L E X D I M G O T O SINH A INT • C O N j G IABS S N G L A L O G C O N T I N U E D L O G IDIM S Q R T A L O G 1 0 COS . D L O G 10 IDINT STOP A M A X 0 CSIN D M A X 1 IF S U B R O U T I N E A M A X 1 C S Q R T D M INI IFIX T A N AMINO DABS D M O D INT T A N I-1 AMIN1 D A I M A G D O I N T E G E R T Y P E A M O D D A T A D O U B L E PRECISION ISIGN W R I T E - Names i d e n t i c a l to DGC extended assembler mnemonics are not av a i l a b l e f o r use as subprogram names. - DATA i n i t i a l i z a t i o n i s provided f o r lab e l e d COMMON only. - Only COMMON variables can be EQUIVALENCed. - DATA i n i t i a l i z a t i o n of labe l e d COMMON i s pos s i b l e i n any Fortran program or subprogram. - Subprogram names must be unique within the f i r s t f i v e chara-cters (ANSI standard i s s i x ) . - The characters > and < cannot be used i n H o l l e r i t h . . s t r i n g s . 57 - A l l integers are of length 2 bytes - A l l r e a l s are length 4 bytes - Data i n i t i a l i z a t i o n statements use the n u l l character as f i l l character. S Format uses the n u l l character as f i l l character (A Format uses the blank character, as on the IBM 360) - Read and write statements use unit numbers 11 and 10. Example: DATA IA/'A'/ AO DATA IA/'A '/ A^ FORMAT (Al) A_ FORMAT(SI) AO For complete information on IBM Fortran, consult: IBM System/360 FORTRAN IV Language, document //C28-6515-7 For Data General Fortran: DGC FORTRAN IV USER'S MANUAL, #093-000053. APPENDIX B ILLUSTRATIONS FROM IGL PROGRAMS: NETWORK ANALYSIS, CPM, LOAD FLOW PICK TWO NODES AND AN ELEMENT, LAST NODE I S SftUEO Rl<> C l r R O T A T E D E L E T E L A B E L U A L U E S SAME REDRAW A N A L Y Z E P L O T R E S T A R T © INSERT DELETE A C T I V I T Y RELATION REDRAW MOVE 20 3 12C 52" D E L E T E R O T A T E KEY MORO h-1 62 APPENDIX C LISTINGS: IGL-SYNTAX, IGLCOM (Only routines that d i f f e r from the published XPL d e s c r i p t i o n [12] are shown). 6 3 P R O D U C T I O N S 1 <PROGRAM> :1= E S T A T E S * 2 <STATES> !!= <STATE> 3 I <STATES> <STATE* U <STATE> ! : = <STATE HEAD> : <STATEMENTLIST> <STATE ENDING* > 5 <STATE HEAD> :!= STATE <NUMBER> 6 <STATEMENTL1ST* ::= S T A T E M E N T * 7 I <STATEMENTLIST> <STATEMENT> 8 <STATE ENDING> . S:= END S.TATE <NUHBER* 9 <STATEMENT> ::= <PICTORIAL ASSIGNMENT> j 10 I <NUMER 1 CAL ASSIGNMENT> f 11 I <0ISPLAY STATEMENT* J 12 I <F0R CONSTRUCT* f 13 I <GOTO STATEMENT* J 1« I <WAIT STATEMENT* J 15 " I <TRACKING STATEMENT* f 16 I <ERASE STATEMENT* ; 17 I <HUOT STATEMENT* ) IB I <FILE STATEMENT* J 19 I 1 20 <PICTORIAl ASSIGNMENT* J'.= <VARIABLE* <REPLACE* <EXPRESSION* 21 N U M E R I C A L ASSIGNMENT* ::= <F0RTRAN V A R I A B L E * = <FORTRANVARIABLE* 22 <REPLACE> tt = t = 23 <DISPLAY STATEMENT* !:= DISPLAY <VIRTUAL IMAGE* 24 I DISPLAY <VIRTUAL IMAGE* ONTO <VALUEPAIR> <VALUEPAIR> 25 <VIRTUAL IMAGE* : : s <IMAGE* 26 I < I M A G E > EVALUATION* 27 < IM A G E * : := <VAR I A B L E * 28 I <VARIABLE> WITHIN <VALUEPAIR* <VALUEPAIR* 29 I <STRING* 30 <FOR CONSTRUCT* l ? = <F0R STATEMENT* : <STATEHENTLIST* <END STATEMENT* 31 <F0R STATEMENT* ::= FOR HIT ON <VARIABLE* 32 <END STATEMENT* ::= END 64 33 <GOTO 3 T A T E M E N T > ::= GOTO STATE <NUMBER> 31 I GO TO STATE <NUMBER> 35 <WAIT STATEHENT> 11 = WAIT FOR INTERRUPT 36 <TRACKING ST.ATEMENT> I I- CURSOR ON 37 I READ CURSOR <VALUEPAIR> 38 I READ KEY F O R T R A N VARIABLF.> 39 <ERASF STATEMENT* ::= ERASE SCREEN AO <PLOT STATEMENT > :;= PLOT <COMPONENTPAIR> 11 <FILE ST ATEMENT> It- STORE <FORTRAN VARIABLE> 12 .1 RESTORE <FORTRAN V A R I A B L E * 13 <EXPRESSION> :;= <PRIMARY> 11 I <EXPRESSION> <OIADIC OPERATOR> <PRIMARY> 15 <DIADIC OPERATOR> : j= + 16 I -17 <PRIMARY> ::= <VALUATP.D VARIABLE> 18 I <VALUATED V A R I A B L E * <UNARY OPERATOR> 19 <UNARY OPERATOR* ::= VSYH < F 0 R T R A N VARI ABl,E> • 50 I HSYM <F0RTRAN VARIABLE> 51 <VALUATED VARIABLE> :!= <ITEM> <VALUATION> 52 I <ITEM> 53 <ITEM* :' . = <VARI A B L E * 51 • I <STRING> 55 I VALUE ( <F0RTRAN VARIABLE> ) 56 I TEXT ( <FORTRAN VARIABLE> ) 57 <VARIABLE> ::= <IDENTIFIER> 58 I <TAGGEO VARIABLE> 59 <TAGGED VARIABLE> ti~ <I DENT IFIER> ( <FORTRAN V A R I A B L E * ) 60 <FORTRAN VARIABLE> t : = <IDENTIFIER> 61 I <NUMBER* 62 I <COORDINATE FUNCTION> 63 C O O R D I N A T E FUNCTION> » : = <FUNCTIONHEAD> <VARIABLE>.) 61 <FUNCTIONHEAD> ::= <FUNCTIONNAME> ( 65 <FUNCTIONNAME> ::= XLOC 66 I YLOC 67 I XSCALE 68 t YSCALE 69 I ANGLE 70 I TAG 71 <VALUATION> ::= COMPONENTS* 72 I <COMPONENTPAIR> 73 <COKPONENTS> : ; s <COMPONENT> 65 71 I <C0MP0NENT3> <COHPONENT> 75 <COMPONENT> ::= AT <VALUEPAIR> 76 I SCALE <VALtJEPAIR> 77 I SCALE <FORTRAN VARIABLE> 78 I ANGLE <FORTRAN VARIABLE> 79 I TAG <EORTRAN VARI ABIE> 80 <COMPONENTPAIR> ll~ FROM <VALUEPAIR> TO <VALUEPAIR> 81 <VALUEPAIR> t:= <FORTRAN VARIABLE> , <FORTRAN VARIABLE> 66 1 2 /ft CARD IMAGE HANDLING PROCEDURE $L *, 3 4 5 GET_CARD V 6 PROCEDURE? 7 /* DOES ALL CARD READING AND L I S T I N G */ 8 DECLARE I F I X E D , (TEMP, TEMPO, REST) CHARACTER, READING B I T ( l ) ; 9 DECLARE F I R S T - C A R D BIT C I ) I N I T I A L ( T R U E ) ) 10 READ! BUFFER = INPUT; 11 I F L E N G T H ( B U F F E R ) = 0 THEN 12 DO; /* SIGNAL FOR EOF */ 13 C A L L ERROR C 1 EOF M I S S I N G OR COMMENT STARTING IN COLUMN 1,1,1) 14 BUFFER = PAD ('* /*•'/* */ EOF;END;EOF ', 8 0 ) ; 15 END; 16 17 E L S E CARD_COUNT = CARD_COIJNT + 1) /* USED TO PRINT ON L I S T I N G */ 18 /* OUTPUT F I R S T L I N E BEFORE F I R S T CARD */ 19 I F FIRST_CARD=TRUE THEN DO; 20 F I.RST_C AR D = F AL5E ; END; 21 /* E L I M I N A T E FORTRAN CARDS */ 22 DO J=0 TO 1 3 ; 23 I F BYTE ( B U F F E R , 0 ) = B Y T E ( 1 C 0 1 2 3 4 5 6 7 8 9 X A I , J ) THEN 24 DO; 25 I F C O N T R O L ( B Y T E ( ' M l ) ) THEN OUTPUT=BUFFER; 26 E L S E IF C O N T R O L ( B Y T E ( * L ' ) ) THEN 27 OUTPUT = I _F 0 R M A T (CARD—COUNT,4)1 I f I I |BUFFER; 28 • O U T P U T ( 2 ) = B U F F E R ; 29 GOTO READ; 30 END; 31 END; ' 32 I F MARGIN„CHOP > 0 THEN 33 DO; /* THE MARGIN CONTROL FROM DOLLAR | */ 34 I = L E N G T H ( B U F F E R ) * MARGIN_CHOP; 35 REST = S U B S T R ( B U F F E R , I ) ; 36 BUFFER = S U B S T R ( B U F F E R , 0, I ) ; 37 END; 38 E L S E REST = " ; 39 S = S U B S T R ( B U F F E R , 0 , 1 ) ; 40 B U F F E R = S U B S T R ( B U F F E R , 1 ) ; 41 TEXT = BUFFER; 42 T E X T _ L I M 1 T = L E N G T H ( T E X T ) - 1 ; . 43 I F C O N 1 R O L C B Y T E C » M 1 ) ) THEN OUTPUT = SI I B U F F E R ) 44 E L S E I F C O N T R O L ( B Y T E ( ' L 1 ) ) THEN 45 OUTPUT = I—F ORMAT (CARD„COUNT, 4) l l » ' l | S I I BUFFER II REST; 46 CP = 0; 47 END GET.CARD; 67 1 ADD_FORTRAN_VAR s 2 PROCEDURE; /* KEEP A LIST OF FORTRAN VARIABLES USEO */ 3 1 END ADD_FORTRAN_VAR; 5 RESET: 6 PROCEDURE? /* RESET VALUATION TO DEFAULT VALUES */ 7 L 0 C = ' , 5 , , 5 i ; 8 SCALES' 1 , , 1 , l » 9 ANGLE='0 o!j 10 T AG= ' 0 ' ? 11 RETURN; 12 END RESET; 13 PAD_8S 11 PROCEDURE; /* PAD VARIABLENAME WITH BLANKS */ 15 I = LENGTH(VAR(MP) ) ; 16 IF I>8 THEN VAR(MP)=SUBSTR(VARCMP ) , 0,8) ; 17 IF I<8 THEN 18 DO; 1 9 S = SU8STRP »,I)> 20 VAR(MP)=VAR(MP) I I S ; 21 END; ' 22 RETURN; 23 END PAD-.8; 21 EXOUTt 25 PROCEDURE(VARTYPE , PRCODE,EXCODE ) ; 26 DECLARE (VARTYPE,PRCODE,EXCODE) FIXED; 27 DECLARE FILEOUT LITERALLY ' OUTPUT(2) CALL ' M l ' j 28 - DECLARE CONTINUATION LITERALLY 'OUTPUT(2) = " * M | | » ; 29 IF EXC0DE=3 THEN FILEOUT 'ASS I G ( M I VAR(MP-2)I I ' ) I ; 30 DO CASE VARTYPE; 31 ; 32 FILEOUT < PRIMA ( ' I IPRCODE I I ' , M IEXCODEI I ', ' I IVAR (MP) | I ' , ' I I LOC ! I 33 ' / M l SCALE I I ' , • I I ANGLE I I ' , M | TAG I I ' ) ' ; 31 FILEOUT 'PRIMS( ' I I PRCODE I M , ' I IEXCODEI I ' /M I LOCI I I,' '»I IVAR(MP) I I I ' < ) I ; 35 FILEOUT 'PR IMC( 1 I IPRCODEI I ',' I I EXCODE I I ' , ' I ILOC I I ' , < IIVAR(MP ) | | • ) ' ; 36 FILEOUT ' PR I MS ( ' I I PRC ODE I I ' , ' I I EXCODEI I ', • I ILOC I I 1 , ' I I VAR(MP ) | | ' ) I ; 37 END; 38 CALL RESET; 39 RETURN; 10 END EXOUT; 11 SYNTHESIZE: 12 PROCEDURE(PRODUCT ION_NUMBER); 13 DECLARE PRODUCTION_NUMBER FIXED; 11 DECLARE LABEL—ST ACK (100) CHARACTER , LP FIXED INITIAL ( 0 ) ; 15 DECLARE CARDNO.STACK (1 00 ) FIXED; 16 DECLARE STMTNO FIXED INITIAL ( 1 0 0 0 ) ; 17 DECLARE UNARY_OP CHARACTER; 18 DECLARE (NUM„VALUE,VARTYPE,FTYPE) FIXED) 19 DECLARE IK_VALUE FIXED; 50 DECLARE (EXCODE, PRCODE ) FIXED; 51 DECLARE (FNAME,VARNAME,VART AG) CHARACTER; 52 DO CA5E PRODUCTION_NUMBER; 53 ; /* CASE 0 I S A DUMMY */ 51 /* <PROGRAM> ::= <STATES> */ 55 IF MP-» = 2 THEN 68 56 DO; 57 CALL ERROR ( 1 EOF AT I N V A L I D P O I N T ' , 1 ) ; 58 CALL STACK„ DUMP; 59 END; 60 E L S E DO; 61 I F LP - i = 0 THEN DO 1 = 1 TO L P ; 62 CALL ERROR( 'UNMATCHED FOR"STATEMENT, L I N E : ' 1 1CARDNO - S T A C K ( L P ) 63 END; 64 C O M P I L I N G = F A L S E ; 6 5 END; 66 /* <STATES> :s= <STATE> */ 67 ? 68 /* <STATES> I!= <STATES> <STATE> */ 69 ; 70 /* <STATE> <ST ATE HEAD> t < S T A T E M E N T t-I S T >,' <STATE ENDING* 71 I F VAR CMP ) T.VAR (MPP1+2) THEN CALL ERROR ( 'LABEL '1 1VAR(MP) | | ' AND END ' 72 VARCMPP1+2) 1 1 ' DON ' ' T MATCH. ' , 0 ) ; 73 /* <STATE HEAD> : : = STATE <NUMBER> */ 74 DO; 75 I F L E N G T H ( V A R ( S P ) ) = 1 THEN S= • 0' 1 1 V A R ( S P ) ) 76 E L S E S = V A R ( S P ) ; 77 I F C O N T R O L ( B Y T E ( ' D ' ) ) THEN 78 O U T P U T ( 2 ) = ' SUBROUTINE STAT M I S ; 79 0 U T P U T ( 2 ) = ' C ----- STATE 1 1 I V A R ( M P P l ) 1 1 — I ; 80 OUTPUT(2)=» LOGICAL H I T 0 N ' ; 81 O U T P U T ( 2 ) = ' COMMON 1 DUMMY(3376)«; 82 V A R ( M P ) = V A R ( M P P 1 ) ; 83 END; 84 /* <STATEMENTLIST> ::= <STATEMENT* */ 85 ; 86 /* <STATEMENTLIST> ::= <STATEMENTLIST> <STATEMENT> */ 87 • i 88 /* <STATE ENDING* 5J= END STATE <NUMBER> */ 89 DO; 90 V A R ( M P ) = V A R ( S P ) ; 91 0 U T P U T ( 2 ) = ' C END STATE >1 1VAR(SP) I I ' - — f<mm 1 J 92 I F C O N T R O L C B Y T E ( ' D ' ) ) THEN 93 0 UTPUT(2)=< RETURN'; 9U O U T P U T ( 2 ) = ' END'; 95 E J E C T - P A G E ; 96 OUTPUT=' I N T E R A C T I V E GRAPHICS COMPILER ( F E B 73 V E R S I O N ) ' ; 97 DOUBLE-SPACE; 98 CARD_COUNT=0; 99 END; 100 /* <STATEMENT> = < P I C T O R I A L ASSIGNMENT* ; */ 101 ; 102 /* <STATEMENT* ::= N U M E R I C A L ASSIGNMENT* ; */ 103 ; 104 /* <STATEMENT> :; = <DISPLAY STATEMENT* ; */ 105 ; 106 , /* <STATEMENT> ::= <FOR CONSTRUCT* ; */ 107 108 /* <STATEMENT> <GOTO STATEMENT* ; */ 109 ; 110 /* <STATEMENT> 1!= <K AIT STATEMENT* ; */ H i ; 112 /* <STATEMENT> <TRACKING STATEMENT* ; */ 113 ; 114 /* <STATEMENT* ::= <ERASE STATEMENT* J * / 115 ; 69 116 / * <STATEMENT> : != <PLOT STATEMENT* t */ 117 > 118 /ft <STATEMENT> t»= <FILE STATEMENT* ; * / 119 | . 120 / * O T A T E M E N T * .•:= ; * / 121 ; 122 / * <PICT0R1AL ASSIGNMENT* '.'.= <VARI A B L E * <REPLACE* <EXPRESSION* * / 123 t 124 / * <NUMERICAL ASSIGNMENT* !:= <F0RTRAN V A R I A B L E * = <F0RTRAN V A R I A B L E * * / 125 IF BYTECVAR(MP)) = BYT E C ' ' ) THEN DO; 126 K = L E N G T H ( V A R(MP) ) » 9 ; 127 V A R ( M P ) = S U B S T R ( V A R ( M P ) , 8 , K ) ; 128 FILEOUT ' CHCHOR(I I IVAR(MP)I I I,' I IVAR(SP)I I ' ) 1 ; 129 END; 130 ELSE 0UTPUT(2) = t ' I IVAR(MP) | I I = M I V A R ( S P ) ; 131 / * <REPLACE> : J = : = * / 132 ; 133 / * <DISPLAY STATEMENT* t:- DISPLAY <VIRTUAL IMAGE* * / 134 DO; 135 DO CASE IM_VALUE; 136 FILEOUT ' D I S P L ( ' I IVAR (SP) I I » , M I LOC I M , 1 I ISCALE I I I, I | | ANGLE I I') 1 ; 137 DO; 138 IF LENGTH(VAR (SP) )>50 THEN VA R C S P ) = S U B S T R (VA R ( S P ) , 0 , 5 0 ) ; 139 FILEOUT » D I S P S ( « • 1 I I VAR(SP ) I | I M , I ; 140 CONTINUATION LOCI I l , 1 I ILENGTHCVAR (SP) ) I M ) ' ; 141 END; 142 END; 143 CALL R E S E T ; 144 END; 145 / * <DISPLAY STATEMENT* J!= DISPLAY <VIRTUAL IMAGE* ONTO <VALUEPAIR> <VALUEPAIR: 146 * / 147 IF IM_VALUE = 0 THEN DO; 148 FILEOUT ' D I S P O ( M IVAR(MP)| I • , M IVAR(MP + 2)I I ' , M IVAR(SP)I I I ) I ; 149 END; 150 / * <VIRTUAL IMAGE* :J = <IMAGE* * / 151 ; 152 / * <VIRTUAL IMAGE* ::= <IMAGE> <VALUATION* * / 153 ; 154 / * <IM A G E * ;:= <VARI A B L E * * / 155 I M „ V A L U E = 0 ; 156 / * <IMAGE> » ;= <VARI A B L E * WITHIN <VALUEPAIR> <VALUEPAIR* * / 157 DO; 158 S = VAR(SP-1 ) I I ' , I I IVAR (SP) ; 159 FILEOUT 'WITHIN( 1 I 131 I < ) I > 160 IM_VALUfc'=0; 161 END; 162 / * <IM A G E > ::= <STRING* * / 163 IM_VALUE=1; 164 / * <FOR STATEMENT* t:= FOR HIT ON <VARI A B L E * * / 165 DO; 166 OUTPUT(2) = ' 0 I I I L A B E L - S T A C K ( L P ) I I I CONTINUE' ; . 167 L P = L P - l ; 168 END; 169 / * <FOR CONSTRUCT* ::= <FOR STATEMENT* t <STATEMENTLIST> <END STATEMENT* * , 170 DO; 171 LP = LP + H 172 STMTNOsSTMTNO + 1; 173 LABEL—STACK(LP) -STMTNO; 174 CARDNO_3TACK(LP)=CARD -COUNT; 175 OUTPUT(2) = " I F ( , N Q T , HITON(" I IVAR (MPP 1+2)11 I)) GOTO 0•I I 70 176 LABEL-STACK(LP)J 177 END; 178 /* <END STATEMENT* 51= END ft/ 179 ; 180 /* <G0T0 STATEMENT* :s= GOTO STATE <NL)MBER* */ 181 DO; 182 IF LENGTHUAR (SP) ) = 1 THEN VAR(SP)= 1 0 ' I I V AR(SP); 183 IF CONTROL(BYTE(t D ' )) THEN 184 0UTPUT(2)=' CALL ST AT 1 I IVAR (SP ) | 185 ELSE 186 FILEOUT 'CHAIN(STAT 1 I IVAR(SP) I I I ,SV) ' ; 167 END; 188 /* <GOTO STATEMENT* t:= GO TO STATE <NUMBER* */ 189 DO; 190 IF LENGTH(VAR(SP ) ) = 1 THEN VAR(SP ) = »0 I I |VAR(SP ) J 191 IF C0NTROL(BYTE(»D') ) THEN 192 0UTPUT(2) = I CALL STAT 1 I IVAR (SP ) J 193 ELSE 191 FILEOUT 'CHAIN(STAT ' I IVAR(SP) I I l ,SV) ' ; 195 END; 196 /* <WAIT STATEMENT* :s= WAIT FOR INTERRUPT */ 197 FILEOUT MvAITINl; 198 /* <TRACKING STATEMENT* !:= CURSOR ON */ 199 FILEOUT 'CURSOR'; 200 /* <TRACKING STATEMENT* ::= READ CURSOR <FDRTRAN PAIR* */ 201 FILEOUT 'RDCUR( ' I I VAR(SP) I I ' ) ' ; 202 /* <TRACKING STATEMENT* ::= READ KEY <FORTRAN VARIABLE* */ 203 FILEOUT ' RDKEY ( 1 I I VAR (SP) I I ' ) ' ; 204 /* <ERASE STATEMENT* :;= ERASE SCREEN */ 205 FILEOUT 'ERASE'; -206 /* <PLOT STATEMENT* ::= PLOT <COMPOMENTPAIR* */ 207 FILEOUT l DRA*K U ILOCI I <, ' I I SCALE I I ' , U I ANGLE I I ') ' ? 208 /* < F11. E STATEMENT* ::= STORE <FORTR AN VARIABLE* */ 209 FILEOUT ' SAVE ( M I VAR (SP ) I M ) ' ; 210 /* <F1LE STATEMFNT* :: = RESTORE <FORTRAN VARIABLE* */ 211 FILEOUT 'RESTOR ( M IVAR (SP) I I ' ) ' ; 212 /* <EXPRESSION* :s= <PRIMARY* */ 213 DO; 214 EXC0DE=3; 215 CALL EXOUT(VARTYPE,PRCODE,EXCODE)> 216 END J 217 /* EXPRESSION* ::= EX P R E S S I O N * <DIADIC OPERATOR* <PR1MARY> */ 218 DO; 219 VAR(MP)=VAR(3P) ; 220 CALL EXOUT(VARTYPE,PRCODE,EXCODE); 221 END; 222 /* <DIADIC OPERATOR* t;= + */ ' 223 EXCODE=l; 224 /* <DIADIC OPERATOR* ; j = * */ 225 EXCODE=2; 226 /* <PRIMARY> ::= <VALUATED VARIABLE* */ 227 PRCODF=0; 228 /* <PRIMARY* ;:= <VALUATED VARIABLE* <UNARY OPERATOR* */ 229 DO; 230 FILEOUT ' UNARY ('I I UNARY-OP I H ) ' ; 231 PRCODE=l; 232 END; 233 /* <UNARY OPERATOR* ::= VSYM <FOKTRAN VARIABLE* */ 234 UNARY—OP='l, ' I I V A R ( S P ) ; 235 /* <UNARY OPERATOR* ::= HSYM <FORTRAN VARIABLE* */ 71 2 3 6 UfsiARY„OP= 1 2 , M I VAR ( S P ) ; 237 / * < V A L U A T f O V A R I A B L E * : : = < I T E M * < V A L U A T I O N > * / 238 ; 2 3 9 / * < V A L U A T E 0 V A R I A B L E * = <ITEM> * / 24 0 ; 241 / * < I T E M * : ? = ^ V A R I A B L E * * / 2 4 2 V A R T Y P E = 1 ; 2 4 3 / * <ITEM> S 5 = <STRING> * / 2 4 4 D O ; 2 4 5 I ~ L E N G T H ( V A R ( M P ) ) ; 2 4 6 I F I >16 THEN V A R ( M P ) = S U B S T R ( V A R ( M P ) , 0 , 16 ) | 2 4 7 I F K 1 6 THEN D O ; 2 4 6 S = S U B 9 T R ( ( 2 4 9 V A R ( M P ) u V A R ( M P ) I I S ; 2 5 0 END J 251 V A R T Y P E = 2 ; 2 5 2 E N D ; 2 5 3 / * <ITEM> : : = V A L U E ( <FORTRAN V A R I A B L E * ) * / 254 D O ; 2 5 5 V A R T Y P E " 3 ; 2 5 6 V A R ( M P ) = V A R ( M P P 1 + 1 ) ; 2 5 7 E N D ; 258 / * < I T E M * JS= TEXT ( < F 0 R T R A N V A R I A B L E * ) * / 2 5 9 D O ; 2 6 0 V A R T Y P E = 4 ; 261 V A R ( M P ) = V A R ( M P P 1 + 1) ; 2 6 2 E N D ; 2 6 3 / * < V A R I A B L E > ; : = < I D E N T I F I E R > * / 2 6 4 D O ; 2 6 5 C A L L P A D - . 8 J 2 6 6 VARNAME--VAR ( M P ) ; 2 6 7 V A R T A G - ' O ' ; 2 6 8 • V A R ( M P ) = » 1 1 • I I V A R N A M E I M ' ',' MV A R T A G ; 2 6 9 E N D ; 2 7 0 / * < V A R I A B L E * « : = <TAGGED V A R I A B L E * * / 271 ; 2 7 2 / * <TAGGED V A R I A B L E * : : = < I O E N T I F I E R > ( <FORTRAN V A R I A B L E * ) * / 2 7 3 D O ; 274 C A L L P A D _ 8 ; 2 7 5 VARNAME = V A R ( M P ) ; 2 7 6 V A R T A G = V A R ( M P P 1 + 1) ; 2 7 7 K = L E N G T H ( V A R T A G ) - 1 ; 2 7 8 I F B Y T E ( V A R T A G , K ) = R Y T E ( ' . ' ) THEN 2 7 9 V A R T A G = S U B S T R ( V A R T A G , 0 , K ) ; 2 8 0 V A R ( M P ) - ' 1 ' t | I V A R N A M E I I 1 ' ' / 1 I I V A R T A G ; 281 E N D ; 2 8 2 / * <FORTRAN V A R I A B L E * : : = <I DENT I F I E R * * / 2 8 3 C A L L A D D - F O R T R A N „ V A R ; 2 8 4 / * <FORTRAN V A R I A B L E * ! « = < N U M B E R * * / 2 8 5 / * CHECK FOR D E C I M A L DOT I N NUMBER * / 2 8 6 D O ; 2 8 7 K = 0 ; 2 6 8 DO 1=0 TO L E N G T H ( V A R ( S P ) ) - l j 2 8 9 I F B Y T E ( V A R ( S P ) , I ) = B Y T E ( ' , ' ) THEN K = l ; 2 9 0 E N D ; 291 IF K = 0 THEN V A R ( S P ) = V A R ( S P ) I I 1 , ' ; 2 9 2 E N D ; 2 9 3 / * < F 0 R T R A N V A R I A B L E * t ! " C O O R D I N A T E F U N C T I O N * * / 294 I F F T Y P E = 6 THEN V A R ( M P ) = ' I T A G F N ( M I VAR (MP ) I I ' ) « ; 2 9 5 E L S E 72 296 VAR(MP)-! CORFUN(I | I VAR (MP) I I I ) I j 297 / * COORDINATE FUNCTION* ::= < F U N C T I 0 N H C A D > <VARI ABLE* ) * / 298 II- FTYPE = 6 THEN VAR(MP)=VAR(Mpp i ) j ELSE 299 VAR(MP)=FTYPEIM,'IIVAR(MPP1); 300 / * <FUNCIIONHEAD* ::= < F U N C TI 0 N N A M E > ( * / 301 ; 302 / * < F U N C TI 0 N N A M E * ::= XLOC * / 303 FTYPE =1; 304 / * <FUNcT 10NN A(•'E* : : = YLOC * / 30b FTYPE = 2 ; 306 / * <FUNCTTONNAME* : ! = XSCALE * / 307 FTYPE = 3; 306 / * < F U N C 1IONNAME* : ; = YSCALE * / 309 FTYPE = 4; 310 / * <FUNCTIONNAME> ::= ANGLE * / 311 FTYPE = 5; 312 / * <FUNCTIONNAME* :s= TAG * / 313 FTYPE=6; 314 / * <VALUATION* :J= <C0MP0NENT3* * / 315 ; 316 / * <VALUATION* : i = COMPONENTPAIR* * / 317 1 318 / * COMPONENTS* ll" COMPONENT* * / 319 ; 320 / * COMPONENTS* ::= COMPONENTS* COMPONENT* * / 321 322 / * COMPONENT* t : = AT <VALUEPAIR* * / 323 LOC=VAR(SP); 324 / * COMPONENT* ::= SCALE <VALUEPAIR> * / 325 SCALE--VAR(SP) ; 326 / * COMPONENT* SCALE <FORTRAN VARIABLE* * / 327 3CALt = VAR(SP)I I • , • I IVAR(Sp); 328 / * COMPONENT* ll- ANGLE <F ORTRAN VARIABLE* * / 329 ANGLEsVAR(SP) ; 330 / * COMPONENT* ::= TAG <FORTRAN VARIABLE* * / 331 DO; 332 TAG=VAR(SP)f 333 K = l.ENGTH(TAG)-l ; 334 IF BYTE(TAGfK) = BYTE(' , ') THEN 335 TAG=SUBSTR(TAG,0,K); 336 END > 337 / * CQMPONENTPAIR* tl- FROM <VALUEPA1R> TO <VALUEPAIR* * / 338 DO; 339 L0C = VAR(MPP1) ; 340 SCALE=VAR(SP); 341 ANGtE='-999, « ; 342 END; 343 / * <VALUEPAIR* = <FORTRAN VARIABLE* , <FOR TRAN VARIABLE* * / 344 VAR(MP)=VAR(MP)IM,M|VAR(SP); 345 END J 346 END SYNTHESIZE; 73 APPENDIX D Device Dependent Support Routines: Supernova: INCOM, RETUR, OVERL, CHAIN. Adage /10: AGTLIB (programmed by H. Rydzik). ;P/R TO CHANGE VALUE OF <*f:MAX0 ;TO POINT TO THE BOTTOM OF BLANK COMMON AREA {TO CALL ; T It.'COMJ .ERORJ SIZE? « CALL INC Oil • TITL IHCOM .NREL .ENT ItJCOM .EXTD .CPYL,.FRET • EXTM ERROR FS. = 0 FS. JSR O.CPYL J LDA 0,CSIZE GET SIZE OF BLANK COMMON AREA NEG 0,0 ; MAKE DECREMENT .SYSTM .MEM I JMP &.EROR I JSR ©.FRET J &RETURN TO CALLING PROGRAM ERROR 000410 COMMON SIZE .END S/R TO RETURN FROM OVERLAY SEGMENT TO CALL : RETURt ERROR? .TITL .NREL .ENT .SYSTM .RTN .SYSTM .ERTN JMP CALL RETUR RETUR RETUR,ERROR .END ; S / R TO OVER!. $TO CALL J .TITL .NREL .ENT .EXTD • EXT'J AY FORTRAN PROGRAMS CALL OVERL ('NAME OVERL OVERL .CPYL,.FRET ERROR OF SEGMENT') OVERL: TEXT=-!S7 F S . = 1 JSR LDA MOVZL SUB .SYSTM .EXEC JMP JSR .ERORt ERROR 9.CPYL ;GET POINTER TO NAME 0,TEXT,5:MAKE BYTE POINTER 0 , 0 @.EROR ©.FRET ;IN AC0 ?CLEAR AC 1 ;CALL IN SEGMENT ;RETURN TO C A L L I N G PROGRAM • END : S / R TO CHAIN OVERLAY SEGMENT ;TO CALL .• CALL CHAIN ( 'NAME OF SEGMENT *> . T I T L .NREL .ENT .EXTD .EXTN CHAIN CHAIN . C P Y L . , . F R E T ERROR TEXT=-167 C H A I N S F S . JSR LDA MOVZL SUBZR .SYSTM .EXEC JMP JSR @.CPYL ;GET POINTER TO NAME 0 , T E X T , 3 ; F O R M BYTE POINTER IN AC0 0 , 0 1,1 ; S E T AC 1 BIT 0 ©.EROR ©.FRET &RETURN TO CALLING PROGRAM .EROR: » ERROR .END 76 1 C I N T E R A C T I V E ADAGE PACKAGE FOR P I E K E ' S IGL SYSTEM---2 C - - - O B J E C I DECK CONTAINS SCONTINUE WITH A G T j B A S I C THEREBY 3 CONCATENATION OF THAT F I L E IS NOT REQUIRED, 4 SUBROUTINE WA1TIN 5 C PROVIDES THE I N T E R A C T I O N - READS KEYBOARD AND CROSSHAIR LOCATION 6 LOGICAL FLAG /.TRUE,/ 7 INTEGER P L O T / i PLOT ' / , Y E S / ' Y '/ 6 COMMON/CURSOR/I H I T , X H I T , Y H I T , K E Y H I T 9 REAL 0(b) 10 IF ( F L A G ) W R I T E ( 6 , 3 0 ) 11 30 F O R M A T C A KEYBOARD ENTRY OF PLOT WILL A U T O M A T I C A L L Y ' / 12 *' COPY THE D I S P L A Y AS A P L O T F I L E ON L O G I C A L UNIT 9 , ' / / 13 *' U N S P E C I F I E D L O G I C A L UNIT PUTS P L O T F I L E IN -PLOT*,') 14 F L A G = , F A L S E , 15 1 CALL A G T M U V ( 5 9 2 5 , 1 , 3 7 ) 16 CALL D I S P L A Y S READY MESSAGE ON SCREEN 17 R E A D ( 5 , 1 0 ) K E Y H I T 18 10 FORMAT (Aa) 19 CALL A G T M O V ( 5 8 8 8 , 1 , 3 7 ) 20 CALL D I S P L A Y S WAITI MESSAGE ON SCREEN 21 C---A KEYBOARD ENTRY OF PLOT WILL AUTOMATICALLY 22 COPY THE D I S P L A Y AS A P L O T F I L E ON LOGICAL UNIT 9,---23 I F ( K E Y H I T , E Q , P L 0 T ) GO TO 100 24 CALL D I A L S ( D ) 25 X H I T = ( D C 4 ) + l , ) * 5 1 2 , / 7 8 0 , 26 Y H J T = ( D ( l ) + i , ) * 5 1 2 , / 7 8 Q , 27 RETURN 28 100 NFL AG = 0 29 W R I T E ( 6 , 2 0 ) 30 20 FORMAT( ' ' , ' I S THIS TO BE THE LAST P L O T ? ' ) 31 R E A D ( 5 , 2 1 ) 1 REPLY 32 21 FORMAT(A 1) 33 IF ( I R E P L Y . E O . Y E S ) N F L A G s l 34 CALL S A V E ( N F L A G ) 35 GO TO 1 36 END 37 C - - - - - - - -38 SUBROUTINE ERASE 39 C ERASES SCREEN A NO I N I T I A L I Z E S THE TERMINAL 40 INTEGER D I S P ( 1 1 2 ) 41 LOGICAL F L A G / . F A L S E , / 42 COMMON/POINTR/NV 43 I F ( F L A G ) GO TO 200 44 F LAG= .TRUE. 45 CALL A G T C V T ( D I S P ( 1 ) , 0 , , 0 , , 0 , 1 ) 46 CALL GENERATES AN EOF CONDITION TO KEEP STORED MESSAGES FROM BEING D I S P L A Y E D 47 CREATE MESSAGES 48 CALL A G T E X T ( - 5 , , 7 , , 1 , , 'WAITI I ,0 , , 5 , D I S P ( 2 ) , N V 0 ) 49 DO 100 J = 3 3 , 3 8 50 100 D I S P ( J ) = 0 51 CALL A G T E X T ( - 5 , , 7 , , 1 , , • R E A D Y ' , 0 , , 5 , D I S P ( 3 9 ) , NVD) 52 CREATE BLANK MESSAGE 53 DO 300 J = 7 6 , 1 1 2 5« 300 D I S P ( J ) = 0 55 200 CALL A G T D S P ( D I S P ( 1 ) , 1 1 2 , 5 8 8 7 , , T R U E , , 0 ) 77 56 CALL AGTMOVC5B88, 1 , 37 ) 57 CALLS WAIT! MESSAGE 58 NV-37 59 RETURN 60 END 61 62 SUBROUTINE VECTOR ( X i,Y1 ,IDRAw) 63 C DRAWS A VECTOR FROM PREVIOUS P O S I T I O N TO NEW X t , Y l WITH PEN 64 C UP OH DO».\ (IDRAW = 0 OR i ) 65 LOGICAL F L A G / , T R U E , / 66 INTEGER D I S P 67 COMMON/POINTR/NV 68 IF ( F L A G ) CALL CHECK 69 F L A G s , F A L S E , 70 X = X l 71 v=ri 72 CALL T S C A L E ( X , Y ) 73 NV=NV+1 74 CREATE VECTOR AND SEND TO AGT 75 CALL AGTCVT ( D I S P , X , Y , I D R A W , 0) 76 CALL A G T D S P ( P I S P , 1 , N V , , F A L S E , , 0 ) 77 RETURN 78 END 79 80 SUBROUTINE D I S P S ( I S , X I , Y l , N C ) 81 C THIS ROUTINE DYNAMICALLY ALLOCATES S U F F I C I E N T STORAGE FOR DSTEXT 82 C A L L S DSTEXT, THEN DROPS STORAGE I M M E D I A T E L Y , 83 EXTERNAL DSTEXT 84 LOGICAL FLAG/,TRUE,/ 85 INTEGER*2 I S U ) 86 IF ( F L A G ) CALL CHECK 87 F L A G = , F A L S E , 88 N=NC*10 89 CALL G S P A C E ( P 0 I S P , N * 4 ) 90 CALL C A L L E R ( D S T E X T , P D I S P , I P T R ( N ) , I P T R ( I S ) , I P T R ( X I ) , I P T R ( Y l ) # 91 H P T R ( N C ) ) 92 CALL F S P A C E ( P D I S P ) 93 RETURN 94 END 95 96 SUBROUTINE D S T E X T ( D I S P , N , I S , X I , Y l ,NC) 97 C D I S P L A Y S A CHARACTER STRING OF NC CHARACTERS AT X I , Y l 98 INTEGER D I S P ( N ) , I S * 2 ( 1 ) 99 COMMON/POINTR/NV 100 NVcNV+1 101 X = X1 102 Y = Y1 103 CALL T S C A L E ( X , Y ) 104 CALL A G T F . X T ( X , Y , 7 8 . / ? 5 6 , , I S , 0 , , N C , D 1 3 P ( 1 ),NVG) 105 I F (NVG.EU.O) GO TO 100 106 CALL A G T D S P ( D I S P ( 1 ) , N V G , N V , , F A L S E , , 0 ) 107 100 NV = NV + NVG-?1 108 RETURN 109 END 110 1 1 1 SUBROUTINE TSCALfc*(X,Y) 112 C L I M I T S X AND Y VALUES AND SCALES FROM I GL TO AGT 113 I F ( X , L T , 0 , ) X=0, 114 I F ( X , G T , 1 0 2 4 , / 7 8 0 , ) X = l 0 2 4 , / 7 8 0 , 115 I F ( Y , L T , 0 . ) Y=0, 7 8 116 I F ( Y , G T , 1 . ) Y= l , 117 x = x * 7 n o , / 5 i , 2 - 1 0 , 116 Y = Y * 7 8 0 , / 5 1 , 2 - 1 0 t 119 RETURN 120 END 121 C - - - - - - - - - - - - - - - - - - -122 SUBROUTINE SAVE ( M F L A G ) 123 C READS THE BUFFER AT THE AGT AND SENDS D I S P L A Y E D IMAGE TO L O G I C A L UNIT 9, 124 COMMON/PuINTR/^V 125 CALL A G T M 0 V C 5 9 6 2 , 1 / 3 7 ) 126 C A L L S BLANK MESSAGE 127 CALL A J P L O T ( 1 0 , , N V ) 128 CALL AGTMOVC5888,1,37) 129 C A L L S WAIT I MESSAGE 130 I F ( N F L A G . E Q , 1 ) CALL PLOTND 131 RETURN 132 END 133 c«--------- „--.--,.-.,..--,.--134 SUBROUTINE CHECK 135 C ENSURES THAT ERASE HAS BEEN CALLED BEFORE VFCTOR AND D I S P S TO 136 C I N I T I A L I Z E S C R E E N , 137 L O G I C A L F LAG/,TRUE,/ 138 I F ( F L A G ) CALL ERASE 139 F L A G = , F A L S E , 140 RETURN 141 END 

Cite

Citation Scheme:

        

Citations by CSL (citeproc-js)

Usage Statistics

Share

Embed

Customize your widget with the following options, then copy and paste the code below into the HTML of your page to embed this item in your website.
                        
                            <div id="ubcOpenCollectionsWidgetDisplay">
                            <script id="ubcOpenCollectionsWidget"
                            src="{[{embed.src}]}"
                            data-item="{[{embed.item}]}"
                            data-collection="{[{embed.collection}]}"
                            data-metadata="{[{embed.showMetadata}]}"
                            data-width="{[{embed.width}]}"
                            async >
                            </script>
                            </div>
                        
                    
IIIF logo Our image viewer uses the IIIF 2.0 standard. To load this item in other compatible viewers, use this url:
http://iiif.library.ubc.ca/presentation/dsp.831.1-0101250/manifest

Comment

Related Items