-+-+-+-+-+-+-+-+ START OF PART 257 -+-+-+-+-+-+-+-+ X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawnodes(C(void)) X/* X** \blurb`7BDraw all nodes in structure network.`7D X*/ X`7B X ptksstruct *s; X X s = topptr->structlist; X nodeidcount = 0; X while (s != NULL)`20 X `7B X drawnode(s); X nodeidcount++; X s = s->next; X `7D X`7D /* drawnodes */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawstructnetnode(C(ptksstruct *) sp) XPreANSI(ptksstruct *sp) X/* X** \parambegin X** \param`7B`7D`7Bsp`7D`7Bpointer to structure record`7D`7BIN`7D X** \paramend X** \blurb`7BDraws a node to represent the structure at sp in the X** structure list, and the node will go into the diagram at xx, yy.`7D X*/ X`7B X Plimit3 boundbox, nodebox; X Pmatrix3 matrix; X Pint err, elptr; X Ppoint3 sh; X X if (ptk_boundingbox(sp->name, &boundbox, TRUE)) X `7B X nodebox = ptk_limit3(-0.5, 0.5, -0.5, 0.5, 0.0, 1.0);`20 X sh = ptk_point3(sp->pos.x, sp->pos.y, 0.0); X ptk_shift3(&sh, PREPLACE, topptr->mat); X ptk_box3tobox3(&boundbox, &nodebox, TRUE, PPRECONCATENATE, topptr->mat,` V20 X &err); X /* jump to `60globaltran' label, this avoids attribute inheritance X ** from the topology structure. X */ X pinqelemptr(&err, &elptr); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "globaltran")); X psetpickid(sp->name); X psetlocaltran3(topptr->mat, PREPLACE); X pexecutestruct(sp->name); X /* jump back */ X psetelemptr(elptr + 3); X note(sp->pos.x, sp->pos.y); X `7D X else X drawnode(sp); X`7D /* drawstructnetnode */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic delstructnodes() X`7B X Pchar sname`5B80`5D; X ptksstruct *s; X X s = topptr->structlist; X while (s != NULL) X `7B X if (s->numchildren > 0) X `7B X sprintf(sname, "topstruct$%d", s->name); X pdelstruct(ptk_stringtoint("structureid", sname)); X ptk_delstring("structureid", sname); X `7D X s = s->next; X `7D X`7D /* delstructnodes */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawstructnode(C(ptksstruct *) sp) XPreANSI(ptksstruct *sp) X/* X** \parambegin X** \param`7B`7D`7Bsp`7D`7Bpointer to structure record`7D`7BIN`7D X** \paramend X** \blurb`7BDraws a node to represent the structure at sp in the X** structure list, and the node will go into the diagram at xx, yy.`7D X*/ X`7B X Plimit3 boundbox, nodebox; X Pmatrix3 matrix; X Pint err, numchild, elptr, stendptr`5B2`5D, lstnum; X Ppoint3 sh; X Pchar sname`5B255`5D; X Peltype elemlist`5B1`5D; X Psrchstatus srchstat; X ptkboolean validbox; X X validbox = ptk_boundingbox(sp->name, &boundbox, FALSE); X if (validbox) X `7B X if (sp->numchildren > 0) X `7B X sprintf(sname, "topstruct$%d", sp->name); X if (!ptk_structexists(ptk_stringtoint("structureid", sname))) X `7B X ptk_openstruct(ptk_stringtoint("structureid", sname)); X pcopyallelemsstruct(sp->name); X /* remove all execute structs */ X elptr = 0; X elemlist`5B0`5D = PEL_EXECUTE_STRUCTURE; X psetelemptr(0); X do X `7B X ptk_findelemtype(elemlist, 1, PFORWARD, &srchstat, &elptr, &lstnum V); X if (srchstat == PSUCCESS) X `7B X psetelemptr(elptr); X pdelelem(); X `7D X `7D while (srchstat == PSUCCESS); X ptk_closestruct(); X `7D X if (validbox) X `7B X sh = ptk_point3(sp->pos.x, sp->pos.y, 0.0); X ptk_shift3(&sh, PREPLACE, topptr->mat); X nodebox = ptk_limit3(-0.5, 0.5, -0.5, 0.5, 0.0, 1.0);`20 X ptk_box3tobox3(&boundbox, &nodebox, TRUE, PPRECONCATENATE,`20 X topptr->mat, &err); X pinqelemptr(&err, &elptr); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "globaltran")); X psetpickid(sp->name); X psetlocaltran3(topptr->mat, PREPLACE); X pexecutestruct(ptk_stringtoint("structureid", sname)); X psetelemptr(elptr + 3); X note(sp->pos.x, sp->pos.y); X `7D X `7D X else X `7B X sh = ptk_point3(sp->pos.x, sp->pos.y, 0.0); X ptk_shift3(&sh, PREPLACE, topptr->mat); X nodebox = ptk_limit3(-0.5, 0.5, -0.5, 0.5, 0.0, 1.0); X ptk_box3tobox3(&boundbox, &nodebox, TRUE, PPRECONCATENATE, topptr->mat V,`20 X &err); X pinqelemptr(&err, &elptr); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "globaltran")); X psetpickid(sp->name); X psetlocaltran3(topptr->mat, PREPLACE); X pexecutestruct(sp->name); X psetelemptr(elptr + 3); X note(sp->pos.x, sp->pos.y); X `7D X `7D X else X drawnode(sp); X`7D /* drawstructnode */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawstructnetnodes(C(void)) X/* X** \blurb`7BDraw all nodes in structure network.`7D X*/ X`7B X ptksstruct *s; X X s = topptr->structlist; X while (s != NULL)`20 X `7B X drawstructnetnode(s); X s = s->next; X `7D X`7D /* drawstructnetnodes */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawstructnodes(C(void)) X/* X** \blurb`7BDraw all nodes in structure network.`7D X*/ X`7B X ptksstruct *s; X X s = topptr->structlist; X while (s != NULL)`20 X `7B X drawstructnode(s); X s = s->next; X `7D X`7D /* drawstructnodes */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawarc(C(Pint) n, C(ptksstruct *) pp, C(ptksstruct *) pc) XPreANSI(Pint n) XPreANSI(ptksstruct *pp) XPreANSI(ptksstruct *pc) X/* X** \parambegin X** \param`7B`7D`7Bn`7D`7Bnumber of reference to p`7D`7BIN`7D X** \param`7B`7D`7Bpp`7D`7Bpointer to parent record`7D`7BIN`7D X** \param`7B`7D`7Bpc`7D`7Bpointer to child record`7D`7BIN`7D X** \paramend X** \blurb`7BDraws the connecting arc to show a reference to 'child' X** by 'parent'. It is 'parent's nth reference.`7D X*/ X`7B X Ppoint p`5B2`5D; X X p`5B0`5D = ptk_point(pp->pos.x - topptr->nodewidth / 2 + X`09 n * topptr->nodewidth / (pp->numchildren + 1), X pp->pos.y - topptr->nodeheight / 2); X p`5B1`5D = ptk_point(pc->pos.x, pc->pos.y + topptr->nodeheight / 2); X ppolyline(2, p); X`7D /* drawarc */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void drawconnections(C(void)) X/* X** \blurb`7BThis is called when all the structures' nodes have been`20 X** placed, and draws the arcs between the nodes which represent structure X** references.`7D X*/ X`7B X ptksstruct *s; X ptksref *child; X Pint childno; X X /* Wipe out the effects of any local trans for the nodes */ X ptk_unitmatrix3(topptr->mat); X psetlocaltran3(topptr->mat, PREPLACE); X s = topptr->structlist; X while (s != NULL)`20 X `7B `20 X /* process each structure in turn */ X child = s->firstchild; X childno = 0; X while (child != NULL)`20 X `7B `20 X /* process each child in order */ X childno++; X drawarc(childno, s, child->structptr); X child = child->next; X `7D X s = s->next; X `7D X`7D /* drawconnections */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void addreference(C(ptksstruct *) pp, C(ptksstruct *) cp, C(Pint) e) XPreANSI(ptksstruct *pp) XPreANSI(ptksstruct *cp) XPreANSI(Pint e) X/* X** \parambegin X** \param`7B`7D`7Bpp`7D`7Bpointer to parent record`7D`7BIN`7D X** \param`7B`7D`7Bcp`7D`7Bpointer to child record`7D`7BIN`7D X** \param`7B`7D`7Be`7D`7Belement pointer`7D`7BIN`7D X** \paramend X** \blurb`7BStores a reference to 'child' at element e in 'parent'.`7D X*/ X`7B X ptksref *newref; X X newref = (ptksref *)malloc(sizeof(ptksref)); X /* create a new reference node */ X if (pp->firstchild == NULL) X pp->firstchild = newref; X else X pp->lastchild->next = newref; X pp->lastchild = newref; X newref->structptr = cp; X newref->element = e; X newref->next = NULL; X`7D /* addreference */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void storereferences(C(void)) X/* X** \blurb`7BRuns along the structlist, inquiring the children of X** each structure, and storing the reference information.`7D X*/ X`7B X ptksstruct *s, *cp; X Pint e, err, foundel, tempstruct, errnum, numelts; X Psrchstatus status; X ptkselcontent elcont; X Pint lstnum; X Pchar *buffer; X#ifdef SUN X Psrcheltypelst includelst, excludelst; X#endif X#ifdef VMS X Peltype srchlist; X Pint srchlen; X#endif X X s = topptr->structlist; X#ifdef SUN X includelst.number = 1; X includelst.elems = (Psrcheltype *)malloc(sizeof(Psrcheltype)); X *(includelst.elems) = PSEL_EXECUTE_STRUCTURE; X excludelst.number = 0; X excludelst.elems = NULL; X#endif X while (s != NULL)`20 X `7B X e = 0; X numelts = ptk_elemcount(s->name); X#ifdef VMS X ptk_openstruct(s->name); X#endif X do X `7B X#ifdef SUN X pelemsrch(s->name, e, PFORWARD, &includelst, &excludelst, &err,`20 X &status, &foundel); X#endif X#ifdef VMS X srchlist = PEL_EXECUTE_STRUCTURE; X srchlen = 1; X psetelemptr(e); X ptk_findelemtype(&srchlist, srchlen, PFORWARD, &status, &foundel,`20 X &lstnum); X#endif X e = foundel + 1; X if (status == PSUCCESS)`20 X `7B X#ifdef SUN X`09ptk_inqelemtypesizecontent(s->name, foundel, &errnum, &buffer, X &elcont); X#endif X#ifdef VMS X`09ptk_inqcurelemtypesizecontent(&errnum, &buffer, &elcont); X#endif X tempstruct = elcont.eldata.idata; X lookupstructure(tempstruct, FALSE, &cp); X addreference(s, cp, foundel); X `7D X `7D while ((status != PFAILURE) && (e <= numelts)); X#ifdef VMS X ptk_closestruct(); X#endif X s = s->next; /* next structure */ X `7D X`7D /* storereferences */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptksrow *selectrow(C(Pint) l, C(ptksrow **) last) XPreANSI(Pint l) XPreANSI(ptksrow **last) X/* X** \blurb`7BTries to return the address of the start of the `60l'th row. X** If this row doesn't exist yet, rowptr is NIL, and a pointer X** to the previous row, if any, is returned in 'last'.`7D X*/ X`7B X ptksrow *r; X Pint lev; X X r = topptr->rowlist; X lev = 1; X *last = NULL; X while (r != NULL && lev != l)`20 X `7B X *last = r; X r = r->next; X lev++; X `7D X return r; X`7D /* selectrow */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void addtorowlist(C(ptksstruct *) sp, C(Pint) level) XPreANSI(ptksstruct *sp) XPreANSI(Pint level) X/* X** \blurb`7BAdds an entry for `60sp' to the `60level'th row; also records X** the level in the structure entry.`7D X*/ X`7B X ptksrow *last, *r, *newr; X ptksnode *np, *newnp, *lastnp; X X r = selectrow(level, &last); X if (r == NULL)`20 X `7B `20 X /* the required level doesn't yet exist */ X newr = (ptksrow *)malloc(sizeof(ptksrow)); X if (last == NULL) X topptr->rowlist = newr; X else X last->next = newr; X newr->next = NULL; X newr->num = 0; X newr->n = NULL; X r = newr; X `7D X X /* So now we are at the start of a row list, which may X or may not be empty. Add the new node to the tail of it*/ X np = r->n; X lastnp = NULL; X r->num++; X while (np != NULL)`20 X `7B X lastnp = np; X np = np->next; X `7D X /* now lastnp = tail */ X newnp = (ptksnode *)malloc(sizeof(ptksnode)); /*create the new node*/ X if (lastnp == NULL) /*chain to tail*/ X r->n = newnp; /*chain to row header*/ X else X lastnp->next = newnp; X newnp->structptr = sp; X newnp->next = NULL; X sp->level = level; X X /* keep track of the maximum level */ X if (level > topptr->maxlevel) X topptr->maxlevel = level; X`7D /* addtorowlist */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptksnode *selectrownode(C(ptksrow *) r, C(ptksstruct *) sp, C(ptksnod Ve **)last) XPreANSI(ptksrow *r) XPreANSI(ptksstruct *sp) XPreANSI(ptksnode **last) X/* X** \blurb`7BLocates the given structure in the given row. It's address X** is returned as the result. Also, if there is a node immediately X** previous to this node, its address is returned in 'last', X** otherwise 'last' is NIL, which means that the first node in X** the row list was found.`7D X*/ X`7B`20 X ptksnode *np; X ptkboolean found; X X np = r->n; X found = FALSE; X *last = NULL; X while (np != NULL && !found)`20 X `7B X if (np->structptr == sp) X found = TRUE; X else`20 X `7B X *last = np; /* record the previous address */ X np = np->next; X `7D X `7D X return np; X`7D /* selectrownode */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void deletefromrowlist(C(ptksstruct *) sp) XPreANSI(ptksstruct *sp) X/* X** \blurb`7BDeletes the entry for sp from its row.`7D X*/ X`7B X ptksrow *r, *dummy; X ptksnode *np, *last; X X r = selectrow(sp->level, &dummy); X if (r == NULL)`20 X `7B X printf("deletefromrowlist: row %d doesn't exist\n", sp->level); X return; X `7D X r->num--; X np = selectrownode(r, sp, &last); X if (np == NULL)`20 X `7B X printf("deletefromrowlist: %d not found on row %d\n", X`09 sp->name, sp->level); X return; X `7D X if (last == NULL) X r->n = np->next; /* first on the list */ X else X last->next = np->next; X free(np); X`7D /* deletefromrowlist */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void getpaths() X`7B X Pint totsize, err; X X pinqdescstruct(topptr->root, PTOP_FIRST, 0, 0, &err, topptr->buffer,`20 X &totsize, &topptr->pathlist); X topptr->buffer = (Pchar *)malloc(totsize); +-+-+-+-+-+-+-+- END OF PART 257 +-+-+-+-+-+-+-+-