A 3D set of routines has been added to SPROGS. Although not display routines, the set does call the normal 2D routines, which can be saved in a file. A perspective projection is used on to a view plane, which is the current region.
The routine:
ZVIEW(XV,YV,ZV,D)
defines the location of the viewer (XV,YV,ZV) and the distance, D, from the viewer to the view plane in the direction of the origin. D may be negative. The viewer always looks towards the view plane and anything behind him will be hidden. There is no hidden line removal in the object itself.
The view plane may cut the object being viewed. The routine:
ZVIS(XI,XO)
will set the intensity level of all lines between the viewer and the plane to XI, and the intensity level of all lines on the other side of the view plane to XO. It is thus possible to obscure one or other of the sections by setting the appropriate intensity to zero.
The current 3D position can be moved by:
SETXYZ(X,Y,Z) and UPDXYZ(DX,DY,DZ)
Lines can be drawn by:
TODXYZ(DX,DY,DZ) TOXYZ(X,Y,Z) VECZ(X1,Y1,Z1,X2,Y2,Z2)
which are all obvious extensions of the 2D routines. 2D routines may be mixed with 3D routines, but the 3D routines will always reset the current 2D position.
3D expansion is performed by:
EXPANZ(X,Y,Z,EX,EY,EZ)
Rotation about a general axis is performed by two routines:
ROTAXZ(X1,Y1,Z1,X2,Y2,Z2)
defines the axis of rotation and:
ROTANZ(TH)
defines the angle (in radians). The order of expansion/rotation is determined by:
ERDRZ(ERDRV)
where
ERDRV = 1.0 means rotation is performed first ERDRV = 2.0 means expansion is performed first
(compare *3.6)
The high level routine:
CUBER(DX,DY,DZ)
will draw a cube from the current point with sides parallel to the respective axes,lengths DX,DY,DZ.
Example
Rotation of a cube:
SDHARD LIMIT(-3.0,-3.0,3.0,3.0 ) ZVIEW(0.0,0.0,20.0,25.0) ROTAXZ(0.0,0.0,0.0,0.0,1.0,0.0) TH = 0.0 SPT = 0.31415926 DO 10 I = 1,6 ROTANZ(TH) SETXYZ(-1.0,-1.0,-1.0) CUBER(2.0,2.0,2.0) ADVFLM 10 TH = TH + STP ENDSPR
It is sometimes necessary to output a frame repeatedly. It is possible to do this for output devices which are able to make use of basic files (*4.7) (currently SD4020 and Tektronix) by using:
ADVRPT(X)
On calling this routine with X>0.0, a basic file is set up, with filename X:::. The conditions for the use of STSAV must hold only one device selected, and no other file-saving in progress. All subsequent output up to the first advance frame order will be saved in the file, the file will be closed and copied X times to the output device. The file will then be emptied and output for the next frame saved. This is more efficient than repeating the FORTRAN commands themselves. The mechanism can be removed by calling:
ADVRPT(0.0)
If frame repetition is required during a DRAW, the display routine:
ADVCNT(X)
is available. The display routine number is 15.
ADVRPT(1.0) must be called prior to the start of the DRAW to set up the file. This will produce single frame output more slowly. ADVCNT can now be used from within a file to vary the number of frame repetitions required. ADVRPT(0.0) must still be used to delete the file from the system.
Example
Z = ANAME('FRED') STDF (2) picture orders ADVFLM ADVCNT(20.0) picture orders ADVFLM FIDF(1.0) ADVRPT(1.0) DRAW(Z) ADVRPT(0.0)
will output the first frame of FRED once and the second 20 times.
This feature is of very little use at present, but has been included to pave the way for some more high-level film routines, which will only operate on relative files (files containing TODXY, UPDXY orders only). The routine:
FREL(F,FNO)
will read the file called F, number FNO, which can consist of a mixture of absolute and relative line-drawing orders, and will issue the equivalent relative orders, starting at the current position. If FREL is called within a file definition, these relative orders will be saved in the new file.
The following routine will read a previously-written SD4020 tape and interpret the orders. This would be useful if, for example, the tape had been written on another computer and the picture required modification, or if output from the tape was required on another device (such as the Tektronix) without re-running the main program.
The tape must be assigned to MT15:
#MT15(1234,MYTAPE)
The routine:
DVITEM(IC,I,X1,X2,X3,X4)
will read the next item off the tape, combining short lines into longer ones and noting line repetition. The settings are:
IC I X1 X2 X3 X4 Meaning 1 N X Y DX DY Line from (X,Y) to (X+DX,Y+DY), repeated N times 2 X Y C M Character C (in SPROGS code), plotted at (X,Y). M ≥ 1 specifies intensity 3 N X Y L L characters to be plotted, starting at (X,Y) if N = 0, or at current position if N = 1. See below for reading the characters 4 N M Advance frame if N = 0, advance repeat M times if N = 1, reset code if N = 2 5 N Filemark.N = count of filemarks to date 6 Read error 7 N Invalid order, N = code read 8 N End of tape, N = record count 9 Record too long 10 X Y C Expose heavy, plot character C at (X,Y) 11 X Y C Expose light, plot character C at (X,Y) 12 N Select camera N (1 = microfilm, 2 = hardcopy, 3=both) 13 Stop code 14 Expand image 15 Reduce image 16 Project slide
Text is saved in an internal buffer for codes 2, 3, 10, 11. The function:
SPGCHA(N)
will return the SPROGS number of the Nth character in the buffer, or
-3.0 for SD4020 code 52 -2.0 for SD4020 code 56 (reset) -1.0 for SD4020 code 12 (no-op) 0.0 for illegal character, or N out of range
It is possible to release the tape before the job has completed by using:
CL15
This will free the deck and should be used as soon as the tape is no longer required.
It is currently possible to cause a file in the sequence list (*9) to repeat indefinitely by using the REPEAT command. Alternatively, the repetition can be specified when the file is added to the sequence list.
The second argument of:
ADSQLL(ANAME('PIC'),X,Y) ADSQLG(ANAME('PIC'),X,Y)
is a marker whose bit settings are significant (*9.2).
As with REPEAT, such a file will execute indefinitely unless terminated from another item in the sequence list. This feature means that a background, for example, can be defined by:
Z = ANAME ('PIC') STDF(Z) picture orders ADVFLM FIDF(1.0)
and drawn once using:
DRAW(Z)
It may also be added to a sequence by:
ADSQLG(Z,2.0,0.0)
when it will be repeated for each frame. Use of the REPEAT command would not allow the single frame DRAW of the same file.
Following the introduction of a NULL file to specify an irregular shaped region for scissoring, it was desirable to easily outline such a boundary.The routine:
BNDRY(FL,P)
will interpret file FL (number specified by current NUMBR setting) as containing pairs of X,Y coordinates, and will output lines to join them together. If P = 0.0, the last part will be joined to the first, otherwise the boundary will be left open.
This facility is akin to the above, but the X,Y coordinates are specified as arrays.
TOXYA(X,Y,I)
will draw lines X(1),Y(1) to X(2),Y(2) to X(3),Y(3) .... to X(I),Y(I). It is equivalent to:
SETXY(X(1),Y(1)) DO 10 J = 2,I 10 TOXY(X(J),Y(J))
but it is more efficient. However, it may not be used inside a file.
The value of the function:
UNLOAD(XIND)
is the current contents of index variable XIND, and provides a complementary routine to LOAD (*7.3).
The following is not really a new feature of SPROGS, but a facility in 1906A FORTRAN. The routines:
TEXT(N,'string') VTEXT(N,'string')
have already been defined (*6.5). Of course, it is possible to use these with variables rather than constant strings:
TEXT(N,A(1))
where array A contains packed text in A format (perhaps from a READ or DATA statement). On the I906A, it is possible to specify that an output stream goes to an array in store rather than to a device by using a Program Description Statement of the form:
OUTPUT 9 = /ARRAY
Calling the routine:
DEFBUF(N,M,A)
will connect the array A to FORTRAN stream number N, with M characters maximum. For example:
DIMENSION A(20) DEFBUF(9,160,A)
will cause all output sent to FORTRAN stream 9 to be packed into array A.
With this facility, it is possible to use the whole power of a FORTRAN format statement (as long as / is not used) to convert numbers to any text format, and then output them to the graphics device:
WRITE(9,100) X,I,J 100 FORMAT(E12.6,3X,2I6) TEXT(27,A(1))
Two routines have been provided to assist the user in drawing graphs, labelling axes etc. The first provides a standard graph, making various assumptions. The second allows the user to vary the type of labelling, tick marks, etc.
GRAPH(N,XAR,YAR,NT,TITLE,NX,XLABEL,NY,YLABEL)
where:
N Number of points for graph, the dimension of arrays XAR,YAR. XAR Single dimensioned arrays giving the X,Y coordinates of the YAR N points making the graph. Straight lines will be drawn between consecutive points. NT Number of characters to appear in the title. TITLE Text for title, either as a text constant or first element of an array containing packed text.The title will appear above the graph. NX Number of characters to appear in the X axis label. XLABEL Text for X axis label, in the same form as TITLE.The label will appear below the scaling values on the axis. NY Count and text for Y axis label, which will appear to the left YLABEL of the scaling values on the Y axis.
GRAPH will find the maximum and minimum values in arrays XAR,YAR, and scale the graph so that it fills as much of the area as possible. Axes, major and minor tick marks are provided, and scale values printed at the major tick positions. The number of major tick marks depends on the values being scaled. Ten minor ticks appear between each major tick. F format is used if the numbers lie in the range ±0.0001 to 100000.0, otherwise E format is used for the scale values.
GRAPH assumes that a region chain has been set up by one of the standard initialising routines such as SDHARD, SDFILM etc (see Section 2.2 in this Supplement) and also that Font 1 has been initialised (using GETFNT). ADVFLM can be used to draw one graph per frame. For drawing multiple graphs, see below.
Example
MASTER XX DIMENSION ARX(100),TITLE(4) DATA TITLE(1)/22H THIS GRAPH HAS A TITLE/ C values for ARX,ARY CALL SDHARD CALL GETFNT(1.0) CALL GRAPH(100,ARX,ARY,22,TITLE(1),16, *,'HORIZONTAL LABEL',14,4, 'VERTICAL LABEL') CALL ADVFLM CALL ENDSPR
GRAFT (I,N,XAR,YAR,GRAT,FORM,APLOT)
where
I Option indicator. The various options available are described below. N Count and arrays of points for graph, as for routine GRAPH XAR YAR GRAT Graticule/tick indicator 0.0 No graticules or tick marks 1.0 Tick marks, major divisions only 2.0 Tick marks, major and minor divisions 4.0 Major graticule markings 8.0 Major and minor graticule markings
Graticules will extend over the whole graph. Any combination of the above may be used (for example, 5.0 will cause major tick marks and major graticules to be drawn). Number of major ticks or graticules depends on the values being scaled (usually between 5 and 15 major marks are used). There are 10 minor divisions between each major division.
FORM Scale value format, tick mark control 0.0 Scales printed in E or F format (see GRAPH) 1.0 Scales printed in I format 2.0 No axis, tick marks or scaling for X 4.0 No axis, tick marks or scaling for Y 8.0 Y axis and scales left shifted for second graph
Any combination of these values may be used Option 8.0 should be used with option 2.0 ie [10.0] FORM does not override GRAT if graticules are requested.
APLOT Graph format 1.0 to 64.0 (option 1, 2 or 4). Graph plotted as separate points using the character defined by SPROGS number. 0.0 Graph plotted as continuous line.
FNAME (option 3 or 5). Axes, scales, etc, are to be saved in file called FNAME (real number representation of the file). This file will contain the basic device orders necessary to reproduce, for the first device encountered in the region chain, the device orders necessary to reproduce the axes quickly for subsequent graphs. No graph will be plotted.
The possible optional values of I are:
In each case, the current region is taken to contain the whole graph. Axes are drawn along the region edges and scales are printed outside the region boundary. Labelling and titling can be performed by:
TITLAB(NT,TITLE,NX,XLABEL,NY,YLABEL)
where the arguments are the same as those in GRAPH,Titles and labels are also printed outside the current region boundary, and TITLAB should be called after a call to GRAFT. Font 1 is used to print the titles, scales,etc, and must be initialised before GRAFT is called. In each case, the visibility outside the current region is altered temporarily to allow the scales, labels and titles to be seen. It does mean, however, that the current region must map into an area which occupies less than the whole screen. The following routine will provide a region with the required characteristics:
GRAFRG(R)
This defines region R in terms of the current region. Region R has the same limits but maps into approximately 0.75 of the current region, leaving a border around the edges,and is then selected. The border at the top is used for the title, that to the left for the Y axis scales and label and that at the bottom for the X axis scales and label. GRAFT option 1 is equivalent to:
GRAFRG(29.0) GRAFT(2,...)
Multiple graphs can be drawn on the same grid by using:
TOXYA (Section 5.7 of this Supplement)
or by making use of parameters:
GRAT = 0.0 FORM = 6.0
which prevent the re-drawing of scales, axes,etc. If a second Y axis labelling scheme is required, use can be made of parameter:
FORM = 10.0
which provides a scaled Y axis to the left of the normal position. The region (and therefore graph) limits can be recalculated or left the same by using option 2 or 4.
Example
C draw a graph of 100 points as a continuous line, scaling, and tick marks CALL GRAFT(2,100,ARX,ARY,2.0,0.0,0.0) C draw second graph as character plots with new Y scales CALL GRAFT(2,50,BRX,BRY,2.0,10.0,37.0) C draw third graph with same limits, different character plot CALL GRAFT(4.80,CRX,CRY,0.0,6.0,38.0)
A small change has been made to the scaling routine:
SCALA(DX,DY,X,Y,XI,XJ,YI,YJ)
(*A11). If either DX or DY is zero, that particular axis will not be scaled.