CHANGING GATE SYMBOL TYPES

Look in src/tkgate/ for the following files:

in.c out.c tri.c ground.c vdd.c tap.c clock.c dip.c switch.c and.c
or.c xor.c buffer.c adder.c mux.c demux.c register.c flipflop.c
lshift.c rshift.c arshift.c roll.c concat.c tribuffer.c ram.c rom.c
mult.c divide.c tty.c nmos.c pmos.c comment.c frame.c led.c

These are the sources files for gate types with bitmap symbols.  Now,
as an example, consider the AND gate file and.c and do the following:

1) Look towards the bottom of and.c for a call to init_and().  In this
function there will be a call to Pixmap_registerFromFile().  The
second argument, in the case "and.b" is the file in which the bitmap
for this gate is stored.

2) The bitmaps are in the "bitmaps" directory.  Use a standard bitmap
utility like "bitmap" to edit them.

3) Usually, you will see eight copies of the symbol in each of the
four orientations and in both bold and non-bold forms.  Edit these
symbols any way you like according to these guidelines:

    a) You do not need to use the same symbol size, you will have a
    chance to specify the size later.

    b) The positioning of the four orientations does not matter, just
    try to conserve space and make sure they do not overlap.

    c) The positioning of the bold forms relative to the non-bold
    forms is important.  tkgate uses a y offset value to shift between
    non-bold and bold.  The bold symbols must be in the same position
    relative to the non-bold symbols and must be exactly below them
    (not shifted left or right).

4) Now go back to and.c, look for the definition of and_iconDims[], it
will look something like:

static iconDimensions and_iconDims[] = {
  {0, 0, 20, 15, 10, 7},
  {21, 0, 15, 20, 7, 9},
  {16, 21, 20, 15, 9, 7},
  {0, 16, 15, 20, 7, 10},
};

Each line is for one of the four orientations (0, 90, 180, 270) of the
gate.  The lines have the general form:

         {x,y,w,h,xc,yc}

where (x,y) is the position in and.b of the upper left corner of the
subregion of the bitmap for the AND gate symbol in that orientation,
(w,h) is the width and height of the subregion, and (xc, yc) is the
center (specification of the center is not that critical, but it will
control where the symbol appears relative to the mark).

5) Now look for the line:

static int and_iconBoldOffset = 37;

This is the y displacement to shift from non-bold to bold symbols in and.b.

6) Now look for declarations of the form:

struct locate and_out_loc[] ={        /* Gate output */
 {10,0,10,0,D_RIGHT},
 {0,-10,0,-10,D_UP},
 {-10,0,-10,0,D_LEFT},
 {0,10,0,10,D_DOWN}};

These are the port position specifiers.  Again each line corresponds
to each of the four orientations.  The format of a line is:

   {x1,y1,x2,y2,dir}

For ports types that do not have a variable number (e.g., AND gate
output), x1=x2 and y1=y2, and (x1,y1) represents the position of that
port in the bitmap.  "dir" represents the direction that that wire
should leave the port and is one of D_RIGHT, D_UP, D_LEFT or D_DOWN.
For port types with a variable number such as AND gate inputs,
(x1,y1)-(x2,y2) represents a line along which those ports should be
distributed.  The line must be vertical or horizontal.

7) This is the tricky part.  If you want the symbols to print
properly, you will also have to change the postscript definition of
the gate symbol.  In this case you look in and.c for a declaration
such as:

static char *psAnd[] = {
  "%",
  "% An AND gate",
  "%",
  "/psand {",
  "  startgate",
  "  2.5 7 moveto",
  "  -10.5 7 lineto",
  "  -10.5 -7 lineto",
  "  2.5 -7 lineto",
  "  2.5 0 7 -90 90 arc",
  "  closepath",
  "  stroke",
  "  grestore",
  "} bind def",
  0
};

You should always begin with a "startgate" and end with the "stroke",
"grestore".  The origin is the same one you set with (xc, yc) in Step
4, and the units are in pixels (actually in points, with one point to
the pixel).  In this case the postscript code sets the pen at (2.5, 7)
, draws a line to (-10.5, 7), then to (-10.5, -7) then to (2.5, -7).
It then draws an arc starting at the current position and centered at
(2.5, 0).  The arc has radius 7 and begins at the -90 degree position
and ends at the 90 degree position.  The "closepath" causes the last
point to be connected to the first point and the "stroke" causes the
path to be drawn.

8) Some gates have special drawing methods.  For example, AND gates
can be drawn with extender bars when there are a larger number of
inputs.  These sorts of things are built into the program and if you
wish to change their behavior, it may require recoding.  In the case
of extender bars, this feature can be turned off if it is a problem.
