Metafile control and printing

A special ASCII file called metafile is needed in order to produce pictures on paper. The metafiles are managed via all workstation control routines previously described. The general sequence of actions to use metafiles is:
- Open a FORTRAN file
- Open a workstation (IOPWK) with the type metafile
- Activate the workstation
- Produce some graphics
- Deactivate the workstation
- Close the workstation

Simplified metafile control

The routine IGMETA is provided in order to minimize the number of calls to specialized HIGZ workstation control routines and to improve the portability of applications. This routine opens, activates, deactivates or closes a metafile.
                       +--------------------------+
                       | CALL  IGMETA (LUN,KWTYPE) |
                       +--------------------------+
                                  
Action: This routine permits the selection of a metafile, offering a choice of graphic output to the screen and/or a metafile. Parameter Description:
LUN
Metafile logical unit number
LUN>0
The subsequent graphic output will be directed to both screen and metafile.
LUN<0
The subsequent graphic output will be directed to the metafile only.
LUN=0
Any previously open metafile is deactivated, and further graphic output will be directed to the screen only.
LUN=999
Any previously open metafile is deactivated and closed, and further graphic output will be directed to the screen only. PostScript metafiles need to be closed in order to be printed.
KWTYPE
Workstation type. If KWTYPE = 0, then IGMETA selects automatically the default workstation type. This defaults workstations depend on the underlying graphics package used (e.g. -111 for HIGZ/X11 or 4 for GKS-GRAL).

PostScript metafile type

In addition to the metafile type provided by the underlaying graphics package (for example 4 with GKS-GRAL), PostScript workstation types are also available independently from the underlying graphics package used allowing generation of high quality outputs. The PostScript workstation types have the following format:
                               -[Format][Nx][Ny][Type]
Where:
Format
Is an integer between 0 and 99 which defines the format of the paper. For example if Format=3 the paper is in the standard A3 format. Format=4 and Format=0 are the same and define an A4 page. The A0 format is selected by Format=99. The US format Letter is selected by Format=100. The US format Legal is selected by Format=200. The US format Ledger is selected by Format=300.
Nx, Ny
Specify respectively the number of zones on the x and y axis. Nx and Ny are integers between 1 and 9.
Type
Can be equal to:
1
Portrait mode with a small margin at the bottom of the page.
2
Landscape mode with a small margin at the bottom of the page.
4
Portrait mode with a large margin at the bottom of the page.
5
Landscape mode with a large margin at the bottom of the page. The large margin is useful for some PostScript printers (very often for the colour printers) as they need more space to grip the paper for mechanical reasons. Note that some PostScript colour printers can also use the so called "special A4" format permitting the full usage of the A4 area; in this case larger margins are not necessary and Type=1 or 2 can be used.
3
Encapsulated PostScript. This Type permits the generation of files which can be included in other documents, for example in LaTeX files. Note that with this Type, Nx and Ny must always be equal to 1, and Format has no meaning. The size of the picture must be specified by the user via the IGRNG routine. Therefore the workstation type for Encapsulated PostScript is -113. For example if the name of an Encapsulated PostScript file is example.eps, the inclusion of this file into a LaTeX file will be possible via (in the LaTeX file):
   \begin{figure}
   \epsffile{example.eps}
   \caption{Example of Encapsulated PostScript in LaTeX.}
   \label{EXAMPLE}
   \end{figure}

Note that all the figures in this manual are included in this way.
With Type=1,2,4 and 5 the pictures are centered on the page, and the usable area on paper is proportional to the dimensions of A4 format. Examples: -111 or -4111 defines an A4 page not divided. -6322 define an A6 landscape page divided in 3 columns and 2 rows.
                       +--------+--------+--------+
                       |   1    |   2    |   3    |
                       +---4----+---5----+---6----+
                       +--------+--------+--------+
                                  
The first picture will be drawn in the area 1. If the program clears the screen via ICLRWK, the graphics output will appear in the next area in the order defined above. If a page is filled, a new page is used with the same grid. Note that empty pages are not printed in order to save paper. Ignoring formats smaller than A12, the total number of possible different PostScript workstation types is: 4x9 x9 x13 +1 =4213 !

Usage of PostScript metafiles in an user application program

This section gives three examples showing the different ways of managing PostScript files. The first example is the more general way, using IOPWK, IACWK and IGQWK (see section ). The second example shows how to use the IGMETA routine. The last example use IGRNG and IGMETA.
                Example 1 :  IOPWK,  IACWK and  IGQWK
                                  
      DIMENSION R(2)

*
*              Open a Fortran file
*
      OPEN(UNIT=10,FILE='test1.ps',FORM='FORMATTED',STATUS='UNKNOWN')
*
*              Open and activate a workstation with the PostScript metafile
*              type -111 and with the workstation ID 5.
*              Note that the UNIT used to open the Fortran (here 10)
*              is given as second parameter.
*
      CALL IOPWK(5,10,-111)
      CALL IACWK(5)
*
*              Get the size of the available space on paper. This is
*              now possible because the Format is known.
*
      CALL IGQWK(5,'MXDS',R)
