3 Environment Level Routines

 3.1 SGS routines
 3.2 PGPLOT routines
 3.3 GKS routines

As with all other packages in ADAM, the only access to objects outside of application programs is via ADAM program parameters. The connection between graphics devices and the application program is controlled by means of a few environment level routines.

3.1 SGS routines

SGS has four environment level subroutines (the SGS ‘parameter’ or SGSPAR routines) which provide the necessary interaction with the outside world. They are :



Subroutine
Function


SGS_ASSOC Associate a graphics workstation with a parameter and open it.
SGS_ANNUL Close a graphics workstation without cancelling the parameter.
SGS_CANCL Close a graphics workstation and cancel the parameter.
SGS_DEACT De-activate ADAM SGS.


Here is a skeletal example of a program using SGS :

        SUBROUTINE SGSTEST( STATUS )
        ..
        INTEGER STATUS
        INTEGER ZONE
  
        ..
  *    Obtain Zone on a graphics workstation
        CALL SGS_ASSOC( ’DEVICE’, ’WRITE’, ZONE, STATUS )
        IF( STATUS .EQ. SAI__OK ) THEN
  
           ..
  
  *       Perform graphics operations on the zone
  
           ..
  
  *       Release Zone
           CALL SGS_ANNUL( ZONE, STATUS )
        ENDIF
  
        ..
  
        CALL SGS_DEACT( STATUS )
  

SGS_ASSOC should be the first SGS routine to be called in the application. It obtains (via the parameter system) the name of the graphics workstation to be used, creates an initial SGS zone on the workstation, and returns an SGS zone identifier which can be used in subsequent SGS subroutine calls.

The first argument of SGS_ASSOC is an ADAM program parameter. It should be defined to be a graphics device parameter in the interface module for the application (see the example interface file in section4). The value of this parameter should be the name of a workstation as defined by GNS (see SUN/57).

The second argument is the access mode required. This can be one of :

’READ’
The application is only going to ‘read’ from the workstation (i.e. perform cursor or similar operations). Screens will not be cleared when vdu workstations are opened.
’WRITE’
The application is going to ‘write’ on the workstation, i.e. actually do some graphics. Workstations are completely initialized when they are opened.
’UPDATE’
The application will modify the graphics on the workstation. Screens will not be cleared when vdu workstations are opened.

Note that the facility to prevent screen clearing is specific to RAL GKS and is not implemented for all workstations.

The third argument is the SGS zone identifier returned to the application.

The fourth argument is the usual status value. It follows the ADAM error strategy as described in SUN/104.

When the application has finished using the workstation, it should be closed using SGS_CANCL unless it is required to keep the parameter active (to update a global parameter for example), in which case SGS_ANNUL should be used.

When the application has finished using SGS, it should be de-activated by calling SGS_DEACT.

3.2 PGPLOT routines

PGPLOT has four environment level subroutines (the PGPLOT ‘parameter’ or PGPPAR routines) which provide the necessary interaction with the outside world. They are :



Subroutine
Function


PGP_ASSOC Associate a graphics workstation with a parameter and open it.
PGP_ANNUL Close a graphics workstation without cancelling the parameter.
PGP_CANCL Close a graphics workstation and cancel the parameter.
PGP_DEACT De-activate ADAM PGPLOT.


Here is a skeletal example of a program using PGPLOT :

        SUBROUTINE PGPTEST( STATUS )
        ..
        INTEGER STATUS
        INTEGER UNIT
  
        ..
  *    Obtain Zone on a graphics workstation
        CALL PGP_ASSOC( ’DEVICE’, ’WRITE’, 1, 1, UNIT, STATUS )
        IF( STATUS .EQ. SAI__OK ) THEN
  
           ..
  
  *       Perform graphics operations on the device
  
           ..
  
  *       Release Device
           CALL PGP_ANNUL( UNIT, STATUS )
        ENDIF
  
        ..
  
        CALL PGP_DEACT( STATUS )

Note the close similarity with the SGS skeleton program. PGP_ASSOC should be the first PGPLOT routine called in the application. It obtains (via the parameter system) the name of the graphics workstation to be used, opens the workstation, and returns a PGPLOT unit number. PGPLOT only supports one graphics device open at one time so this unit number is always returned as one1.

The first, second and last arguments of PGP_ASSOC are the same as the corresponding arguments of SGS_ASSOC.

The third and fourth arguments are the number of sub-plots per page in X and Y (c.f. PGBEG).

The fifth argument is the unit identifier returned to the application.

When the application has finished using the workstation, it should be closed using PGP_CANCL unless it is required to keep the parameter active (to update a global parameter for example), in which case PGP_ANNUL should be used.

When the application has finished using PGPLOT, it should be de-activated by calling PGP_DEACT.

3.3 GKS routines

GKS has five environment level subroutines (the GKS ‘parameter’ or GKSPAR routines). Four provide the necessary interaction with the outside world and one gives access to the GKS internal status. They are :



Subroutine
Function


GKS_ASSOC Associate a graphics workstation with a parameter and open it.
GKS_ANNUL Close a graphics workstation without cancelling the parameter.
GKS_CANCL Close a graphics workstation and cancel the parameter.
GKS_DEACT De-activate ADAM GKS.
GKS_GSTAT Inquire whether GKS has reported an error (see Section 5).


Here is a skeletal example of a program using GKS :

        SUBROUTINE GKSTEST( STATUS )
        ..
        INTEGER STATUS
        INTEGER WKID
  
        ..
  *    Obtain Workstation
        CALL GKS_ASSOC( ’DEVICE’, ’READ’, WKID, STATUS )
        IF( STATUS .EQ. SAI__OK ) THEN
  
           ..
  
  *    Perform graphics operations on the workstation
  
           ..
  
  *       Release Workstation
           CALL GKS_ANNUL( WKID, STATUS )
        ENDIF
  
        ..
  
        CALL GKS_DEACT( STATUS )

Note the close similarity with the SGS skeleton program. GKS_ASSOC should be the first GKS routine to be called in the application. It obtains (via the parameter system) the name of the graphics workstation to be used, opens it, and returns a GKS workstation identifier which can be used in subsequent GKS subroutine calls.

The notes in the previous section on the arguments of SGS_ASSOC apply equally well to GKS_ASSOC with the exception that the third argument is a GKS workstation identifier rather than an SGS zone identifier.

The workstation is closed using GKS_ANNUL or GKS_CANCL when the application has finished using it.

When the application has finished using GKS, it should be de-activated by calling GKS_DEACT.

1PGBEG has a similar redundant argument so that if, one day, PGPLOT is extended to support multiple devices, existing programs would not have to be changed.