-+-+-+-+-+-+-+-+ START OF PART 288 -+-+-+-+-+-+-+-+ X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_setterminalfloatformat(C(Pint) windid, C(Pchar *) rformat) XPreANSI(Pint windid) XPreANSI(Pchar *rformat) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bterminal window identifier`7D`7BIN`7D X** \param`7BPchar *`7D`7Brformat`7D`7Bstring giving C-type float number outp Vut style`7D`7BIN`7D X** \paramend X** \blurb`7BThis function sets the format for writing floating-point numbers X** to a TERMINAL window. The format used is the same syntax as in the X** C language.`7D X*/ X`7B X Pint rlen; X X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKETERMINALWINDOW) X `7B X rlen = strlen(rformat); X if (rlen > ptkcfloatformat)`20 X rlen = ptkcfloatformat;`20 X strncpy(windptr->term.floatformat, rformat, (rlen + 1)); X `7D X `7D X`7D /* ptk_setterminalfloatformat */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqterminalfloatformat(C(Pint) windid, C(Pint) size,`20 X C(Pint *) totalsize, C(Pchar *) rformat, C(Pint *) err) XPreANSI(Pint windid) XPreANSI(Pint size) XPreANSI(Pint *totalsize) XPreANSI(Pchar *rformat) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bterminal window identifier`7D`7BIN`7D X** \param`7BPint`7D`7Bsize`7D`7Bsize of buffer, in bytes, as allocated by ap Vplication`7D`7BIN`7D X** \param`7BPint *`7D`7Btotalsize`7D`7Bactual size of buffer`7D`7BIN`7D X** \param`7BPchar *`7D`7Brformat`7D`7Bstring giving C-type float number outp Vut style`7D`7BIN`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function may be used to obtain the floating-point used X** for writing floating-point numbers to a TERMINAL window. X** The error code = 1 if `7B\tt windid`7D doesn't exist and = 2 if it is X** not a terminal window.`7D X*/ X`7B X *err = 0; X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKETERMINALWINDOW) X `7B X *totalsize = strlen(windptr->term.floatformat) + 1; X if (size >= *totalsize) X `7B X strncpy(rformat, windptr->term.floatformat, *totalsize); X rformat`5B*totalsize - 1`5D = '\0'; X `7D X `7D X else X *err = 2; X `7D X else X *err = 1; X`7D /* ptk_inqterminalfloatformat */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqterminalstructid(C(Pint) windid, C(Pint *) termtextstid, X C(Pint *) err) XPreANSI(Pint windid) XPreANSI(Pint *termtextstid) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bterminal window identifier`7D`7BIN`7D X** \param`7BPint *`7D`7Brformat`7D`7Bstring giving C-type real number output V style`7D`7BIN`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function may be used to obtain the identifier of the X** structure used to display the text written to a TERMINAL window. X** The error code = 1 if `7B\tt windid`7D doesn't exist and = 2 if it is X** not a terminal window.`7D X*/ X`7B X *err = 0; X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKETERMINALWINDOW) X *termtextstid = windptr->term.textstid; X else X *err = 2; X `7D X else X *err = 1; X`7D /* ptk_inqterminalstructid */ X X/*-------------------------------------------------------------------------- V*/ X/*----------------------- Topology window functions ------------------------ V*/ X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_settopologyviewarea(C(Pint) windid, C(Plimit *) viewarea) XPreANSI(Pint windid) XPreANSI(Plimit *viewarea) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bwindow identifier`7D`7BIN`7D X** \param`7BPlimit *`7D`7Bviewarea`7D`7Barea of topology to view`7D`7BIN`7D X** \paramend`20 X** \blurb`7BThis function sets the viewing area of a topology diagram posted X** to a TOPOLOGY window. The area is defined in the range `5B0, 1`5D.`7D X*/ X`7B X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKETOPOLOGYWINDOW) X `7B X /* calculate aspect ratio of window */ X windptr->topviewarea = windptr->window = *viewarea; X windptr->prp.x = windptr->window.xmin +`20 X (windptr->window.xmax - windptr->window.xmin) / 2.0; X windptr->prp.y = windptr->window.ymin +`20 X (windptr->window.ymax - windptr->window.ymin) / 2.0; X updateview(); X `7D X `7D X`7D /* ptk_settopologyviewarea */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqtopologyviewarea(C(Pint) windid, C(Plimit *) viewarea, X C(Pint *) err) XPreANSI(Pint windid) XPreANSI(Plimit *viewarea) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bwindow identifier`7D`7BIN`7D X** \param`7BPlimit *`7D`7Bviewarea`7D`7Barea of topology to view`7D`7BOUT`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend`20 X** \blurb`7BThis function may be used to obtain the viewing area X** of a topology diagram posted to a TOPOLOGY window. X** The error code = 1 if `7B\tt windid`7D doesn't exist and = 2 if it is X** not a topology window.`7D X*/ X`7B X *err = 0; X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKETOPOLOGYWINDOW) X *viewarea = windptr->topviewarea; X else X *err = 2; X `7D X else X *err = 1; X`7D /* ptk_inqtopologyviewarea */ X X/*-------------------------------------------------------------------------- V*/ X/*----------------------- Content window functions ------------------------- V*/ X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_setcontentviewrange(C(Pint) windid, C(Pint) range1,`20 X C(Pint) range2) XPreANSI(Pint windid) XPreANSI(Pint range1) XPreANSI(Pint range2) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bwindow identifier`7D`7BIN`7D X** \param`7BPint`7D`7Brange1`7D`7Bstart element number`7D`7BIN`7D X** \param`7BPint`7D`7Brange2`7D`7Bend element number`7D`7BIN`7D X** \paramend`20 X** \blurb`7BThis function sets the range of elements of a structure X** content diagram to view in a CONTENT window.`7D X*/ X`7B X Pfloat projht, projwt, winht, winwt, aspectratio, winaspectratio; X Pfloat diff, elemspace, fudge; X Pint numelems, first, last, viewelems; X X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKECONTENTWINDOW) X `7B X /* check range is valid */ X first = range1; X last = range2; X if (range1 < 0) X first = windptr->range1; X if ((range2 > windptr->range2) `7C`7C (range2 == 0)) X last = windptr->range2; X if (last < first) X last = first; X X windptr->viewrange1 = first; X windptr->viewrange2 = last; X /* calculate window given element range to view */ X numelems = windptr->range2 - windptr->range1 + 2; X `20 X if (numelems < 10)`20 X elemspace = 0.1; X else X elemspace = 1.0 / (Pfloat)numelems; X fudge = 0.01/(Pfloat)numelems; X windptr->window.ymax = 1.0 - ((Pfloat)(first - windptr->range1 + 1) *` V20 X elemspace); X windptr->window.ymin = 1.0 - ((Pfloat)(last - windptr->range1 + 2) *`2 V0 X elemspace) - fudge; X windptr->window.xmin = 0.0; X viewelems = last - first + 1; X if (numelems < 10) X windptr->window.xmax = 1.0; X else X windptr->window.xmax = (Pfloat)viewelems / (Pfloat)numelems; X /* calculate aspect ratio of window */ X projht = windptr->window.ymax - windptr->window.ymin; X projwt = windptr->window.xmax - windptr->window.xmin; X aspectratio = projht / projwt; X `20 X /* adjust view area to have same aspect ratio as window */ X windptr->viewbox = windptr->viewport = windptr->viewlims; X winht = windptr->viewport.ymax - windptr->viewport.ymin; X winwt = windptr->viewport.xmax - windptr->viewport.xmin; X winaspectratio = winht / winwt; X `20 X if (aspectratio > winaspectratio) X `7B X /* decrease x */ X diff = (winwt - ((1.0 / aspectratio) * winht)); X windptr->viewport.xmax -= diff; X `7D X else X if (aspectratio < winaspectratio) X `7B X /* decrease y */ X diff = (winht - (aspectratio * winwt)); X windptr->viewport.ymin += diff; X `7D `20 X X windptr->prp = ptk_point3( X (windptr->window.xmax - windptr->window.xmin) / 2.0,`20 X (windptr->window.ymin + X (windptr->window.ymax - windptr->window.ymin) / 2.0), 2.0); X X updateview(); X `7D X `7D X`7D /* ptk_setcontentviewrange */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqcontentviewrange(C(Pint) windid, C(Pint *) range1,`20 X C(Pint *) range2, C(Pint *) err) XPreANSI(Pint windid) XPreANSI(Pint *range1) XPreANSI(Pint *range2) XPreANSI(Pint *err) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bterminal window identifier`7D`7BIN`7D X** \param`7BPint`7D`7Brange1`7D`7Belement number`7D`7BIN`7D X** \param`7BPint`7D`7Brange2`7D`7Belement number`7D`7BIN`7D X** \param`7BPint *`7D`7Berr`7D`7Berror indicator`7D`7BOUT`7D X** \paramend X** \blurb`7BThis function may be used to obtain the viewing range of X** a structure content diagram which is posted to a CONTENT window. X** The error code = 1 if `7B\tt windid`7D doesn't exist and = 2 if it is X** not a content window.`7D X*/ X`7B X *err = 0; X setwindow(windid); X if (windptr != NULL) X `7B X if (windptr->windowtype == PTKECONTENTWINDOW) X `7B X *range1 = windptr->viewrange1; X *range2 = windptr->viewrange2; X `7D X else X *err = 2; X `7D X else X *err = 1; X`7D /* ptk_inqcontentviewrange */ X X/*-------------------------------------------------------------------------- V*/ X/*----------------------- Window type functions ---------------------------- V*/ X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_setwindowtype(C(Pint) windid, C(ptkewindowtype) windtype) XPreANSI(Pint windid) XPreANSI(ptkewindowtype windtype) X/* X** \parambegin X** \param`7BPint`7D`7Bwindid`7D`7Bwindow identifier`7D`7BIN`7D X** \param`7Bptkewindowtype`7D`7Bwindtype`7D`7Bwindow type`7D`7BIN`7D X** \paramend`20 X** \blurb`7BThis function sets the type of a window to one of X** STRUCT, TOPOLOGY, CONTENT and TERMINAL. The default window type is X** STRUCT. All items are unposted from the window before the type X** is set.`7D X*/ X`7B X Pchar stname`5B20`5D; X X setwindow(windid); X if (windptr != NULL) X `7B X windptr->windowtype = windtype; X ptk_unpostallfromwindow(windid); X switch (windtype) X `7B X case PTKESTRUCTWINDOW: X break; X `20 X case PTKETERMINALWINDOW: X /* create a text structure */ X sprintf(stname, "struct$term%d", windid); X windptr->term.textstid = ptk_stringtoint("structureid", stname); X `20 X /* post to window */ X ptk_openstruct(windptr->windowstid); X ptk_seteditmode(PEDIT_INSERT); X psetelemptr(0); X psetelemptrlabel(ptk_stringtoint("label", "begin-window")); X pexecutestruct(windptr->term.textstid); `20 X ptk_unseteditmode(); X ptk_closestruct(); X `20 X /* initialise */ X windptr->term.curr_line = 0; X windptr->term.visline = 0; X strncpy(windptr->term.floatformat, "%.5e", 5); X windptr->term.lastline = NULL; X ptk_setterminaldata(windid, 20, 1, 1); X windptr->term.curr_colm = windptr->term.columns; X /* initialise view */ X windptr->cameraswitch = PTKECAMERAOFF; X initialiseterminal(); X ptk_scrollterminal(windid, PTP_UP, 1); X break; X `20 X case PTKETOPOLOGYWINDOW: X windptr->viewport = ptk_limit3(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); `20 X /* default viewing variables */ X windptr->proj = PPARALLEL; X windptr->vrp = ptk_point3(0.0, 0.0, 0.0); X windptr->prp = ptk_point3(0.5, 0.5, 2.0); X windptr->vpn = ptk_point3(0.0, 0.0, 1.0); X windptr->vup = ptk_point3(0.0, 1.0, 0.0); X windptr->topviewarea = windptr->window = ptk_limit(0.0, 1.0, 0.0, 1.0) V; X windptr->viewplane = windptr->frontplane = 1.0; X windptr->backplane = 0.0; X `20 X /* other window defaults */ X windptr->cameraswitch = PTKECAMERAOFF; X updateview(); X break; X `20 X case PTKECONTENTWINDOW: X windptr->cliplimit = windptr->viewlims; X /* default viewing variables */ X windptr->proj = PPARALLEL; X windptr->vrp = ptk_point3(0.0, 0.0, 0.0); X windptr->prp = ptk_point3(0.5, 0.5, 2.0); X windptr->vpn = ptk_point3(0.0, 0.0, 1.0); X windptr->vup = ptk_point3(0.0, 1.0, 0.0); X windptr->window = ptk_limit(0.0, 1.0, 0.0, 1.0); X windptr->viewplane = windptr->frontplane = 1.0; X windptr->backplane = 0.0; X `20 X /* other window defaults */ X windptr->cameraswitch = PTKECAMERAOFF; X updateview(); X break; X `7D X `7D X`7D /* ptk_setwindowtype */ X X/*-------------------------------------------------------------------------- V*/ X X/* end of wind.c */ X $ CALL UNPACK [.SOURCE.LIBRARY]WIND.C;2 2118179075 $ v=f$verify(v) $ EXIT