h59318
s 00371/00000/00000
d D 1.1 83/03/17 15:50:53 tes 1 0
c date and time created 83/03/17 15:50:53 by tes
e
u
4
U
t
T
I 1
#-h-  ddw675.c            local   03/24/82  11:21
#-h-  ddw675.rat          local   03/24/82  11:21
subroutine ddw675 (contrl, intin, rlin, intout, rlout)
########################################################################
#                                                                      #
#          THIS MATERIAL IS CONFIDENTIAL AND IS FURNISHED UNDER        #
#          A WRITTEN LICENSE AGREEMENT.  IT MAY NOT BE USED,           #
#          COPIED OR DISCLOSED TO OTHERS EXCEPT IN ACCORDANCE          #
#          WITH THE TERMS OF THAT AGREEMENT.                           #
#                                                                      #
#          COPYRIGHT (C) 1982 GRAPHIC SOFTWARE SYSTEMS INC.            #
#          ALL RIGHTS RESERVED.                                        #
#                                                                      #
#     Function: GSS-CORE device driver for WATANABE WX4675 six pen     #
#               plotter                                                #
#                                                                      #
#     Input Parameters:                                                #
#            contrl(1-3) - An integer array with following information #
#                          contrl(1) - opcode for driver function      #
#                          contrl(2) - length of integer array intin   #
#                          contrl(3) - length of real input array rlin #
#                                                                      #
#            intin   -     Array of integer input parameters           #
#                                                                      #
#            rlin    -     Array of real input parameters              #
#                                                                      #
#     Output Parameters:                                               #
#            contrl(4-6) - contrl(4) - length of integer array intout  #
#                          contrl(5) - length of integer array rlout   #
#                          contrl(6) - count of any other control parms#
#                                                                      #
#            rlout  -     Array of integer output parameters           #
#                                                                      #
#     Routines Called:                                                 #
#            Drwata - move/draw for Watanabe plotter                   #
#            dpwata - change pens for Watanabe plotter                 #
#            gdevot - put a character to device                        #
#            gdstot - convert a binary integer to a character string   #
#            gimnmx - bound an integer variable                        #
#                                                                      #
########################################################################
include mgsdef
 
# local defines
define(X_LIMITS_WAT4675,3450.)             #plotter surface width
define(Y_LIMITS_WAT4675,2600.)             #plotter surface height
 
integer contrl(1),intin(1),intout(1)
real rlin(1),rlout(1)
 
integer opcode, i, gimnmx, length,
        newfrm(2), setup(15),
        txsize(4), tsize,
        mrkout(6), mtype, mk1out(7),
        lstyle(8), kstyle, kscale,
        txrota(3), trotat,
        txtcap, lstcap, clrcap, tszcap, mrkcap, trtcap, bflcap
real chrwid, chrhgt, rtemp, x1, x2, y1, y2, hlfsiz, fulsiz
 
include mgscom
 
# The following equivalence statements are used to decrease the amount of code
#    necessary to access specific array elements. The arrays and the
#    variables equivalenced are listed below:
#
#       devcap(TEXT_CAP)         :: txtcap
#       devcap(LINESTYLE_CAP)    :: lstcap
#       devcap(COLOR_CAP)        :: clrcap
#       devcap(TEXT_SIZE_CAP)    :: tszcap
#       devcap(MARKER_CAP)       :: mrkcap
#       devcap(TEXT_ROT_CAP)     :: trtcap
#       devcap(BAR_FILL_CAP)     :: bflcap
#
#       txsize(2) :: tsize
#
#       mrkout(5) :: mtype
#
#       lstyle(2) :: kstyle
#       lstyle(8) :: kscale
#
#       txrota(2) :: trotat
#
#
equivalence (devcap(TEXT_CAP), txtcap), (devcap(LINESTYLE_CAP), lstcap),
            (devcap(COLOR_CAP), clrcap), (devcap(TEXT_SIZE_CAP), tszcap),
            (devcap(MARKER_CAP), mrkcap), (devcap(TEXT_ROT_CAP), trtcap),
            (devcap(BAR_FILL_CAP), bflcap),
            (txsize(2), tsize),
            (mrkout(5), mtype),
            (lstyle(2), kstyle), (lstyle(5), kscale),
            (txrota(2), trotat)
 
