PltDef.doc version 2.0
Tim Mooney 3/22/88

   A PltDef file describes the physical specifications and command
language of a plotter so that IntroCAD can render drawings on it. 
IntroCAD uses only the most primitive capabilities of a command language
so that a wide variety of plotters can be supported.

   PltDef files, for the most part, are ASCII files which contain only
printable characters and which can be edited with an ordinary text editor. 
This is because the most common plotter command languages use only printable
ASCII characters.  But the file format contains no strategy for encoding
non-printable characters in terms of printable codes (as the format of a
PrtDef file does) and so a PltDef file MAY contain non-printable ASCII
codes.


   IntroCAD makes a few assumptions about plotter command languages
that you must be clear on before attempting to write a PltDef file.

1) Coordinates:

      Points on the plotter page are referred to by pairs
   of integers; the X and Y coordinates.  The X coordinate is the
   first number of the pair, the Y coordinate the second.  The X and
   Y coordinates are separated by some character or string of
   characters--normally a space or a comma;  you must tell IntroCAD
   what the SEPARATOR is.  Pairs of coordinates are separated by the
   same character or string.


   Example: "100 200 150 300"
      Here: "100" and "150" are X coordinates; "200" and "300" are Y
      coordinates; coordinates are separated by space characters.

2) Pen Motion Commands:

      The command language contains at least a MOVE command and
   a DRAW command.  The MOVE command instructs the plotter to move,
   with the pen up off the page, to some location.  MOVE is followed
   by one pair of coordinates.  The DRAW command instructs the plotter
   to put the pen down on the page and drag it, from wherever it now
   lies, to each of several locations.  DRAW may be followed by any
   number of coordinate pairs.
      A complete command of any kind is followed by a TERMINATOR
   character or string.  You must tell IntroCAD what the TERMINATOR is.

   Example: "PU 100 200; "
      Here: "PU" is a MOVE command; " " is the coordinate SEPARATOR;
      "100 200" is a coordinate pair; and ";" is a command
      TERMINATOR.

   Example: "PU 10 200; PD 10 300 20 400 10 200; "
      Here: "PU" is a MOVE command; "PD" is a DRAW command; "10 200",
      "10 300", and "20 400" are coordinate pairs.  The coordinate
      SEPARATOR is a space and the command TERMINATOR is a semicolon.


3) Other Commands:

      IntroCAD also assumes the command language contains commands
   which direct the plotter to select a numbered pen, store the current
   pen, and select a numbered line type.  (IntroCAD 2.0 tolerates
   command languages which don't have a "line type" command, plotting
   solid lines regardless of the line type shown on the screen.)


   A PltDef file consists of eleven lines of text.  All lines must
contain fewer than 80 characters.  The first line is a comment line which is
read but otherwise ignored by IntroCAD.  The second line contains numbers
used for scaling a drawing to the plotter page.  The remaining lines contain
portions of plotter commands--strings of ASCII characters which are to be
sent to a plotter to accomplish some simple task. 

   Line by line:

1) TITLE

   Normally this line contains the name of the plotter or command
language for which the PltDef file was written.  This line may contain
anything or nothing. 

2) SCALE

   This line must contain the following three numbers in order:

   a) "UNITS_PER_INCH" -- This is the number of plotter units per
      inch for both the X and Y directions.  The number must be
      an integer.  This number is not normally the same as the
      plotter "resolution" or "repeatability" specification.  It
      is, rather, the scale factor which relates the numbers sent
      to the plotter with the distance the plotter pen moves.

   b) "X_INCHES" -- This number describes the page size in the X
      direction in inches and may be a real number.

   c) "Y_INCHES" -- This number describes the page size in the Y
      direction in inches and may be a real number.


      -----------------------------------------------------------------
      |                                                               |
      |   The remaining lines contain strings of characters which are |
      | typically plotter commands.  Since the strings may contain a  |
      | variable number of characters, a delimiting character is      |
      | used to mark the end of the string.  The delimiting           |
      | character need not be the same for all lines.  The first      |
      | character on a line is the delimiter for that line.           |
      |                                                               |
      |   Example:                                                    |
      |@ACB@                                                          |
      |   Here, "@" is the delimiting character and "ABC" is          |
      | the string to be sent to the plotter.                         |
      |                                                               |
      |   Example:                                                    |
      |!!                                                             |
      |   Here, "!" is the delimiting character and there is no       |
      | string to be sent to the plotter.  Note: if this is specified |
      | for a command which is to be followed by a number, the        |
      | number will still be sent.  (Exception: IntroCAD 2.0 doesn't  |
      | send the line type number if the line type command is         |
      | specified as !!.)                                             |
      -----------------------------------------------------------------


3) INITIALIZE

   The string enclosed in delimiters is sent to the plotter once
before any command strings or data.
(max length: 79 characters.)


4) SEPARATOR

   The string enclosed in delimiters may be sent to the plotter at any
time except in the middle of a number or another command string.
(max length: four characters.)


5) TERMINATOR

   The TERMINATOR string is sent to the plotter immediately following a
complete command.  See "Pen Motion Commands" above for examples of
IntroCAD's use of the TERMINATOR.
(max length: four characters.)


6) SELECT_PEN

   The SELECT_PEN string is always followed by an integer which tells the
plotter which pen to select.  Pen numbers begin at one.
(max length: four characters.)


7) STORE_PEN

   The STORE_PEN string directs the plotter to put the current pen away in
its holder.  (This string will not be followed by a number.)
(max length: four characters.)


8) MOVE

   The MOVE string instructs the plotter to move, with the pen up off the
page, to a location given by a pair of coordinates which follow.  MOVE will
always be followed by one pair of numbers.
(max length: four characters.)


9) DRAW

   The DRAW command instructs the plotter to put the pen down on the page and
drag it, from wherever it now lies, to each of several locations.  DRAW may
be followed by any number of coordinate pairs. 
(max length: four characters.)


10) LINE_TYPE

   The LINE_TYPE string is always followed by a number which tells the plotter
which line type to use.  IntroCAD assumes the new line type will be used until
another LINE_TYPE command is sent.
(max length: four characters.)


11) CLOSE

   The string enclosed in delimiters is sent to the plotter once after all
commands and data have been sent. 
(max length: 79 characters.)


----------------------------------------------------------------------------

BUGS:

   IntroCAD sends a space character after sending a one-digit number which
selects a pen.  This happens regardless of the SEPARATOR specification.

   After a complete DRAW command, IntroCAD sends a SEPARATOR followed by
a TERMINATOR.  (HPGL tolerates this behavior with no comment.)


----------------------------------------------------------------------------
Sample PltDef file.  
   In the following file, the exclamation point is used as a delimiting
character.  The capitalized text in line two will be ignored by IntroCAD.
In lines three through eleven, text which follows the second exclamation
point will also be ignored.
----------------------------------------------------------------------------
HPGL 1.0                   TITLE, VERSION
1016 10. 8.                UNITS_PER_INCH, X_INCHES, Y_INCHES
!DF;.N;19:.I81;;17:! INITIALIZE
! !                        SEPARATOR  (use space character if possible)
!;!                        TERMINATOR (for most languages, use nothing)
!SP!                       SELECT_PEN
!SP!                       STORE_PEN
!PU!                       MOVE
!PD!                       DRAW
!LT!                       LINE_TYPE
!!                         CLOSE      (nothing needed for my HPGL plotter)
----------------------------------------------------------------------------
