home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / SNAV0111.ZIP / SNAV.PRN < prev    next >
Encoding:
Text File  |  1990-04-16  |  50.3 KB  |  787 lines

  1. <         the╔══╗╔══╗╔                      ╔
  2.             ║  ╙╢  ╙╢                      ║ █
  3.             ║   ║   ║ ╔═══╗ ╠═ ╔═══╗╔ ╔═══╗║ ╔ ╔═══╗╔ ╔═══╗╔ ╓─╖ ╔═══╗╔ ╔═╗╔═╗╔
  4.             ║   ║   ║ ║   ║ ║  ║   ╙╢ ║   ╙╢ ║ ║   ╙╢ ║   ╙╢ ║╓╜ ║   ╙╢ ║ ╙╢ ╙╢
  5.             ║   ║   ║┌╫───╜ ║ ┌╢    ║┌╢    ║ ║┌╢    ║┌╢    ║ ║║ ┌╢    ║ ║  ║  ║
  6.             ║   ║   ║│║   ╓─╢ │║   ╓╢│║   ╓╢ ║│║   ╓╢│║   ╓╢ ║║ │║   ╓╢ ║  ║  ║
  7.             ╜   ╨   ╙┘╚═══╝ ╚═╛╚═══╝╙┘╚═══╝╙─╨┘╚═══╝╙┘╚═══╝║┌╜╙─┘╚═══╝╙─╜  ╨  ║
  8.                                                       ╓────╫┘                 ║
  9.             ╓─────────────────────────────────────────╚════╝──────────────────╜
  10.             ╙─── architecture
  11.          
  12.             (software foundation)
  13.                                 SNAV - main documentation
  14.                                    - 16.4.90 page 1 -
  15.          
  16.                            ┌───────┐
  17.                  ─────────>│ AVNER │
  18.                  ─────────>│  BEN  │──────> Software Engineering Method
  19.                            └───────┘
  20.                  10 Dov-Hoz st. Tel-Aviv 63416 Israel tel. 972-3-221535
  21.          
  22.          
  23.          
  24.          
  25.          
  26.          
  27.          
  28.          
  29.          
  30.          
  31.          
  32.                    ┌─────────────────────────────────────────────────┐
  33.                    │             "The Screen NAVigator"              │
  34.                    │                                                 │
  35.                    │             THE C++ IMPLEMENTATION              │
  36.                    │                                                 │
  37.                    │            Version 1.10, April 1990.            │
  38.                    └─────────────────────────────────────────────────┘
  39.          
  40.                             Copyright (c) 1990 by Avner Ben.
  41.          
  42.          
  43.          
  44.          
  45.          
  46.          
  47.                                                   Written by  Avner Ben
  48.                                                               13 April 1990.
  49.                                              Original written 28 November 1989.
  50.                                 SNAV - main documentation
  51.                                    - 16.4.90 page 2 -
  52.          
  53.          EPREFACEF
  54.          E───────────────────────────────────────────────────────────────────────F
  55.          
  56.          The Screen NAVigator version 1.10 is implemented in 4 source files and
  57.          3  corresponding  header  files,  named  "snav0"  Through  "snav4".  A
  58.          make-file is  supplied to  compile these  files and  bind them  into a
  59.          library.  The code was developed on an AT clone using the Zortech  C++
  60.          compiler version 2.0.
  61.          
  62.          The  distribution  of  the  code  to  these  4 source files reflects a
  63.          functional partitioning.  Snav0  furnishes the most elementary  level:
  64.          a simple "geometry" of characters.  It supplies the basic objects  and
  65.          operators on which the whole of the system draws.  Snav1 supplies  the
  66.          (semigraphic)  "alphabet"  object.    The  data-structure  it supplies
  67.          allows the application to define semigraphic entities on the character
  68.          level,   and   manipulate   them   in   complete  disregard  to  their
  69.          machine-architecture,     collating-sequence     or     console-device
  70.          implementation.    Snav2  is  the  beginning  of a working application
  71.          level. precisely, it  supplies two generic  entities that the  user is
  72.          expected  to  elaborate  upon,  and  custom-tailor  to  his/her  exact
  73.          application, using the C++ implementation of polymorphism.  These  are
  74.          the  generic  "panel"  -  a  formatted  output device, and the generic
  75.          "shape" - an  outline drawing using  the semigraphic character  set or
  76.          course "typewriter graphics" (TWG).   While the "shape"  class complex
  77.          is supplied as a complete  application, which the user is  expected to
  78.          improve and extend, the "panel" class contains a "hollow  compartment"
  79.          (pure  virtual  methods),  which  the  user  must  fill-in  with   the
  80.          particulars of the various devices  he/she may be manipulating in  the
  81.          real world.
  82.          
  83.          A complete, annotated listing of the classes, hidden data and enclosed
  84.          methods  is  supplied  in  the  three  header  files.    The following
  85.          documentation discusses the contents in nontechnical language.  For  a
  86.          thorough study of  the data structures  involved and the  logic behind
  87.          their design, refer to file "article.prn".
  88.                                 SNAV - main documentation
  89.          E                                PREFACEF
  90.                                    - 16.4.90 page 3 -
  91.          
  92.          -1Technical note.-0
  93.          
  94.          The SNAV C++ implementation reflects many compromises in an attempt to
  95.          ensure  a  minimal  degree   of  machine  efficiency  in   an  overall
  96.          partitioning that is absolutely object-oriented.  Compromises apply to
  97.          method  implementation  and  hidden  data  redundancy.   SNAV does not
  98.          involve garbage collection; it attempts not to produce it  (references
  99.          that cannot be deallocated), at the cost of overhead, common with such
  100.          design policies.  The user  should be aware of when  functions receive
  101.          and return  by reference  and when  by value,  and work his/her memory
  102.          management policy accordingly.
  103.          
  104.          SNAV  applications  should  have  a  good  response time with fast 286
  105.          machines and above.  On slow AT's and fast XT's a negligible delay may
  106.          be apparent,  compared with  assembly-written drivers,  but, for  most
  107.          applications,  it  will  be  acceptable.    On  slow XT's and PC-G's a
  108.          noticeable delay may (not at all cases) become apparent.  For the last
  109.          4 years, I have been running my own character-graphic utilities, based
  110.          on early  versions of  SNAV, on  a number  of 4.77Mhz  XT's, and  have
  111.          survived the performance.  C++ does not compete assembler code in  the
  112.          field of performance.  C++ code, on the other hand, achieves  superior
  113.          performance in the  field of software  maintenance.  The  SNAV code is
  114.          generic.  Once you register your  copy, you may easily improve it,  to
  115.          suit your  application.   For example,  by replacing machine-sensitive
  116.          portions with  inline assembly,  a practice  enabled by  most modern C
  117.          compilers.
  118.                                 SNAV - main documentation
  119.                                    - 16.4.90 page 4 -
  120.          
  121.          ENOTATIONF
  122.          E───────────────────────────────────────────────────────────────────────F
  123.          
  124.          the following specification  makes use of  Object-Dependency Diagrams.
  125.          ODD is a  private notation developed  by me in  conjunction with Snav.
  126.          For syntax specification, refer to file "notation.prn".
  127.                                 SNAV - main documentation
  128.                                    - 16.4.90 page 5 -
  129.          
  130.          ESNAV0 - CHARACTER GEOMETRYF
  131.          E───────────────────────────────────────────────────────────────────────F
  132.          
  133.          ┌─────────────────────────────────────────────────────────────────────┐
  134.          │                                                                     │
  135.          │             │             │             │            │              │
  136.          │           d4│          d16│             │d2          │d16           │
  137.          │        ┌────┴────┐    ┌───┴───┐     ┌───┴───┐   ┌────┴───┐          │
  138.          │        │direction│    │inter- │  ┌─>│  axis │   │weight_d│          │
  139.          │        └─────────┘    │section│  │  └───┬───┘   └────┬───┘          │
  140.          │                       └───┬───┘  │      │            │              │
  141.          │                           │      │      │            │              │
  142.          │                           ├──────┘      └──┐         │              │
  143.          │                           │                │         │              │
  144.          │                         c4│                │         │              │
  145.          │                      ┌────┴────┐           │    ┌────┴───┐          │
  146.          │                      │direction│           └───>│ axis/  │          │
  147.          │                      └─────────┘                │ weight │          │
  148.          │                                                 └────────┘          │
  149.          │                                                                     │
  150.          └─────────────────────────────────────────────────────────────────────┘
  151.          
  152.          Compatibility.  Snav0 is the oldest part of the SNAV system. its logic
  153.          is deeply researched and is well tested.  Modifications due are likely
  154.          to expand its scope and affect mainly the hidden internals of classes.
  155.          Such  changes  are  not  likely  to affect referencing code seriously,
  156.          though some minor changes are possible.   The user is warned never  to
  157.          use explicit  integer values  when initializing or modifying  objects,
  158.          limit  the explicit usage of  enumerated values, and count as much  as
  159.          possible on system-supplied defaults.
  160.                                 SNAV - main documentation
  161.          E                      SNAV0 - CHARACTER GEOMETRYF
  162.                                    - 16.4.90 page 6 -
  163.          
  164.          -1DIRECTION.-0
  165.          
  166.          The  datatype  "direction"  has  a  domain of five values, represented
  167.          internally  by  an  integer.    It  is  really an enumerated type with
  168.          methods.  The values correspond  to the four directions of  the plane,
  169.          and the null direction.  Methods are supplied for obtaining the  names
  170.          of  these  values.    By  default,  an  object  of  class direction is
  171.          initialized to "Right", weighing 1 (being the most common direction in
  172.          European language texts).   Operators are supplied for  "incrementing"
  173.          and "decrementing" the value to obtain a succession of directions (the
  174.          order is predefined).  This makes possible such typical loops as:
  175.          ┌─────────────────────────────────────────────────────────────────────┐
  176.          │ for (direction dir; dir(); dir++) // dir() returns integer value    │
  177.          └─────────────────────────────────────────────────────────────────────┘
  178.          
  179.          The  values  are  incremented  in  powers  of  2, to allow for bitwise
  180.          arithmetic,  and   set  operations   in  the   more  complex  datatype
  181.          "intersection".  The bitwise arithmetic makes the application somewhat
  182.          less conceptual, but  has proven to  reduce response time  of the demo
  183.          program in about 10%, over ordinary multiplication and division.  Note
  184.          that  direction  and  intersection  method  references  are  the  most
  185.          frequent  operations  in  a   SNAV  application,  and  their   optimal
  186.          performance must overcome design elegance.
  187.          
  188.          For  convenience,  snav0  predefines  five  objects of type direction,
  189.          supplying the whole domain, (intended to be read only).
  190.          
  191.          Compatibility.    Future  versions  of  SNAV  may expand the direction
  192.          domain to acknowledge directions of  the dimension of depth.   Also, a
  193.          scheme may be introduced to allow the user to define his/her direction
  194.          ordering.   Neither of  these changes  is expected  to affect  present
  195.          applications seriously.
  196.                                 SNAV - main documentation
  197.          E                      SNAV0 - CHARACTER GEOMETRYF
  198.                                    - 16.4.90 page 7 -
  199.          
  200.          -1INTERSECTION.-0
  201.          
  202.          The datatype "intersection" is a bitwise implementation for a "set  of
  203.          directions".    Its  domain  includes  16  values.  An object of class
  204.          intersection may "include" (but  not physically yield), at  any moment
  205.          of its  existence, between  zero and  four distinct  directions.   The
  206.          intersection does not  physically allocate the  set of directions  for
  207.          reasons of  machine efficiency.   Anyway,  the need  for that does not
  208.          come up in practice. This typically results in loops such as this:
  209.          ┌─────────────────────────────────────────────────────────────────────┐
  210.          │ // given is intersection avdir (available directions)               │
  211.          │ for (direction dir; dir(); dir++)                                   │
  212.          │   if avdir>=dir ...      // direction is included                   │
  213.          └─────────────────────────────────────────────────────────────────────┘
  214.          
  215.          Supplied  are  the  necessary  set-theoretic  operators for inclusion,
  216.          exclusion and their test, on both member and subset level.
  217.          
  218.          Intersections are classified in  "types", according to their  internal
  219.          organization,  having  functional  significance  in  the   semigraphic
  220.          application, such  as "corners",  "forks", "arrowheads"  etc.  Methods
  221.          for obtaining these types and  their names are supplied.   By default,
  222.          an object of class intersection is initialized to all directions (type
  223.          "cross").
  224.          
  225.          Snav0 predefines a limited  number of intersection objects,  having to
  226.          do with class "axis".
  227.          
  228.          Compatibility.   All changes  to the  direction domain  will naturally
  229.          affect the intersection domain (being derived from it).
  230.                                 SNAV - main documentation
  231.          E                      SNAV0 - CHARACTER GEOMETRYF
  232.                                    - 16.4.90 page 8 -
  233.          
  234.          -1AXIS.-0
  235.          
  236.          "Axis" (or  dimension) is  a private  case of  intersection, including
  237.          exactly two directions,  that are held  to be "opposite".   Of the  16
  238.          intersections possible with the four directions of the plane,  exactly
  239.          2 qualify for axis.  These are called normally "horizontal"  (weighing
  240.          1) and "vertical" (weighing 2), and sometimes "y" and "x".
  241.          
  242.          An obvious case for using  an axis (rather than plain  intersection or
  243.          direction), is  to measure  the weight  of a  character.   The need to
  244.          generalize  directions  into  an  axis  also  arises  when plotting or
  245.          tracing an arc on the screen.
  246.          ┌─────────────────────────────────────────────────────────────────────┐
  247.          │ // given is direction dir                                           │
  248.          │ axis dim(dir); // allocates the axis on which dir is progressing    │
  249.          └─────────────────────────────────────────────────────────────────────┘
  250.          
  251.          Snav0 predefines objects  for the axis  domain, and the  corresponding
  252.          intersections.
  253.          
  254.          Compatibility.  SNAV 1.10 implementation of axis assumes 2  dimensions,
  255.          for machine efficiency.  The  addition of a third dimension  may  cause
  256.          loss of performance, but no serious effect on current code.
  257.          
  258.          -1AXIS_WGT.-0
  259.          
  260.          A technical datatype  needed by weight_d.   Stores the  "weight" (line
  261.          thickness) on an axis of the plane.  Has no important methods, and  is
  262.          not normally referenced.
  263.                                 SNAV - main documentation
  264.          E                      SNAV0 - CHARACTER GEOMETRYF
  265.                                    - 16.4.90 page 9 -
  266.          
  267.          -1WEIGHT_D.-0
  268.          
  269.          The datatype  "weight_d" (weight  distribution) is  the bridge between
  270.          the  abstract  geometrical  concepts  defined  so  far  and  the  more
  271.          practical world  of characters  on the  panel.   It is  also the first
  272.          class dealt with so far, that internally allocates objects of  another
  273.          class, rather than a simple numeric code.
  274.          
  275.          An object of class weight distribution internally allocates a pair  of
  276.          axis/weight objects, storing the weight (line thickness), possibly  of
  277.          some character  or class  of characters,  on each  axis of  the plane.
  278.          Where characters are concerned, that obviously denotes the  horizontal
  279.          stroke  and  vertical  stroke.    In  SNAV, Semigraphic characters are
  280.          assumed to have  an even weight  distribution, and therefore,  exactly
  281.          two weights, one per axis.
  282.          
  283.          Obviously  ,the  combination  of  weight-distribution and intersection
  284.          uniquely defines one semigraphic. for example:
  285.          ┌─────────────────────────────────────────────────────────────────────┐
  286.          │ intersection avdir(RTDIR+LTDIR+DNDIR); // initialized by int value  │
  287.          │ weight_d wgt(2,1); // initialized to double horizontal stroke       │
  288.          └─────────────────────────────────────────────────────────────────────┘
  289.          has  the  potential  to  yield  the  character  ╤  (we  still  need an
  290.          "alphabet" class to generate it - see snav1).
  291.          
  292.          Four weights are assumed arbitrarily (expressing the pc extended ASCII
  293.          code-set):  1 and 2 denote the semigraphic subset of the pc (or  other
  294.          "newcode") alphabet. 3 ("full") is used for the full-pixel  character.
  295.          0 is used for  "TypeWriter Graphics" (TWG) -  the characters + -  | <>
  296.          V^, but only when combined to create rudimentary charts.
  297.          
  298.          Snav0 predefines objects for pc-useful weight distributions.
  299.          
  300.          Compatibility.    All  changes  to  the  number of axes supported will
  301.          naturally affect the internal  storage of weight distribution.   Added
  302.          arguments will default to support a two-dimensional system as subset.
  303.                                 SNAV - main documentation
  304.                                    - 16.4.90 page 10 -
  305.          
  306.          ESNAV1 - CHARACTER GEOMETRYF
  307.          E───────────────────────────────────────────────────────────────────────F
  308.          
  309.          ┌─────────────────────────────────────────────────────────────────────┐
  310.          │                                                                     │
  311.          │                                       │                             │
  312.          │                                       │p*                           │
  313.          │                                   ┌───┴────┐                        │
  314.          │                                   │computer│                        │
  315.          │                                   │alphabet│                        │
  316.          │                                   └───┬────┘                        │
  317.          │                                       │                             │
  318.          │                            ┌──────────┴────────┐                    │
  319.          │                          d*│                c16│                    │
  320.          │                          ┌─┴──┐          ┌─────┴──────┐             │
  321.          │            ∙∙∙∙∙∙∙∙∙∙∙∙∙∙│char│      ∙∙∙>│intersection│             │
  322.          │            ∙             └─┬──┘      ∙   └────────────┘             │
  323.          │            ∙     ∙∙∙∙∙∙∙∙∙∙│∙∙∙∙∙∙∙∙∙∙         │                    │
  324.          │            ∙     ∙  ┌──────┴─────┐             │                    │
  325.          │            ∙     ∙ c│           c│          c16│                    │
  326.          │            ∙  ┌─────┴──────┐ ┌───┴────┐    ┌───┴────┐               │
  327.          │            ∙  │intersection│ │weight_d│∙∙∙>│weight_d│               │
  328.          │            ∙  └────────────┘ └────────┘    └───┬────┘               │
  329.          │            ∙                                   │                    │
  330.          │            ∙                                   │                    │
  331.          │            ∙                                   │                    │
  332.          │            ∙                                 ┌─┴──┐                 │
  333.          │            ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙>│char│                 │
  334.          │                                              └────┘                 │
  335.          │                                                                     │
  336.          └─────────────────────────────────────────────────────────────────────┘
  337.          
  338.          Compatibility.   Any reference  whatsoever to  snav1 involves  objects
  339.          defined on snav0, so  any change to the  latter will affect it  in the
  340.          obvious way.  Snav1 itself is a rather  straightforward implementation
  341.          of the general architecture  needed to support a  semigraphic alphabet
  342.          on most  current computers.   A  PC-oriented alphabet  is supplied  by
  343.          default, which may be replaced or dynamically modified by the user.
  344.                                 SNAV - main documentation
  345.          E                      SNAV1 - CHARACTER GEOMETRYF
  346.                                    - 16.4.90 page 11 -
  347.          
  348.          -1COMPUTER_ALPHABET.-0
  349.          
  350.          An alphabet object consists of an  array of weights  and intersections
  351.          (stored by  integer value),  where each  pair defines  the semigraphic
  352.          qualities,  if  any,  of  the  character  bearing  that  number in the
  353.          collating sequence in use.  A  method is supplied to "poke" values  to
  354.          the array, thus modifying  the collating sequence during run-time.  In
  355.          addition, the alphabet constructor optionally takes a  null-terminated
  356.          integer array, specifying all the needed pokes in advance.
  357.          
  358.          The Constructor must  receive the maximum  number of characters  to be
  359.          used, including binary  zero (256 in  the pc example).   This may  not
  360.          change.      From   this   information,   the   alphabet  allocates  a
  361.          cross-reference  table,  allowing  fast  retrieval  of  characters  by
  362.          semigraphic attributes, which is the main purpose of the SNAV  system.
  363.          The  reference   table  is   updated  in   real-time,  reflecting  any
  364.          modification to  the collating  sequence.   For example,  a method  is
  365.          supplied for "inverting"  the whole alphabet  on a selected  axis, for
  366.          uses such  as migrating  from English  to Hebrew  in the  middle of  a
  367.          sentence.    Note  that  the  alphabet  has  no copy operator, so each
  368.          alphabet declared (normally referenced by pointer) must be initialized
  369.          separately.      Note   that   SNAV  expects  semigraphic-to-character
  370.          assignments to be unique.  No check is made to ensure that you do  not
  371.          assign the same  attributes to two  characters (by collating  sequence
  372.          number).  The matching mechanism will come up with the match of  lower
  373.          ascii value, which may not always be what you may expect!
  374.          
  375.          The important alphabet methods deal with retrieval of characters  from
  376.          the present collating sequence, using separately prepared  semigraphic
  377.          attributes (weight and intersection), and with the opposite,  querying
  378.          the attributes of a given character.  These methods may be combined to
  379.          create  continuous  contour  shapes,  using  semigraphics  of  various
  380.          weights - see snav2.
  381.          
  382.          "Cdir" and  "cweight" are  low-level methods  that retrieve  character
  383.          attributes.  "Get_c" is a delicate mechanism for retrieving  character
  384.          by  attributes.    It  tests  a  sequence  of  6  search  paths,  from
  385.          straightforward  to  less  obvious  alternatives,  before  it gives up
  386.          (returning space).  This mechanism is based upon long experience  with
  387.          live material.  The user is warned not to modify it, unless in case of
  388.          real emergency, because many higher level objects expect it to  behave
  389.          this way!  "Translate" does the same working the specification from  a
  390.          sample character.
  391.                                 SNAV - main documentation
  392.          E                      SNAV1 - CHARACTER GEOMETRYF
  393.                                    - 16.4.90 page 12 -
  394.          
  395.          Higher  level  methods  deal  with  character  "connectivity",   where
  396.          elements are considered two at a time.  "Ccont" (Character  CONTinues)
  397.          tests if two characters connect in  a given direction. it is the  main
  398.          primitive of semigraphic shape construction and recognition.   "Carrw"
  399.          (one Character in ARRoW) is the bridge between the technical  alphabet
  400.          and application world of shapes.  Carrw suggests the next character in
  401.          an  "arc"  (straight  line),  given  its weight, general direction (In
  402.          SNAV,  everything  is  either  moving  in  some  direction  or  is not
  403.          semigraphic), planned length,  position and if it is pointed.  The key
  404.          argument is the "environment string", a type of argument used all over
  405.          the system.  This consists  of five characters, number zero  being the
  406.          target character,  and the  other four  its neighbors  on the  screen,
  407.          their  positions  (1-4)  determined  by  the  order  inherent  in  the
  408.          direction datatype  (obtained by  direction::serial()).   The user  is
  409.          warned not  to use  explicit integer  values for  constructing env.  A
  410.          typical method for constructing env is:
  411.          ┌─────────────────────────────────────────────────────────────────────┐
  412.          │ // given position y:x on some screen, occupied by char c            │
  413.          │ char env[6];                                                        │
  414.          │ *env=c;                                                             │
  415.          │ for (direction dir; dir(); dir++)                                   │
  416.          │   env[dir.serial()]=my_screen.get_neighbour(y,x,dir)                │
  417.          │ env[5]='\0';                                                        │
  418.          └─────────────────────────────────────────────────────────────────────┘
  419.          
  420.          The  method  returns  a  character  value  to  the  user,  who is then
  421.          responsible for  putting it  in the  desired place.   "Cearrw"  (carrw
  422.          affecting Environment) is  an extended version  of carrw that  "trims"
  423.          inelegant  "excess"  of the  neighbors, and makes some  other nonlocal
  424.          considerations.  The user is expected to know where to put each of the
  425.          elements in the string.   Note that the method modifies  its argument!
  426.          Cearrw incurs a loss  of response time, so  make sure that you  really
  427.          need its  improved esthetics.   It  is automatically  used by  the arc
  428.          manager (snav2) if ENVMODIFY is #defined.
  429.          
  430.          Snav1 defines a  default alphabet object,  referenced by pointer.   It
  431.          includes an "in memory  file" in the form  of integer array, which  it
  432.          uses to initialize the object  to the IBM-PC extended ASCII  collating
  433.          sequence.    The  user  may  then  replace  it  with specific alphabet
  434.          object(s), to suit the machine or application.
  435.          
  436.          Compatibility.  Currently, the  alphabet object has no  facilities for
  437.          generating its  own character  shapes, counting  entirely on  the host
  438.          display device.  This  may force developers of  pixel-oriented graphic
  439.          software to extend the model to acknowledge their ability to  generate
  440.          their own  characters.   Future versions  may include  the ability  to
  441.          generate  the   semigraphic  subset,   possibly  by   downloading  the
  442.          definition to an  external device, such  as an EGA  screen or printer.
  443.          This may imply extensions to  internal class architecture, and to  the
  444.          constructor.  However, such modification is not expected to affect the
  445.          methods  concerned  with  character  recognition  and retrieval, using
  446.          semigraphic  attributes,  (applying  to  most  traffic to the alphabet
  447.          object).
  448.                                 SNAV - main documentation
  449.                                    - 16.4.90 page 13 -
  450.          
  451.          ESNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  452.          E───────────────────────────────────────────────────────────────────────F
  453.          
  454.          Panel:
  455.          ┌─────────────────────────────────────────────────────────────────────┐
  456.          │                                                                     │
  457.          │                                │                       │            │
  458.          │                              p0│<∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙│p*          │
  459.          │                             ┌──┴──┐                   ┌┴┐           │
  460.          │                             │panel│                ┌─>│?│           │
  461.          │                             └──┬──┘                │  └─┘           │
  462.          │                                │                   │                │
  463.          │               ┌───────────┬────┴────┬─────────┬────┘                │
  464.          │               │           │       d2│         │                     │
  465.          │          ┌────┴────┐ ┌────┴────┐ ┌──┴──┐ ┌────┴─────┐               │
  466.          │          │point_pos│ │direction│ │color│ │square_pos│               │
  467.          │          └─────────┘ └─────────┘ └─────┘ └────┬─────┘               │
  468.          │                                               │                     │
  469.          │                                               │                     │
  470.          │                                             d2│                     │
  471.          │                                          ┌────┴────┐                │
  472.          │                                          │point_pos│                │
  473.          │                                          └─────────┘                │
  474.          │                                                                     │
  475.          └─────────────────────────────────────────────────────────────────────┘
  476.          
  477.          Shape:
  478.          ┌─────────────────────────────────────────────────────────────────────┐
  479.          │                                                                     │
  480.          │                      │                             │                │
  481.          │                      │                           p*│<∙∙∙∙∙∙∙∙∙∙∙    │
  482.          │                    ┌─┴─┐                        ┌──┴──┐       ┌─┐   │
  483.          │                    │arc│                        │shape│   ┌──>│?│   │
  484.          │                    └─┬─┘                        └──┬──┘   │   └─┘   │
  485.          │                      │                             │      │         │
  486.          │            ┌─────────┼─────────┬─────────┐         ├──────┘         │
  487.          │            │         │         │         │       p*│                │
  488.          │         ┌──┴──┐ ┌────┴───┐ ┌───┴─────┐   │     ┌───┴──┐             │
  489.          │         │color│ │weight_d│ │direction│   └────>│stroke│             │
  490.          │         └─────┘ └────────┘ └─────────┘         └───┬──┘             │
  491.          │                                                    │                │
  492.          │                                                    │                │
  493.          │                                                    │                │
  494.          │                                               ┌────┴────┐           │
  495.          │                                               │point_pos│           │
  496.          │                                               └─────────┘           │
  497.          │                                                                     │
  498.          └─────────────────────────────────────────────────────────────────────┘
  499.                                 SNAV - main documentation
  500.          E              SNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  501.                                    - 16.4.90 page 14 -
  502.          
  503.          Compatibility.    Unlike  snav0  and  snav1  that  are  based  upon  a
  504.          theoretical  foundation   (see  "article.prn"),   snav2  is   a  first
  505.          generation prototype (though by no  means an improvisation).  The  art
  506.          of building character-oriented screen drivers has little surprises  to
  507.          offer.    The  screen  driver  in  snav1 (class "panel") draws from my
  508.          experience  in  maintaining  and  writing  character-oriented   screen
  509.          drivers in Fortran-4, Turbo-Pascal, ANSI-C and now C++.  I am  waiting
  510.          for  user  responses  to  this  particular  design  (see  "bug report"
  511.          attached  to  the  registration  form),  to  fine-tune  it into a real
  512.          "generic" class.
  513.          
  514.          The generic "shape" owes to the SNAV approach, that contour shapes are
  515.          charted by cursor in motion, and given the snav0 and snav1 arsenal  of
  516.          objects   (direction,    intersection,   axis,    weight_distribution,
  517.          alphabet),  and  their  operators.    Again,  I  am  looking  for user
  518.          response, because I am not sure what applications people may find  for
  519.          it, and what effect applications I have not thought of may have on the
  520.          basic design.
  521.          
  522.          When   enough   applicative   information   is   gathered,   I    will
  523.          reverse-engineer  the  logical  schema  from  the  prototype, and then
  524.          reconstruct the code to suit the theoretical foundation.  Until  then,
  525.          I cannot promise complete compatibility.
  526.                                 SNAV - main documentation
  527.          E              SNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  528.                                    - 16.4.90 page 15 -
  529.          
  530.          -1PANEL.-0
  531.          
  532.          An object of class  panel (must be referenced  by pointer) may be  any
  533.          formatted output medium, wether static like a printed page or  dynamic
  534.          like a CRT screen,  that can take characters,  one at a time,  so that
  535.          each has a fixed position  on the two axes of  the plane,  distributed
  536.          evenly, like  a matrix.   This  generic panel  implementation does not
  537.          support nonproportional spacing  or varying  font  sizes.  It  is on a
  538.          level definitely lower than the  medium assumed by DTP software.   The
  539.          panel is  assumed to  be able  to generate  the  appropriate character
  540.          shape by its collating-sequence number, and retrieve the value of  the
  541.          character occupying each cell by y:x address, at any given moment.  It
  542.          is also supposed to manage  colors (or visual "attributes") for  these
  543.          cells, in the same way.
  544.          
  545.          A snav panel is much like a "window", in being restricted to an oblong
  546.          slice  of  a  larger  screen  object,  transparently  managed  by  the
  547.          hardware.  Class "point_pos" is supplied to access cells on the panel.
  548.          The whole  window is  specified by  an object  of class  "square_pos",
  549.          consisting  of  two  points,  specifying  top-left  and   bottom-right
  550.          corners.    Also  provided  is  struct  "color_ind", grouping together
  551.          visual attribute state variables.   Color management follows  the ANSI
  552.          example.  The attributes  maintained are background color  (enumerated
  553.          on  an  8  color  scale),  foreground  color  (same)  and  "attribute"
  554.          (supported  are  high-intensity,  reverse-video,  blink, underline and
  555.          invisible).
  556.          
  557.          A  panel  object  manages  a  point_pos  object for cursor position, a
  558.          direction  object  for  cursor  direction,  and a color_ind object for
  559.          visual  attributes.    Cursor   addressing  is  done  using   absolute
  560.          hardware-screen  positions.    There  is  no facility for interpreting
  561.          cursor addressing, relative to window start.  Since the abstract panel
  562.          leaves physical cursor positioning and reading to the  implementation,
  563.          cursor  addresses   outside  panel   bounds  should   be  ignored   at
  564.          character-print/read  level,  in  the  physical driver implementation,
  565.          using the method "ask_legal".
  566.          
  567.          The  cursor-direction  object  is  used  in  order to compute the next
  568.          point, after  a character  "put" operation.   By  default, the  cursor
  569.          direction  is  initialized  to  "Right"  (actually,  the  value   that
  570.          direction() is  initialized to),  but the  user may  change it  during
  571.          run-time, to  acknowledge a  Semitic or  Asian language  text, or  for
  572.          arc-processing.  In each case,  the cursor will behave accordingly  (I
  573.          am  sure  about  the  Semitic  cursor.    The "Asian" cursor is just a
  574.          guess).
  575.          
  576.          Although   the   generic   panel   is   expected   to  behave  like  a
  577.          two-dimensional  array,  no  assumption  whatsoever  is made as to its
  578.          physical architecture.  My private SNAV application works with half  a
  579.          dozen  inherited  screen  types,  one  of  them,  a sparse matrix with
  580.          variable  length  lines  and  unlimited  size,  used to edit pages for
  581.          print, implemented by  a host of  pointers.  Yet  this formidable data
  582.          structure answers the same methods as the simpleminded matrix CRT.
  583.                                 SNAV - main documentation
  584.          E              SNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  585.                                    - 16.4.90 page 16 -
  586.          
  587.          There are two ways to paint the panel, reflected by the use of pointer
  588.          arguments  for  point  and  direction.    If  an explicit point is not
  589.          specified (NULL argument), the cursor will be used (and advanced), and
  590.          same  goes  for  direction.    Note  that  "direct  cursor addressing"
  591.          (specifying the arguments) leaves cursor and direction unchanged,  and
  592.          do not wrap around.  The  cursor, on the other hand, will  wrap around
  593.          at the end  of the line (and  bottom of screen), if  setup by the
  594.          method "toggle_wrap".
  595.          
  596.          The panel protocol  consists of two  levels.  In  the lower level  are
  597.          defined "virtual" methods, which are so device-specific that may never
  598.          be defined to fit the general case.  The second level offers "macros",
  599.          of  various  complexity,  taking  the  generic  methods  for  granted.
  600.          Because the  use of  polymorphism in  C++ will  not allow  the user to
  601.          refer to methods defined in the inherited class (and because the  user
  602.          must declare an inherited class, if he/she wants anything more than  a
  603.          heap of empty stubs),  I have tried to include all nontrivial  methods
  604.          in the  generic definition.   However  I did  not include methods that
  605.          assume a specific working procedure, such as newline.
  606.          
  607.          For a complete listing  of the panel protocol,  see snav2.hpp.  For  a
  608.          sample implementation of a real-world device driver inheriting  panel,
  609.          see the sample application, demo1.hpp and demo1.cpp.
  610.          
  611.          An extra service supplied by  the generic panel is "TWG"  - TypeWriter
  612.          Graphics conversion.   The  algorithm used  (one of  the only cases of
  613.          long hard-to-follow code in the  SNAV package) is a generalization  of
  614.          the line-oriented algorithm by that name, that I distributed in the PD
  615.          in ordinary C, two years  ago.  Unlike the line-oriented  version, the
  616.          full-screen version  can handle  mixed TWG/semigraphic  shapes, and is
  617.          responsible  for   a  somewhat   more  intelligent   result  (but   is
  618.          considerably slower, referring to the whole SNAV foundation).  It does
  619.          not account for the "fix" in line-oriented TWG, concerning open boxes.
  620.          
  621.          Twg's  main  function  is  to  allow  character-graphic  charts  to be
  622.          transferrable to character sets that do not support real  (connecting)
  623.          semigraphic  characters,  such  as  most  old  ASCII  127  and  EBCDIC
  624.          "oldcode"    implementations.    It  is  also useful for  fast-drawing
  625.          semigraphic  charts,  if  a  few  common-sense  rules  are   observed.
  626.          Experiment with the TWG option in  the enclosed demo.  The shapes  you
  627.          experiment on must be charted using the 0:0 weight distribution!
  628.                                 SNAV - main documentation
  629.          E              SNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  630.                                    - 16.4.90 page 17 -
  631.          
  632.          -1ARC.-0
  633.          
  634.          Since SNAV deals with characters  in motion, an object of  class "arc"
  635.          (straight  line)  stores  only  its  direction  (exactly  one), weight
  636.          distribution (exactly  one, and  only the  relevant axis  considered),
  637.          length (in  characters) and  if it  is pointed  (version 1.10 does not
  638.          support  double-tipped  arrows).    Unlike many pixel-oriented graphic
  639.          packages, the  origin point  is not  stored.   The arc  is an abstract
  640.          entity  that  may  be  listed  starting  at any given point, affecting
  641.          whatever is logically implied on the following path.  This concept may
  642.          be  demonstrated  dramatically  by  experimenting  with  the "cut" and
  643.          "paste" operations in the enclosed demo program.
  644.          
  645.          The  method  "list"  is  a  gate  on  this side, for the real arc-list
  646.          method, implemented within the generic panel (called "arclist").   The
  647.          reason for this, is to maintain information hiding within class  panel
  648.          (at the cost of importing functionality).  This ensures an  absolutely
  649.          device-independent drawing  medium.   The listing  invokes the current
  650.          alphabet's method "carrw" ("cearrw" if ENVMODIFY is #defined) in order
  651.          to  elegantly  "weld"  each  semigraphic  element  to  its   immediate
  652.          environment, if that too is semigraphic.  In order to understand  what
  653.          semigraphic "welding" is, experiment  with the enclosed demo  program,
  654.          drawing one of the regular shapes supplied, and then crossing it  with
  655.          arcs of arbitrary weights.
  656.          
  657.          If a color is specified with  the arc, it used for drawing  instead of
  658.          the current  screen color.   Neighboring  characters welded  by cearrw
  659.          calls are left in their own foreground color.  Currently, welding  does
  660.          not apply to color.  The current color is always replaced.
  661.          
  662.          -1STROKE.-0
  663.          
  664.          Class  stroke  inherits  class  arc,  making  it  a list member.  This
  665.          enables  the  creation  of  a  semigraphic  curve.    Each arc listing
  666.          proceeds from the  exact point its  predecessor stopped (to  allow for
  667.          "welding").      A   "pen-down"   toggle   allows   jumping  over  the
  668.          drawing-board, where a  discontinued shape is  desired.  Class  stroke
  669.          also has a point_pos used to  denote offset from shape start, by  some
  670.          shape-building procedures.
  671.          
  672.          Note. stroke has no start-of-list  pointer.  It is naturally  intended
  673.          to be  managed by  the iterator-class  "shape".   The user's role ends
  674.          with creating  a stroke  and "appending"  it to  some shape.   Do  not
  675.          assign the same stroke to  two shapes, because the shape's  destructor
  676.          will delete it!
  677.          
  678.          Compatibility.   Some future  release may  account for  the listing of
  679.          strings of characters, perhaps in connection with arc listing  (often,
  680.          arcs are accompanied by caption text).   This may have some effect  on
  681.          the internal structure of either arc of stroke.
  682.                                 SNAV - main documentation
  683.          E              SNAV2 - THE GENERIC PANEL AND GENERIC SHAPEF
  684.                                    - 16.4.90 page 18 -
  685.          
  686.          -1SHAPE.-0
  687.          
  688.          Shape is a semi-generic entity, normally referenced by pointer.   But,
  689.          unlike the  generic entity  "panel", it  contains primitives  that are
  690.          likely to be too simplistic for more regular or arbitrary shapes,  and
  691.          are therefore defines as "virtual"  methods.  Class shape's main  role
  692.          is to serve as iterator-class for class stroke.
  693.          
  694.          When a shape is created,  it is initialized to either  a user-supplied
  695.          stroke-list, or  to NULL.   The  user than  "appends" strokes, be them
  696.          individuals  or  chains,  to  the  stroke-list.    Append  attempts to
  697.          optimize the shape, by ignoring and/or unifying redundant strokes.
  698.          
  699.          The virtual methods "list" and "clear" scan the available stroke-list.
  700.          The  derived  shape  "oblong",   brought  in  snav3  as   an  example,
  701.          demonstrates  a  more  elegant  approach.    Since oblong is a regular
  702.          shape, only  the relevant  arcs are  allocated, and  listed twice,  in
  703.          opposite  directions.    The  derived  shape  "zigzag" in demo3, is an
  704.          example of  a two-element  pattern, listed  in a  loop.   This process
  705.          redundancy may save storage space for very large shapes, provided they
  706.          have a programmable underlying logic.
  707.          
  708.          Compatibility.  The current implementation  of shape assumes it to  be
  709.          either chaotic or  display a repeating  pattern.  Future  releases may
  710.          accommodate a shape that is made of subshapes.
  711.                                 SNAV - main documentation
  712.                                    - 16.4.90 page 19 -
  713.          
  714.          ESNAV3 - SHAPE RECOGNITIONF
  715.          E───────────────────────────────────────────────────────────────────────F
  716.          
  717.          ┌─────────────────────────────────────────────────────────────────────┐
  718.          │                                                                     │
  719.          │              │                  │                                   │
  720.          │            p*│<∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙│p*                                 │
  721.          │           ┌──┴──┐           ┌───┴───┐                               │
  722.          │           │shape│   ┌──────>│tracing│                               │
  723.          │           └──┬──┘   │       └───┬───┘                               │
  724.          │              │      │           │                                   │
  725.          │              ├──────┘     ┌─────┴────┐                              │
  726.          │            p*│            │        p*│                              │
  727.          │           ┌──┴───┐   ┌────┴────┐ ┌───┴────┐                         │
  728.          │           │stroke│   │point_pos│ │landmark│                         │
  729.          │           └──────┘   └─────────┘ └───┬────┘                         │
  730.          │                                      │                              │
  731.          │                               ┌──────┴─────┐                        │
  732.          │                               │            │                        │
  733.          │                               │          d2│                        │
  734.          │                          ┌────┴────┐ ┌─────┴──────┐                 │
  735.          │                          │point_pos│ │intersection│                 │
  736.          │                          └─────────┘ └────────────┘                 │
  737.          │                                                                     │
  738.          └─────────────────────────────────────────────────────────────────────┘
  739.          
  740.          Compatibility.    At  the  present  release, pattern recognition is of
  741.          experimental status.  The implementation calls for much  optimization,
  742.          and  further  research  into  its   logic.    It  is  supplied   as  a
  743.          demonstration of the principle.  No compatibility promised.
  744.                                 SNAV - main documentation
  745.          E                       SNAV3 - SHAPE RECOGNITIONF
  746.                                    - 16.4.90 page 20 -
  747.          
  748.          -1TRACING.-0
  749.          
  750.          The  general  derived  shape  "tracing"  is  a procedural entity whose
  751.          function is to generate arbitrary shapes, presumably scanned from "the
  752.          real world".   The  tracing constructor  is a "probe constructor". its
  753.          function may be defined as follows:
  754.          ┌─────────────────────────────────────────────────────────────────────┐
  755.          │ If there  exists in  the real  world (screen)  in the  coordinates  │
  756.          │ specified (point) something that you may take for a shape, copy it  │
  757.          │ as best as you can.                                                 │
  758.          └─────────────────────────────────────────────────────────────────────┘
  759.          
  760.          The additional  data hidden  in class  tracing are  technical, and are
  761.          merely  "working  storage"  for  executing  the  scan,  and  have   no
  762.          significance once the constructor returns.
  763.          
  764.          Class  tracing  is  the  main  primitive  for  applications  involving
  765.          semigraphic pattern recognition.   For a  typical application, see  my
  766.          ANSI editor "The Lecturer", where an early version of SNAV is  used to
  767.          automatically track  semigraphic shapes  on the  screen, preserved for
  768.          animation in the same scan order.
  769.          
  770.          Compatibility.   The stroke-list  built by  an object  of the  current
  771.          version "tracing" class, is highly  unnormalized.  It is a  sequential
  772.          scan (in direction() order), involving many unnecessary pen-jumps  and
  773.          broken lines.  To demonstrate  that, use the enclosed demo  program to
  774.          draw a fence-like shape all over  the screen, then "cut" it, and  then
  775.          "paste" it, forcing your  computer to its slowest  speed.  As you  can
  776.          see, the route the pen takes calls for optimization.  Future  releases
  777.          may include  tracing normalization  and automatic  recognition of some
  778.          regular shapes.
  779.          
  780.          -1OBLONG.-0
  781.          
  782.          Class oblong is supplied as an  example for a "regular" shape.   Since
  783.          it is made of a repeating element with programmable underlying  logic,
  784.          only the  essential pattern  elements are  stored in  the shape.   The
  785.          complete shape is created  during list-time by the  overloaded lister.
  786.          Oblong is also used by the "enframe" panel method in snav2.
  787.