#    The watanabe WX4675 defines characters by using a base cell of 7 units
#    square. The character height is 7 units and width is 4 with an inter-
#    character gap of 3 units. There is no interline gap specified. We will
#    add 10% to the height to obtain an interline gap.
 
#    chrwid = 7./X_LIMITS_WAT4675
data chrwid /0.00202899/
 
# chrhgt = (7.+.7)/X_LIMITS_WAT4675
data chrhgt /0.002231889/
 
# fulsiz = 36. / X_LIMITS_WAT4675   full width/height of marker
data fulsiz /0.0104347/
 
# hlfsiz = 18. / X_LIMITS_WAT4675   half width/height of marker
data hlfsiz /0.0052173/
 
#            Marker output /S<8><CR>N<0><CR>/
data mrkout /BIGS, DIG8, CR, BIGN, 0, CR/
 
#            Marker 1 output /S<1><5><CR>N<1><CR>/
data mk1out /BIGS, DIG1, DIG5, CR, BIGN, DIG1, CR/
 
#            Line style /L<0><CR>B<0><0><0><CR>/
data lstyle /BIGL, 0, CR, BIGB, 0, 0, 0, CR/
 
#            text rotation /Q<0><CR>/
data txrota /BIGQ, 0, CR/
 
#            text size /S<0><0><CR>/
data txsize /BIGS, 0, 0, CR/
 
#            Home /H<CR>/
data newfrm /BIGH, CR/
 
#            Set up - /<CR><CR><CR><CR>H<CR>L0<CR>S3<CR>Q0<CR>/
data setup  /CR, CR, CR, CR, BIGH, CR, BIGL, DIG0, CR, BIGS, DIG3, CR,
             BIGQ, DIG0, CR/
 
 
opcode=contrl(OPCODE)
 
#
#  opcode move and draw
#
if  ((opcode == DRAW) | (opcode == MOVE)) {
 
   if (opcode == DRAW & ndclrp ~= ndclrl) call dpwata (ndclrl)
 
   call drwata (opcode, rlin)
   }
 
#
#  opcode text
#
else if (opcode == TEXT) {
 
      if (ndclrp ~= ndclrt) call dpwata (ndclrt)
 
      call gdevot (BIGP)                # text command
      i = contrl(INTEGER_IN_LENGTH)
      call gdstot (i, intin)
      call gdevot (CR)                  # terminate string
      call gdevot (NEWLINE)
      }
 
#
#  opcode marker
#
else if (opcode == MARKER) {
 
      i= gimnmx (intin(1), 1, 6)   #map index (1-6) to (1-6)
      intout (1) = i
 
      # clip marker to device limits
      x1 = rlin(1) - hlfsiz
      x2 = x1 + fulsiz
      y1 = rlin(2) - hlfsiz
      y2 = y1 + fulsiz
      if ((amin1(x1,y1) < 0.0) | (x2 > zdxlng) | (y2 > zdylng)) return
 
      if (ndclrp ~= ndclrm) call dpwata (ndclrm)
 
      # set text scale for marker, we use size 8
      #    which is about .14 in. in size
      #    for markers 2 - 6.  We use size 15 for marker 1 which
      #    is a period.
 
      if (i == 1) {
         call gdstot (7, mk1out)       #output marker 1 at large size
         }
      else {
         # mrkout(5) is mtype
         mtype = i + DIG0    # set marker symbol in output array
         call gdstot (6, mrkout) # output marker
         }
 
      # restore the correct character size
      length = itoch (ndtxsz, tsize, 2, ierror)
      length = length + 2
      txsize(length) = CR
      call gdstot (length, txsize)
      }
 
#
#  opcode set fill pattern
#
else if (opcode == SET_FILL_COLOR) {
   ndclrf = gimnmx (intin(1), 0, 7)   # Emulated fill has 8 patterns
   intout(1) = ndclrf
   }
 
#
#  opcode polygon edge style
#
else if (opcode == SET_POLYGON_EDGE_STYLE) {
      ndedgs = intin(1)
      }
 
#
#  opcode text size
#
else if (opcode == TEXT_SIZE) {
      areain = rlin(1)*rlin(2)
      for (i=1; i<=17; i=i+1) {
         rtemp = float(i)
         darea = rtemp * chrwid * rtemp * chrhgt
         if (darea > areain) break
         }
      ndtxsz = gimnmx ((i-2), 0, 15)   # The plotter has 16 sizes (0-15)
 
      # txsize(2) is tsize
      length = itoch (ndtxsz, tsize, 2, ierror)
      length = length + 2
      txsize (length) = CR
      call gdstot (length, txsize)    # Output text size command to device
      rtemp = float (ndtxsz + 1)
      rlout(1) = rtemp * chrwid
      rlout(2) = rtemp * chrhgt
      }
 
