Escape Functions


The GKS escape function provides a standard way of implementing nonstandard GKS features. The escape function call is shown below. An example of how to invoke GESC in the NCAR GKS package to create multiple metafiles in a single job is given in example pgkex21. For information on running GKS example codes, see Appendix A.
-------------------------------------------------------
           Argument | Type          | Mode  | Dimension
-------------------------------------------------------
CALL GESC  (FCTID,  | Integer       | Input |
            LIDR,   | Integer       | Input |
            IDR,    | Character *80 | Input |   LIDR
            MXODR,  | Integer       | Input |
            LODR,   | Integer       | Input |
            ODR)    | Character *80 | Input |   LODR
-------------------------------------------------------
FCTID
A function identifier.
LIDR
Dimension of the IDR input data record array.
IDR
Input data record.
MXODR
Maximum length of the ODR output data record array.
LODR
Dimension of the ODR output data record array.
ODR
Output data record.
Errors:
8, 180
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gescape(
    Gint                   func_id,      /*  function identifier      */
    const Gescape_in_data  *in_data,     /*  input data record        */
    Gstore                 *store_data,  /*  storage for output data  */
    Gescape_out_data       **out_data    /*  output data record       */
);

--------------------------------------------------------------------------
Distributed with NCAR graphics is a set of user entries that will perform the setting of the escape data records and call the GKS escape function. An escape function relevant to NCAR GKS has meaning only in NCAR GKS, and not in any other GKS packages. You should use the entries NGSETI, NGSETR, or NGSETC to make your escape calls. See the man pages for those utilities (which exist only in Version 4.0 or later). See also the man page for ngmisc_params which describes all of the available parameters. Here is a summary of the escape functions that exist in NCAR GKS:

Table 1: Summary of escapes in NCAR GKS

---------------------------------------------------------------------------
      |                                                |           | ngmisc
  #   |             Description                        |   Notes   | param.
---------------------------------------------------------------------------
-1390 | Returns 'NCAR_GKS0A--VERSION_4.0' in ODR       |           | none
-1391 | File name to be used for the next opened file  |           | ME
      | (using GOPWK) of category MO.                  |           |
-1393 | Picture name for the next picture. To name the | ncgm only | PI
      | first picture, call this escape before opening |           |
      | the workstation.                               |           |
-1394 | Flags whether segments will be deleted when    |           | SE
      | WISS is closed. Default is to delete them.     |           |
-1398 | Specify maximum number of GKS error messages   |           | ER
      | to issue before aborting. Default is ten.      |           |
-1399 | Flag to indicate if clipping to the NDC        |           | CL
      | viewport is on. The default is yes (incurring  |           |
      | about an 8% overhead.                          |           |
-1400 | Specifies the error allowed in matching the    | X11 only  | PE
      | requested colors, expressed as a percentage.   |           |
      | Default is 10.                                 |           |
-1401 | Tells the X driver to specify its own color    | X11 only  | PR
      | map rather than sharing with other windows.    |           |
      | Default is to share.                           |           |
-1512 | Specify spacing between software fill lines.   | PS only   | FI
-1513 | Specify spacing between hatch pattern lines.   | PS only   | HA
-1514 | Maximum size of the operand stack.             | PS only   | ST
-1515 | Maximum number of points in a path.            | PS only   | PA
-1516 | Scale factor for nominal linewidth.            | PS only   | NO
-1517 | Specifies whether background color will        | PS only   | FU
      | fill the entire page or just the viewport.     |           |
      | Default is viewport.                           |           |
-1518 | Specify type of line join. Default is "round". | PS only   | JO
-1519 | Specify type of line cap. Default is "round".  | PS only   | CA
-1520 | Specify miter limit of line joins. Default     | PS only   | MI
      | Default is 10.                                 |           |
-1521 | Coordinate points for positioning output.      | PS only   | LX,LY,
      | Default is largest square on output device.    |           | UX,UY
-1522 | Scale factor for representing coordinates.     | PS only   | CO
---------------------------------------------------------------------------
For details on escape functions that apply specifically to PostScript output workstations, see PostScript escapes.

To elaborate on the escape functions that apply specifically to direct X11 output, first consider escape number -1400. In the default environment, all X11 windows share a common color table and this table has 256 entries. This means that, in general, it is not possible to display 256 distinct colors in a single window. If some application is using a bunch of colors, then it may be that the window you are using to display NCAR Graphics will have only a limited number of colors available to it. If you request more colors, via calls to GSCR, than there are available to the given window, then a color matching algorithm is employed. The idea of the algorithm is that the color in the current color table that is "closest" to the requested color will be selected. "closest" is defined in terms of the normal distance metric on the RGB cube. If the closest color is farther away than the percentage error allowed times the length of the diagonal of the RGB color cube, then error number -220 is issued together with a warning. The closest color is still assigned for the requested color. A value of "0" for the error percentage specified in escape -1400 is a special value meaning "I don't care what color is selected." A value of "0" is the same as a value of "100". If a value of "0" or "100" is assigned, then the closest available color is assigned, no error message or warning is issued, and execution is continued.

Sometimes you might need to guarantee that 256 distinct colors are available to a given X window. The -1401 escape is meant to handle this situation. After escape -1401 is invoked, then when the mouse pointer is in the given window, that window will use the entire X11 color table for its own purpose. This may result in the colors in other windows being modified in accordance with the color table being used in the selected window. Colors are assigned to the color table of the selected window in response to GSCR calls, and these calls must be made after the escape is called.

As was stated earlier, you should invoke the GKS escape function calls, mentioned in Table 1 by calling the appropriate subroutine NGSETI, NGSETR, or NGSETC. For example, suppose you want to specify that the percentage error to allow in the color matching algorithm for output to an X11 window is "20" and you want the window to be able to use 256 distinct colors. The following code would accomplish this:

      PROGRAM DEMO
      C
      C  Open GKS, open and activate an X11 output workstation.
      C
            CALL GOPKS (6,IDUM)
            CALL GOPWK (3, 2, 8)
            CALL GACWK (3)
      C
      C  Specify a color matching percentage error of 20 for output
      C  to an X window workstation with identifier "3".
      C
            CALL NGSETI('Workstation ID',3)
            CALL NGSETI('Percentage error',20)
      C
      C  Specify that the window will have its own private color map.
      C
            CALL NGSETI('Private color map',1)
      C
      C  Define up to 256 colors.
      C
            CALL GSCR(3,0,0.,0.,0.)
            CALL GSCR(3,1,1.,1.,1.)
            CALL GSCR(3,2,1.,0.,0.)
            .
            .
            .
If you invoke an escape function that applies to a specific workstation type, it will have no affect on any of the other workstation types.
Links: GKS Index, GKS Home