SMOG and SPROGS are fairly stable systems as regards their basic design thus it is now possible to devote more effort into providing user oriented routines. In general these routines will be available to users of both SMOG and SPROGS, therefore, only one copy that will work for either system is required. A series of notes entitled GRAPHICS USER NOTES is being issued. Each note contains documentation on a set of routines in the library and in this manner it is hoped to keep users informed of the latest developments to the two graphics systems.
Currently the library (:GRAFLIB.GRAFLIB) contairs routines for: contouring, drawing bold text, displaying complex three-dimensional objects, drawing maps, shading in areas, drawing three-dimensional histograms and curve-fitting.
An example using some of the contour plotting routines in the library is shown in section 2.8.
The use of bold/blocked text is described in ([7] 2) and the use of the standard text on the FR80 is best described in ([6] 5). This section will show the differences between the two types of text and as a result how to use both types of text.
In the example a line of text is written horizontally using the same character size for each type of text and then a word is written at ninety degrees clockwise from the horizontal to show how to rotate text.
For the example the hardcopy camera is used in "many-up" mode and the cine area is selected. The limits for this area are chosen so that x ranges from 0 to 16 and y ranges from 0 to 12. In the next four sections of the program the first subroutine called refers to the blocked characters and the other one or two refer to the FR80 hardware characters. The last section finishes the plotting.
The character sizes are chosen to be one unit high with a suitable width set up so that 16 characters can be written across the frame with sufficient spacing between each one. The text plotted is "the same line" and using blocked characters the bottom left of the string is plotted at the point (1.0,11.0) as follows:
CALL WRIGHT (1.0,11.0,'THE SAME LINE',13)
The 13 is the number of characters (including spaces) to be plotted. For hardware text the bottom left of the string is set at the point (1.0,9.0) using the standard SETXY subroutine ([6] 4.1.1) then the 13 characters are plotted as follows:
CALL SETXY(1.0,9.0) CALL HTEXT(13,'THE SAME LINE')
The next section rotates the text so that it is written downwards. For the blocked characters the text is rotated about a point, in this example it is (4.0,7.0) in a clockwise direction. The example rotates the text by ninety degrees clockwise as follows:
CALL WANGLE (4.0,7.0,90.0)
The hardware text can be written at one of eight angles, the set of angles is a multiple of forty-five degrees anticlockwise from the horizontal. The routine CHOCT is used to select the angle. In the example the required angle is ninety degrees clockwise or six lots of forty-five degrees anticlockwise. The routine is called as follows:
CALL CHOCT(6.0)
Whichever type of text is being used, the rotation routines affect all subsequent text of the appropriate type, until a different rotation is selected.
The next call outputs the word "thick" with the lower left corner at the point (4.0,7.0). The previously selected rotation rotates it about this point and thus the text is written down the frame. The writing routine is the same as before and is used as follows:
CALL WRIGHT (4.0,7.0,'THICK',5)
Similarly for the hardware text although in this case the rotation occurs about the start point of the text, in this case (11.0,7,0). The word "thin" is written as follows:
CALL SETXY(11.0,7.) CALL HTEXT(4,'THIN')
Finally the plotting is terminated by the usual call to ENDSPR, complete program and the output is shown below:
LIST MASTER TEXTTYPE C------------------------------------------------------------- c COMPARE FR80 HARDWARE TEXT WITH THE BLOCKED CHARACTERS C------------------------------------------------------------- C INITIALISE THE PLOTTING AND SELECT COORDINATES. CALL FRHCM CALL CINE CALL LIMITV (0.0,0.0,16.0,12.0) C C SET UP THE CHARACTER SIZES. CALL WCHFAC(1.0,1.0) CALL JCHSIZ (1) C C OUTPUT THE SAME LINE TWICE, CALL WRIGHT (1.0,11.0,'THE SAME LINE',13) CALL SETXY (1.0,9.0) CALL HTEXT (13,'THE SAME LINE') C C SET TEXT ROTATION TO 270 DEGREES ANTICLOCKWISE. CALL WANGLE (4.0,7.0,90.0) CALL CHOCT (6.0) C C OUTPUT SOME ROTATED TEXT. CALL WRIGHT (4.0,7.0,'THICK',5) CALL SETXY (11.0,7.0) CALL HTEXT (4,'THIN') C C FINISH PLOTTING CALL ENDSPR STOP END
The command was:
TASK SMOG,*CR:GRAFEX.THICKANDTHIN,JT25,*LP,#LP6,LIB:GRAFLIB.GRAFLIB
The LIB parameter is included for the bold text as the routines are in the graphics library.
This set of routines in the library ([7] 5) takes a shape defined by a series of x and y coordinates and shades it in. The shading is a series of vertical lines an equal distance apart. There are two user routines, the first sets up the scanning area and the second shades in the picture. When setting up the user coordinates it is advisable to define an area greater than the picture occupies. The shading routine only scissors the shape in the x direction, that is, any part of the picture which is outside the range 0 ≤ x ≤ ISIZE is not drawn.
In the example the shape is made up of 29 (x,y) coordinates which are read into the array IPIC, where, IPIC (1,I) I=1,...,29 are the x values and IPIC(2,I) I=1,...,29 are the y values. The shape has an x and y range from 0 to 800 and the user limits for the many-up hardcopy cine area are set to 1000*800 as follows:
CALL JLIMV (0,0,1000,800)
The scanning area is set up by the routine SCSZIN (ISIZE,INC) where ISIZE is the x range for the scanning routine and INC is the scanning increment. For the example ISIZE is set to 800 and INC to 5 thus, a maximum of 160 scan lines are drawn to produce the shape, that is, scanning occurs on every 5th possible scan line.
The shape is shaded by the scanning routine which requires two arguments, firstly the number of points in the shape and secondly, the array of x, y coordinates. The example is as follows:
CALL SCANAR(29,IPIC)
and thus the whole of array IPIC is used to define the shape to be scanned.
Finally, as with all SMOG/SPROGS programs the terminating routine needs to be called as follows:
CALL ENDSPR
The program, data and FR80 output follow:
LIST MASTER SHADING,- C C THE ARRAY IPIC HOLDS 29 SETS OF (X,Y) COORDINATES. DIMENSION IPIC (2,29) C C SELECT THE CINE AREA OF MANY-UP HARDCOPY. CALL FRHCM CALL CINE C C CHOOSE SUITABLE COORDINATES FOR THIS AREA, CALL JLIMV (0,0,1000,800) C C SET THE SCANNING AREA AND SHADE 1 IN 5, CALL SCSZIN (800,5) C C READ IN THE PICTURE TO BE SHADED. READ (1,10) (IPIC(1,J),IPIC(2,J),J=1,29) 10 FORMAT (214) C C SHADE THE PICTURE IN 'IPIC'. CALL SCANAR (29,IPIC) C C TERMINATE THE GRAPHICS IN THE USUAL WAY. CALL ENDSPR STOP END ****
600 400 800 600 600 800 400 600 200 800 0 600 200 400 0 200 200 0 400 200 600 0 800 200 600 400 550 350 550 250 450 250 400 200 350 250 250 250 250 350 200 400 250 450 250 550 350 550 400 600 450 550 550 550 550 450 600 400 ****
The following command was issued whilst logged in:
TASK SM,*CR:GRAFEX.SCANNING,#CR:GRAFEX.SCANDATA,- LIB:GRAFLIB.GRAFLIB,JT25,*LP,#LP6
where SM is short for SMOG and the - at the end of the first line is the continuation character.
The Archuleta package ([7] 3 and [8] 10) is a sophisticated set of routines for accepting plane polygons in three dimensions as input, manipulating these polygons and displaying them in various ways. The high-level routines are in pairs, the first, to input the surface and the second to draw the surface. The routine names end in I and D respectively. In general users will only require these high-level routines but it is possible to use some of the intermediate routines for greater flexibility. The standard method of use is to input a surface, perform some transformations on the surface and then display the surface using the corresponding drawing routine. The surface manipulation and displaying can be performed many times without the need to re-input the data.
In the example, the data is three arrays each two-dimensional and so suitable for the GSURF routines. The mesh that is produced by the example data forms a solid by setting the first row of the arrays equal to the last and likewise with the first and last columns. The data is stored in file :GRAFEX.SOLID as five sets of X, Y and Z coordinates per line and it is input in 15F5.0 format. There are nine lines of data in all.
In the program the two COMMON blocks FREE and BUCKY have to be set up. A free storage working area of 2500 and a resolvability of 512 are used as follows:
COMMON/FREE/IFREE(2,2500) COMMON/BUCKY/IE(512)
The initialising routine INFREE is called as follows:
CALL INFREE (2500,512)
The data for the surface is read into the arrays X, Y and Z. The cine area for many-up hardcopy is given the limits (0,0) to (512,512) (the resolvability that the Archuleta routines were initialised with) as follows:
CALL FRHCM CALL CINE CALL JLIMV (0,0,512,512)
The surface is input to the Archuleta routines using the routine GSURFI as follows:
CALL GSURFI (X,1,5,1,Y,1,9,1,Z,5)
The arguments are; the arrays X, Y and Z with the first dimension having a starting index of one, an end index of five and a step length of one similarly for the second dimension with 1,9,1. The five at the end is the size of the first dimension of the arrays, in this example all of the arrays are used and it is equal to the end index for the first dimension.
The system has now initialised the surface so that its centre is in the centre of the screen, this means that half of it is behind the viewer. The viewing is along the positive Z-axis and therefore by moving the surface in this direction all of it will become visible. The routine CTRAN is used to move the surface and then GSURFD is used to display it as follows:
CALL CTRAN (O.,0.,100.) C C DRAW IT! CALL GSURFD (X,1,5,1,Y,1,9,1,Z,5,1,90.)
The arguments to GSURFD are the same as for GSURFI with the 1,90. at the end causing a line drawing of the surface and a cone of vision of ninety degrees respectively.
As can be seen from the first picture in section 4.3.3 the shape of the surface is not very clear. To get a better view it is necessary to rotate it but first it is wise to move it back to the origin so that it is not rotated out of the viewing area. The routine CXROT is used to rotate it -30.0 degrees about the x-axis as follows:
CALL CTRAN (0.,0.,-100.0) CALL CXROT (-30.0) CALL CTRAN (0.,0.,100.0)
Finally before it can be drawn it is best to move to the next frame unless the two pictures are to be superimposed. The routine ADVFLM. moves to the next frame and then an identical call of GSURFD causes the surface to be drawn at the new angle.
Last of all the plotting routines called is the routine ENDSPR to terminate the graphics successfully.
LIST MASTER THREED C C SET UP THE WORK AREA. COMMON /FREE/ IFREE(2,2500) COMMON /BUCKY/ IB(512) DIMENSION X(5,9),Y(5,9),Z(5,9) C C THE OBJECT CONSISTS OF 8 SQUARE PRISMS. C INITIALISE THE WORK AREA AND INPUT THE OBJECT CALL INFREE (2500,512) DO 20 J=1,9 READ (1,10) (X(I,J),Y(I,J),Z(I,J),I=1,5) 10 FORMAT (15F5.0) 20 CONTINUE C C INITIALISE THE GRAPHICS. CALL FRHCM CALL CINE CALL JLIMV (0,0,512,512) C C SET UP THE OBJECT. CALL GSURFI (X,1,5,1,Y,1,9,1,Z,5) C C MOVE THE OBJECT BACK A BIT. CALL CTRAN (0.,0.,100.) C C DRAW IT! CALL GSURFD (X,1,5,1,Y,1,9,1,Z,5,1,90. ) C C ROTATE THE OBJECT SO MORE OF IT CAN BE SEEN CALL CTRAN (0.,0.,-100.) CALL CXROT (-30.0) CALL CTRAN (0.,0.,100.) CALL ADVFLM CALL GSURFD (X,1,5,1,Y,1,9,1,Z,5,1,90.) C C TERMINATE THE PLOTTING. CALL ENDSPR STOP END
10. 0. 40. 20. 10. 40. 10. 20. 40. 0. 10. 40. 10. 0. 40. 10. 0. 60. 20. 10. 60. 10. 20. 60. 0. 10. 60. 10. 0. 60. 40. 0. 90. 40. 10. 80. 40. 20. 90. 40. 10. 100. 40. 0. 90. 60. 0. 90. 60. 10. 80. 60. 20. 90. 60. 10. 100. 60. 0. 90. 90. 0. 60. 70. 10. 60. 90. 20. 60. 100. 10. 60. 90. 0. 60. 90. 0. 40. 70. 10. 40. 90. 20. 40. 100. 10. 40. 90. 0. 40. 60. 0. 10. 60. 10. 20. 60. 20. 10. 60. 10. 0. 60. 0. 10. 40. 0. 10. 40. 10. 20. 40. 20. 10. 40. 10. 0. 40. 0. 10. 10. 0. 40. 20. 10. 40. 10. 20. 40. 0. 10. 40. 10. 0. 40. ****
The command issued whilst logged in was:
TASK SMOG,TI15,JT25,*CR:GRAFEX.OBJECT,#CR:GRAFEX.- SOLID,LIB:GRAFLIB.CGRAFLIB,*LP,#LP6
where the hyphen at the end of the first line is a continuation character. When a command is this long it is best to input it into a file, for example: :GRAFEX.COMD. There are two things that have to be remembered when running a job like this. Firstly, any JD parameters which TASK separates out for the user have to be removed from the command. In the above example only the JT25 is a JD parameter. Secondly, an additional line is needed, the command ENDJOB has to be issued as well.
To run the job now only requires the following to be typed when logged in.
RUNJOB MOPEXAMPLE,:GRAFEX.COMD,JD(JT25)
or when not logged in:
RUNJOB MOPEXAMPLE,:NTBE34,GRAFEX.COMD,JD(JT25)
The file :GRAFEX.COMD is shown below:
TASK SMOG,TI15,*CR:GRAFEX.OBJECT,#CR:GRAFEX.- SOLID,LIB:GRAFLIB.GRAFLIB,*LP,#LP6 ENDJOB
The other advantage of this method is a reduction in typing errors.
The MAPS set of routines ([7]4) reads in a data file of latitudes and longitudes representing the land masses of the world. This data is then plotted from the desired viewpoint in any of eight projection types (an example of each projection type is shown at the end of [7]4). The main use for this set of routines is to provide a background for plotting such things as satellite orbits. For the example in this section the world is plotted in "Mercator's Cylindrical" projection (type 7) from 120 degrees and from 240 degrees around the equator.
The data for the world map is stored in the DA file :GRAFLIB.MAPS-DAT. There are three places where the data file has to be mentioned; firstly, in the parameter list it is necessary to add the following:
#DA2:GRAFLIB.MAPS-DAT
This states that DA2 is to be assigned "read only" to the DA file :GRAPLIB.MAPS-DAT, secondly, in the Program Description Segment this stream must be associated with a FORTRAN unit number, in the example unit 4 is used as follows:
USE 4=DA2/UNFORMATTED/512
this line is inserted before the END statement in a copy of the default Program Description Segment stored as file :SUBLIB.TASK-SPD, finally, the last argument in the call to MAPS must state the FORTRAN unit number to be used, in this example four is used.
The routine MAPS was originally written for the SD4020 and this is reflected in the coordinates produced. When the limits are selected one has to select an area which has its origin in the top left corner and sets the bottom right corner to (1023,1023). In the example a square based on the 'cine' area of 'many-up' hardcopy was set up as follows:
CALL FRHCM CALL CINE CALL JLIMS (0,1023,1023,0,1,1)
The arguments in the call of MAPS are as follows
type of map 4 latitude and longitude for centre of projection 0.,PLONG where PLONG = 120.0 and 240.0 angular radius from the centre to the top 85.,85. and side of the projection respectively user coordinates from the centre to the top 511.,511. and side of the projection respectively centre of the projection in user coordinates 511.,511. shape of boundary, 0 = circular, 1 = square 1 interval for latitudes and longitudes in 10 degrees, not plotted if set to zero FORTRAN unit number for data of world 4
The job is terminated in the usual way, by a call to ENDSPR as the last graphics routine called.
LIST PROGRAM(SPRG) ABNORMAL FUNCTIONS COMPRESS INTEGER AND LOGICAL OUTPUT 98,(MONITOR)=LP0 OUTPUT 12=LP5 OUTPUT 13=LP6 OUTPUT 99=LP10 USE 97=/ARRAY INPUT 1,5=CR0 OUTPUT 2,6=LP9 USE 4=DA2/UNFORMATTED/512 END MASTER MAPTEST C C*** SET UP USER COORDINATE SYSTEM C CALL FRHCM CALL CINE CALL JLIMS (0,1023,1023,0,1,1) C C*** DRAW TYPE 7 FROM TWO ANGLES C PLONG=120.0 DO 10 I=1,2 CALL MAPS (4,0.,PLONG,85.0,85.0,511.,511.,511., *511.,1,10,4) PLONG=PLONG+120.0 CALL ADVFLM 10 CONTINUE C C*** END PROGRAM C CALL ENDSPR STOP END ****
TASK SMOG,*CR:GRAFEX.WORLD,LIB:GRAFLIB.GRAFLIB,OPT,JT65,- #DA2:GRAFLIB.MAPS-DAT,TI50,*LP,#LP6
Three dimensional histograms are plotted by calling the routine HIST3D ([7]6.2). The data is a set of heights covering a rectangular grid. At each height a column is drawn to produce the 3-D effect at least, that part of the column which is not obscured by any in front of it. The histogram is plotted as a perspective view of the three dimensional object formed by the columns. The routine not only removes those lines of a column which are hidden by others in front but also removes the line between adjacent columns. This effect can be seen very clearly in the example in Section 4.5.2.
The complete list of arguments passed to HIST3D in the example, is as follows:
CALL HIST3D(HDATA,10,8,8,100.0,1.0.,1.0, 130.0,45.0,10.0)
where: HDATA is the two-dimensional array holding the heights; 10 is the first dimension of the array; 8,8 are the number of grid points in the x and y directions respectively; 100.0 is the maximum of the z values; 1.0,1.0 are the y and z scaling factors relative to the x side of the histogram; 30.0, 45.0 are the horizontal and vertical angle of the viewing point; 10.0 is the horizontal distance for the viewing point. When looking at the histogram it should be noted that; the left corner of the grid is the origin, the right corner is maximum x and y, the near corner is maximum x and minimum y and, the far corner is minimum x and maximum y. The reason for setting the maximum z value to a larger number than the real maximum is so that subsequent histograms using this same value will have the same scale and hence visual comparison is easy, assuming none of the other scaling or angular values are changed.
One warning about HIST3D is that it changes the limits for the user area and thus it is necessary to select some suitable limits if anything other than the histogram is to be plotted, for example, some titling.
LIST MASTER TEST DIMENSION HDATA (10,10) C C--NOT ALL OF ARRAY HDATA IS USED. C--ONLY A SQUARE 8*8. DATA HDATA/45.0,0.0,67.0,4*0.0,50.0,6*0.0, 132.0,26*0.0,60.0,4*0.0,85.0,6*0.0,50.0, 22*0.0,35.0,3*0.0,72.0,16*0.0,55.0,22*0.0/ C C--SET UP MANY-UP HARDCOPY. C--AREA UNITS NOT RELEVANT. CALL FRHCM CALL CINE CALL JLIMV (0,0,1,1) C C--DRAW 3D HISTOGRAM SET UP BY DATA STATEMENT. C--REMEMBER HIST3-D ALTERS USER AREA LIMITS. CALL HIST3D (HDATA,10,8,8,100.0,1.0,1.0, 130.0,45.0,10.0) C C--PLOTTING NOW FINISHED. CALL ENDSPR STOP END
The following command should be issued whilst logged in:
TASK SMOG,*CR:GRAFEX.HIST3-D,LIB:GRAFLIB.GRAFLIB,*LP,#LP6,JT25
The program is stored in the file :GRAFEX.HIST3-D. The graphics library is stored in :GRAFLIB.GRAFLIB and contains the three dimensional histogram routines. The two parameters *LP and #LP6 ensure that the lineprinter output is one listing instead of three separate pieces. The program could be run just as easily using SPROGS but it would be more expensive to do so.