Contact us Heritage collections Image license terms
HOME ACL ACD ICF SUS DCS G&A STARLINK Literature
Further reading □ OverviewContentsPrefaceNotation1. Introduction2. Graphical output3. Coordinates4. Segments and Attributes5. Input devices6. Interaction styles7. Workstations8. Environment9. Input control10. Segment storage11. Metafiles12. Further facilities13. Individual attributesA. AbbreviationsB. Language bindingC. Complete programIndex
C&A INF CCD CISD Archives Contact us Heritage archives Image license terms

Search

   
ACDLiteratureBooksGKS
ACDLiteratureBooksGKS
ACL ACD C&A INF CCD CISD Archives
Further reading

OverviewContentsPrefaceNotation1. Introduction2. Graphical output3. Coordinates4. Segments and Attributes5. Input devices6. Interaction styles7. Workstations8. Environment9. Input control10. Segment storage11. Metafiles12. Further facilities13. Individual attributesA. AbbreviationsB. Language bindingC. Complete programIndex

Chapter 11: Metafiles

11.1 INTRODUCTION

When GKS is closed, all the information stored in GKS segments is lost. Segments only provide a mechanism for storing graphical information within a single invocation of GKS. A mechanism for long-term storage of graphical information is provided by GKS, the GKS metafile. A metafile may be written by one invocation of GKS and reused by subsequent invocations which may be the same program, a different program, a different user, a program at a different site etc.

The format and content of metafiles is a separate project within ISO. The CGM specifies a file and data format for the description of pictures (see Section 1.6). GKS specifies how metafiles are to be written and read and suggests one method for storing the metafile. This format is an interim measure until the CGM becomes an International Standard. However, there are occasions when this metafile will still be required. The format will not be discussed in this book.

Metafiles are treated by GKS as special categories of workstation. Metafiles are opened and closed by the same functions as other workstations. More than one metafile output workstation can be active simultaneously, to allow for different metafile formats (or media) being written simultaneously. Similarly, more than one metafile input workstation can be open simultaneously for reading. An installation will define particular workstation types belonging to categories GKS metafile input and GKS metafile output.

11.2 METAFILE OUTPUT

A GKS metafile output workstation has the following characteristics:

  1. Output functions are stored if the workstation is active.
  2. Attribute functions are stored.
  3. Segments are stored if the workstation is active.
  4. Geometric data is stored in a form equivalent to NDC.
  5. Non-GKS data may be written using the special function WRITE ITEM TO GKSM.

A metafile is regarded by GKS as a sequence of items, each of which has three components:

  1. Item type
  2. Item data record length
  3. Item data record

One or more items are generated for each GKS function call.

Suppose workstation type 12 is a GKS metafile output workstation. A trivial program creating output on a display and storing the information in a metafile is as follows:

      OPEN GKS(ERFILE, SU)
      OPEN WORKSTATION(1, 1, 3) 
      OPEN WORKSTATION(2, 2, 12) 
      ACTIVATE WORKSTATION(1) 
      ACTIVATE WORKSTATION(2)
      DUCK
      DEACTIVATE WORKSTATION(1) 
      DEACTIVATE WORKSTATION(2) 
      CLOSE WORKSTATION(1) 
      CLOSE WORKSTATION(2)
      CLOSE GKS

The duck will appear on the display and will also be stored on the metafile. The routine DUCK outputs two polylines and they will be stored as separate items on the metafile with their type set to indicate that they represent polylines.

GKS provides a function to allow an application program to store non-graphical data in the metafile:

WRITE ITEM TO GKSM(WS, TYPE, LENGTH, LDRA, DRA)

The particular values of TYPE (item type) that the application program may use and the maximum value of LENGTH (length of item data record) allowed are implementation dependent quantities and will be documented in the local installation handbook. In FORTRAN, DRA is the CHARACTER*80 array containing the information to be sent and LDRA is the dimension of the array. A typical use of this function would be to store alphanumeric descriptions of objects along with their graphical descriptions in the metafile.

11.3 METAFILE INPUT

When a GKS metafile input workstation is opened, the first item becomes the current item. There are three GKS functions for use in getting input from a GKS metafile input workstation: GET ITEM TYPE FROM GKSM, READ ITEM FROM GKSM and INTERPRET ITEM. The first is:

GET ITEM TYPE FROM GKSM(WS, TYPE, LENGTH)

This returns the type and data record length of the current item. TYPE is used to decide what action needs to be taken. The major differentiation is between the item type defining the end of the file, the item types defining non-graphical data, and the graphical item types. LENGTH may be used by the application program to check that it has sufficient space to store the metafile item and is also used by INTERPRET ITEM if the record is to be interpreted.

READ ITEM FROM GKSM(WS, MAXLEN, LDRA, DRA)

This returns the current item data record in the array DRA, which is of dimension LDRA, and MAXLEN is the maximum value of the item data record length. If the LENGTH returned by GET ITEM TYPE FROM GKSM is greater than MAXLEN, the excess parts of the data record are lost. Specifying a zero MAXLEN value, gives an efficient way of skipping records. The next item in the metafile becomes the current item.

INTERPRET ITEM(TYPE, LENGTH, LDRA, DRA)

This interprets the last data item read by READ ITEM FROM GKSM. The parameters to INTERPRET ITEM are the ones obtained by calling GET ITEM TYPE FROM GKSM and READ ITEM FROM GKSM. Interpreting an item may lead to an implicit regeneration (see Section 7.11).

The use of these three functions is illustrated in the following program where workstation type 13 is assumed to be a metafile input workstation and workstation type 3 is a refresh display:

      OPEN WORKSTATION(1, 5, 13) 
      OPEN WORKSTATION(2, 6, 3) 
      ACTIVATE WORKSTATION(2)
 100  CONTINUE
      GET ITEM TYPE FROM GKSM(1, TYPE, LENGTH) 
      IF(TYPE .EQ. EOF) GOTO 200 
      IF(LENGTH .GT. MAXLEN) STOP 
      READ ITEM FROM GKSM(1, MAXLEN, LDRA, DRA) 
      INTERPRET ITEM(TYPE, LENGTH, LDRA, DRA)
      GOTO 100
 200  CONTINUE
      DEACTIVATE WORKSTATION(2) 
      CLOSE WORKSTATION(1) 
      CLOSE WORKSTATION(2)

Note that it is not necessary to activate the metafile input workstation. If this program were given the metafile created by the example program in the previous section, the effect on the display from the two programs would be the same. If non-graphical output had been included in the metafile, the program would need to process these specially rather than allow them to be treated by INTERPRET ITEM.

⇑ Top of page
© Chilton Computing and UKRI Science and Technology Facilities Council webmaster@chilton-computing.org.uk
Our thanks to UKRI Science and Technology Facilities Council for hosting this site