-+-+-+-+-+-+-+-+ START OF PART 255 -+-+-+-+-+-+-+-+ X** `7B\tt stid`7D in the currently open structure at the current editing`20 X** position. The diagram consists of a table of elements represented X** by rectangles and labelled with element type and number. The table X** has a heading with the format: X** `7B\tt "structure N "name" (M elements)"`7D X** where N is the structure identifier, name is the structure name X** extracted from the "structureid" hashtable and M is the total X** number of elements in the structure. The error code = 1 if there X** is no open structure and = 2 if `7B\tt stid`7D doesn't exist. X** This function requires hashtable "label".`7D`20 X*/ X`7B X Popenstructstatus structst; X Pint i, err, curname, lenstr, elptr; X Peltype etype; X Pchar str`5B80`5D, name`5B30`5D; X Ppoint3 arrowcentre; X Ppoint3 arrowshift; X Pmatrix3 mat; X X stctwsid = wsid; X stfirstel = firstel; X stlastel = lastel; X stctfont = font; X *error = 0; X X pinqopenstruct(error, &structst, &curname); X if (structst == PSTRUCT_NONE)`20 X `7B X *error = 1; X fprintf(stderr, "ptk_structcontent: needs a structure open\n"); X return; X `7D X X if (!ptk_structexists(stid))`20 X `7B X *error = 2; X fprintf(stderr, "ptk_structcontent: structure %d doesn't exist\n", stid) V; X return; X `7D X X ptk_seteditmode(PEDIT_INSERT); X /* validate the requested element range */ X no_els = ptk_elemcount(stid); X if (stfirstel <= 0) X stfirstel = 1; X if ((stlastel > no_els) `7C`7C (stlastel == 0)) X stlastel = no_els; X if (stlastel < stfirstel) X stlastel = stfirstel; X X pinqelemptr(&err, &first_element); X plabel(ptk_stringtoint("label", "globaltran")); X plabel(ptk_stringtoint("label", "elementpointer")); X plabel(ptk_stringtoint("label", "start-structcontent")); X ptk_unitmatrix3(mat); X psetlocaltran3(mat, PREPLACE); X initialise(); X X /* heading */ X if (ptk_hashtableused("structureid")) X `7B X ptk_inttostring("structureid", stid, 30, name, &lenstr); X if (lenstr != 0) X sprintf(str, "structure %d \"%s\" (%d elements)\0", stid,`20 X name, no_els);`20 X else X sprintf(str, "structure %d (%d elements)\0", stid,`20 X no_els);`20 X `7D X tp = ptk_point(topleftbox.x + OFFSET, topleftbox.y - 0.05); X ptext(&tp, str); `20 X topleftbox.y -= elemheight; X /* elements */ X for (i = stfirstel; i <= stlastel; i++)`20 X `7B X ptk_inqelemtype(stid, i, error, &etype); X psetpickid(i); /* pick identifier = element pointer */ X elemtypebox(etype, i); X if (i == elemptr) X `7B `20 X pinqelemptr(&err, &elptr); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "elementpointer")); X arrowshift = ptk_point3(0.9, topleftbox.y - 0.05, 0.0); X ptk_shift3(&arrowshift, PREPLACE, mat); X psetlocaltran3(mat, PREPLACE); X /* insert arrow */ X arrowcentre = ptk_point3(0.0, 0.0, 0.0); X ptk_arrow(0.1, 0.075, &arrowcentre, 90.0); X /* jump back */ X psetelemptr(elptr + 2); X `7D X topleftbox.y -= elemheight; X `7D X X setscaling(); X plabel(ptk_stringtoint("label", "end-structcontent")); X ptk_unseteditmode(); X`7D /* ptk_structcontent */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqstructcontentrange(C(Pint) contentstid, C(Pint *) firstel V, X C(Pint *) lastel, C(Pint *) err) XPreANSI(Pint contentstid) XPreANSI(Pint *firstel) XPreANSI(Pint *lastel) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bcontentstid`7D`7Bcontent structure identifier`7D`7BIN` V7D X** \param`7BPint *`7D`7Bfirstel`7D`7Belement pointer`7D`7BOUT`7D X** \param`7BPint *`7D`7Blastel`7D`7Belement pointer`7D`7BOUT`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function may be used to obtain the element range which appe Vars X** in the structure content diagram. The error code = 1 if `7B\tt contentsti Vd`7D X** is not a structure content diagram.`7D X*/ X`7B X Pint elptr, lstnum; X ptkselcontent elcont; X Psrchstatus stat; X Pchar *buffer; X Peltype eltype; X X *err = 0; X ptk_openstruct(contentstid); X psetelemptr(0); X if (ptk_findlabel(ptk_stringtoint("label", "start-structcontent"), &elptr) V) X `7B X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "start-structcontent")); X eltype = PEL_TEXT; X ptk_findelemtype(&eltype, 1, PFORWARD, &stat, &elptr, &lstnum); X psetelemptr(elptr + 1); X ptk_findelemtype(&eltype, 1, PFORWARD, &stat, &elptr, &lstnum); X psetelemptr(elptr + 1); X ptk_findelemtype(&eltype, 1, PFORWARD, &stat, &elptr, &lstnum); X if (stat == PSUCCESS) X `7B X ptk_inqelemtypesizecontent(contentstid, elptr, err, &buffer, &elcont); X#ifdef SUN X *firstel = atoi(elcont.eldata.tx.str); X#endif X#ifdef VMS X *firstel = atoi(elcont.eldata.text.string); X#endif X free(buffer); X `7D X psetelemptrlabel(ptk_stringtoint("label", "end-structcontent")); X ptk_findelemtype(&eltype, 1, PBACKWARD, &stat, &elptr, &lstnum); X if (stat == PSUCCESS) X `7B X ptk_inqelemtypesizecontent(contentstid, elptr, err, &buffer, &elcont); X#ifdef SUN X *lastel = atoi(elcont.eldata.tx.str); X#endif X#ifdef VMS X *lastel = atoi(elcont.eldata.text.string); X#endif X free(buffer); X `7D X `7D X else X *err = 1; X ptk_closestruct(); X`7D /* ptk_inqstructcontentrange */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_setstructcontentelemptr(C(Pint) contentstid, C(Pint) elemptr V) XPreANSI(Pint contentstid) XPreANSI(Pint elemptr) X/* X** \parambegin X** \param`7BPint`7D`7Bcontentstid`7D`7Bcontent structure identifier`7D`7BIN` V7D X** \param`7BPint`7D`7Belemptr`7D`7Belement pointer`7D`7BIN`7D X** \paramend X** \blurb`7BThis function draws an arrow pointing the element `7B\tt elemptr V`7D X** in the structure content diagram.`7D X*/ X`7B X Pint range1, range2, err; X Ppoint3 arrowcentre; X Ppoint3 arrowshift; X Pmatrix3 mat; X X /* find element range */ X ptk_inqstructcontentrange(contentstid, &range1, &range2, &err); X if (err == 0) X `7B X if ((elemptr >= range1) && (elemptr <= range2)) X `7B X ptk_openstruct(contentstid); X psetelemptr(0); X pdelelemslabels(ptk_stringtoint("label", "elementpointer"), X ptk_stringtoint("label", "start-structcontent")); X arrowshift = ptk_point3(0.9, 0.0, 0.0); X arrowshift.y = 0.95 + (-0.1 * (Pfloat)(elemptr - range1 + 1)); X ptk_shift3(&arrowshift, PREPLACE, mat); X psetpickid(elemptr); X psetlocaltran3(mat, PREPLACE); X /* insert arrow */ X arrowcentre = ptk_point3(0.0, 0.0, 0.0); X ptk_arrow(0.1, 0.075, &arrowcentre, 90.0); X ptk_closestruct(); X `7D X `7D `20 X`7D /* ptk_setstructcontentelemptr */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqstructcontentelemptr(C(Pint) contentstid,`20 X C(Pint *) elemptr, C(Pint *) err) XPreANSI(Pint contentstid) XPreANSI(Pint *elemptr) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bcontentstid`7D`7Bcontent structure identifier`7D`7BIN` V7D X** \param`7BPint *`7D`7Belemptr`7D`7Belement pointer`7D`7BOUT`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function may be used to obtain the element number pointed X** to by the element arrow in the structure content diagram. X** The error code = 1 if `7B\tt contentstid`7D is not a`20 X** structure content diagram.`7D X*/ X`7B X Psrchstatus stat; X Pint elptr, lstnum; X Peltype elemlist`5B2`5D; X X *err = 0; X ptk_openstruct(contentstid); X psetelemptr(0); X if (ptk_findlabel(ptk_stringtoint("label", "elementpointer"), &elptr)) X `7B X psetelemptrlabel(ptk_stringtoint("label", "elementpointer")); X poffsetelemptr(1); X elemlist`5B0`5D = PEL_PICK_ID; X elemlist`5B1`5D = PEL_LABEL; X ptk_findelemtype(elemlist, 2, PFORWARD, &stat, &elptr, &lstnum); X if ((stat == PSUCCESS) && (lstnum == 0)) X ptk_getpickid(contentstid, elptr, elemptr); X `7D X else X *err = 1; X ptk_closestruct(); X`7D /* ptk_inqstructcontentelemptr */ X X/*-------------------------------------------------------------------------- V*/ X X/* end of stct.c */ $ CALL UNPACK [.SOURCE.LIBRARY]STCT.C;1 1997713266 $ create 'f' X/*-------------------------------------------------------------------------- V-- X X Module name: TopDraw X X Author: Toby Howard X X Function: Implements the PHIGS structure network topology drawing tool. X X External function list: ptk_topology. X X Internal function list: X X Hashtables used: "structureid", "name", "label". X X Modification history: (Version), (Date), (Name), (Description). X X 1.0, ????, Toby Howard, First version. X`20 X 1.1, 29th July 1988, Steve Larkin, Modified to use Vax Phigs instead of`20 X KRT3. X X 2.0, 10th June 1991, Gareth Williams, Translated to C. X X---------------------------------------------------------------------------- V*/ X X#include X#include X#include X#include "ptk.h" X X/*-------------------------------------------------------------------------- V*/ X X/* The width and height of the nodes in the diagram */ X X#define WIDTH 1.0 X X#define HEIGHT 1.0 X X/* The horizontal and vertical separations of the nodes */ X X#define HSPACING (3.0 * WIDTH) X X#define VSPACING (4.0 * HEIGHT) X X/* for storage of structure information */ X Xtypedef struct ptksstruct`20 X`7B X Pint name; /* structure identifier */ X Pint numchildren; /* number of children */ X Pint numunique; /* number of unique children */ X Pint level; /* max level in picture */ X Ppoint pos; /* position in picture */ X ptkboolean placed; /* placed yet? */ X struct ptksref *firstchild, *lastchild; /* list of children */ X struct ptksref *firstparent, *lastparent; /* list of parents */ X struct ptksstruct *next; /* next ptksstruct record */ X`7D ptksstruct; X X/* for storage of structure references */ X Xtypedef struct ptksref`20 X`7B X ptksstruct *structptr; /* structure being referenced */ X Pint element; /* element doing the referencing */ X struct ptksref *next; /* next ptksreference */ X`7D ptksref; X X/* this is a node in the diagram */ X Xtypedef struct ptksnode`20 X`7B X ptksstruct *structptr; X struct ptksnode *next; X`7D ptksnode; X X/* this is for the list of rows */ X Xtypedef struct ptksrow`20 X`7B X Pint num; X ptksnode *n; X struct ptksrow *next; X`7D ptksrow; X Xtypedef struct ptkskeytable`20 X`7B X Pchar key`5B256`5D, an`5B256`5D; X`7D ptkskeytable; X Xtypedef struct ptkstopdraw`20 X`7B X Pint topologyid; X Pint topologystid; X ptketopologytype topologytype; X Pint txfont; X Pint textcolour; X Pint linecolour; X Pint edgecolour; X Pint intcolour; X Pint topologyname; X Pintlst posted; X `20 X /* highlight node */ X Pint highlightnode; X Pint highlightedge; X Pint highlightint; X X struct ptkstopdraw *next; X `20 X Pint root; X X Pintlst hlist; /* list of nodes to highlight ? */ X ptksstruct *structlist; /* the head of the structure info list */ X ptksrow *rowlist; /* the head of the row list */ X X Pmatrix3 globaltran, mat; X Pexecreflstlst pathlist; /* structure network paths */ X Pchar *buffer; /* buffer to hold paths data */ X X Pfloat annotextheight; /* size of characters for annotation */ X Pint nodebounds; /* for drawing the nodes */ X Ppoint nodepoints`5B5`5D; X Pfloat nodeheight, nodewidth; X X Plimit3 extent; X Pfloat xinc, yinc; X Pfloat rowmaxx`5B255`5D; X Pfloat topx, topy; X Pint maxlevel; X `20 X ptkskeytable keytablelst`5B255`5D; X Pint keyno; X`7D ptkstopdraw; X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptkstopdraw *topptr = NULL; X Xstatic ptkstopdraw *firsttop = NULL; Xstatic ptkstopdraw *lasttop = NULL; Xstatic nodeidcount = 0; X Xstatic topologycount = 0; X X/*-------------------------------------------------------------------------- V*/ X Xstatic void settop(C(Pint) topid) XPreANSI(Pint topid) X`7B X ptkstopdraw *ptr; X X if (firsttop == NULL) X `7B X topptr = NULL; X return; X `7D X ptr = firsttop; X while (ptr->topologyid != topid) X `7B X ptr = ptr->next; X if (ptr == NULL) X `7B X topptr = NULL; X return; X `7D X `7D X topptr = ptr; X`7D /* settop */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void note(C(Pfloat) xx, C(Pfloat) yy) XPreANSI(Pfloat xx) XPreANSI(Pfloat yy) X/* X** \parambegin X** \param`7B`7D`7Bxx`7D`7Bx coordinate`7D`7BIN`7D X** \param`7B`7D`7Byy`7D`7By coordinate`7D`7BIN`7D X** \paramend X** \blurb`7BUpdates `60extent' using xx, yy.`7D X*/ X`7B X if (xx > topptr->extent.xmax) X topptr->extent.xmax = xx; X if (yy > topptr->extent.ymax) X topptr->extent.ymax = yy; X if (xx < topptr->extent.xmin) X topptr->extent.xmin = xx; X if (yy < topptr->extent.ymin) X topptr->extent.ymin = yy; X`7D /* note */ X X/*-------------------------------------------------------------------------- V*/ X X/* Key handling X** X** When the algorithm has drawn the nodes for all the structures in X** the hierarchy, it attempts to draw the structure names against the nodes, X** and tries various positions to avoid overlapping with adjacent nodes. If X** it is unable to place the text reasonably, it gives up, and resorts to X** a simple 'key' scheme, where the name is associated with a key, and the X** node is labelled with the key instead of the full name (the assumption X** being that the key will be only a few characters long. If keys are used, V a X** list of keys and their corresponding names is added to the picture at the X** end. X*/ X +-+-+-+-+-+-+-+- END OF PART 255 +-+-+-+-+-+-+-+-