UNITED STATED DEPARTMENT OF THE INTERIOR
U. S. GEOLOGICAL SURVEY
JKPLOT VERSION 2.00: A device-independent plotting system written in QuickBasic for an IBM PC
by John O. Kork
Open-File Report 91-450A Program Disks 91-450B
************************** DISCLAIMERS *************************** Although these programs have been used by the U. S. Geological Survey, no warranty, expressed or implied, is made by the USGS as to the accuracy and functioning of the programs and related material, nor shall the fact of distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith. Any use of trade names is for descriptive purposes only and does not imply endorsement by the U. S. Geological Survey. This report is preliminary and has not been reviewed for conformity with the U. S. Geological Survey editorial standards. ***************** Denver, Colorado July, 1991 CONTENTS
I. Introduction 1 A. Development System 1 B. JKPLOT General Design Considerations 1 C. Instructions for Executing the Example Programs 2 II. Overviews A. General Graphics Software Considerations 4 1. Types of Graphics Software 4 2. Device Independence 4 3. Graphics Metafiles 5 B. Overview of the Software 6 1. Overview of the JKPLOT Device-Independent Code Modules and Possible Configurations 6 2. Overview of the JKPLOT Device-Dependent Code Modules and Possible Configurations 7 C. Overview of the Documentation 8 III. 2D-BASIC - The Basic 2 dimensional Plotting Routines 9 A. The Basic Plotting System 9 B. The Elementary JKPLOT Instructions 9 1. PLOTS 9 2. PLOT 10 3. SYMBOL 10 4. CSYMBOL 11 5. NUMBER 11 6. POLYLINE 11 7. NEWPEN 12 8. FACTOR 13 9. COMMENT 13 10. SETFNAM 13 C. Expanded Font Tables and Environmental Variables 13 D. Default Scaling 14 E. Structure and Use of the JKPLOT Device Drivers 14 1. Direct vs. Metafile Mode : 14 2. Code Modules for Direct Mode Plotting . 15 3. Metafile Mode " 17 4. Configuration Files 19 F. Examples Using the Elementary Plot System 19 1. Example 1 20 2. Modification of an Intermediate Plot File 21 3. Example 2 22 G. Windows, Viewports, and Clipping 22 1. Normalized Device Coordinates (NDC) 22 2. 2-Dimensional World Coordinates 23 3. General Window to Viewport Mappings 24 4. Clipping 26 5. 2-Dimensional Transformations 26 6. World Coordinate and Work Station Pipes 27 H. Using the Special JKPLOT System Switches 28 I. Constructing JKPLOT System Libraries 29 1. Stand Alone Libraries 29 2. Quick Libraries 29 J. Capabilities and Use of the File-reading Plot Driver, QF1.BAS 30 IV. 2D-AXES - 2 Dimensional Axes and Scaled Plotting 33 A. Introduction 33 B. Axis Types 33 C. The Axis Parameters 34 D. Drawing Axes 34 E. Setting Axis Parameters 37 F. Scaled Plotting 39 G. Axis Example Program 39 H. Intermediate Plot Files with Axis Commands 40 V. Basic 3D Plotting 41 A. Introduction 41 B. The 3d Workbox 41 C. Specifying the 3d Viewpoint 42 D. Initializing a 3d Plot 42 E. 3d Drawing Commands 45 F. Drawing 2d Plots in 3 dimensions 46 G. More General 3d Setup Commands 47 H. Windows, Viewports, Transformations, and Clipping Windows in 3d Plotting 48 I. Metafile Mode for 3d Plotting 49 VI. 3D-AXES - 3d Axes and Scaled Plotting 51 A. Introduction 51 B. Drawing Axes 51 C. 3d Axis Example Programs 52 D. Intermediate Plot Files with the 3d Axis Commands 53 VII. Conclusion 55 VIII. References 55 Appendices
A. TABLES . B. FIGURES C. EXAMPLE PROGRAMS D. EXAMPLE PLOT FILES E. COMPLETE LIST OF FUNCTIONS AND SUBROUTINES ORGANIZED BY MODULE F. COMPLETE LIST OF FUNCTIONS AND SUBROUTINES ORGANIZED ALPHABETICALLY G. JKPLOT SUBROUTINES AND FUNCTIONS WITH FILE OUTPUT FORM ORGANIZED BY MODULE H. JKPLOT SUBROUTINES AND FUNCTIONS WITH FILE OUTPUT FORM ORGANIZED ALPHABETICALLY I. GETTING STARTED J. CHANGING OR ADDING FONTS OR CHARACTERS
11 APPENDIX A - TABLES Appendix A - Page Table 1 - Four configurations and code size totals of the device-independent code modules in the JKPLOT system...... 1 Table 2. Numerical codes and defined constants for JKPLOT output devices ...... 1 Table 3. Defined constant and symbolic values for use with the NEWPEN command ...... 2 Table 4. Summary of standard calling sequences ...... 3-4 Table 5. Device specific code for plot drivers ...... 4 Table 6. Examples of intermediate plot file output for JKPLOT subroutine calls ...... 5-6 Table 7. Structured variable for storing axis information common to both vertical and horizontal axes. 6 Table 8. Structured variable type for defining axes...... 7
Table 9. Axis routines which cause drawing to occur...... 8 Table 10. Axis parameter-setting routines...... 8 Table 11. Scaled plotting subroutines...... 9
111 APPENDIX B - FIGURES Appendix B - page Figure 1. JKPLOT character fonts for standard SYMBOL call .. 1 Figure 2. Symbols for centered CSYMBOL call ...... 5 Figure 3. Examples of type of line drawn for selected values of the parameters LINTYP% and INC% .... 5 Figure 4. An elementary example showing the use of the JKPLOT system (size reduced) ...... 6 Figure 5. An example showing the result of modifying the intermediate plot file for Figure 4 (size reduced) ...... 6 Figure 6. An example showing the use of most of the elementary commands available in the JKPLOT system (size reduced) ...... 7 Figure 7. Sequence of images showing a duck in world coordinates, normalized device coordinates, and screen coordinates under default plot system settings ...... 8 Figure 8. Sequence of images of a duck in world coordinates, normalized device coordinates, and screen coordinates with a world coordinate window, work station window, and work station viewport selected ...... 8 Figure 9. Sequence of images of a duck in world coordinates, normalized device coordinates, and screen coordinates with a world coordinate^ viewport half as high as the world coordinate window ...... 9 Figure 10. Sequence of images of a duck showing the order of operations to complete a transformation.... 10 Figure 11. The complete 2-dimensional JKPLOT pipeline ...... 10 Figure 12. Images of an octagon as it is passed through the JKPLOT pipeline under cumulatively more complex operations ...... 11 Figure 13. Effect of JKPLOT system switches ...... 12 Figure 14. Menu for plot modification selections available using QF1.BAS ...... 12 iv Figure 15. Axis plot using all default parameters (size reduced) ...... 13 Figure 16. Suppression function effects on a single horizontal axis. A) no suppression, B) sub nolab, C) sub nunum, D) sub nofrst, E) sub nolast, F) sub noend ...... 13 Figure 17. Axis and scaled plotting example ...... 14 Figure 18. Location of the hypothetical "viewer" as specified by use of the subroutine call "vuabs(-5,-5,5) H ...... 15 Figure 19. Location of the hypothetical "viewer" as specified by use of the subroutine call »vuang(45 / 35 / 8.66)" ...... 15 Figure 20. Figure of a stadium-like object plotted within the default unit 3d workbox as viewed from the default 3d viewpoint ...... 16 Figure 21. Four figures of a stadium-like object plotted within specified workboxes. The workbox dimensions as specified by the Setwkbox subroutine are A) 1,1,1 B) 2,2,2 C) 1,2,1 and D) 1,1,2 ...... 17 Figure 22. 3D spiral drawn using absolute 3d coordinates .... 18 Figure 23. Defining the orientation of a plane in 3 dimensions for the Strgrafiti subroutine ..... 19 Figure 24. A simple plot using the grafiti commands ...... 19 Figure 25. Reproduction of five figures from Foley and \ f Van Dam [2]. A) Figure 8.46, page 307, B) Figure 8.47, page 307. C) Figure 8.47, using code on page 308. D) Figure 8.49, page 309 E) Figure 8.41, page 303 ...... 20 Figure 26. 3D spiral plotted using 3d axis commands and 3d scaled plotting ...... 20 Figure 27. Graph using 3d axis and scaled plotting commands . 21 APPENDIX C - EXAMPLE PROGRAMS