*
*              Compute the size of the viewport according to the paper
*              size. Note that if the screen has not the same RATIO the
*              picture on screen and on paper will be different. In this
*              case the user must inquire the screen size and compute
*              a new viewport with this size and redraw on the screen
*              with the metafile deactivated.
*
      XV=R(1)/R(2)/2.
      YV=XV
      CALL ISVP(2,0.,XV,0.,YV)
      CALL ISWN(2,X1,X2,Y1,Y2)
      CALL ISELNT(2)
          .
          .
        Drawing
          .
          .
*
*              Deactivate and close the metafile
*
      CALL IDAWK(5)
      CALL ICLWK(5)
      CLOSE(10)
                        Example 2 :  IGMETA
                                  

      DIMENSION R(2)
      OPEN(UNIT=10,FILE='test2.ps',FORM='FORMATTED',STATUS='UNKNOWN')
*
*              IGMETA permits the opening and activating of the metafile
*
      CALL IGMETA(10,-111)
      CALL IGQWK(2,'MXDS',R)
      XV=MIN(1.,R(1)/R(2))
      YV=MIN(1.,R(2)/R(1))
      CALL ISVP(2,0.,XV,0.,YV)
      CALL ISWN(2,X1,X2,Y1,Y2)
      CALL ISELNT(2)
          .
          .
        Drawing
          .
          .
*
*              Deactivate the metafile
*
      CALL IGMETA(0,0)
*
*              Close the metafile
*
      CALL ICLWK(2)
      CLOSE(10)
                         Example 3 :  IGRNG
                                  
      DIMENSION R(2)
      OPEN(UNIT=10,FILE='test4.ps',FORM='FORMATTED',STATUS='UNKNOWN')
      CALL IGMETA(-10,-111)
*
*              IGRNG defines a size in cm centered on the page.
*              Even if the RATIO of the screen and the RATIO of
*              the paper are not the same the picture will appear
*              exactly the same on both.
*              Note that in the case of Encapsulated PostScript~(-113)
*              a call to IGRNG is mandatory.
*
      CALL IGRNG(10.,10.)
          .

          .
        Drawing
          .
          .
      CALL IGMETA(0,0)
      CALL ICLWK(2)
      CLOSE(10)

LaTeX metafile type

HIGZ is able to produce metafiles which are ready to be included in LaTeX documents. These metafiles make use of the \picture environment. Compared to other possibilities of merging graphics into documents, LaTeX metafiles have a number of advantages:
  1. The dvi file is fully transportable as \special commands are not used. This file can be output on any device for which a driver exists. Documents can be written, formatted, and previewed on workstations while the dvi file can be sent via the network to a central server for printing.
  2. The metafile can be also merged into the LaTeX file to keep the full document in a single file.
  3. The power of LaTeX in text processing can be used in the primitive ITX for example to generate complicated mathematical formulae on a document.

    LaTeX metafile capabilities

    The capabilities of the \picture environment are basically limited to drawing straight horizontal or vertical lines. Slanted lines do exist but only in a limited number of slopes and a minimum length of #4mm. Therefore slanted lines have to be approximated by small steps of straight lines where the step size should be close to the printer resolution. The workstation type for LaTeX metafiles is -777 for embedded files or -778 for stand-alone files. Coordinates written to the metafile are integer numbers assuming a grid spacing of 0.1mm. Therefore the settings for XSIZE and YSIZE should approximately correspond to the final picture size.

    Line and marker types

    Line types 1 through 4 and marker types 1 through 5 are supported.

    Text fonts

    In addition to the software characters the font numbers -1 through -8 at precision 0 can be used. They map to the TeX fonts Roman, Emphatic, Bold, Italic, Slanted, Sans Serif, Small Caps, and Typewriter, respectively. TeX fonts look much nicer and are faster to generate than software characters generated by IGTEXT, but the disadvantage is that they are available in horizontal orientation only and the character size does not scale with the picture size. When using TeX fonts the IGTEXT control characters ``<>[]"#^?!'' are interpreted to obtain superscripts, greek letters, and other special characters. If a text string contains a ``\'' or ``{'' the remaining part is written verbatim into the metafile. This allows to use TeX formatting commands for elaborate displays. Of course ``{'' and ``}'' must be properly matched. The whole text is typeset in math mode which does not allow a change of fontsize in between. In order to format a formula on a larger size the formula text must be preceded by ``{}$\large$''.

    Configuration parameters

    To some extent, the appearance of a picture can be changed at formatting time by defining configuration parameters (in the LaTeX file) which have the following default values:
    \newdimen\higzunit \higzunit=0pt
    \newcount\higzstep \higzstep=2
    \newcount\higzdraft \higzdraft=0
    
    By default the picture is automatically scaled to fill the full page width. The picture size can be changed by setting \higzunit to the wanted grid spacing, e.g. to get the true XSIZE:
    \newdimen\higzunit \higzunit=0.1mm
    
    Slanted lines are approximated by straight lines along the major axis. The step size along the minor axis is \higzstepx\unitlength. By setting \higzstep=1 curves will look smoother but if line segments come too close to the printer resolution the dvi driver may choose not to display them. A larger value will result in faster formatting requiring less TeX memory. Setting \higzdraft=1 replaces the actual picture by an empty box of the same size to save formatting time during drafting.