-+-+-+-+-+-+-+-+ START OF PART 249 -+-+-+-+-+-+-+-+
X  `7B
X    fprintf(fileptr, "structure %d", stlist.integers`5Bi`5D);
X
X    /* get corresponding string for structure id from hashtable */
X    if (dostring)
X    `7B
X      ptk_inttostring("structureid", stlist.integers`5Bi`5D, 255, str,`20
X                      &totallength);
X
X      /* print string, if there is one */
X      if (totallength == 0)
X        fprintf(fileptr, "\n");
X      else`20
X      `7B
X        fprintf(fileptr, " \"%s\"\n", str);
X      `7D
X    `7D
X    else
X      fprintf(fileptr, "\n");
X  `7D
X`7D  /* ptk_structsummary */
X
X/*--------------------------------------------------------------------------
V*/
X/*--------------------- Attribute Functions --------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_setattrasf(C(Pint) numattrs, C(Pattrid *) attrs, C(Pasf) asf
V)
XPreANSI(Pint numattrs)
XPreANSI(Pattrid *attrs)
XPreANSI(Pasf asf)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bnumattrs`7D`7Blength of attribute list`7D`7BIN`7D
X** \param`7BPattrid *`7D`7Battrs`7D`7Battribute list`7D`7BIN`7D
X** \param`7BPasf`7D`7Basf`7D`7Baspect source flag`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function inserts a structure element into
X** the open structure to set the aspect source flags for each of the
X** \pardesc`7Bnumattrs`7D attributes in the
X**  list \pardesc`7Battrs`7D, according to \pardesc`7Basf`7D.`7D
X*/
X`7B
X  Pint i;
X
X  for (i = 0; i < numattrs; i++)
X    psetindivasf(attrs`5Bi`5D, asf);
X`7D  /* ptk_setattrasf */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_setallattrasf(C(Pasf) asf)
XPreANSI(Pasf asf)
X/*
X** \parambegin
X** \param`7BPasf`7D`7Basf`7D`7Baspect source flag`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function inserts a structure element into
X** the open structure to set the aspect source flags for all primitive`20
X** attribiutes, according to \pardesc`7Basf`7D.`7D
X*/
X`7B
X  static Pint numattr = 18;
X  static Pattrid attrlist`5B`5D = `7BPLINETYPE, PLINEWIDTH_SCALE_FACTOR,
X  PPOLYLINE_COLOUR_INDEX, PMARKERTYPE, PMARKERSIZE_SCALE_FACTOR,
X  PPOLYMARKER_COLOUR_INDEX, PTEXT_FONT, PTEXT_PRECISION,
X  PCHARACTER_EXPANSION_FACTOR, PCHARACTER_SPACING, PTEXT_COLOUR_INDEX,
X  PINTERIOR_STYLE, PINTERIOR_STYLE_INDEX, PINTERIOR_COLOUR_INDEX,
X  PEDGE_FLAG, PEDGETYPE, PEDGEWIDTH_SCALE_FACTOR, PEDGE_COLOUR_INDEX`7D;
X
X  ptk_setattrasf(numattr, attrlist, asf);
X`7D  /* ptk_setallattrasf */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern Pedgebundl ptk_setedgebundlerec(C(Pedgef) eflag, C(Pint) etype,
X                    C(Pfloat) escale, C(Pint) ecolour)
XPreANSI(Pedgef eflag)
XPreANSI(Pint etype)
XPreANSI(Pfloat escale)
XPreANSI(Pint ecolour)
X/*
X** \parambegin
X** \param`7BPedgef`7D`7Beflag`7D`7Bedge on or off`7D`7BIN`7D
X** \param`7BPint`7D`7Betype`7D`7Bedge type (solid, dotted,..)`7D`7BIN`7D
X** \param`7BPfloat`7D`7Bescale`7D`7Bedge width scale factor`7D`7BIN`7D
X** \param`7BPint`7D`7Becolour`7D`7Bedge colour index`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function sets creates and
X** returns an edge bundle attribute record whose fields are set as specified
V.`7D
X*/
X`7B
X  Pedgebundl edgerec;
X
X  edgerec.flag = eflag;
X  edgerec.type = etype;
X  edgerec.scale = escale;
X  edgerec.colour = ecolour;
X  return edgerec;
X`7D  /* ptk_setedgebundlerec */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern Pinterbundl ptk_setinteriorbundlerec(C(Pinterstyle) istyle,
X                     C(Pint) index, C(Pint) icolour)
XPreANSI(Pinterstyle istyle)
XPreANSI(Pint index)
XPreANSI(Pint icolour)
X/*
X** \parambegin
X** \param`7BPinterstyle`7D`7Bistyle`7D`7Binterior style (solid, hollow,..)`7
VD`7BIN`7D
X** \param`7BPint`7D`7Bindex`7D`7Binterior style index for pattern or hatch`7
VD`7BIN`7D
X** \param`7BPint`7D`7Bicolour`7D`7Binterior colour index`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function sets creates and
X** returns an interior bundle attribute record whose fields are set as speci
Vfied.`7D
X*/
X`7B
X  Pinterbundl inrec;
X
X  inrec.style = istyle;
X  inrec.index = index;
X  inrec.colour = icolour;
X  return inrec;
X`7D  /* ptk_setinteriorbundlerec */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern Plnbundl ptk_setpolylinebundlerec(C(Pint) ltype, C(Pfloat) lwidth,
X                  C(Pint) lcolour)
XPreANSI(Pint ltype)
XPreANSI(Pfloat lwidth)
XPreANSI(Pint lcolour)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bltype`7D`7Bline type (solid, dotted,..)`7D`7BIN`7D
X** \param`7BPfloat`7D`7Blwidth`7D`7Bline width scale factor`7D`7BIN`7D
X** \param`7BPint`7D`7Blcolour`7D`7Bline colour index`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function sets creates and
X** returns a polyline bundle attribute record whose fields are set as specif
Vied.`7D
X*/
X`7B
X  Plnbundl lnrec;
X
X  lnrec.type = ltype;
X  lnrec.width = lwidth;
X  lnrec.colour = lcolour;
X  return lnrec;
X`7D  /* ptk_setpolylinebundlerec */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern Pmkbundl ptk_setpolymarkerbundlerec(C(Pint) mtype, C(Pfloat) msize,
X                  C(Pint) mcolour)
XPreANSI(Pint mtype)
XPreANSI(Pfloat msize)
XPreANSI(Pint mcolour)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bmtype`7D`7Bmarker type (dot, circle,..)`7D`7BIN`7D
X** \param`7BPfloat`7D`7Bmsize`7D`7Bmarker size scale factor`7D`7BIN`7D
X** \param`7BPint`7D`7Bmcolour`7D`7Bmarker colour index`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function sets creates and
X** returns an polymarker bundle attribute record whose fields are set as spe
Vcified.`7D
X*/
X`7B
X  Pmkbundl mkrec;
X
X  mkrec.type = mtype;
X  mkrec.size = msize;
X  mkrec.colour = mcolour;
X  return mkrec;
X`7D  /* ptk_setpolymarkerbundlerec */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern Ptxbundl ptk_settextbundlerec(C(Pint) tfont, C(Ptxprec) tprec,
X                  C(Pfloat) texp, C(Pfloat) tspace, C(Pint) tcolour)
XPreANSI(Pint tfont)
XPreANSI(Ptxprec tprec)
XPreANSI(Pfloat texp)
XPreANSI(Pfloat tspace)
XPreANSI(Pint tcolour)
X/*
X** \parambegin
X** \param`7BPint`7D`7Btfont`7D`7Btext font`7D`7BIN`7D
X** \param`7BPtxprec`7D`7Btprec`7D`7Btext precision`7D`7BIN`7D
X** \param`7BPfloat`7D`7Btexp`7D`7Bcharacter expansion factor`7D`7BIN`7D
X** \param`7BPfloat`7D`7Btspace`7D`7Bcharacter spacing`7D`7BIN`7D
X** \param`7BPint`7D`7Btcolour`7D`7Btext colour index`7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function sets creates and
X** returns a text bundle attribute record whose fields are set as specified.
V`7D
X*/
X`7B
X  Ptxbundl txrec;
X
X  txrec.font = tfont;
X  txrec.precision = tprec;
X  txrec.exp = texp;
X  txrec.space = tspace;
X  txrec.colour = tcolour;
X  return txrec;
X`7D  /* ptk_settextbundlerec */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_computecharsize(C(Pint) wsid, C(Pchar *) str, C(Ppoint *) bo
Vx,
X                                C(Pint) font, C(Pfloat *) charht,`20
X                                C(Pfloat *) charexp)
XPreANSI(Pint wsid)
XPreANSI(Pchar *str)
XPreANSI(Ppoint *box)
XPreANSI(Pint font)
XPreANSI(Pfloat *charht)
XPreANSI(Pfloat *charexp)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D
X** \param`7BPchar *`7D`7Bstr`7D`7Bstring`7D`7BIN`7D
X** \param`7BPpoint *`7D`7Bbox`7D`7Bwidth and height of box`7D`7BIN`7D
X** \param`7BPint`7D`7Bfont`7D`7Btext font`7D`7BIN`7D
X** \param`7BPfloat *`7D`7Bcharht`7D`7Bcharacter height`7D`7BOUT`7D
X** \param`7BPfloat *`7D`7Bcharexp`7D`7Bcharacter expansion`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function computes the character height and expansion for`20
X**  string \pardesc`7Bstr`7D, using font \pardesc`7Bfont`7D,`20
X** in order for it to fit into the rectangle specifed by \pardesc`7Bbox`7D.`
V7D
X*/
X`7B
X  Pint err, totsize;
X  Pchar *buffer;
X  Pconnid connid;
X  Prect rect;
X  Ppoint offset;
X  Pwstype wstype;
X  Pfloat stringwidth, charheight;
X
X  pinqwsconntype(wsid, 0, &err, buffer, &connid,
X                 &totsize, &wstype);
X  buffer = (Pchar *)malloc(totsize);
X  pinqwsconntype(wsid, totsize, &err, buffer, &connid,
X                 &totsize, &wstype);
X  ptk_inqtextextent(wstype, font, 1.0, 0.0, 0.01, PTP_RIGHT,`20
X    PAH_NORMAL, PAV_NORMAL, str, &err, &rect, &offset);
X
X  charheight = rect.ur.y - rect.ll.y;
X  *charht = 0.01 * (box->y/charheight);
X
X  ptk_inqtextextent(wstype, font, 1.0, 0.0, *charht, PTP_RIGHT,`20
X    PAH_NORMAL, PAV_NORMAL, str, &err, &rect, &offset);
X  stringwidth = rect.ur.x - rect.ll.x;
X  *charexp = 1.0 * (box->x/stringwidth);
X  free(buffer);
X`7D  /* ptk_computecharsize */
X
X/*--------------------------------------------------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_computecharheight(C(Pint) wsid, C(Pchar *) str,`20
X                           C(Ppoint *) box, C(Pint) font, C(Pfloat *) charht
V)`20
XPreANSI(Pint wsid)
XPreANSI(Pchar *str)
XPreANSI(Ppoint *box)
XPreANSI(Pint font)
XPreANSI(Pfloat *charht)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D
X** \param`7BPchar *`7D`7Bstr`7D`7Bstring`7D`7BIN`7D
X** \param`7BPpoint *`7D`7Bbox`7D`7Bwidth and height of box`7D`7BIN`7D
X** \param`7BPint`7D`7Bfont`7D`7Btext font`7D`7BIN`7D
X** \param`7BPfloat *`7D`7Bcharht`7D`7Bcharacter height`7D`7BOUT`7D
X** \paramend
X** \blurb`7BThis function computes the character height for`20
X**  string \pardesc`7Bstr`7D, using font \pardesc`7Bfont`7D,`20
X** in order for it to fit into the rectangle specifed by \pardesc`7Bbox`7D.`
V7D
X*/
X`7B
X  Pint err, totsize;
X  Pchar *buffer;
X  Pconnid connid;
X  Prect rect;
X  Ppoint offset;
X  Pwstype wstype;
X  Pfloat stringwidth, charheight, width, height;
X
X  pinqwsconntype(wsid, 0, &err, buffer, &connid,
X                 &totsize, &wstype);
X  buffer = (Pchar *)malloc(totsize);
X  pinqwsconntype(wsid, totsize, &err, buffer, &connid,
X                 &totsize, &wstype);
X  ptk_inqtextextent(wstype, font, 1.0, 0.0, 0.01, PTP_RIGHT,`20
X    PAH_NORMAL, PAV_NORMAL, str, &err, &rect, &offset);
X
X  charheight = rect.ur.y - rect.ll.y;`20
X  stringwidth = rect.ur.x - rect.ll.x;
X  height = 0.01 * (box->y / charheight);
X  width = stringwidth * (height / 0.01);
X  if (width > box->x)
X    height *= (box->x / width);
X
X  *charht = height;
X  free(buffer);
X`7D  /* ptk_computecharheight */
X
X/*--------------------------------------------------------------------------
V*/
X/*----------------------- Viewing Functions --------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_setstandardviewport(C(Plimit3 *) vlimits, C(Pviewrep3 *) rep
V)
XPreANSI(Plimit3 *vlimits)
XPreANSI(Pviewrep3 *rep)
X/*
X** \parambegin
X** \param`7BPlimit3 *`7D`7Bvlimits`7D`7Bviewport bounding box`7D`7BIN`7D
X** \param`7BPviewrep3 *`7D`7Brep`7D`7Bview representation`7D`7BOUT`7D
X** \paramend
X** \blurb`7BFor a window of `5B0,1`5D, this function creates in \pardesc`7Br
Vep`7D
X**  a view representation
X**  for a viewport of`20
X** \pardesc`7Bvlimits`7D.`7D
X*/
X`7B
X  Pviewmapping3 viewmap;
X  Pint err;
X
X  viewmap.view_plane = 1.0;
X  viewmap.proj = PPARALLEL;
X  viewmap.prp = ptk_point3(0.5, 0.5, 2.0);
X  viewmap.window = ptk_limit(0.0, 1.0, 0.0, 1.0);
X  viewmap.back_plane = -1.0;
X  viewmap.front_plane = 1.0;
X  viewmap.viewport = *vlimits;
X  pevalviewmappingmatrix3(&viewmap, &err, rep->mapping_matrix);
X  ptk_unitmatrix3(rep->orientation_matrix);
X  rep->clip_limit = *vlimits;
X  rep->clip_xy = PCLIP;
X  rep->clip_front = PCLIP;
X  rep->clip_back = PCLIP;
X`7D  /* ptk_setstandardviewport */
X
X/*--------------------------------------------------------------------------
V*/
X/*--------------------------- Post Functions -------------------------------
V*/
X
X/*function:external*/
Xextern void ptk_poststruct(C(Pint) wsid, C(Pint) stid, C(Pfloat) priority)
XPreANSI(Pint wsid)
XPreANSI(Pint stid)
XPreANSI(Pfloat priority)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bwsid`7D`7Bworkstation identifier`7D`7BIN`7D
X** \param`7BPint`7D`7Bstid`7D`7Bstructure identifier`7D`7BIN`7D
X** \param`7BPfloat`7D`7Bpriority`7D`7Bpriority with which to post structure`
V7D`7BIN`7D
X** \paramend
X** \blurb`7BThis function posts structure \pardesc`7Bstid`7D to
X** workstation \pardesc`7Bwsid`7D, but only if the structure exists.`7D
X*/
X`7B
X  if (ptk_structexists(stid))
X    ppoststruct(wsid, stid, priority);
X`7D  /* ptk_poststruct */
X
X/*--------------------------------------------------------------------------
V*/
X
Xtypedef struct prirec`20
X`7B
X  Pint index;
X  ptkboolean distinct;
X  struct prirec *next;
X`7D prirec;
X
X/*--------------------------------------------------------------------------
V*/
X
Xstatic void ptk_redistributepriorities(C(Pint) ws,`20
X                                       C(Pstructpostlst *) structlist)
XPreANSI(Pint ws)
XPreANSI(Pstructpostlst *structlist)
X/*
X** \parambegin
X** \param`7BPint`7D`7Bws`7D`7Bworkstation identifier`7D`7BIN`7D
X** \param`7BPstructpostlst *`7D`7Bstructlist`7D`7Barray of posted structures
V to reorder`7D`7BIN`7D
X** \paramend
X** \blurb`7BThe priorities in the array are redistributed so that they `20
X** are evenly spaced in the range 0-1 whilst retaining their relative`20
X** ordering.`20
X** For exam<ple, the set of priorities`20
X**   `5B0.1, 0.4, 0.45, 0.475, 0.4875, 0.5, 0.9, 0.95, 1`5D`20
X** would become`20
X**   `5B0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9`5D.`7D
X*/
X`7B
X  Pint s, pricount;
X  prirec *p, *prilist, *ptr;
X  ptkboolean placefound, founddistinct;
X  Pfloat currpriority, pristep;
X
X  /* first order priorities into a linked list */
X  prilist = (prirec *)malloc(sizeof(prirec));
X  /* start list off with first priority in array */
X  prilist->index = 0;
X  prilist->distinct = TRUE;
X  prilist->next = NULL;
X  pricount = 1;
X  for (s = 0; s < structlist->number; s++)`20
X  `7B
X    p = (prirec *)malloc(sizeof(prirec));
X    p->index = s;
X    /* check against first item in list */
+-+-+-+-+-+-+-+-  END  OF PART 249 +-+-+-+-+-+-+-+-