#
#  opcode line style
#
else if (opcode == LINESTYLE) {
      i = intin(1)
      if (i == 1) {
         ndlntp = 0
 
         # lstyle(2) is kstyle
         kstyle = DIG0
         call gdstot(3, lstyle)        #    set solid line type
         }
      else {
 
         # lstyle(2) is kstyle
         kstyle = DIG1             # Set broken line parameter
         # line scale defines both the length of a dash segment and the gap
         i = (i-1) * 10
         ndlntp = gimnmx (i, 10, 127)
         # lstyle(5) is kscale
         length = itoch (ndlntp, kscale, 3, ierror)
         length = length + 5
         lstyle (length) = CR
         call gdstot (length, lstyle)
         }
      intout(1) = (ndlntp/10) + 1     # return the line style selected
      }
 
#
#  opcode line color
#
else if (opcode == SET_LINE_COLOR) {
      i = gimnmx (intin(1), 1, 6)   # Device has 6 pen stations
      ndclrl = i + DIG0
      intout (1) = i          # Inform upper level of color selected
      }
 
#
#  opcode text color
#
else if (opcode == SET_TEXT_COLOR) {
      i = gimnmx (intin(1), 1, 6)   # Device has 6 pen stations
      ndclrt = i + DIG0
      intout (1) = i          # Inform upper level of color selected
      }
#
#  opcode marker color
#
else if (opcode == SET_MARKER_COLOR) {
      i = gimnmx (intin(1), 1, 6)   # Device has 6 pen stations
      ndclrm = i + DIG0
      intout (1) = i          # Inform upper level of color selected
      }
#
#  opcode text rotation
#
else if (opcode == CHAR_ROTATION) {
      i = amod ((rlin(1)+45.)/90., 4.)  # Device can rotate in 90 degree
      ndtxrt = i + DIG0                 #    increments
 
      # txrota(2)
      trotat = ndtxrt
      call gdstot (3, txrota)
      rlout(1) = i*90
      }
#
#    opcode new_frame
#
else if (opcode == NEW_FRAME) {
      call gdstot (2, newfrm)    # Go to home position
      call dnfplt               # prompt user for new paper
      }
 
#
# opcode set_device_parameters
#
else if (opcode == SET_DEVICE_PARAMETERS) {
 
      # set up device capability array
 
      txtcap = YES   # Text capability
      lstcap = 14    # Capable of 14 different linestyles
      clrcap = 6     # Capable of 6 different colors
      tszcap = 16    # Capable of 16 different text sizes
      mrkcap = 6     # Capable of 6 different markers
      trtcap = 4     # Capable of 4 different text rotations
 
      # Initialize Device Driver globals
 
      zdlgax = X_LIMITS_WAT4675 # Set the length of the longest axis in device
                                #    units
      zdxlng = 1.0              # Set x and y axis lengths in NDC units
      zdylng = 0.75362319       # Y_LIMITS_WAT1/X_LIMITS_WAT1
 
      ndtxrt = DIG0
      ndtxsz = 3
      ndlntp = 0
      ndclrp = DIG1
      ndclrl = DIG1
      ndclrt = DIG1
      ndclrm = DIG1
      zdxpos = 0.0
      zdypos = 0.0
 
      # initialize plotter
 
      call gdstot (15, setup)
      }
 
#
#     stop graphics
#
else if (opcode == STOP_GRAPHICS) {
      call gdstot (2, newfrm)
      call gdevot (NEWLINE)
      }
 
#
#     inquire screen size
#
else if (opcode == INQUIRE_SCREEN_SIZE) {
      rlout(1) = zdxlng
      rlout(2) = zdylng
      rlout(3) = X_LIMITS_WAT4675
      }
 
#
#  opcode escape
#
else if (opcode == ESCAPE) {
      i = contrl(INTEGER_IN_LENGTH)
      call gdstot (i, intin)
      }
 
return
end
#-t-  ddw675.rat          local   03/24/82  11:21
#-h-  watana.sup          local   03/24/82  11:21
E 1
