B SGS–GKS INTERACTION

SGS does not aim to address all the graphics facilities that are available through GKS, and although the majority of graphics programs will not call GKS routines directly, some more sophisticated programs will have to. SGS has been designed to make this as easy as possible, but in order to mix SGS and GKS successfully it is necessary to have some understanding of how SGS controls the state of GKS and how changing the state of GKS may affect the result of SGS calls.

Two routines are provided for obtaining the numbers that GKS uses to identify workstations, and which are often required as inputs to GKS routines.

  CALL SGS_ICURW (IWKID)}

will return the GKS workstation identifier of the current SGS zone, and:

  CALL SGS_WIDEN (WKSTN,ITYPE,ICONID,ISTAT)}

will translate the SGS workstation name WKSTN to a GKS workstation type and connection identifier. ISTAT is set to zero if WKSTN is a valid SGS name, but this does not guarantee that the workstation can be opened. This routine may be called before SGS_OPEN.

SGS makes various assumptions about the state of GKS but rarely enforces them. Therefore changing GKS’s state (for example the aspect source flag settings) can be used to alter the behaviour of SGS in subtle and creative ways, but of course if used unwisely can produce bizarre and unexpected effects.

Coordinate systems

In the discussion that follows, (i) all the coordinate systems mentioned will be 2-D and rectangular, (ii) official GKS terms will be given in capitals when they are being defined, and (iii) only rather ordinary cases are described. It should be read in conjunction with the diagram, which follows the discussion.


pdfpict

Figure 1: GKS Coordinate Systems


The workstation is the complete graphics station, consisting of at least a display device and perhaps some input devices as well. An example of a workstation is a VDU with keyboard and joystick; the VDU is the display device in this case. The region of a display device on which images can be displayed is called the display surface; for the example of the VDU the display surface is the addressable area of the screen.

Moving now to the other end of the chain, world coordinates are those in which the user (i.e. the programmer) wishes to work. The units may be natural for the information being plotted (counts versus Ångstroms for example) but equally often will simply be convenient units for planning the picture. (Note that the world coordinate x and y always increase from left to right and from bottom to top; this is a fundamental property of GKS.)

The window is mapped onto the display surface by means of a sequence of two independently controllable transformations. Each of the two transformations proceeds from a ‘window’ to a ‘viewport’.

The first transformation, called the normalisation transformation, starts with the user’s region of interest in world coordinates which is called simply the window. This maps onto an intermediate system, called normalised device coordinates (NDC); the NDC space consists of a square region whose bottom left and top right corners are respectively (0,0) and (1,1). The region within NDC space onto which the world coordinate window maps is called the viewport.

The second transformation is called the workstation transformation. For each workstation, there is a region in NDC space called the workstation window, and this maps onto part or all of a region of the display surface called the workstation viewport.

The NDC space is an idealised model of the different plotting devices; in particular, the things plotted in NDC space appear on the various devices without change of shape—a circle in NDC space will appear circular on all display devices, for example. Because of this conservation of aspect ratio, the workstation window may not map onto the whole of the workstation viewport, although this will commonly be contrived.

The normalisation transformation allows the window to be positioned on the display surface without needing to refer to any device units, and the workstation transformation allows different workstations to be treated separately.

Each workstation has its own workstation viewport and window and there can be many window (world coordinates) to viewport (NDC) transformations in existence, the one used to transform output coordinates being selected by GSELNT.

Buffering

Polylines and text strings are buffered within SGS and so at any time there may be lines and text which have been ‘plotted’ by SGS calls but have not yet been passed to GKS (let alone output to the workstation). Therefore any GKS calls should normally be preceded by a call to SGS_FLUSH to ensure that all graphics activities are presented to GKS in the correct order.

Transformations

SGS only sets normalization transformation number 1. Selecting a new zone is the only SGS activity that selects this to be the current transformation. Transformation 1 is used by SGS_SETCU when it sets the locator position.

SGS_SELZ also sets the input priority of transformation 1 to be greater than that of transformation 0 and the locator input routines expect transformation 1 to have the highest priority of all transformations.

Aspect source flags

SGS_OPEN and SGS_INIT set the following aspect source flags:

POLYLINE
— bundled
POLYMARKER
— individual
TEXT
— individual

SGS assumes these settings when it manipulates the polyline, marker and text attributes.

Polylines

Setting the SGS pen number simply sets the polyline index. If the ASF for any attribute has been changed to individual then that attribute will be unaffected by changing the SGS pen. Pen numbers greater than 4 may be used provided that the corresponding polyline index has been defined (either explicitly or by default). If any polyline indices (or any other primitive index) are set explicitly then this must be done before any drawing takes place, otherwise GKS will consider that the picture needs to be regenerated. When this happens, any drawing done outside a segment will be lost. Since Close Workstation forces regeneration if it is required, the net effect is for the workstation to be cleared when it is closed!

Markers

When the SGS pen number is changed, the colour index of the new pen on the current workstation is inquired and the polymarker colour index set to the same value. This results in markers being plotted in the same colour as lines on the current workstation but not necessarily on any other workstations that may be active. Activating a new workstation by selecting a new SGS zone modifies the colour index to match the polylines on the new workstation. If either the polyline colour index ASF has been set to individual or the polymarker colour index ASF has been set to bundled, this mechanism will fail.

The SGS marker routines set the current marker type. If the marker type ASF has been set to bundled, the marker type argument will have no effect.

Text

Text colour works in exactly the same way as marker colour and the same remarks apply. If any other text ASF is set to bundled, setting the corresponding SGS text attribute will have no effect.