4 ZONES

 4.1 Zone creation
 4.2 Zone selection and release
 4.3 Clearing zones
 4.4 Inquiries
 4.5 Controlling NDC

An SGS zone is a block of display surface on a particular workstation which behaves in many respects as if it were an independent plotting device.

A zone has an extent (in world coordinates), a position and size on the display surface (or, more correctly, in normalised device coordinates—see Appendix B) and a workstation. Clipping occurs at the zone boundary (unless disabled via GKS).

There are routines to create new zones and to switch plotting from the current one to another. When a zone is created it is allocated a zone identifier by SGS which is thereafter used by the program to refer to that zone. When a workstation is opened (in either SGS_OPEN or SGS_OPNWK), a ‘base’ zone is created which occupies the whole display surface. This base zone has a world coordinate extent such that the square (0,0) to (1,1) spans the zone in at least one coordinate and appears on the display surface as a square; the bottom left hand corner is (0,0). A similar default coordinate system is set up whenever a zone is created. It is possible to have more than one base zone on a given workstation.

One important use of the zone facility is to enable the allocation of plotting resources to be separated from the plotting itself. Thus the user might decide that the three graphs he is about to plot should, on one occasion, go to three regions of his VDU screen, and on another occasion to two regions of his screen and to a pen plotter respectively; by using zones the plotting program can operate as if the three plots were always on separate workstations, and switch freely between them during plotting. Activation and deactivation of workstations as well as control of the various windows and viewports is handled automatically by SGS (see Appendix B).

Another occasion on which SGS zones can be useful is when it is convenient to operate in several world coordinate systems within one graph. For example, a program might create one zone for plotting axes and annotation, and create one or more smaller zones within that zone for plotting data in world coordinates.

There is always a current zone, within which plotting occurs. Zones are created in terms of the current zone, with no restriction on the number of levels deep. Overlapping zones are permissible, but a new zone must lie entirely within the current one. There is a maximum number of zones that can exist at any one time, and a routine is available for dispensing with a zone once it is no longer required. There is no hierarchy of zones; once a zone has been created within the current zone and then made current, the parent zone can be released.

4.1 Zone creation

In all the create zone routines the new zone is automatically ‘selected’, so that further plotting is to the new zone. The IZONID argument is the zone identifier, supplied by SGS. ISTAT is the status return, which will be zero if the routine succeeds. The world coordinate system that the new zone is born with is such that (0,0) is at the bottom left hand corner, the top right corner of the zone has one coordinate unity and the other unity or more, and a square in world coordinates appears square on the display surface.

A zone can be created within a nominated region of the current zone by means of:

  CALL SGS_ZONE (X1, X2, Y1, Y2, IZONID, ISTAT)

X1, X2, Y1, Y2 are the bounds of the new zone in the world coordinate system of the current zone. Note that the new zone will have the default coordinate system, which will, in general, be different from that of the parent. To create a new zone the coordinates of which match those of the parent, follow the SGS_ZONE call with a call to SGS_SW and specify the same X1, X2, Y1, Y2 in each case. SGS_SW is described below.

A zone of nominated shape (on the display surface) can be fitted into the current zone as follows:

  CALL SGS_ZSHAP (AR, POS, IZONID, ISTAT)

AR is the aspect ratio x/y. Thus a normal TV raster has an AR of about 1.33. The new zone has this aspect ratio, and fills the parent zone in at least one dimension. POS is a character string specifying the position of the new zone within the parent zone. The first character is ‘B’, ‘C’ or ‘T’, to position the new zone at the bottom of the parent zone, centred vertically, or at the top. The second character is ‘L’, ‘C’ or ‘R’, for left, centre or right respectively. Thus a POS value of ‘BL’ would set up the new zone at the bottom left of the parent zone; ‘CC’ would centre the new zone in the parent.

For a zone of nominated absolute size:

  CALL SGS_ZSIZE (XM, YM, POS, IZONID, ISTAT)

XM,YM are the dimensions of the new zone in metres. POS is as for SGS_ZSHAP.

The current zone can be partitioned into a number of equally sized pieces by:

  CALL SGS_ZPART (NX, NY, IZONES, ISTAT)

where NX is the number of new zones horizontally and NY is the number of new zones vertically. A total of NX x NY new zones will be created and the zone identifiers returned in the array IZONES, starting with the bottom left hand corner zone in the first element, the second zone in the bottom row in the next element, and so on. The last element of the array will contain the zone identifier of the top right had corner zone. Unlike the other zone creation routines, SGS_ZPART leaves the current zone unchanged, and to plot in one of the new zones it must be explicitly selected (see section 4.2).

