-+-+-+-+-+-+-+-+ START OF PART 278 -+-+-+-+-+-+-+-+ X bannertextcolourind = bannertextcol; X tlcolourind = tlcol; X brcolourind = brcol; X arrowcolourind = arrowcol; X arrowedgecolourind = arrowedgecol; X`7D /* ptk_setvieweditorattrs */ X X/*-------------------------------------------------------------------------- V*/ X X/*function:external*/ Xextern void ptk_inqvieweditorattrs(C(Pint *) menufont, C(Pint *) windowfont, V`20 X C(Pint *) menucol, C(Pint *) menutextcol, C(Pint *) windowcol,`20 X C(Pint *) bannercol, C(Pint *) bannertextcol, C(Pint *) tlcol,`20 X C(Pint *) brcol, C(Pint *) arrowcol, C(Pint *) arrowedgecol) XPreANSI(Pint *menufont) XPreANSI(Pint *windowfont) XPreANSI(Pint *menucol) XPreANSI(Pint *menutextcol) XPreANSI(Pint *windowcol) XPreANSI(Pint *bannercol) XPreANSI(Pint *bannertextcol) XPreANSI(Pint *tlcol) XPreANSI(Pint *brcol) XPreANSI(Pint *arrowcol) XPreANSI(Pint *arrowedgecol) X/* X** \parambegin X** \param`7BPint *`7D`7Bmenufont`7D`7Bmenu text font`7D`7BIN`7D X** \param`7BPint *`7D`7Bwindowfont`7D`7Bwindow text font`7D`7BIN`7D X** \param`7BPint *`7D`7Bmenucol`7D`7Bmenu colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Bmenutextcol`7D`7Bmenu text colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Bwindowcol`7D`7Bwindow interior colour index`7D`7BIN` V7D X** \param`7BPint *`7D`7Bbannercol`7D`7Bwindow banner colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Bbannertextcol`7D`7Bwindow banner text colour index`7 VD`7BIN`7D X** \param`7BPint *`7D`7Btlcol`7D`7Btop-left colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Bbrcol`7D`7Bbottom-right colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Barrowcol`7D`7Barrow colour index`7D`7BIN`7D X** \param`7BPint *`7D`7Barrowedgecol`7D`7Barrow edge colour index`7D`7BIN`7D X** \paramend X** \blurb`7BThis function may be used to obtain the text font and`20 X** colour attribute values of menus and windows used in the PHIGS view X** editor.`7D X*/ X`7B X *menufont = menutextfont; X *windowfont = windowtextfont; X *menucol = menucolourind; X *windowcol = windowcolourind; X *menutextcol = menutextcolourind; X *bannercol = bannercolourind; X *bannertextcol = bannertextcolourind; X *tlcol = tlcolourind; X *brcol = brcolourind; X *arrowcol = arrowcolourind; X *arrowedgecol = arrowedgecolourind; X`7D /* ptk_inqvieweditorattrs */ X X/*-------------------------------------------------------------------------- V*/ X X/* end of view.c */ $ CALL UNPACK [.SOURCE.LIBRARY]VIEW.C;2 1534602544 $ create 'f' X/*-------------------------------------------------------------------------- V-- X X Module name: PHIGS windows. X X Author: Gareth Williams. X X Function: This module contains functions for displaying PHIGS structures X in windows. X X Dependencies: X X Internal function list:`20 X X External function list:`20 X X Hashtables used: "structureid", "name", "label", "viewindex". X X Modification history: (Version), (Date), (name), (Description). X X 1.0, 5th September 1991, G. Williams, First version. X X---------------------------------------------------------------------------- V*/ X X#include X#include X#include X#ifdef SUN X#include X#include `20 X#endif X#include X#include "ptk.h" X X/* constants */ X X#define PI 3.14159 X X/* data types */ X X#define ptkctmmaxlinelen 80 X X#define ptkctmlinespace 0.008 X X#define ptkcfloatformat 20 X Xtypedef struct ptksterminal`20 X`7B X Pint textstid; X Pint lines, columns, curr_colm, curr_line; X Pint visline; X Pfloat increment; X Pchar floatformat`5Bptkcfloatformat`5D; X Pchar *lastline; X Pfloat realcols, reallines; X Pint txfont, txcolour; X`7D ptksterminal; X Xtypedef struct ptkswindow X`7B X /* window variables */ X Pint windowid; X Pint windowstid; X ptkewindowtype windowtype; X ptkewindowstate windowstate; X Pint iconstid; X Pint wsid; X Pint currentstid; X Pint windowname; X ptkboolean posted; X X Pint windowviewind; X Ppoint windowsize; X Ppoint windowposition; X Ppoint iconsize; X Ppoint iconposition; X Ppoint framesize; X Pint usericon; X ptkboolean defaulticon; X Pint backgdcolour, edgecolour, frametlcolour, framebrcolour, bannercolour; X Pchar titlestring`5B50`5D; X Pfloat bannerheight; X Pint titlefont, titlecolour; X X Plimit3 viewlims, viewbox; X Ppoint3 viewvolume; X ptkecamerastate cameraswitch; X X /* camera variables */ X Pfloat swivelangle, twistangle, spinangle; X Ppoint3 position; /* prp */ X Ppoint3 ptinterest; /* vrp */ X Ppoint3 positionaxis; X Ppoint3 ptinterestaxis; X Ppoint3 lastvpn, lastvup; X Pprojtype cameraproj; X Ppoint3 xaxis, yaxis; X X /* viewing variables */ X Ppoint3 vrp, prp; X Ppoint3 vpn, vup; X Plimit window; X Plimit3 viewport; X Pprojtype proj; X Pfloat viewplane, backplane, frontplane; X Pclip clipxy, clipfront, clipback; X Plimit3 cliplimit; X X /* terminal window variables */ X ptksterminal term; X X /* topology view area */ X Plimit topviewarea; X X /* content window variables */ X Pint range1, range2; X Pint viewrange1, viewrange2; X X /* next window */ X struct ptkswindow *next; X`7D ptkswindow; X Xtypedef struct`20 X`7B X ptkboolean postedwindows; X ptkswindow *frontptr; X ptkswindow *backptr; X Pint frontstid; X Pint backstid; X`7D ptkswswindow; X X/*-------------------------------------------------------------------------- V*/ X X/* PHIGS viewing variables */ Xstatic Ppoint3 vrp; Xstatic Ppoint3 vpn, vup; Xstatic Pviewmapping3 vmap; X Xstatic ptkswindow *windptr = NULL; Xstatic ptkswindow *firstwind = NULL; Xstatic ptkswindow *lastwind = NULL; X Xstatic Pint numwsids = 0; Xstatic Pint wsids`5B10`5D; Xstatic ptkswswindow wswindows`5B10`5D; Xstatic Pint windowcount = 0; X Xstatic Ppoint3 origin = `7B0.0, 0.0, 0.0`7D; X X/*-------------------------------------------------------------------------- V*/ X Xstatic void setwindow(C(Pint) windid) XPreANSI(Pint windid) X`7B X ptkswindow *ptr; X X if (firstwind == NULL) X `7B X windptr = NULL; X return; X `7D X ptr = firstwind; X while (ptr->windowid != windid) X `7B X ptr = ptr->next; X if (ptr == NULL) X `7B X windptr = NULL; X return; X `7D X `7D X windptr = ptr; X`7D /* setwindow */ X X/*-------------------------------------------------------------------------* V/ X Xstatic ptkboolean getwindowid(C(Pint) windowstid, C(Pint *) windowid) XPreANSI(Pint windowstid) XPreANSI(Pint *windowid) X`7B X ptkswindow *ptr; X X ptr = firstwind; X while (ptr->windowstid != windowstid) X `7B X ptr = ptr->next; X if (ptr == NULL) X return FALSE; X `7D X *windowid = ptr->windowid; X return TRUE; X`7D /* getwindowid */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void findwsid(C(Pint) wsid, C(Pint *) ind) XPreANSI(Pint wsid) XPreANSI(Pint *ind) X`7B X Pint i; X X *ind = -1; X for (i = 0; i < numwsids; i++) X if (wsids`5Bi`5D == wsid) X *ind = i; X`7D /* findwsid */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void checkws(C(Pint) wsid) XPreANSI(Pint wsid) X`7B X Pint ind; X X findwsid(wsid, &ind); X if (ind == -1) X `7B X wsids`5Bnumwsids`5D = wsid; X wswindows`5Bnumwsids`5D.postedwindows = FALSE; X wswindows`5Bnumwsids`5D.frontptr = NULL; X wswindows`5Bnumwsids`5D.backptr = NULL; X numwsids++; X `7D X`7D /* checkws */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic ptkboolean iswindow(C(Pint) windstid, C(ptkswindow **) wptr) XPreANSI(Pint windstid) XPreANSI(ptkswindow **wptr) X`7B X ptkswindow *ptr; X ptkboolean found; X X ptr = firstwind; X found = FALSE; X while ((ptr != NULL) && (!found)) X `7B X if (ptr->currentstid == windstid) X `7B X *wptr = ptr; X found = TRUE; X `7D X else X ptr = ptr->next; X `7D X return found; X`7D /* iswindow */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void findfront(C(Pint) wsid, C(ptkswswindow *) wsfront) XPreANSI(Pint wsid) XPreANSI(ptkswswindow *wsfront) X`7B X Pstructpostlst structlist; X Pint numstructs, error, i; X Pfloat priority; X ptkboolean found; X ptkswindow *wptr; X X found = FALSE; X priority = 0.0; X i = 0; X pinqpostedstruct(wsid, 0, 0, &error, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &error, &structlist, &numstructs); X for (i = 0; i < numstructs; i++)`20 X `7B X /* find highest priority window structure */ X if (iswindow(structlist.postings`5Bi`5D.id, &wptr)) X if (structlist.postings`5Bi`5D.priority > priority) X `7B X priority = structlist.postings`5Bi`5D.priority; X wsfront->frontptr = wptr; X found = TRUE; X `7D X `7D X if (!found) X wsfront->postedwindows = FALSE; X`7D /* findfront */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void findback(C(Pint) wsid, C(ptkswswindow *) wsback) XPreANSI(Pint wsid) XPreANSI(ptkswswindow *wsback) X`7B X Pstructpostlst structlist; X Pint numstructs, error, i; X Pfloat priority; X ptkboolean found; X ptkswindow *wptr; X X priority = 1.0; X pinqpostedstruct(wsid, 0, 0, &error, &structlist, &numstructs); X structlist.postings = (Pstructpost *)calloc(numstructs,`20 X sizeof(Pstructpost)); X pinqpostedstruct(wsid, numstructs, 0, &error, &structlist, &numstructs); X for (i = 0; i < numstructs; i++)`20 X `7B X /* find lowest priority window structure */ X if (iswindow(structlist.postings`5Bi`5D.id, &wptr)) X if (structlist.postings`5Bi`5D.priority < priority) X `7B X priority = structlist.postings`5Bi`5D.priority; X wsback->backptr = wptr; X found = TRUE; X `7D X `7D X if (!found) X wsback->postedwindows = FALSE; X`7D /* findback */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void setvalidwindowpos() X`7B X Plimit lim; X X lim = ptk_limit(windptr->windowposition.x - (windptr->windowsize.x / 2.0), V`20 X windptr->windowposition.x + (windptr->windowsize.x / 2.0), X windptr->windowposition.y - (windptr->windowsize.y / 2.0), V`20 X windptr->windowposition.y + (windptr->windowsize.y / 2.0) V +`20 X windptr->bannerheight); X if ((lim.xmin < 0.0) && (lim.ymin < 0.0)) X `7B X /* bottom left */ X windptr->windowposition.x += MIN(1.0 - lim.xmax, -lim.xmin); X windptr->windowposition.y += MIN(1.0 - lim.ymax, -lim.ymin); X `7D X else X if ((lim.xmin < 0.0) && (lim.ymax > 1.0)) X `7B X /* top left */ X windptr->windowposition.x += MIN(1.0 - lim.xmax, -lim.xmin); X windptr->windowposition.y -= MIN(lim.ymin, lim.ymax - 1.0); X `7D X else X if ((lim.xmax > 1.0) && (lim.ymin < 0.0)) X `7B X /* bottom right */ X windptr->windowposition.x -= MIN(lim.xmin, lim.xmax - 1.0); X windptr->windowposition.y += MIN(1.0 - lim.ymax, -lim.ymin); X `7D X else X if ((lim.xmax > 1.0) && (lim.ymax > 1.0)) X `7B X /* top right */ X windptr->windowposition.x -= MIN(lim.xmin, lim.xmax - 1.0); X windptr->windowposition.y -= MIN(lim.ymin, lim.ymax - 1.0); X `7D X else`20 X if (lim.xmin < 0.0) X windptr->windowposition.x += MIN(1.0 - lim.xmax, -lim.xmin); X else X if (lim.xmax > 1.0) X windptr->windowposition.x -= MIN(lim.xmin, lim.xmax - 1.0); X else X if (lim.ymin < 0.0) X windptr->windowposition.y += MIN(1.0 - lim.ymax, -lim.ymin); X else X if (lim.ymax > 1.0) X windptr->windowposition.y -= MIN(lim.ymin, lim.ymax - 1.0); X`7D /* setvalidwindowpos */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void setvalidwindowsize() X`7B X Plimit lim; X X lim = ptk_limit(windptr->windowposition.x - (windptr->windowsize.x / 2.0), V`20 X windptr->windowposition.x + (windptr->windowsize.x / 2.0), X windptr->windowposition.y - (windptr->windowsize.y / 2.0), V`20 X windptr->windowposition.y + (windptr->windowsize.y / 2.0)) V; X if (lim.xmin < 0.0) X lim.xmin = 0.0; X if (lim.xmax > 1.0) X lim.xmax = 1.0; X if (lim.ymin < 0.0) X lim.ymin = 0.0; X if (lim.ymax + windptr->bannerheight > 1.0) X lim.ymax = 1.0 - windptr->bannerheight; X windptr->windowposition = ptk_point(lim.xmin + (lim.xmax - lim.xmin) / 2.0 V, X lim.ymin + (lim.ymax - lim.ymin) / 2.0 V); X windptr->windowsize = ptk_point(lim.xmax - lim.xmin, lim.ymax - lim.ymin); X`7D /* setvalidwindowsize */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void maxadjustlimits(C(Ppoint3 *) boundvolume) XPreANSI(Ppoint3 *boundvolume) X`7B X Pfloat projht, projwt, aspectratio, maxdimen; X X /* calculate aspect ratio of window */ X projht = windptr->viewlims.ymax - windptr->viewlims.ymin; X projwt = windptr->viewlims.xmax - windptr->viewlims.xmin; X aspectratio = MAX(projht, projwt) / MIN(projht, projwt); X X /* adjust view volume to have same aspect ratio as window */ X maxdimen = MAX(boundvolume->x, MAX(boundvolume->y, boundvolume->z)); X windptr->viewvolume = ptk_point3(maxdimen, maxdimen, maxdimen); X X if (projht == projwt) X `7B X if (maxdimen > boundvolume->y) X windptr->viewvolume.y *= aspectratio; X if (maxdimen > boundvolume->x) X windptr->viewvolume.x *= aspectratio; X if (maxdimen > boundvolume->z) X windptr->viewvolume.z *= aspectratio; X `7D X else X if (projht > projwt) X windptr->viewvolume.y *= aspectratio; X else X if (projht < projwt) X windptr->viewvolume.x *= aspectratio; X X /* X ** calculate zmax so that projection viewport has same X ** aspect ratio as view volume. X */ X X windptr->viewlims.zmax = windptr->viewvolume.z *`20 +-+-+-+-+-+-+-+- END OF PART 278 +-+-+-+-+-+-+-+-