home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / SOURCES / IPL / PART01.Z / PART01
Encoding:
Text File  |  1998-07-24  |  32.6 KB  |  1,059 lines

  1. Subject:  v21i032:  2D graphic system with table beautifier, Part01/14
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: eda626f5 fdf50b5e ae715bc8 9011af1b
  5.  
  6. Submitted-by: Steve Grubb <uunet!lsr-vax!scg>
  7. Posting-number: Volume 21, Issue 32
  8. Archive-name: ipl/part01
  9.  
  10. [  Yes there are many shar files, but the size is small.  -r$ ]
  11.  
  12. ipl    a 2-D graphic production system with table beautifier
  13.  
  14. Version 1.0, January 1990.
  15.   This directory contains the sources and examples for ipl,
  16. a 2-D graphics production system.  It produces scatterplots, 
  17. lineplots, bargraphs, range displays, pie graphs, U.S./Canada 
  18. maps, schedule charts, boxes, arrows, text, etc.  Produces 
  19. Postscript or Sunview output, based on a user-supplied control 
  20. file.  Included are a gallery of several dozen examples.  
  21. Also includes:
  22.   [] A table beautifier which is useful for taking plain text 
  23. tables, spreadsheet output, etc. and setting in a nice font.
  24.   [] A low-level subroutine library for producing nearly equivalent
  25. graphics (with shading) on Postscript and Sunview.
  26.  
  27. There are 14 shar files of 20-35 KBytes each.  
  28.  
  29.     Steve Grubb
  30.     uunet!lsr-vax!scg
  31.  
  32. # ipl part01
  33. #    This is a shell archive.
  34. #    Remove everything above and including the cut line.
  35. #    Then run the rest of the file through sh.
  36. #---------------------- cut here -----------------------------
  37. #!/bin/sh
  38. # shar:    Shell Archiver
  39. #    Run the following text with /bin/sh to create:
  40. #        README
  41. #        src/Makefile
  42. #        Cover
  43. #        Introduction
  44.  
  45. mkdir src bin tplates examples
  46.  
  47. cat << \SHAR_EOF > README
  48. ipl    a 2-D graphic production system with table beautifier
  49.  
  50. Version 1.0, January 1990.
  51.   This directory contains the sources and examples for ipl,
  52. a 2-D graphics production system.  It produces scatterplots, 
  53. lineplots, bargraphs, range displays, pie graphs, U.S./Canada 
  54. maps, schedule charts, boxes, arrows, text, etc.  Produces 
  55. Postscript or Sunview output, based on a user-supplied control 
  56. file.  Included are a gallery of several dozen examples.  
  57. Also includes:
  58.   [] A table beautifier which is useful for taking plain text 
  59. tables, spreadsheet output, etc. and setting in a nice font.
  60.   [] A low-level subroutine library for producing nearly equivalent
  61. graphics (with shading) on Postscript and Sunview.
  62.  
  63.  Developed on a SPARC machine (Solbourne 5/600) running SunOS 4.0, with 
  64. Sunview and Apple Laser-writers.  Also verified on Sun-3. 
  65.  I won't be able to send fixes or answer mail after 2-28-90.
  66. For anyone interested in converting to this XView-- sunview code is
  67. contained in one file only: sunv.c.
  68.  
  69. Written by:     Steve Grubb
  70.         Johns Hopkins University School of Medicine
  71.         550 North Broadway, 9th Floor
  72.         Baltimore, MD 21205  USA
  73.  
  74.  
  75.  
  76. TO VIEW THE SUNVIEW EXAMPLES: Do the following:
  77.     cd examples 
  78.     demo.sipl
  79. TO PRINT THE POSTSCRIPT EXAMPLES: Do the following:
  80.     cd examples
  81.     demo.pipl
  82. TO READ ONLINE DOCUMENTATION: read the "Introduction" file
  83. TO PRINT A COPY OF THE USER'S GUIDE: Enter run.manual
  84. TO PRINT A COPY OF THE EXAMPLES GUIDE: Enter run.examples
  85.  
  86. TO INSTALL: 
  87.      Uses ~ 1116 blocks after building.
  88.      Root permission is not required.
  89.      Run the shell script run.install, which will: 
  90.         build an install.h file 
  91.     do a "make" on the contents of the src directory
  92.      Executable will go in ./bin.  
  93.      You will have to create links in a "real" bin:
  94.     cd /usr/local/bin  (or whatever)
  95.     ln -s $d/bin/ipl tipl   # postscript 
  96.     ln -s $d/bin/ipl sipl   # sunview
  97.     ln -s $d/bin/ipl vipl   # interactive annotator
  98.     ln -s $d/bin/pipl pipl  # postscript to lpr(1)
  99.     ln -s $d/bin/nicetab nicetab  # the table beautifier
  100.  
  101. TO MODIFY CODE:
  102.      If IPL has already been installed and you are modifying 
  103.      code in the src directory, just do a "make".
  104.  
  105.  
  106. SHAR_EOF
  107. ############################
  108.  
  109. cat << \SHAR_EOF > src/Makefile
  110. # Makefile for IPL source    1-21-90 scg
  111. #
  112. #
  113.  
  114. IPL_OBJ = areadef.o areadress.o arrow.o bargraph.o boxplot.o \
  115. distribution.o draw.o errorbars.o exit.o \
  116. getdata.o initialize.o legend.o \
  117. lineplot.o map.o nicetab.o page.o pie.o \
  118. point.o polygon.o proc_call.o rangebar.o rect.o \
  119. text.o vbargraph.o vector.o vrangebar.o 
  120.  
  121. GRAPHIC_OBJ = graphic.o 
  122.  
  123. PICK_OBJ = dataclick.o get_point.o pick.o siplmenu.o viplmenu.o
  124.  
  125. GDP_OBJ = main.o gget.o constraint_check.o util.o
  126.  
  127. DRIVER_OBJ = sunv.o iplps.o pcode.o
  128.  
  129. LIB_OBJ = lib.o 
  130.  
  131.  
  132. # Use the following when Sunview is not available..
  133. # LIBES = -lm 
  134. # ipl: $(IPL_OBJ) $(GRAPHIC_OBJ) $(GDP_OBJ) $(PICK_OBJ) pcode.o iplps.o $(LIB_OBJ)
  135. #    cc $(IPL_OBJ) $(GRAPHIC_OBJ) $(GDP_OBJ) $(PICK_OBJ) $(DRIVER_OBJ) $(LIB_OBJ) \
  136. #      $(LIBES) -o ../bin/ipl
  137.  
  138. # Use the following when Sunview is available..
  139. LIBES = -lm -lsuntool -lsunwindow -lpixrect
  140. ipl: $(IPL_OBJ) $(GRAPHIC_OBJ) $(GDP_OBJ) $(PICK_OBJ) $(DRIVER_OBJ) $(LIB_OBJ)
  141.     cc $(IPL_OBJ) $(GRAPHIC_OBJ) $(GDP_OBJ) $(PICK_OBJ) $(DRIVER_OBJ) $(LIB_OBJ) \
  142.       $(LIBES) -o ../bin/ipl
  143.  
  144. $(GRPAHIC_OBJ) $(IPL_OBJ) $(GDP_OBJ) : ../install.h
  145. $(GRAPHIC_OBJ) : graphic.h
  146. $(GRAPHIC_OBJ) : graphic.x
  147. $(GRAPHIC_OBJ) : graphic.d
  148.  
  149. $(IPL_OBJ) $(PICK_OBJ) : ipl.h
  150. $(IPL_OBJ) $(PICK_OBJ) : ipl.x
  151. $(IPL_OBJ) $(PICK_OBJ) : ipl.d
  152. $(IPL_OBJ) $(PICK_OBJ) : graphic.h
  153. $(IPL_OBJ) $(PICK_OBJ) : graphic.x
  154. $(IPL_OBJ) $(PICK_OBJ) : graphic.d
  155.  
  156. $(GDP_OBJ) : gdp.h
  157. $(GDP_OBJ) : gdp.x
  158. $(GDP_OBJ) : gdp.d
  159.  
  160. map.o : mapdata.h
  161. areadef.o nicetab.o : areas.h
  162. sunv.o : shading.h
  163. SHAR_EOF
  164. ############################
  165.  
  166. cat << \SHAR_EOF > Cover
  167.     
  168.         ______________________________________________________
  169.     
  170.                 IPL Graphics Utility
  171.     
  172.     
  173.                    Version 1.0, Jan. 1990
  174.  
  175.                      USERS GUIDE
  176.         ______________________________________________________
  177.     
  178.  
  179.     
  180.             This guide contains the following:
  181.     
  182.  
  183.         [] Manual pages for ipl and nicetab
  184.  
  185.         [] Introduction paper
  186.     
  187.             I.     Introduction
  188.             II.     Control Files
  189.             III.     The Graphics Environment
  190.             IV.     Data Analysis Considerations
  191.             V.    Postscript and Sunview Drivers
  192.             VI.    Adding and Customizing
  193.             VII.    NT graphics primitives library
  194.     
  195.     
  196.         [] Template listings: Each IPL procedure has a template 
  197.           which defines every implemented parameter, its data type, 
  198.           and its default value if any.
  199.     
  200.         [] Example control files and graphic output.
  201. SHAR_EOF
  202. ############################
  203.  
  204. cat << \SHAR_EOF > Introduction
  205. _______________________________________________________________________
  206.  
  207. ipl(1)                                                      ipl(1)
  208.  
  209.  
  210. NAME:
  211.     ipl - a 2-D graphics production system
  212.  
  213.  
  214. SYNOPSIS:
  215.     pipl controlfile [arg2 arg3.. argN]
  216.     tipl controlfile [arg2 arg3.. argN]
  217.     sipl controlfile [arg2 arg3.. argN]
  218.     vipl controlfile [arg2 arg3.. argN]
  219.  
  220.  
  221. DESCRIPTION:
  222.     Produces 2-D graphics, based on a user-supplied controlfile,
  223.     on Postscript and Sunview devices.  Arg2.. argN are optional,
  224.     and will be substituted into the control file at $2, $3, etc.
  225.  
  226.     There are four different commands which are all really links
  227.     to the same executable: 
  228.     pipl - emits Postscript and sends it directly to lpr(1);
  229.     tipl - emits Postscript on standard output;
  230.     sipl - draws graphics under SunOS sunview(1);
  231.     vipl - allows interactive placement of text, arrows, boxes,
  232.         etc. under SunOS sunview(1).
  233.  
  234.     Ipl produces scatterplots, lineplots, bargraphs, range displays,
  235.     pie graphs, U.S./Canada maps, schedule charts, boxes, arrows, 
  236.     text, etc.  There is also a text table beautifier.  Field-
  237.     oriented plot data (separated by white-space) is expected.  
  238.     You can run the demo shell scripts (see below) to see for 
  239.     yourself.
  240.  
  241.     Often, graph development is done as follows:
  242.     - Copy an existing control file.  A number are supplied as
  243.     examples (see EXAMPLES, below);
  244.     - Edit the control file in a text editor.  It is helpful to
  245.     have template listings while doing this;
  246.     - Display using sipl if you have access to a workstation
  247.     running sunview, or pipl otherwise;
  248.     - Add annotations using vipl;
  249.     - Print using pipl or tipl.
  250.  
  251.     All files are located within the source distribution directory.
  252.     Your system administrator can tell you where this is.
  253.  
  254.  
  255. FILES:
  256.     ./Introduction   - user information
  257.     ./tplates/[A-Z]* - templates for all graphics functions
  258.  
  259.  
  260. EXAMPLES:
  261.     ./examples/demo.sipl ./examples/demo.pipl - demos
  262.     ./examples/*.g   - control file examples
  263.  
  264.  
  265. AUTHOR:
  266.     Steve Grubb, Johns Hopkins University School of Medicine
  267.  
  268. _______________________________________________________________________
  269.     
  270. nicetab(1)                                                  Nicetab(1)
  271.  
  272.  
  273. NAME:
  274.     nicetab - a text table beautifier
  275.  
  276.  
  277. SYNOPSIS:
  278.     nicetab tablefile [btextsize areaname ttextsize]
  279.  
  280.  
  281. DESCRIPTION:
  282.     Takes a text table (as produced in a text editor or by a
  283.     program) and attempts to set it up in a nice font.  Shading
  284.     and rulings can also be added.  Your finished table will get 
  285.     sent to the printer.
  286.  
  287.     Tablefile is the file containing the text table.  The three 
  288.     optional arguments must either all be given, or all omitted.  
  289.     They are: btextsize (text size of table body in points); areaname
  290.     (predefined IPL area name, see Areadef template); and ttextsize 
  291.     (text size of title in points).
  292.  
  293.     Nicetab is handy for obtaining publication quality tables 
  294.     quickly, without having to set up for tbl(1).  
  295.  
  296.     This is really a shell script which invokes pipl and gives
  297.     it a control file, and exists for convenience.  
  298.  
  299.     Things work best if you use two or more blank lines to
  300.     separate the title from the body; and use two or more spaces
  301.     to separate different cells on a row.  See the IPL Nicetab 
  302.     template for more information.
  303.  
  304. FILES:
  305.     ./tplates/Nicetab - ipl template 
  306.  
  307. EXAMPLES:
  308.     All files are located within the source distribution directory.
  309.     Your system administrator can tell you where this is.
  310.  
  311.     Try the following:
  312.         cd ./examples
  313.         nicetab table10
  314.  
  315.  
  316. _______________________________________________________________________
  317.  
  318.  
  319. INTRODUCTION
  320.  
  321.   IPL is a program which produces two-dimensional graphics, for data 
  322.  
  323. analysis and presentation.  It is written in C under SunOS 4.01 (Unix), 
  324.  
  325. and produces similar displays on Postscript printers or under Sunview.
  326.  
  327.   Its design goals include: good presentation-quality output, a rich set of
  328.  
  329. features and user-controllable parameters, and a simple, intuitive user
  330.  
  331. interface.  IPL is intended for any Unix environment where Postscript 
  332.  
  333. printers are available.  If Sunview is available, development time (and 
  334.  
  335. paper use) can be reduced by using the Sunview previewer.
  336.  
  337.   Any number of plots and tables can be combined or overlaid on a page.
  338.  
  339. Many graphic details can be controlled if desired-- however, many 
  340.  
  341. come with defaults, so that a decent looking plot can be composed
  342.  
  343. quickly, with a minimum of specification.
  344.  
  345.  
  346. TO TRY:
  347.  
  348.   Go to the directory where IPL was installed.  To find out what this
  349.  
  350. directory is, look at the end of this Introduction, where it should be
  351.  
  352. listed as the last in the installation history.  Enter: "cd examples".
  353.  
  354. You can now run a series of pre-made examples (on the laser-printer) by
  355.  
  356. entering the command "demo.pipl".  Beware-- this will run several dozen
  357.  
  358. pages worth of examples, and may tie up the printer for a while.  If you 
  359.  
  360. are at a Sun monitor running Sunview you can view the examples there, by
  361.  
  362. entering "demo.sipl".  Press return to see each graph.  The examples
  363.  
  364. can be run individually also.
  365.  
  366.   The files here which end in .g are the control files which produce
  367.  
  368. the examples.  Perhaps the easiest way to get started is to copy some
  369.  
  370. of these control files to your working directory and change them to suit 
  371.  
  372. your requirements.  Then run them using either the "pipl" command (for
  373.  
  374. laser printer) or the "sipl" command (for Sunview), as described below.
  375.  
  376.  
  377.  
  378.  
  379. THIS "INTRODUCTION" DOCUMENT:
  380.  
  381.   The document includes I) this introduction; II) a description of the
  382.  
  383. parameter files you use with IPL;  III) a description of the graphics
  384.  
  385. environment; IV) data analysis considerations; V) differences between
  386.  
  387. the Sunview previewer and Postscript output; VI) customizing IPL;
  388.  
  389. VII) the NT graphics primitive library.
  390.  
  391.  
  392. GENERATING A USER'S GUIDE:
  393.  
  394.   The complete User's Guide contains additional material.  To generate a
  395.  
  396. User's Guide, go to the IPL directory (see above) and execute "run.manual".
  397.  
  398. A large set of examples can be generated by executing "run.examples". 
  399.  
  400. Again, each of these will generate several dozen pages of printed output.
  401.  
  402.  
  403.  
  404. NOTICE:
  405.  
  406.   All code in the distribution directory has been placed into the public
  407.  
  408. domain and may be freely redistributed, as long as the following remains intact:
  409.  
  410. IPL Version 1.0 Jan. 5, 1990.  Copyright 1990.  Written by:    
  411.  
  412.     Steve Grubb
  413.     Wilmer Clinical Trials and Biometry
  414.     Johns Hopkins University School of Medicine
  415.     550 North Broadway #900
  416.     Baltimore, MD 21205
  417.  
  418. Use of any IPL code in products developed for profit is not allowed.
  419.  
  420.   No responsibility will be assumed for the correctness or completeness of this
  421.  
  422. software nor results or consequences suffered as a result of installing or 
  423.  
  424. using this software.  Users are entirely responsible for the correctness of 
  425.  
  426. their results.  The data in the examples is completely fictitious.  Good luck!
  427.  
  428.  
  429.  
  430. BUGS: 
  431. |
  432. | Lineplots using the stairstep option and not starting at the x minima
  433. | may go wild.
  434. |
  435. | Nicetab shaded blocks sometimes cover up bits of text descenders.
  436. |
  437. | On the Sunview previewer text appearance and size are just an approximation 
  438. | of the Postscript result.  Same for shading darkness.
  439. |
  440.  
  441. II. CONTROL FILES
  442.  
  443.   Control files are the files which tell IPL what to do.  They are supplied by
  444.  
  445. the user and made using the editor.  They could also be generated by a
  446.  
  447. program.  All the .g files in the examples directory are control files.
  448.  
  449. GENERAL FORMAT: The general format for these files is:        
  450.  
  451. |        Proc Procname:
  452. |          Parametername:    value
  453. |          Parametername:    text
  454. |                    more text
  455. |          Parametername:    value
  456. |
  457. |        Proc Procname:
  458. |          Parametername:    value
  459. |          Parametername:    value
  460. |            ...etc
  461.  
  462.  
  463. SYNTAX: An attempt has been made to make the syntax easy and intuitive to 
  464.  
  465. use.  Blank lines and spacing (as long as there is at least one blank or 
  466.  
  467. tab) are optional and a matter of style.  Capitalization of proc and parameter 
  468.  
  469. names is required, as are the colons.  The word "Proc" is required at the 
  470.  
  471. beginning of each procedure specification.  Note that text parameters may
  472.  
  473. use one of more lines.  Paramters that are lists must be contained on one line.
  474.  
  475.  
  476.  
  477. PROCS: Within the control file are one or more "procs".  Each proc performs 
  478.  
  479. an isolated function:
  480.  
  481.  
  482. | Procedure    Function is:
  483. | --------        ----------------------------------------------
  484. | Areadef     setting up a current graphics area on the page, including
  485. |           scaling, axes, subtitles, etc;
  486. | Bargraph     producing a bar graph; 
  487. | Boxplot    producing a Tukey box distribution representation;
  488. | Distribution  producing a scatter plot or bar distribution;
  489. | Draw        producing miscellaneous lines and rulings;
  490. | Errorbars    producing error bars;
  491. | Getdata     specifying plot data source and reading data;
  492. | Lineplot     producing a line plot; 
  493. | Legend    adding a legend;
  494. | Map         producing a United States / Canada map and state distributions;
  495. | Nicetab    beautifying tables; 
  496. | Page         specifying page title, paper position, and global parameters;
  497. | Pagebreak    force a page eject;
  498. | Pie        produces pie graphs
  499. | Polygon    drawing miscellaneous outlined and/or shaded polygons;
  500. | Rangebar    distribution representations in Y
  501. | QuitAppend    suppress final page eject so subsequent runs can be appended;
  502. | Text        adding labels, blocks of text, etc.;
  503. | Vbargraph    producing a vertical bar graph (same as bargraph above 
  504. |        except that bars go from left to right);
  505. | Vector        produces vector or arrow displays
  506. | Vrangebar     same as Rangebar but bars go from left to right.
  507.  
  508.   The procedures are executed in the order given.  A suggested sequence
  509.  
  510. would include "Page" to set up the page title, then "Getdata" to read in
  511.  
  512. some data.  Then, for every graphics area (window) on the page, "Areadef" to
  513.  
  514. set up a area to draw or plot in, then finally Bargraph or another of the
  515.  
  516. above to produce graphics within that window.  
  517.  
  518.  
  519. PROC TEMPLATES: The proc templates (located under "tplates" in the distribution 
  520.  
  521. directory) define the set of viable parameters, along with data types, default 
  522.  
  523. values, and English language descriptions.  There is one template per proc.  
  524.  
  525. It is helpful to have listings of these templates with you when you work.
  526.  
  527.  
  528.  
  529. PARAMETERS: Most procs have some parameters.  In your control file, you may 
  530.  
  531. specify as many parameters as you wish; those left unspecified will default 
  532.  
  533. to the value shown in the template.  Next to the parameter's name in the template
  534.  
  535. file is its data type.  
  536.  
  537. | Parameter data types used in IPL control files:
  538. |                          Data type              Sample legal value
  539. | Class:                    --------------------       --------------
  540. | numeric range            n to m, e.g. 0 to 5    2
  541. | any number             number            3.1415
  542. | a set                {center,left,right}    left
  543. | a data field number        dfield            3
  544. | character size         charsize        6
  545. | a shade (0 to 1)        color            0.9
  546. | a font name            font            /Helvetica
  547. | a word             token            hello
  548. | an (x,y) coordinate pair    coordpair        3.55 2.00
  549. | free form text         text            Hello world,
  550. |                            Are you there?
  551.  
  552. Sometimes, a parameter's data type entry in a template will be followed by 
  553.  
  554. a modifier in parentheses, such as (list10) which indicates that a list of 
  555.  
  556. up to 10 items of the given type will be expected; or (M) which indicates 
  557.  
  558. a mandatory parameter.  Other modifiers exist but are used internally.
  559.  
  560.  
  561.   COMMENTS are indicated by making the first non-white-space character on
  562.  
  563. the line a '#'.  Everything following will be ignored by the processor.
  564.  
  565.  
  566.   COMMAND LINE ARGUMENTS can be substituted into the parameter file as 
  567.  
  568. parameter values using the '$' followed by argument number.  $1 will 
  569.  
  570. become the first argument string, $2 the second, etc.  Since the parameter 
  571.  
  572. file is usually the first command line argument, the first usable command 
  573.  
  574. line argument will be the second, which can be accessed using $2.  The
  575.  
  576. '$' operator cannot be mixed with other text, e.g. "Subtitle: $1 Study"
  577.  
  578. is not allowed.  Example:     pipl "Number of Books Read" "During 1990"
  579.  
  580.                 Subtitle:    $2
  581.                         $3
  582.  
  583.  
  584.   CLONING: The "Saveas" and "Clone" parameters, which are available
  585.  
  586. for all procs, can be used to save and load environments to and from
  587.  
  588. files, meaning that only parameters that differ need to be specified again.  
  589.  
  590. See examp12.g, in the examples.   Because of implementation limits,
  591.  
  592. "Clone" and "Saveas" can not be used in the same proc.
  593.  
  594.  
  595.   COMMON USER MISTAKES: Among the most common of user errors is the 
  596.  
  597. mis-spelling of a parameter name (the parameter will be ignored silently!!),
  598.  
  599. omission of a colon, etc.  Make sure that any colons (:) that appear in
  600.  
  601. continuation lines of parameters are preceded with a backslash (\).
  602.  
  603. Be sure that the Areadef parameters Xticfmt and Yticfmt are appropriate 
  604.  
  605. for your data range-- for example if your Y range is from 0 to 1, you 
  606.  
  607. have to set Yticfmt to %4.1f.  Note that if you misspell a Postscript
  608.  
  609. font name or use a negative linewidth, chances are you won't get any 
  610.  
  611. laser printer output.  When doing bar graphs be sure that the 
  612.  
  613. Areadef parameter Xstart.0or1 is set to 1.  Other mistakes to avoid are: 
  614.  
  615. inconsistencies or extraneous matter in the data fields; not defining 
  616.  
  617. scaling or scaling increment properly; or giving a wild text, token, 
  618.  
  619. or list value.
  620.  
  621.  
  622.  
  623.  
  624. III. THE GRAPHICS ENVIRONMENT
  625.  
  626.   COORDINATE SYSTEM is always in inches, with the origin (0,0) in the lower 
  627.  
  628. left corner (a slight margin may exist).  Graphics areas are rectangles
  629.  
  630. on the display or page whose dimensions are specified in inches.  The user
  631.  
  632. can specify desired scaling within the graphics area, which becomes the
  633.  
  634. DATA coordinate system, since it is often set up to fit some data.  The
  635.  
  636. raw inch units described above are the ABSOLUTE coordinate system.
  637.  
  638.   TYPE can be of varied size and font.  Size is expressed in point sizes.  In
  639.  
  640. the templates, any parameter ending in "size" refers to a character size.  Gen-
  641.  
  642. erally, normal size is 10 to 12 point, with 8 point becoming small and 13
  643.  
  644. tending to be fairly large.  A point is equal to approx. 1/72 inch.
  645.  
  646. Paramters ending in "font" allow you to select a font by name from
  647.  
  648. available Postscript fonts.  Postscript font names start with a slash
  649.  
  650. (/).  The available fonts vary from printer to printer, but usually
  651.  
  652. the following are available: 
  653.  
  654. |  /Helvetica
  655. |  /Helvetica-Oblique
  656. |  /Helvetica-Bold
  657. |  /Helvetica-BoldOblique
  658. |  /TimesRoman
  659. |  /Times-Bold 
  660. |  /Times-Italic
  661. |  /Times-BoldItalic 
  662. |  /Courier 
  663. |  /Courier-Oblique 
  664. |  /Courier-Bold 
  665. |  /Courier-BoldOblique 
  666. |  /Helvetica-Narrow 
  667. |  /Helvetica-Narrow-Oblique 
  668. |  /Helvetica-Narrow-Bold 
  669. |  /Helvetica-Narrow-BoldOblique
  670. |  /Symbol
  671.  
  672.   POINTS can generally be marked by the use of a point symbol.  There are a
  673.  
  674. number of pre-defined symbols which can be accessed using the word "sym"
  675.  
  676. followed by a digit, indicating the shape, and a lower-case letter,
  677.  
  678. indicating the style.  For example, "Mark: sym1f" will produce lightly
  679.  
  680. shaded, outlined, triangles in Proc Distribution.  A display of available 
  681.  
  682. shapes and styles is included in the examples.
  683.  
  684.   LINES can sometimes be controlled in regards to line thickness and dash
  685.  
  686. pattern.  Any parameter ending in "linethick" will allow you to set the
  687.  
  688. line thickness.  A value of "1" is usually the default, with lower values
  689.  
  690. producing thinner lines, and higher values producing thicker lines.  Any
  691.  
  692. parameter ending in "linetype" will allow you to set the dash pattern of
  693.  
  694. lines.  A linetype of "0" produces a solid line.  For the dash patterns
  695.  
  696. and their linetype numbers see the accompanying example (example0.g).
  697.  
  698. Any parameter ending in "Magnify" will allow you to control the density
  699.  
  700. of the dash pattern, if a dash pattern is being used.  A smaller number
  701.  
  702. will cause more repetitions of the pattern to be drawn within any given
  703.  
  704. segment, while a higher "magnify" value will have the opposite effect.
  705.  
  706. "3" is a normal value for "magnify".
  707.  
  708.   SHADING can be specified by parameters ending in "..shade".  The
  709.  
  710. range of values is normally 1.0 for white to 0.0 for black.  The number of
  711.  
  712. gradients actually available depends on the printer hardware, but should
  713.  
  714. be at least eight.
  715.  
  716.  
  717.  
  718. IV. DATA ANALYSIS CONSIDERATIONS
  719.  
  720.    IPL follows the Unix philosophy in that incoming data is assumed to be
  721.  
  722. newline-terminated records containing data items delineated by white space 
  723.  
  724. (spaces or TABS).  For plotting purposes, these items are recognized as
  725.  
  726. "fields", beginning with field 1, up to the default maximum of 24 fields per
  727.  
  728. record.  The default maximum number of records is 1000.  The default number
  729.  
  730. of characters allowed in a field is 20.  The Getdata proc
  731.  
  732. is used to read in data from a file, or Unix command pipeline.  Data can
  733.  
  734. also be defined in the parameter file itself.  Data fields can be numeric,
  735.  
  736. alphabetic, or special characters.  Getdata includes joining, appending, 
  737.  
  738. and field selection capabilities.
  739.  
  740.   Plotting procs access data by field number, e.g. "Field: 3".  An effort
  741.  
  742. has been made for the plotting procs to handle non-numeric data fields (such as
  743.  
  744. missing codes) gracefully.
  745.  
  746.  
  747.  
  748. V. POSTSCRIPT AND SUNVIEW DRIVERS:
  749.  
  750.   Although ideally they should produce identical output, there are
  751.  
  752. some differences in the graphical output that is produced by the two
  753.  
  754. drivers.  Most of these are due to the resolution capability of the
  755.  
  756. hardware-- while laser printers offer 300 dots per inch or better,
  757.  
  758. the standard Sun screen is about 64 dots per inch.  This effects the
  759.  
  760. quality of shading and fonts rendering.  In general, the Sunview
  761.  
  762. displayer should be used as a previewer, then the output should
  763.  
  764. be finalized on the laser printer, with particular attention paid to
  765.  
  766. text.
  767.  
  768.  
  769.   "..WINDOW NOT PASSED IN ENVIRONMENT": If you see this or a similar
  770.  
  771. message when starting sipl or vipl, it is because of a Sunview bug 
  772.  
  773. which occurs when you do an "su -" to another UID and then try to 
  774.  
  775. create a window.
  776.  
  777.  
  778.   CHARACTER FONTS: The laser-printer driver uses high resolution
  779.  
  780. Postscript fonts.  The Sunview driver uses the fixed-width fonts
  781.  
  782. supplied with Sunview, which are available for most (but not all)
  783.  
  784. point sizes.  It tries to use the "cour.b" (Courier bold) series,
  785.  
  786. but may use other styles for certain point sizes.  Some point
  787.  
  788. sizes may not be available at all, in which case the closest available
  789.  
  790. size will be used.  When this happens, things may not line up the
  791.  
  792. same way that they will on the laser printer (such as blocks of text).
  793.  
  794. Also, since the graphics are scaled to the window size (while characters
  795.  
  796. are rendered at an absolute size), changes in the window size can also
  797.  
  798. cause discrepancies in output.  IPL expects the Sunview fonts to be in 
  799.  
  800. the directory /usr/lib/fonts/fixedwidthfonts.
  801.  
  802.   IMPORTANT: The Sunview driver does not display characters running 
  803.  
  804. vertically (such as the Y axis identifying label).  They are handled normally
  805.  
  806. by the Postscript driver.
  807.  
  808.  
  809.  
  810.   SHADING: The shading on the Sunview driver has been set up to correspond
  811.  
  812. closely to the equivalent Postscript shading, however it is coarser and
  813.  
  814. some shades contain visible patterns of pixels, again because of the lower 
  815.  
  816. resolution available.   Currently the Sunview driver works on standard,
  817.  
  818. gray-scale, and color displays, but does not exploit the gray-scale or
  819.  
  820. color capabilities.
  821.  
  822.  
  823.  
  824.   EPS CONSIDERATIONS: An attempt has been made towards making the Postscript
  825.  
  826. code generated by IPL compatible with the EPS guidelines.  All units are standard
  827.  
  828. 1/72 inch units, and each page is preceded by a save and followed by a restore.
  829.  
  830. The code does however, contain "showpage" commands which cause the page to get
  831.  
  832. printed and ejected.  These should be filtered out (i.e. with sed(1)) before 
  833.  
  834. combining with other images.
  835.  
  836.  
  837.  
  838. VI. ADDING AND CUSTOMIZING:
  839.  
  840.   It is possible to modify the graphics code, or add additional procedures 
  841. to IPL.  It is also possible to use the NT low-level graphics library
  842. in your own software.  The NT graphics library is a collection of routines 
  843. which produce equivalent graphic output on Postscript and Sunview.  
  844.  
  845. To add or modify a procedure do the following:
  846.  
  847. 1) Write (modify) the C subroutine to perform the desired function, using 
  848. the NT low-level graphics calls.  It should be put in the ./src directory,
  849. unless there is a good reason to do otherwise.  Pipl emits Postscript 
  850. code on standard output-- so make sure any messages you generate go to 
  851. standard error.  The header "ipl.x" should be #included.  The NT graphics
  852. calls are macros and can be found in ./src/graphic.d.
  853.    Wherever a parameter is needed, use the gget() routine, and create a name for 
  854. the parameter, such as "File".  For example, suppose we are writing a (trivial) 
  855. procedure for removing a file.
  856.     Remove( )
  857.         {
  858.         char fname[60];
  859.         gget( fname, "File" ); /* retrieve the "File" parameter value
  860.                     and place it in variable "fname" */
  861.         unlink( fname );
  862.         }
  863. The routine gget() will get the file name from the user's control file, or if
  864. not found there, it will check the default template file.  
  865.    The first letter of proc names should be capitalized.
  866.  
  867. 2) Add (modify) the template for your procedure to the directory ./tplates.
  868. Give the template the same name as your subroutine.  All parameters used in your 
  869. subroutine must have an entry in the template.  Also, the parameters "Saveas" and
  870. "Clone" must be present.  Check some of the other template files to get the
  871. idea.  For our example:
  872. |
  873. | Proc Remove:
  874. | File:        token    :    : file to be removed
  875. | Saveas:    token    :    : for saving parameter set
  876. | Clone:    token    :    : for loading parameter set
  877. | #
  878. | # This will remove the given file.
  879. |
  880. Since IPL 1.0 uses compile-time information instead of the template files,
  881. the following must by done: 1) Add the template information to ./gdp/template.h;
  882. 2) Update the indexes in ./gdp/template.h (each integer corresponds to number
  883. of lines in the respective template); 3) Make sure that the template information
  884. in ./template.h matches the information in the template file, since the latter
  885. is what users will go by.
  886.  
  887. 3) Add a line to ./src/proc_call.c. so that your subroutine will be invoked:
  888. | ...
  889. | else if( strcmp( proc, "Draw" )==0 ) Draw( );
  890. | else if( strcmp( proc, "Polygon" )==0 ) Polygon( );
  891. | else if( strcmp( proc, "Pagebreak" )== 0 ) { NTshow(); NTpaper( 0 ); }
  892. | else if( strcmp( proc, "Remove" )==0 ) Remove();  /* <<<-------  */
  893. | ..etc
  894.  
  895. 4) Update the Makefile, and do a make.
  896.  
  897. 5) Test by making a small control file and running:
  898. |
  899. | Proc Remove:
  900. | File: temp
  901. |
  902.  
  903. 6) Document what you did in the ./src/README file.
  904.  
  905.  
  906. To use the NT graphics library in other software:
  907.  
  908. 1) Make sure ./src/graphic.h or ./src/graphic.x are #included in your source
  909. files.
  910.  
  911. 2) Be sure to call NTinit( d ) early in your program to initialize the system.  
  912. The argument to NTinit() should be 't' for Postscript or 's' for Sunview.
  913.  
  914.  
  915. VII.  The NT low-level graphics primitive library
  916.  
  917.   This collection of subroutines can be used by other software for producing 
  918. graphics.  The object files sunv.o, iplps.o, pcode.o, and graphic.o must be 
  919. included at load time.  The header file "graphic.x" must be included in your 
  920. C source files.
  921.   There are two kinds of units: Absolute units are equivalent to inches, with
  922. the origin in the lower-left; Data units are set up by the user.
  923.   Shaded areas are done as in Postscript-- by defining a "fill path" consisting
  924. of a number of points, then shading the polygon defined by those points.
  925.  
  926.  
  927. NTinit( dev )    
  928. char dev;
  929.   This initializes the system based on the type of display device.  Currently 
  930. 't' and 's' are supported--  't' causes Postscript output to be emitted (on 
  931. standard output), while 's' causes graphics to be generated under sunview.
  932.  
  933. NTpaper( x )
  934. double x;
  935.   This sets paper orientation (0.0 = portrait, 1.0 = landscape).
  936.  
  937. NTmov( x , y )    
  938. double x, y;
  939.   Moves "current position" to the given absolute location.
  940.  
  941. #define NTlin( x , y )
  942. double x, y;
  943.   Draws a line to the given absolute location.
  944.  
  945. NTpath( x , y )
  946. double x, y;
  947.   Includes the given absolute location in the current fill path.
  948.  
  949. NTshade( x )
  950. double x;
  951.   Fill the current fill path with shade x.  X should be from 0.0 to 1.0.
  952.  
  953. NTtext( s )        
  954. char s[];
  955.   Generate text in the current font, size, and direction, starting at the
  956. current location.
  957.  
  958. /* center text between current location and a point w ABSOLUTE units away in the current text direction */
  959. NTcentext( s , w )    
  960. char s[];
  961. double w;
  962.   Centers text between the current position and a point w absolute units away 
  963. in the current text direction.
  964.  
  965. NTrightjust( s, w )
  966. char s[];
  967. double w;
  968.   Right justify text bewteen current location and a point w ABSOLUTE units 
  969. away in the current text direction.
  970.  
  971. NTfont( s )        
  972. char s[];
  973.   Set current font to s.  S must be a Postscript font name, must start with
  974. a '/', and must be available on the printer being used.  This must be called
  975. before producing text.
  976.  
  977. NTptsize( x )
  978. double x;
  979.   Set the current character size to x.  X is in points (approxomately 1/72 inch).
  980.  
  981. NTchardir( x )
  982. double x;
  983.   Set the current text rendering direction to x.  X is in degrees counter-clockwise.
  984. Zero degrees is normal, i.e., horizontal.  Note that anything other that 0 will
  985. not show up under sunview.
  986.  
  987.  
  988. /* select line attributes-- dash pattern string, line width, dash magnifier  */
  989. NTlinetype( s, x, y )    
  990. char s[];
  991. double x, y;
  992.   Sets current line drawing attributes.  S is the dash pattern ("0" through "8",
  993. see the IPL legend example), x is the line width (default is 1.0), and y is the
  994. dash pattern magnification factor (default is 3.0).
  995.  
  996. NTnormline()        
  997.   Resets line drawing attributes to a "normal line", i.e. all defaults.
  998.  
  999. NTshow()        
  1000.   Ejects page (printers).  Clears screen (sunview).
  1001.  
  1002. *** The following are used for setting up a user data space ***
  1003.  
  1004. setscale_x( xlow, xhi, datalow, datahi )
  1005. double xlow, xhi, datalow, datahi;
  1006.   Sets up data units in x, for an area from absolute location xlow to xhi, scaled
  1007. from datalow to datahi.
  1008.  
  1009. setscale_y( ylow, yhi, datalow, datahi )
  1010. double ylow, yhi, datalow, datahi;
  1011.   Sets up data units in y, for an area from absolute location ylow to yhi, scaled
  1012. from datalow to datahi.
  1013.  
  1014. NTm( x , y )        
  1015. double x, y;
  1016.   Move to the given point in data units.
  1017.  
  1018. NTl( x , y )        
  1019. double x, y;
  1020.   Draw a line to the given point in data units.
  1021.  
  1022. NTp( x , y )
  1023. double x, y;
  1024.   Add the given point (data units) to the fill path.
  1025.  
  1026. double da_x( d ) Translate the given data x location to absolute x.
  1027. double da_y( d ) Translate the given data y location to absolute y.
  1028. double ab_x( d ) Translate the given absolute x location to data x.
  1029. double ab_y( d ) Translate the given absolute y location to data y.
  1030. yymm_to_i( m ) Translate the given yymm (year/month) location to integer.
  1031.  
  1032. *** The following can be used for interactive mouse-oriented applications ***
  1033. *** See ./src/pick.c for more information. ***
  1034. getpick( rtn, proc, new, draw )
  1035. get_event( x, y, e )
  1036. get_string( s, p )
  1037. get_text( buf, p )
  1038. get_string_box( s, p, x1, y1, x2, y2 )
  1039. get_text_box( s, p, x1, y1, x2, y2 )
  1040. get_text_box_tp( s, p, x1, y1, x2, y2 )
  1041.  
  1042. *** Misc. ***
  1043. NTbatch_on() These invoke batching which increases efficiency.
  1044. NTbatch_off()    
  1045.  
  1046.  
  1047. INSTALLATION HISTORY:
  1048. --------------------
  1049. 011990 IPL installed on helios at: /usr/home/550/pub/src/ipl_1.0
  1050. 012290 IPL installed on helios at: /usr/home/550/pub/src/ipl_1.0
  1051. 012290 IPL installed on helios at: /usr/home/550/pub/src/ipl_1.0
  1052. 012290 IPL installed on helios at: /usr/home/550/pub/src/ipl_1.0
  1053. SHAR_EOF
  1054. ############################
  1055.  
  1056.  
  1057.