Once a zone has been created (by SGS_OPEN, SGS_OPNWK or one of the above routines), it can be given a suitable coordinate system as follows:

  CALL SGS_SW (X1, X2, Y1, Y2, ISTAT)

X1, X2, Y1, Y2 are the bounds of the current zone in the new world coordinate system. Note that it is a fundamental property of GKS that the world coordinate x and y values always increase from left to right and from bottom to top respectively.

4.2 Zone selection and release

To start plotting on a new zone:

  CALL SGS_SELZ (IZONID, ISTAT)

Plotting is suspended on the current zone and the new zone, specified by the zone identifier IZONID, is made the current one. Subsequent plotting goes to the new zone. The selection may imply a change of workstation; this is handled by SGS.

Once a zone is no longer required it is wise to release it:

  CALL SGS_RELZ (IZONID)

This liberates workspace within SGS, thereby making room for one more zone later on. Neither the current zone nor a base zone can be released, but if this is attempted no error message is produced.

4.3 Clearing zones

The current zone may be cleared by:

  CALL SGS_CLRZ

This will ensure that the area covered by the zone is empty. On some devices only the area covered by the zone will be cleared but on others the whole display surface may be cleared (because the hardware is not capable of clearing selected areas). On a hardcopy device a call to SGS_CLRZ will cause the paper to be advanced to a new frame except when the whole plotting surface is already empty. If any part of the surface has has been plotted on, even if the current zone is empty, a new frame will be started. This behaviour should be contrasted with that of SGS_CLRBL (see section 5.4) which never causes a frame advance. Whether SGS_CLRZ will clear the whole display surface can be inquired by:

  CALL SGS_ISLER (BLKER)

If BLKER (LOGICAL) is .TRUE. then the workstation is capable of clearing selected areas and the whole display surface will not be cleared (unless the current zone fills the entire area). The whole display surface can always be cleared by clearing the base zone.

4.4 Inquiries

The zone identifier for the current zone is available via:

  CALL SGS_ICURZ (IZONID)

To find out the size of the current zone:

  CALL SGS_IZONE (X1, X2, Y1, Y2, XM, YM)

X1, X2, Y1, Y2 are the world coordinate bounds. XM, YM are the dimensions in metres.

When two zones overlap, the same point on the display surface corresponds to different positions in world coordinates in the two zones. A position in one zone can be converted to the corresponding position in another by:

  CALL SGS_TPZ (IZIN, XIN, YIN, IZOUT, XOUT, YOUT, ISTAT)

where XIN, YIN is a point in the zone IZIN, and IZOUT is the ID of the zone to which the position is to be converted. The position in this zone is retured in XOUT, YOUT. ISTAT will be zero if both zone IDs are valid. Although all plotting is clipped at the boundary of the current zone, the world coordinates are still meaningful outside the zone, and so the point to be converted can be outside one or both zones and the conversion will still succeed.

To optimise plotting efficiency it is sometimes necessary for a program to find out what the plotting resolution is. The inquiry:

  CALL SGS_IDUN (DXW, DYW)}

returns the plotting resolution of the current zone, in world coordinates, in x and y separately.

4.5 Controlling NDC

This section is only of interest if you are mixing SGS calls with use of other high level graphics packages in the same program.

Some high level packages make make assumptions about what area of Normalized Device Coordinates (NDC—see appendix B) is visible on the device, for example that the whole of the NDC unit square is visible. When SGS opens a workstation it arranges that the whole display surface is available for plotting and on a workstation whose display surface is not square this inevitably results in part of the NDC unit square not being visible.

The routine SGS_BZNDC allows the area of NDC occupied by a base zone to be manipulated.

  CALL SGS_BZNDC (X1, X2, Y1, Y2, POS, ISTAT)

sets the NDC limits of the current zone, which must be a base zone, to be X1 to X2 in x and Y1 to Y2 in y. All four limits must be between 0.0 and 1.0, and X2 and Y2 must be greater than X1 and Y1 respectively. Since the modified zone will, in general, not be the same aspect ratio as the display surface, the display surface will not be filled in one of either x or y. The character argument POS specifies how the zone should be positioned (c.f. SGS_ZSHAP above). ISTAT is the usual status argument.

In order to achieve its effect SGS_BZNDC has to set the workstation transformation, which would both alter the properties of any other zones on the workstation and cause the picture to require regeneration. Therefore it can only be used when the workstation is empty and when no other zones exist on the workstation. It will typically be used immediately after opening the workstation.