-+-+-+-+-+-+-+-+ START OF PART 258 -+-+-+-+-+-+-+-+ X pinqdescstruct(topptr->root, PTOP_FIRST, 0, totsize, &err,`20 X topptr->buffer, &totsize, &topptr->pathlist); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void buildlists(C(void)) X/* X** \blurb`7BConstructs the main data structures used by the topology`20 X** drawer. It creates the structure list, and the row list.`7D X*/ X`7B X Pint cur_level, p, path; X ptksstruct *sp; X ptkboolean rowentryinvalid; X X /* do first node */ X lookupstructure(topptr->root, TRUE, &sp); X addtorowlist(sp, 1); X for (p = 0; p < topptr->pathlist.number; p++)`20 X `7B `20 X /* do a path */ X cur_level = 1; X for (path = 0; path < topptr->pathlist.erls`5Bp`5D.number; path++)`20 X `7B `20 X /* each member of path */ X rowentryinvalid = TRUE; /* assume it will change the row list */ X /* Look for this structure, and create it if it isn't there */ X if (!lookupstructure(topptr->pathlist.erls`5Bp`5D.ers`5Bpath`5D.struct V_id,`20 X TRUE, &sp))`20 X `7B X`09/* it was already there */ X`09if (sp->level < cur_level) X`09 deletefromrowlist(sp); X`09else X`09 rowentryinvalid = FALSE; X `7D X if (rowentryinvalid) X`09addtorowlist(sp, cur_level); X cur_level++; X `7D /* each member of path */ X /* go to next path */ X `7D /* a path */ X storereferences(); X`7D /* buildlists */ X X/*-------------------------------------------------------------------------- V*/ X X Xstatic void disposenodelist(C(ptksnode *) nodeptr) XPreANSI(ptksnode *nodeptr) X`7B X if (nodeptr->next == NULL) X free(nodeptr); X else X disposenodelist(nodeptr->next); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void disposereflist(C(ptksref *) refptr) XPreANSI(ptksref *refptr) X`7B X if (refptr->next == NULL) X free(refptr); X else X disposereflist(refptr->next); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void disposestructlist(C(ptksstruct *) stptr) XPreANSI(ptksstruct *stptr) X`7B X if (stptr->next == NULL) X `7B X if (stptr->firstchild != NULL) X disposereflist(stptr->firstchild); X if (stptr->firstparent != NULL) X disposereflist(stptr->firstparent); X free(stptr); X `7D X else X disposestructlist(stptr->next); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void disposerowlist(C(ptksrow *) rowptr) XPreANSI(ptksrow *rowptr) X`7B X if (rowptr->next == NULL) X `7B X if (rowptr->n != NULL) X disposenodelist(rowptr->n); X free(rowptr); X `7D X else X disposerowlist(rowptr->next); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic inqnamelist(C(ptksstruct *) stptr, C(Pintlst *) namelist) XPreANSI(ptksstruct *stptr) XPreANSI(Pintlst *namelist) X`7B X ptksref *refptr; X X refptr = stptr->firstchild; X while (refptr != NULL) X `7B X if (inintlst(refptr->structptr->name, namelist) == -1) X namelist->integers`5Bnamelist->number++`5D = refptr->structptr->name; X inqnamelist(refptr->structptr, namelist); X refptr = refptr->next; X `7D X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void setnodeposition(C(Pint) topid, C(Pint) nodeid,`20 X C(Ppoint *) nodept, C(ptkenodetype) nodetype) XPreANSI(Pint topid) XPreANSI(Pint nodeid) XPreANSI(Ppoint *nodept) XPreANSI(ptkenodetype nodetype) X`7B X ptksstruct *structptr; X Pint err, i, totsize; X Ppoint3 toppt, nodept3; X Pmatrix3 invglobalmat; X Ppoint3 delta; X Pintlst stids, nameset; X Pint ids`5B255`5D, name; X X settop(topid); X ptk_invertmatrix3(topptr->globaltran, invglobalmat, &err); X nodept3 = ptk_point3(nodept->x, nodept->y, 0.0); X toppt = ptk_transform3(invglobalmat, &nodept3); X switch (nodetype) X `7B X case PTKESINGLE:`20 X structptr = topptr->structlist; X for (i = 0; i < nodeid; i++) X structptr = structptr->next; X structptr->pos = ptk_point(toppt.x, toppt.y); X break; X `20 X case PTKEGROUP: X /* calculate dx, dy, X follow ref list, add dx, dy to position X */ X structptr = topptr->structlist; X for (i = 0; i < nodeid; i++) X structptr = structptr->next; X delta = ptk_point3(toppt.x - structptr->pos.x, X toppt.y - structptr->pos.y, 0.0); X /* inquire structure identifiers of sub tree */ X stids.integers = ids; X stids.number = 1; X ids`5B0`5D = structptr->name; X inqnamelist(structptr, &stids); X for (i = 0; i < stids.number; i++) X `7B X structptr = topptr->structlist; X while (structptr->name != stids.integers`5Bi`5D) X structptr = structptr->next; X structptr->pos.x += delta.x; X structptr->pos.y += delta.y; X `7D X free(stids.integers); X break; X `7D X ptk_openstruct(topptr->topologystid); X psetelemptr(0); X pdelelemslabels(ptk_stringtoint("label", "globaltran"),`20 X ptk_stringtoint("label", "highlightattrs")); X pdelelemslabels(ptk_stringtoint("label", "highlightnode"),`20 X ptk_stringtoint("label", "attrs")); X pdelelemslabels(ptk_stringtoint("label", "starttopology"),`20 X ptk_stringtoint("label", "endtopology")); X topptr->extent = ptk_limit3(1000000.0, -10000000.0, 10000000.0, X -10000000.0, 0.0, 1.0); X pseteditmode(PEDIT_INSERT); `20 X setnode(1.0, 1.0); X switch (topptr->topologytype) X `7B X case PTKEBOXTOPOLOGY:`20 X drawnodes(); X break; X X case PTKESTRUCTNETTOPOLOGY: X drawstructnetnodes(); X break; X X case PTKESTRUCTTOPOLOGY: X drawstructnodes(); X break; X `7D X nameset.integers = &name; X nameset.number = 1; X name = topptr->topologyname; X premovenameset(&nameset); X drawconnections(); X drawnames(); X drawkeys(); X setscaling(); X ptk_closestruct(); X`7D /* setnodeposition */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void redrawtopology(C(void)) X`7B X Pintlst nameset; X Pint name, k; X X /* remove keys */ X topptr->keyno = 0; X for (k = 0; k <= 254; k++) X topptr->rowmaxx`5Bk`5D = -32768.0; X pemptystruct(topptr->topologystid); X ptk_openstruct(topptr->topologystid); X `20 X ptk_seteditmode(PEDIT_INSERT); /* We want to insert elements */ X nameset.integers = &name; X nameset.number = 1; X name = topptr->topologyname; X paddnameset(&nameset); X plabel(ptk_stringtoint("label", "globaltran")); X X plabel(ptk_stringtoint("label", "highlightattrs")); X psetedgecolourind(topptr->highlightedge); X psetintcolourind(topptr->highlightint); X psetintstyle(PSOLID); X psetedgeflag(PEDGE_ON); X plabel(ptk_stringtoint("label", "highlightnode")); X plabel(ptk_stringtoint("label", "attrs")); X psetlinecolourind(topptr->linecolour); X psetintcolourind(topptr->intcolour); X psetedgecolourind(topptr->edgecolour); X psettextfont(topptr->txfont); X psettextcolourind(topptr->textcolour); X plabel(ptk_stringtoint("label", "starttopology")); X X placenodes(); X switch (topptr->topologytype) X `7B X case PTKEBOXTOPOLOGY:`20 X drawnodes(); X break; X X case PTKESTRUCTNETTOPOLOGY: X drawstructnetnodes(); X break; X X case PTKESTRUCTTOPOLOGY: X drawstructnodes(); X break; X `7D X premovenameset(&nameset); X drawconnections(); X drawnames(); X X /* In case any nodes were labelled with keys because there was no room X for proper annotation, draw the keytable. */ X drawkeys(); X plabel(ptk_stringtoint("label", "endtopology")); X X /* now we've drawn it all, so we find the appropriate scale to put it all X in `5B0,1`5D */ X setscaling(); X X ptk_unseteditmode(); X ptk_closestruct(); `20 X`7D /* redrawtopology */ X X/*-------------------------------------------------------------------------- V*/ X/*--------------------- External Topology Functions ------------------------ V*/ X/*-------------------------------------------------------------------------- V*/ X Xstatic void createtopology(C(Pint) topid, C(Pint) root, C(Pint) txfont, X C(Pint) linecol, C(Pint) textcol, C(Pint) edgecol, X C(Pint) intcol, C(Pint *) error) XPreANSI(Pint topid) XPreANSI(Pint root) XPreANSI(Pint txfont) XPreANSI(Pint linecol) XPreANSI(Pint textcol) XPreANSI(Pint edgecol) XPreANSI(Pint intcol) XPreANSI(Pint *error) X/*`20 X** \parambegin X** \param`7BPint`7D`7Btopid`7D`7Btopology identifier`7D`7BIN`7D X** \param`7BPint`7D`7Broot`7D`7Bstructure network identifier`7D`7BIN`7D X** \param`7BPint`7D`7Btxfont`7D`7Blabel text font`7D`7BIN`7D X** \param`7BPint`7D`7Blinecol`7D`7Bpolyline colour index`7D`7BIN`7D X** \param`7BPint`7D`7Btextcol`7D`7Btext colour index`7D`7BIN`7D X** \param`7BPint`7D`7Bedgecol`7D`7Bedge colour index`7D`7BIN`7D X** \param`7BPint`7D`7Bintcol`7D`7Binterior colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D X** \paramend X** \blurb`7BCreate topology diagram of given structure network.`7D X*/ X`7B X Pint curname; X Pchar stname`5B255`5D; X Pintlst nameset; X Pint name; X X /* if there already exists a topology with this identifier, error */ X *error = 0; X settop(topid); X if (topptr == NULL) X `7B `20 X if (lasttop == NULL) X `7B X firsttop = lasttop = topptr = X (ptkstopdraw *)malloc(sizeof(ptkstopdraw)); X topptr->next = NULL; X `7D X else X `7B X lasttop->next = topptr = (ptkstopdraw *)malloc(sizeof(ptkstopdraw)); X topptr->next = NULL; X lasttop = lasttop->next; X `7D X X topologycount++; `20 X topptr->topologyid = topid; X topptr->posted.number = 0; X topptr->posted.integers = (Pint *)calloc(10, sizeof(Pint)); X sprintf(stname, "struct$topology%d", topid); X topptr->topologystid = ptk_stringtoint("structureid", stname); X sprintf(stname, "name$topology%d", topid); X topptr->topologyname = ptk_stringtoint("name", stname); X topptr->root = root; X topptr->topologytype = PTKEBOXTOPOLOGY; X topptr->txfont = txfont; X topptr->textcolour = textcol; X topptr->linecolour = linecol; X topptr->edgecolour = edgecol; X topptr->intcolour = intcol; X topptr->highlightnode = -1; X topptr->highlightedge = intcol; X topptr->highlightint = edgecol; X *error = 0; X `20 X if (!ptk_structexists(topptr->root))`20 X `7B X *error = 1; X fprintf(stderr, "ptk_createtopology: structure `5B%d`5D doesn't exist\ Vn", topptr->root); X return; X `7D X `20 X ptk_openstruct(topptr->topologystid); X `20 X initialise(); X getpaths(); X buildlists(); X `20 X ptk_seteditmode(PEDIT_INSERT); /* We want to insert elements */ X nameset.integers = &name; X nameset.number = 1; X name = topptr->topologyname; X paddnameset(&nameset); X plabel(ptk_stringtoint("label", "globaltran")); X plabel(ptk_stringtoint("label", "highlightattrs")); X psetedgecolourind(topptr->highlightedge); X psetintcolourind(topptr->highlightint); `20 X psetintstyle(PSOLID); X psetedgeflag(PEDGE_ON); X plabel(ptk_stringtoint("label", "highlightnode")); X plabel(ptk_stringtoint("label", "attrs")); X psetlinecolourind(topptr->linecolour); X psetintcolourind(topptr->intcolour); X psetedgecolourind(topptr->edgecolour); X psettextfont(topptr->txfont); X psettextcolourind(topptr->textcolour); X plabel(ptk_stringtoint("label", "starttopology")); X `20 X placenodes(); X drawnodes(); `20 X premovenameset(&nameset); X drawconnections(); X drawnames(); X `20 X /* In case any nodes were labelled with keys because there was no room X for proper annotation, draw the keytable. */ X drawkeys(); X plabel(ptk_stringtoint("label", "endtopology")); X X /* now we've drawn it all, so we find the appropriate scale to put it al Vl X in `5B0,1`5D */ X setscaling(); X `20 X ptk_unseteditmode(); X ptk_closestruct(); X `7D X else X `7B X *error = 2; X `7D X`7D /* createtopology */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_createtopology(C(Pint) topid, C(Pint) root, C(Pint *) err) XPreANSI(Pint topid) XPreANSI(Pint root) XPreANSI(Pint *err) X/*`20 X** \parambegin X** \param`7BPint`7D`7Btopid`7D`7Btopology identifier`7D`7BIN`7D X** \param`7BPint`7D`7Broot`7D`7Bstructure network identifier`7D`7BIN`7D X** \param`7BPint *`7D`7Berror`7D`7Berror code`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function creates a diagram of the structure network X** specified by `7B\tt root`7D. The diagram is a PHIGS structure which X** uses boxes connected by lines to represent structures and X** EXECUTE STRUCTURE elements. The error code = 1 if the root structure X** does not exist and = 2 if `7B\tt topid`7D already exists. X** This function requires hashtables "structureid", "label", "name".`7D`20 X*/ X`7B X createtopology(topid, root, 1, 1, 1, 1, 0, err); X`7D /* ptk_createtopology */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_settopologyattrs(C(Pint) topid, C(Pint) txfont, X C(Pint) linecol, C(Pint) textcol, C(Pint) edgecol, X C(Pint) intcol, C(Pint) htedgecol, C(Pint) htintcol V) XPreANSI(Pint topid) XPreANSI(Pint txfont) XPreANSI(Pint linecol) XPreANSI(Pint textcol) XPreANSI(Pint edgecol) XPreANSI(Pint intcol) XPreANSI(Pint htedgecol) XPreANSI(Pint htintcol) X/*`20 X** \parambegin X** \param`7BPint`7D`7Btopid`7D`7Btopology identifier`7D`7BIN`7D X** \param`7BPint`7D`7Btxfont`7D`7Blabel text font`7D`7BIN`7D X** \param`7BPint`7D`7Blinecol`7D`7Bpolyline colour index`7D`7BIN`7D X** \param`7BPint`7D`7Btextcol`7D`7Btext colour index`7D`7BIN`7D X** \param`7BPint`7D`7Bedgecol`7D`7Bedge colour index`7D`7BIN`7D X** \param`7BPint`7D`7Bintcol`7D`7Binterior colour index`7D`7BIN`7D +-+-+-+-+-+-+-+- END OF PART 258 +-+-+-+-+-+-+-+-