-+-+-+-+-+-+-+-+ START OF PART 190 -+-+-+-+-+-+-+-+ X Modification history : (Version), (Date), (Name), (Description). X X 1.0, 18th February 1991, G. Williams, First Version. X X SunOS requirements: SunPHIGS (all versions before v2.0), X SunView or OpenWindows. X VMS requirements: DEC PHIGS v2.2, DECWindows workstation type. X (To run with ReGIS workstation type remove all printf statements) X X---------------------------------------------------------------------------- V*/ X X#include X#include X#include X#include "ptk.h" X X#define WS1 1 X#define TABLE 1 X Xstatic Pfloat devx, devy, devz; X X/*-------------------------------------------------------------------------- V*/ X Xstatic void outputcolourvalues(C(Pint) inum, C(Pchar *) colourname, X C(Pcobundl *) rgb) XPreANSI(Pint inum) XPreANSI(Pchar *colourname) XPreANSI(Pcobundl *rgb) X/* Output colour model values of colourname in RGB, HSV and HSL X** coordinates. X*/ X`7B X Pcobundl hsv, hsl; X X#ifdef SUN X printf("%d) RGB value of %s is %f %f %f\n", inum, colourname, rgb->x,`20 X rgb->y, rgb->z);`20 X ptk_rgbtohsv(rgb, &hsv); X printf("%d) HSV value of %s is %f %f %f\n", inum, colourname, hsv.x,`20 X hsv.y, hsv.z);`20 X ptk_rgbtohsl(rgb, &hsl); X printf("%d) HSL value of %s is %f %f %f\n\n", inum, colourname, hsl.x,`2 V0 X hsl.y, hsl.z);`20 X#endif X#ifdef VMS X printf("%d) RGB value of %s is %f %f %f\n", inum, colourname, rgb->rgb.r V,`20 X rgb->rgb.g, rgb->rgb.b);`20 X ptk_rgbtohsv(rgb, &hsv); X printf("%d) HSV value of %s is %f %f %f\n", inum, colourname, hsv.hsv.h, V`20 X hsv.hsv.s, hsv.hsv.v);`20 X ptk_rgbtohsl(rgb, &hsl); X printf("%d) HSL value of %s is %f %f %f\n\n", inum, colourname, hsl.hls. Vh,`20 X hsl.hls.s, hsl.hls.l);`20 X#endif X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void options(C(void)) X/* enable input of colour names using PHIGS string device */ X`7B X Pchar colourname`5B50`5D; X Pint err, lencolourname; X ptkboolean cnsquit; X Plimit echoarea; X Pcobundl rgb; X X cnsquit = FALSE; X echoarea = ptk_limit(0.0, devx * 0.5, 0.0, devy * 0.05); X do X `7B X /* input a colour name and display the colour */ X ptk_readstring(WS1, "white", "Input colourname (white) >", &echoarea, X 50, colourname, &lencolourname); X if (strncmp(colourname, "quit", lencolourname) == 0) X `7B X cnsquit = TRUE; X `7D `20 X else X `7B X /* convert colourname to RGB colour model */ X ptk_cnstorgb(colourname, &rgb); X /* set entry in colour table */ X psetcolourrep(WS1, 1, &rgb); X pemptystruct(TABLE); X /* display entry in colour table */ X ptk_drawcolourtable(TABLE, 1, 1); `20 X outputcolourvalues(1, colourname, &rgb); X `7D X pupdatews(WS1, PPERFORM); X `7D while (cnsquit == FALSE); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xmain() X`7B X FILE *fileptr; X Pint i, numcolours; X Pchar colourname`5B64`5D, dummystr`5B255`5D; X Pint dummylen; X Plimit echoarea; X Pwstype wst; X X /* open PHIGS */ X X printf("Demonstrating the Colour Naming Scheme of the PHIGS Toolkit...\n") V; X#ifdef VMS X printf("Opening DEC PHIGS...\n"); X popenphigs(0, 0); X popenws(WS1, 0, 0); X#endif X#ifdef SUN X printf("Opening SunPHIGS...\n"); X popenphigs(stderr, PDEFAULT_MEM_SIZE); X `20 X /* create the workstation type (tool) */ X X wst = phigs_ws_type_create( phigs_ws_type_sun_tool, X PHIGS_COLOR_TABLE_SIZE, 256, X`09PHIGS_TOOL_LABEL, "SunPHIGS Tool Workstation", X`090); X if ( !wst )`20 X `7B X pclosephigs(); X exit(1); X `7D X`20 X /* open the workstation */ X X popenws(WS1, (Pconnid)NULL, wst); X `7B X Pwsstate ws_state; X`09 X pinqwsst(&ws_state); X if (ws_state != PWSOP) X exit(3); X `7D X#endif X X#ifdef VMS X ptk_inqmaxdevicecoords(WS1, &devx, &devy); X devz = 0.0; X#endif X#ifdef SUN X devx = devy = devz = 1.0; X#endif X X /* set up hashstrings colour table */ X ptk_inithashtables(); X ptk_createhashtable("colourindex", 1, 256); X X psetdisplayupdatest(WS1, PWAIT, PNIVE); X X ptk_drawcolourtable(TABLE, 0, 0); `20 X ppoststruct(WS1, TABLE, 0.0); X X pupdatews(WS1, PPERFORM); X X options(); X X pclosews(WS1); X printf("Closing PHIGS...\n"); X pclosephigs(); X exit(0); X`7D X X/*-------------------------------------------------------------------------- V*/ X X/* end of cnstest.c */ $ CALL UNPACK [.SOURCE.DEMO]CNSTEST.C;2 1683902904 $ create 'f' X/*-------------------------------------------------------------------------- V-`20 X X Program name: Menus demonstration program. X X Author: Gareth Williams X X Description: This program demonstrates box menus, user menus and rotators X and enables interaction using the pick, locator and string input devices. X X Modification history : (Version), (Date), (Name), (Description). X X 1.0, 1st March 1991, G. Williams, First Version. X X SunOS requirements: SunPHIGS (all versions before v2.0), X SunView or OpenWindows. X VMS requirements: DEC PHIGS v2.3A, DECWindows workstation type. X (To run with ReGIS workstation type remove all printf statements) X X---------------------------------------------------------------------------- V*/ X X#include X#include X#include X#include "ptk.h" X X#define WS1 1 X#define NUMCPTS 19 X#define PI 3.14 X Xstatic Pchar *colwrd`5B`5D =`20 X `7B X `09"WHITE", "GREEN",`20 X `09"BLUE", "MEDIUM GREEN", "MAGENTA", "MEDIUM MAGENTA",`20 X "BLACK", "GREY", "RED"`20 X `7D; X Xstatic Pwstype wst; Xstatic Pint mainmenuid, inputmenuid, boxmenuid, usermenuid, userboxid; Xstatic Pint rotator1, rotator2, rotator3; Xstatic Pfloat devx, devy, devz; Xstatic Plimit3 pointecho; Xstatic Plimit3 boxport = `7B0.0, 0.2, 0.0, 0.2, 0.0, 0.1`7D; Xstatic ptkboolean docolour = FALSE; X X/*-------------------------------------------------------------------------- V*/ X Xstatic void makecircle(C(Ppoint3 *) centre, C(Pfloat) radius,`20 X C(Ppoint3 *) pts) XPreANSI(Ppoint3 *centre) XPreANSI(Pfloat radius) XPreANSI(Ppoint3 *pts) X`7B X Pfloat delta; X Pint i; X X delta = 2 * PI / NUMCPTS; X for (i = 0; i < NUMCPTS; i++)`20 X `7B X pts`5Bi`5D.x = centre->x + radius * cos(i * delta); X pts`5Bi`5D.y = centre->y + radius * sin(i * delta); X pts`5Bi`5D.z = centre->z; X `7D X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void makeellipse(C(Ppoint3 *) centre, C(Pfloat) xradius,`20 X C(Pfloat) yradius, C(Ppoint3 *) pts) XPreANSI(Ppoint3 *centre) XPreANSI(Pfloat xradius) XPreANSI(Pfloat yradius) XPreANSI(Ppoint3 *pts) X`7B X Pfloat delta; X Pint i; X X delta = 2 * PI / NUMCPTS; X for (i = 0; i < NUMCPTS; i++)`20 X `7B X pts`5Bi`5D.x = centre->x + xradius * cos(i * delta); X pts`5Bi`5D.y = centre->y + yradius * sin(i * delta); X pts`5Bi`5D.z = centre->z; X `7D X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void shadebox(C(Ppoint3 *) pos, C(Pfloat) height, C(Pfloat) width, X C(Pfloat) xpercent, C(Pfloat) ypercent,`20 X C(Pint) tlcol, C(Pint) brcol, C(Pint) mcol) XPreANSI(Ppoint3 *pos) XPreANSI(Pfloat height) XPreANSI(Pfloat width) XPreANSI(Pfloat xpercent) XPreANSI(Pfloat ypercent) XPreANSI(Pint tlcol) XPreANSI(Pint brcol) XPreANSI(Pint mcol) X`7B X Ppoint3 pts`5B6`5D; X Ppointlst3 sets; X X psetintstyle(PSOLID); X psetintcolourind(mcol); X pts`5B0`5D = ptk_point3(pos->x - (width / 2.0), pos->y - (height / 2.0),`2 V0 X pos->z); X pts`5B1`5D = ptk_point3(pts`5B0`5D.x, pts`5B0`5D.y + height, pos->z); X pts`5B2`5D = ptk_point3(pts`5B0`5D.x + width, pts`5B1`5D.y, pos->z); X pts`5B3`5D = ptk_point3(pts`5B2`5D.x - (width * xpercent),`20 X pts`5B2`5D.y - (height * ypercent), pos->z); X pts`5B4`5D = ptk_point3(pts`5B1`5D.x + (width * xpercent), pts`5B3`5D.y, p Vos->z); X pts`5B5`5D = ptk_point3(pts`5B4`5D.x, pts`5B0`5D.y + (height * ypercent), V pos->z); X X pts`5B2`5D = ptk_point3(pts`5B3`5D.x, pts`5B5`5D.y, pos->z); X pfillarea3(4, &pts`5B2`5D); X X psetedgeflag(PEDGE_ON); X psetintcolourind(tlcol); X psetedgecolourind(tlcol); X pts`5B2`5D = ptk_point3(pts`5B0`5D.x + width, pts`5B1`5D.y, pos->z); X sets.number = 6; X sets.points = pts; X ptk_fillareaset3(1, &sets); X X psetintcolourind(brcol); X psetedgecolourind(brcol); X pts`5B1`5D.x += width; X pts`5B1`5D.y -= height; X pts`5B4`5D.x = pts`5B3`5D.x; X pts`5B4`5D.y = pts`5B5`5D.y; X ptk_fillareaset3(1, &sets); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void makeshademenu() X`7B X Ppoint3 itemcentre, pts`5B20`5D; X Pint white, black, blue, i; X Ptxalign align; X Ppoint txpt, boxpt; X Pfloat charheight; X X if (docolour) X `7B X white = ptk_stringtoint("colourindex", "white"); X black = ptk_stringtoint("colourindex", "black"); X blue = ptk_stringtoint("colourindex", "blue"); X `7D X else X `7B X white = 1; X black = 0; X blue = 0; X `7D X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu1")); X itemcentre = ptk_point3(0.4, 0.7, 0.0); X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X /* dashed line */ X psetlinewidth(3.0); X psetlinetype(PLN_DASH); X pts`5B0`5D = ptk_point3(0.35, 0.65, 0.0); X pts`5B1`5D = ptk_point3(0.45, 0.75, 0.0); X ppolyline3(2, pts); X ptk_closestruct(); X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu3")); X itemcentre.y -= 0.2; X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X /* circle */ X makecircle(&itemcentre, 0.05, pts); X pts`5B19`5D = pts`5B0`5D; X ppolyline3(20, pts); X ptk_closestruct(); X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu5")); X itemcentre.y -= 0.2; X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X /* ellipse */ X makeellipse(&itemcentre, 0.05, 0.025, pts); X pts`5B19`5D = pts`5B0`5D; X ppolyline3(20, pts); X ptk_closestruct(); X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu2")); X itemcentre = ptk_point3(0.6, 0.7, 0.0); X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X /* polygon */ X `20 X pts`5B0`5D = ptk_point3(0.55, 0.75, 0.0); X pts`5B1`5D = ptk_point3(0.65, 0.75, 0.0); X pts`5B2`5D = ptk_point3(0.53, 0.63, 0.0); X pts`5B3`5D = ptk_point3(0.67, 0.63, 0.0); `20 X pts`5B4`5D = pts`5B0`5D; X ppolyline3(5, pts); X ptk_closestruct(); X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu4")); X itemcentre.y -= 0.2; X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X psetintcolourind(white); X psetintstyle(PHATCH); X psetintstyleind(-5); X for (i = 0; i < 5; i++) X pts`5Bi`5D.y -= 0.2; X pfillarea3(4, pts); X ptk_closestruct(); X X ptk_openstruct(ptk_stringtoint("structureid", "shademenu6")); X itemcentre.y -= 0.2; X shadebox(&itemcentre, 0.2, 0.2, 0.05, 0.05, white, black, blue); X X /* capital A */ X boxpt = ptk_point(0.2 - (0.2 * 0.1), 0.2 - (0.2 * 0.1)); X ptk_computecharheight(WS1, "A", &boxpt, -6, &charheight); X psetcharheight(charheight); X psettextfont(-6); X align.hor = PAH_CENTRE; X align.ver = PAV_HALF; X psettextalign(&align); X txpt = ptk_point(itemcentre.x, itemcentre.y); X ptext(&txpt, "A"); X ptk_closestruct(); `20 X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void highlightshadeitem(C(Pint) itemnum) XPreANSI(Pint itemnum) X`7B X Pint err, tlcol, brcol; X ptkselcontent elcont; X Pchar *buffer; X X if (itemnum != 0) X `7B X switch (itemnum) X `7B X case 1: ptk_openstruct(ptk_stringtoint("structureid", "shademenu1")); X break; X X case 2: ptk_openstruct(ptk_stringtoint("structureid", "shademenu2")); X break; X X case 3: ptk_openstruct(ptk_stringtoint("structureid", "shademenu3")); X break; X X case 4: ptk_openstruct(ptk_stringtoint("structureid", "shademenu4")); X break; X X case 5: ptk_openstruct(ptk_stringtoint("structureid", "shademenu5")); X break; X X case 6: ptk_openstruct(ptk_stringtoint("structureid", "shademenu6")); X break; X X `7D X psetelemptr(5); X ptk_inqcurelemtypesizecontent(&err, &buffer, &elcont); X tlcol = elcont.eldata.idata; X free(buffer); X psetelemptr(8); X ptk_inqcurelemtypesizecontent(&err, &buffer, &elcont); X brcol = elcont.eldata.idata; X free(buffer); X psetelemptr(5); X ptk_seteditmode(PEDIT_REPLACE); X psetintcolourind(brcol); X poffsetelemptr(1); X psetedgecolourind(brcol); X psetelemptr(8); X psetintcolourind(tlcol); X poffsetelemptr(1); X psetedgecolourind(tlcol); X ptk_unseteditmode(); X ptk_closestruct(); X `7D X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void pickinput(C(Pint *) itemnum) XPreANSI(Pint *itemnum) X`7B X Ppick pickinit; X Plimit3 pickecho; X Ppickrec pickrec; X Ppathorder pickorder; `20 X Pqpick pickdata; X Ppickpathel pickarray`5B10`5D; X Ppoint3 *aperture; X Pint pickpet; X ptksgeneralinput pickinput; X ptksmenuoutput pickoutput; X Pintlst menuset, emptyset, menunames; X Pint menusetlist`5B20`5D, menunamelist`5B20`5D; X Pint totsize, i, err; X X /* test picking */ X *itemnum = 0; X printf("Pick a menu item...\n"); X /* initialise pick */ X pickinit.status = PP_NOPICK; X pickinit.pick_path.depth = 0; X pickecho.xmin = 0.0; X pickecho.ymin = 0.0; X pickecho.zmin = 0.0; X pickecho.xmax = devx; X pickecho.ymax = devy; X pickecho.zmax = devz; X pickorder = PBOTTOM_FIRST; X `20 X emptyset.number = 0; X menunames.number = 0; X menuset.integers = menusetlist; X menunames.integers = menunamelist; X ptk_inqpostedmenus(WS1, 20, &menuset, &totsize, &err); X for (i = 0; i < totsize; i++) X `7B +-+-+-+-+-+-+-+- END OF PART 190 +-+-+-+-+-+-+-+-