Before any output is produced for a graphical device, it is necessary to define its position. For example, in order to draw a line, the two end points must be defined in terms of the units of the graphical device. The device may be such that the initial position is already known (the current pen position) and only the displacements are required. Alternatively, the absolute coordinates of the start and finish of the lines may be required.
The user, however, does not wish to be concerned with the unit system of a particular output device (1024 × 1024 in the case of the SD4020), but, instead, wishes to use units which are relevant to his particular problem. Consequently, an important part of any graphical system is the flexibility with which the user can define his own units and how they relate to the equivalent positions on the display area.
The user defines a line between two points (X,Y) and (A,B) in his own coordinate system, which has been defined by selecting an area known as a region. The system must decide whether the whole line is on the display area and, if not, calculate the part that is. In order to allow photographic effects such as wipes, there is also a need to mask certain parts of the output. The system is designed to be both flexible and, if desired, efficient.
Normally it is sufficient just to draw a line. Each line has certain parameters associated with it which define the type of line (for example, the intensity). The type of display may well influence the point where these are taken into account. In the SD4020, none of these parameters can be achieved by hardware and, consequently, they are dealt with by software at a higher level. For the moment, only how a simple line between (X,Y) and (A,B), which gets mapped onto the display area, is considered.
The routine:
RGLIM (R, XMIN, YMIN, XMAX, YMAX)
allows the user to set up his own coordinate system in region R, so that, when he selects this region and draws a line from (X,Y) to (A, B), the line coordinates will be interpreted in his own units. The region R can normally be considered as a rectangle whose bottom left-hand corner is (XMIN, YMIN) and whose top right-hand corner is (XMAX, YMAX) (but see RGPRM definition).
REGION (R)
selects region R. Hence, (using routine VEC to draw the line)
RGLIM (1.0, 0.0, 0.0, 10.0, 10.0) REGION (1.0) VEC (0.0, 10.0, 10.0, 0.0)
would draw a line from the top left-hand corner to the bottom right-hand corner of the region.
On entry to SPROGS, region 0 is selected, with limits (0.0, 1023.0, 1023.0, 0.0) corresponding exactly to the raster of the SD4020. (Thus, the bottom left-hand corner of the SD4020 raster is (0, 1023).) Note that there is no reason why XMIN and YMIN should be numerically less than XMAX and YMAX respectively.
It is possible to define one region 1n terms of another.
RGPLIM (R, P, XPMIN, YPMIN, XPMAX, YPMAX)
defines region R in terms of region P, such that XPMIN, YPMIN, YPMAX, YPMAX are normally the equivalent values of XMIN, YMIN, XMAX, YMAX in the units of region P (but see RGPRM definition).
When a line is drawn in a selected region, the coordinates of the line are converted from the units of the selected region to the units of the next region in the chain, and so on until the chain end is reached (see below). Thus, if region 0 is chosen as the basic output region for the SD4020 (see below), the following command sequence:
RGLIM (1.0, 0.0 , 0.0 , 10.0 , 10.0) RGPLIM (1.0, 0.0, 0.0, 1023.0, 1023.0, 0.0) REGION (1.0) VEC (0.0, 10.0, 10.0, 0.0)
will cause a line to be drawn from the top left-hand corner of the SD4020 frame to the bottom right-hand corner. The line coordinates will be converted from region 1 units to region 0 units, becoming 0.0, 0.0, 1023.0, 1023.0.
Changing the settings of XPMIN, YPMIN, XPMAX, YPMAX has the effect of moving region R, and all lines drawn in it, with respect to region P. Thus, replacing the RGPLIM call above by:
RGPLIM (1.0, 0.0 , 0.0 , 1023.0, 511.0, 512.0)
would cause the line to be drawn from top left to bottom right of a square occupying the bottom left hand quarter of the SD4020 frame. Normally, the point (X, Y) in region R will be converted to (X', Y') in region P where:
X' = XPMIN + (X-XMIN) (XPMAX-XPMIN) /(XMAX-XMIN) Y' = YPMIN + (Y-YMIN) (YPMAX-YPMIN) /(YMAX-YMIN)
However, other forms of conversion are possible.
The routine:
RGPRM (R, CNV, BSC, XMI, XMO, SWOUTP)
allows the user to select the required conversion to be performed by setting CNV. The allowable values are:
X" = (XPMIN+XPMAX+YPMIN+YPMAX)/2 - Y' Y" = (YPMIN+YPMAX-XPMIN-XPMAX)/2 + X'
X' = XPMIN+(X-XPMIN)*COS(XPMAX)-(Y-YPMIN)*SIN(XPMAX) Y' = YPMIN+(X-XPMIN)*SIN(XPMAX)+(Y-YPMIN)*COS(XPMAX)The value of YPMAX is ignored.
SPROGS is designed to run with a variety of output devices. A user can select one or more by:
DVOUT (DEVS)
where the bit settings of DEVS indicate which devices have been selected. Currently, the devices available are:
thus:
DVOUT (9.0)
will select SD4020 microfilm and lineprinter graphical.
Lineprinter graphical output draws lines on the lineprinter, plotting with the character * on a 120 × 120 grid. The plotting character changes to + where lines coincide.
Lineprinter output consists of a listing of the coordinates of lines (after transformation), and is mainly of use for debugging (see below).
If output is required to both microfilm and hardcopy on the SD4020, the user should use:
DVOUT (32.0)
rather than:
DVOUT (3.0)
since the latter will lead to excessive camera shutter movement which can damage the device.
As there are a number of different devices connected to SPROGS (and more will be added later), the user can specify which regions are to be treated as the basic output region for a given device. Initially, region 0 is selected to be the basic region for SD4020 microfilm and hardcopy. The routine:
RGPRM (R, CNV, BSC, XMI, XMO, SWOUTP)
allows the user to select region R as the basic output region for devices specified by the bit pattern in SWOUTP (set in the same way as DEVS in the description of DVOUT). The other arguments will be explained later.
A line drawn in a given region will have its coordinates converted through the region chain until a region is reached which is the basic output region for one of the currently selected devices. At this point, no conversion takes place. Instead, the current coordinates are sent to this device. If more than one device has been selected, and not all the selected devices have been satisfied, conversion continues down the chain until all output is complete.
Thus:
RGLIM (1.0, 0.0, 0.0, 10.0, 10.0) RGPLIM (1.0, 0.0, 0.0, 1023.0, 1023.0, 0.0) RGPLIM (0.0, 2.0, 0.0, 0.0, 119.0, 119.0) RGLIM (2.0, 0.0, 0.0, 119.0, 119.0) RGPRM (2.0, CNV, BSC, XMI, XMO, 8.0) DVOUT (40.0) REGION (1.0) VEC (0.0, 10.0, 10.0, 0.0)
will cause the line to be output from the top left to bottom right on both microfilm and hardcopy on the SD4020 and on the lineprinter in graphical mode.
Note that the above has assumed that the settings of the other parameters of region 0 are as initialised. The user can of course redefine any of these parameters. Note also that there is no inherent ordering in the region numbering system, the chain defined above being 1 to 0 to 2. Regions may be numbered from 0 to 29 inclusive.
A region can be considered as dividing the whole plotting area into two parts (inside and outside). In general, a line will be split into three by a region (two parts outside and one part inside) although it may be wholly inside, wholly outside or split only into two. SPROGS allows the user to control the visibility of each line segment by specifying the visibility conditions for inside segments and outside segments. For example, the region could be made to act as a window, by forcing all segments outside it to be invisible. Since each region in a chain can have separate visibility settings, differing effects can be obtained by causing the visibility to depend on the previous region.
At the start of a conversion through the region chain, the line being drawn is split into inside and outside segments. The parameters XMI, XMO in RGPRM define the visibility effect of the region. Possible settings are:
Thus lines which become invisible may revert to being visible aga1n later on in the chain.
Hence:
RGPRM (R, CNV, BSC, 1.0, 0.0, SWOUTP)
would mean that only visible interior line segments will remain visible. All invisible interior line segments and all exterior line segments (whether originally visible or not) will become invisible. This setting is often chosen for basic output regions since it is not possible to plot off the hardware frame.
Thus, the order of actions when transforming through the region chain is:
It can be seen that, for the last basic output region in a chain, the setting of RGPLIM is superfluous, and the settings of RGLIM only affect line visibility (by scissoring).
The argument BSC in RGPRM defines the basic shape of the region, and hence controls what scissoring is to take place. The normal shape of the region is rectangular, but two other shapes have been defined. The three settings are:
Note that BSC defines the meaning of the arguments of RGLIM. However, RGPLIM conversion will still make use of the values of XMIN, YMIN, XMAX and YMAX, independent of the region shape.
Normally, this would produce a definition loop. However; if a user defines a region by:
RGLIM (1.0, XMIN, YMIN, XMAX, YMAX) RGPLIM (1.0, 0.0, XPMIN, YPMIN, XPMAX, YPMAX)
and subsequently writes:
RGPLIM (1.0, 1.0, XMN, YMN, XMX, YMX)
this is equivalent to writing:
RGPLIM (1.0, 0.0, XPMN, YPMN, XPMX, YPMX)
where:
XPMN = XPMIN + (XMN - XMIN) (XPMAX - XPMIN) / (XMAX - XMIN) YPMN = YPMIN + (YMN - YMIN) (YPMAX - YPMIN) / (YMAX - YMIN) XPMX = XPMIN + (XMX - XMIN) (XPMAX - XPMIN) / (XMAX - XMIN) YPMX = YPMIN + (YMX - YMIN) (YPMAX - YPMIN) / (YMAX - YMIN)
(assuming CNV = 0.0 for this region)
If a negative region number is used in RGLIM, RGPLIM or RGPRM, the currently selected region is assumed. Thus:
REGION (2.0) RGLIM (-1.0, XMN, YMN, XMX, YMX)
will change the limits of region 2. Also, if any other arguments in RGPRM are negative, the current values of those arguments are retained. Thus:
RGPRM (R, -1.0, -1.0, 1.0, 0.0, -1.0)
will set the visibility markers for region R but leave the other arguments (CNV, BSC, and SWOUTP) unaltered.
Initially, region 0 is set up as the basic output region for the SD4020 and region 1 as the basic output region for lineprinter graphical. Various routines are provided to aid the user in oft-required region parameter settings.
LIMIT (XM, YM, XN, YN)
sets the region limits for the current region.
PLIMIT (P, XM, YM, XN, YN)
defines the current region in terms of region P.
VISO (XMI, XMO) VISOR (R, XMI, XMO)
sets the visibility markers for the current region or region R.
BASE (SWOUTP) BASER (R, SWOUTP)
sets the current region or region R as basic output region for the devices selected by SWOUTP.
SHAPE (CNV, BSC) SHAPER (R, CNV, BSC)
sets the shape parameters, CNV, BSC for the current region or region R (see Sections 2.3 and 2.5).
WINDOW
sets the current region visibility to 1.0 inside, 0.0 outside (outside invisible).
SHIELD
DSALL
sets the current region visibility to 1.0 inside and out (no scissoring).
In terms of the routines previously defined:
LIMIT (XM,YM,XN,YN) = RGLIM (-1.0,XM,YM,XN,YN) PLIMIT (P,XM,YM,XN,YN) = RGPLIM (-1.0,P,XM,YM,XN,YN) VISO (XMI,XMO) = RGPRM (-1.0,-1.0,-1.0,XMI,XMO,-1.0) VISOR (R,XMI,XMO) = RGPRM (R,-1.0,-1.0,XMI,XMO,-1.0) BASE (SWOUTP) = RGPRM (-1.0,-1.0,-1.0,-1.0,-1.0,SWOUTP) BASER (R, SWOUTP) = RGPRM (R,-1.0,-1.0,-1.0,-1.0,SWOUTP) SHAPE (CNV,BSC) = RGPRM (-1.0,CNV,BSC,-1.0,-1.0,-1.0) SHAPER (R,CNV,BSC) = RGPRM (R,CNV,BSC,1.0,-1.0,-1.0) WINDOW = RGPRM (-1.0,-1.0,-1.0,1.0,0.0,-1.0) SHIELD = RGPRM (-1.0,-1.0,-1.0,0.0,1.0,-1.0) DSALL = RGPRM (-1.0,-1.0,-1.0,1.0,1.0,-1.0)
The following routines set up regions.
SDHARD
defines region 1 in terms of region 0, sets region 0 to be the basic output region for SD4020, sets limits of region 1 to (0,0,1023,1023), selects region 1 and SD4020 hardcopy output.
SDFILM
does the same as SDHARD but selects SD4020 microfilm output.
LPGRAF
sets region 1 to be the basic output region for lineprinter graphical output, with limits (0,0,119,119), selects region 1 and lineprinter graphical output.
OUTR (R,XN)
sets region R to be the basic output region for the devices specified by XN, and selects these devices.
The drawing opposite was produced by the following program. It shows how a complex region chain might be used.
RGLIM (6.0,10.0,10.0,60.0,50.0) RGPLIM (6.0,5.0,10.0,10.0,60.0,50.0) VISOR (6.0,0.0,3.0) C RGLIM (5.0,30.0,20.0,90.0,70.0) RGPLIM (5.0,4.0,30.0,20.0,90.0,70.0) VISOR (5.0,2.0,1.0) C RGLIM (4.0,20.0,30.0,70.0,60.0) RGPLIM (4.0,3.0,20.0,30.0,70.0,60.0) VISOR (4.0,1.0,2.0) C RGLIM (3.0,80.0,40.0,100.0,50.0) RGPLIM (3.0,2.0,80.0,40.0,100.0,50.0) VISOR (3.0,0.0,1.0) C RGLIM (2.0,50.0,55.0,60.0,75.0) VISOR (2.0,1.0,0.0) BASER (2.0,2.0) C DVOUT (2.0) REGION (6.0) DO 10 J=I,12 VEC (0.0,0.0,100.0,100.0) DO 10 1=5,100,5 XI=I VEC (0.0,XI,100.0-XI,100.0) VEC (XI,0.0,100.0,100.0-XI) 10 CONTINUE