GDDM V3R2 Base Application Programming Guide
Previous topic | Next topic | Contents | Index | Contact z/OS | Library | PDF | BOOK


Plotting to scale

GDDM V3R2 Base Application Programming Guide
SC33-0867-01



You may need to plot your program's output at a specific size. You can do this by making each window (world-coordinate) unit represent a particular physical measurement in the plotted output. The programming example in Figure 117 makes one window unit plot as one millimeter, and then draws a 100-millimeter square.

To define the window units as required, you need to query three things: the number of rows and columns of notional cells in the current graphics field, the number of plotter units per cell in each direction, and the density of plotter units (or resolution) in both directions. This information is obtained at C and E .

The subsequent statements show how to calculate the number of window units to make one unit equal to one millimeter when plotted. The calculations multiply the number of rows and columns by the depth and width of a cell in plotter units to obtain the depth and width of the graphics field in plotter units. This value is divided by the number of plotter units per meter, and multiplied by 1000 to convert meters to millimeters.

Before the device can be queried, it must be opened, as at A . It is then made current, at B . Before the graphics field can be queried, it must be created. The example forces the creation of a default graphics field by issuing a graphics primitive call (GSMOVE at D ). Another way that the program could create the same graphics field is by explicitly using a GSFLD call, specifying the page size as returned in QDEV(3) and QDEV(4). The statements D and E would be replaced by the following lines:


     ROWS = QDEV(3);
     COLS = QDEV(4);
     CALL GSFLD(1,1,ROWS,COLS);

After the required graphics window has been created at F , a square of 100 window units is drawn. When plotted following the FSFRCE call at G , it is 100-millimeters square.



PLOT3: PROC OPTIONS(MAIN);

DCL PROCOPT_LIST(1) FIXED BIN(31); DCL NAME_LIST(2) CHAR(8); DCL DEV_TOKEN CHAR(8); DCL QDEV(8) FIXED BIN(31); DCL (ROW_POS,COL_POS,ROWS,COLS) FIXED BINARY(31); DCL (CELL_WIDTH,CELL_DEPTH,VERTCL_RESLN,HORZTL_RESLN, WINDOW_DEPTH,WINDOW_WIDTH) FLOAT DEC(6);

CALL FSINIT; /**************************************************************/ /* OPEN THE PLOTTER */ /**************************************************************/

NAME_LIST(1)='*'; /* Is attached to invoking term.*/ NAME_LIST(2)='ADMPLOT'; /* special GDDM-defined name */

/* DEV ID FAMILY TOKEN OPTIONS NAME */ CALL DSOPEN(303, 1, '*', 0,PROCOPT_LIST, 2,NAME_LIST); A

CALL DSUSE(1,303); /* Use as primary device */ B

/**************************************************************/ /* SET UP WINDOW TO GIVE 1 WINDOW UNIT = 1 MILLIMETER */ /**************************************************************/

CALL DSQDEV(303,DEV_TOKEN,0,PROCOPT_LIST,0,NAME_LIST,8,QDEV); C

CALL GSMOVE(0.0,0.0); /* Force creation of default */ D /* graphics field */ CALL GSQFLD(ROW_POS,COL_POS,ROWS,COLS); E

CELL_DEPTH = QDEV(5); /* Cell depth in plotter units */ CELL_WIDTH = QDEV(6); /* Cell width in plotter units */ VERTCL_RESLN = QDEV(7); /* Plotter units/meter vertically*/ HORZTL_RESLN = QDEV(8); /* Plotter units/meter horizontally*/ WINDOW_DEPTH = (CELL_DEPTH*ROWS/VERTCL_RESLN)*1000;/*Calculate required X..*/ WINDOW_WIDTH = (CELL_WIDTH*COLS/HORZTL_RESLN)*1000;/* ..and Y window units */

CALL GSUWIN(0.0,WINDOW_WIDTH,0.0,WINDOW_DEPTH); F

/**************************************************************/ /* DRAW A SEGMENT (A SQUARE) */ /**************************************************************/

CALL GSSEG(2); /* Current position = 0,0 */ CALL GSLINE(100.0,0.0); CALL GSLINE(100.0,100.0); CALL GSLINE(0.0,100.0); CALL GSLINE(0.0,0.0); CALL GSSCLS;

CALL FSFRCE; /* Send to plotter */ G

CALL FSTERM;

%INCLUDE ADMUPINA; %INCLUDE ADMUPIND; %INCLUDE ADMUPINF; %INCLUDE ADMUPING;

END PLOT3;


Figure 117. Scale plotting program

Go to the previous page Go to the next page



Copyright IBM Corporation 1990, 2012