-+-+-+-+-+-+-+-+ START OF PART 194 -+-+-+-+-+-+-+-+ X strcpy(vrec.uvalpet1_datarec.label, "Twist"); X pinitval( WS1, DEVICE4, 0.0, -1, &ea, &vrec); X psetvalmode( WS1, DEVICE4, PSAMPLE, PES_ECHO); X X ea.xmin = 0.0; ea.xmax = 1.0;`20 X ea.ymin = 0.0; ea.ymax = 0.5;`20 X crec.choicepet3_datarec.number = 2; X crec.choicepet3_datarec.strings = strs; X X pinitchoice(WS1, 3, initstatus, initvalue, 3, &ea, &crec); X psetchoicemode(WS1, 3, PEVENT, PES_ECHO); X#endif X#if VMS X ea = ptk_limit(devx * 0.8, devx, devy * 0.8, devy);`20 X vrec.valpet1_datarec.low = 0.0; X vrec.valpet1_datarec.high = 360.0; X vrec.valpet1_datarec.title_string = winstrs`5B0`5D; X pinitval( WS1, DEVICE1, 0.0, 1, &ea, &vrec); X psetvalmode( WS1, DEVICE1, PSAMPLE, PES_ECHO); X X ea = ptk_limit(devx * 0.8, devx, devy * 0.6, devy * 0.8);`20 X vrec.valpet1_datarec.low = 0.0; X vrec.valpet1_datarec.high = 2.0; X vrec.valpet1_datarec.title_string = winstrs`5B1`5D; X pinitval( WS1, DEVICE2, 1.0, 1, &ea, &vrec); X psetvalmode( WS1, DEVICE2, PSAMPLE, PES_ECHO); X X ea = ptk_limit(devx * 0.8, devx, devy * 0.4, devy * 0.6);`20 X vrec.valpet1_datarec.low = 0.0; X vrec.valpet1_datarec.high = 360.0; X vrec.valpet1_datarec.title_string = winstrs`5B2`5D; X pinitval( WS1, DEVICE3, 0.0, 1, &ea, &vrec); X psetvalmode( WS1, DEVICE3, PSAMPLE, PES_ECHO); X X ea = ptk_limit(devx * 0.8, devx, devy * 0.2, devy * 0.4);`20 X vrec.valpet1_datarec.low = 0.0; X vrec.valpet1_datarec.high = 360.0; X vrec.valpet1_datarec.title_string = winstrs`5B3`5D; X pinitval( WS1, DEVICE4, 0.0, 1, &ea, &vrec); X psetvalmode( WS1, DEVICE4, PSAMPLE, PES_ECHO); X X ea = ptk_limit(devx * 0.8, devx, devy * 0.0, devy * 0.2);`20 X crec.choicepet1_datarec.number = 2; X crec.choicepet1_datarec.strings = strs; X crec.choicepet1_datarec.title_string = chtitle; X pinitchoice(WS1, 1, initstatus, initvalue, 1, &ea, &crec); X psetchoicemode(WS1, 1, PEVENT, PES_ECHO); X#endif X`7D X X/*-------------------------------------------------------------------------- V*/ X Xstatic void camerainterface(C(Pint) windid) XPreANSI(Pint windid) X`7B X Pevent event; /* Event input data. */ X Pchoice choice; `20 X Pfloat spinval, oldspinval, newspin; X Pfloat swivelval, oldswivelval, newswivel; X Pfloat twistval, oldtwistval, newtwist; X Pfloat zoomval, oldzoomval, newzoom; X X init_input(); /* Initialise input devices. */ X oldspinval = 0.0; X oldswivelval = 0.0; X oldtwistval = 0.0; X oldzoomval = 1.0; X while (1) X `7B X psampleval(WS1, DEVICE1, &spinval); X psampleval(WS1, DEVICE2, &zoomval); X psampleval(WS1, DEVICE3, &swivelval); X psampleval(WS1, DEVICE4, &twistval); X newspin = spinval - oldspinval; X newswivel = swivelval - oldswivelval; X newtwist = (twistval - oldtwistval); X if (oldzoomval != 0.0) X newzoom = zoomval / oldzoomval; X if (newspin != 0.0) X ptk_rotatecameraposition(windid, newspin); X if (newzoom != 1.0) X ptk_scaleviewwindow(windid, newzoom); X if (newswivel != 0.0) X ptk_rotatecameraptinterest(windid, newswivel); X if (newtwist != 0.0) X ptk_rotatecameraupvector(windid, newtwist); X oldspinval = spinval; X oldswivelval = swivelval; X oldtwistval = twistval; X oldzoomval = zoomval; X pawaitevent(0.2, &event); /* See if choice picked. */ X pupdatews(WS1, PPERFORM); X if (event.class == PI_CHOICE) X `7B`20 X pgetchoice(&choice); X if (choice.choice == 1) X `7B X init_input(); X oldspinval = 0.0; X oldswivelval = 0.0; X oldtwistval = 0.0; X oldzoomval = 1.0; X `7D X if (choice.choice == 2) X break; X `7D X `7D X psetvalmode(WS1, DEVICE1, PREQUEST, PES_ECHO); X psetvalmode(WS1, DEVICE2, PREQUEST, PES_ECHO); X psetvalmode(WS1, DEVICE3, PREQUEST, PES_ECHO); X psetvalmode(WS1, DEVICE4, PREQUEST, PES_ECHO); X#ifdef VMS X psetchoicemode(WS1, 3, PREQUEST, PES_ECHO); X#endif X#ifdef VMS X psetchoicemode(WS1, 1, PREQUEST, PES_ECHO); X#endif X`7D /* camerainterface */ X X/*-------------------------------------------------------------------------- V*/ X Xstatic void options(C(void)) X`7B X Pchar commandstr`5B20`5D, writestr`5B50`5D; X Pint lencom, lenstr, err, elem1, elem2, lampid, currentwindow, red, green; X ptkboolean quit; X Ppoint pos, size; X Plimit echoarea; X Pint lampiconstid; X X quit = FALSE; X currentwindow = 1; X do X `7B X echoarea = ptk_limit(0.0, devx * 0.5, 0.0, devy * 0.05); X ptk_readstring(WS1, "camera", "Input command (default = camera)>",`20 X &echoarea, 20, commandstr, &lencom); X if (strncmp(commandstr, "camera", lencom) == 0) X `7B X camerainterface(currentwindow); X `7D X else X if (strncmp(commandstr, "position", lencom) == 0) X `7B X pos.x = ptk_readfloat(WS1, 0.5, "Input position, x (0.5) >", &echoarea V); X pos.y = ptk_readfloat(WS1, 0.5, "Input position, y (0.5) >", &echoarea V); X ptk_setwindowposition(currentwindow, &pos); X `7D X else`20 X if (strncmp(commandstr, "size", lencom) == 0) X `7B X Ppoint userpos, usersize; X X size.x = ptk_readfloat(WS1, 0.5, "Input size, x (0.5) >", &echoarea); X size.y = ptk_readfloat(WS1, 0.5, "Input size, y (0.5) >", &echoarea); X ptk_setwindowsize(currentwindow, &size); X `7D X else X if (strncmp(commandstr, "iconposition", lencom) == 0) X `7B X pos.x = ptk_readfloat(WS1, 0.5, "Input icon position, x (0.5) >",`20 X &echoarea); X pos.y = ptk_readfloat(WS1, 0.5, "Input icon position, y (0.5) >",`20 X &echoarea); X ptk_seticonposition(currentwindow, &pos); X `7D X else`20 X if (strncmp(commandstr, "iconsize", lencom) == 0) X `7B X size.x = ptk_readfloat(WS1, 0.1, "Input icon size, x (0.1) >",`20 X &echoarea); X size.y = ptk_readfloat(WS1, 0.1, "Input icon size, y (0.1) >",`20 X &echoarea); X ptk_seticonsize(currentwindow, &size); X `7D X else`20 X if (strncmp(commandstr, "framesize", lencom) == 0) X `7B X size.x = ptk_readfloat(WS1, 0.01, "Input frame size, x (0.01) >",`20 X &echoarea); X size.y = ptk_readfloat(WS1, 0.01, "Input frame size, y (0.01) >",`20 X &echoarea); X ptk_setframesize(currentwindow, &size); X `7D X else`20 X if (strncmp(commandstr, "open", lencom) == 0) X `7B X ptk_openwindow(currentwindow); X `7D X else`20 X if (strncmp(commandstr, "close", lencom) == 0) X `7B X ptk_closewindow(currentwindow); X `7D X else X if (strncmp(commandstr, "front", lencom) == 0) X `7B X ptk_frontwindow(currentwindow); X `7D X else`20 X if (strncmp(commandstr, "back", lencom) == 0) X `7B X ptk_backwindow(currentwindow); X `7D X else X if (strncmp(commandstr, "bannerheight", lencom) == 0) X `7B X Pfloat height; X X height = ptk_readfloat(WS1, 0.01, "Input banner height >", &echoarea); X ptk_setbannerheight(currentwindow, height); X `7D X else X if (strncmp(commandstr, "bannercolours", lencom) == 0) X `7B X Pint bancol, titlecol; X X bancol = ptk_readint(WS1, 0, "Input banner colour index >",`20 X &echoarea); X titlecol = ptk_readint(WS1, 1, "Input title string colour index >",`20 X &echoarea); X ptk_setbannercolours(currentwindow, bancol, titlecol); X `7D X else`20 X if (strncmp(commandstr, "phinter", lencom) == 0) X `7B X ptk_callphinter(); X `7D X else if (strncmp(commandstr, "hardcopy", lencom) == 0) X `7B X Pint stid, lenname; X Pchar filename`5B80`5D; X X ptk_readstring(WS1, "window",`20 X "Input filename (default = window) >", &echoarea, X 80, filename, &lenname); X X#ifdef VMS X popenws(2, filename, 61); X#endif X#ifdef SUN X popenws(2, filename, phigs_ws_type_cgm_out); X#endif X ptk_copyviewtable(1, 2); X ptk_copypostedstruct(1, 2); X X pupdatews(2, PPERFORM); X pclosews(2); X `7D `20 X else if (strncmp(commandstr, "help", lencom) == 0) X `7B X printf("windtest options\n"); X printf("----------------\n"); X printf("camera - start up camera interface\n"); X printf("position - set window position (centre)\n"); X printf("size - set window size\n"); X printf("iconposition - set icon position (centre)\n"); X printf("iconsize - set icon size\n"); X printf("framesize - set window frame thickness\n"); X printf("open - open window\n"); X printf("close - close window\n"); X printf("front - bring window/icon to front of display\n"); `20 X printf("back - send window/icon to back of display\n"); `20 X printf("bannerheight - set window banner height\n"); X printf("bannercolours - set window banner colours\n"); X printf("phinter - call phinterface\n"); X printf("hardcopy - post window to hardcopy workstation\n"); X printf("quit - exit windtest\n"); X `7D `20 X else`20 X if (strncmp(commandstr, "quit", lencom) == 0) X `7B X quit = TRUE; X `7D `20 X else X `7B X printf("Command unknown\n"); `20 X `7D X pupdatews(WS1, PPERFORM); X `7D while (quit == FALSE); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xmain() X`7B X Pwstype wst; X Pint lampid; X Pintlst lamplist; X Ppoint pos, size; X X printf("Demonstrating the PHIGS windows module of the PHIGS Toolkit...\n") V; X#if VMS X printf("Opening DEC PHIGS...\n"); X popenphigs(0, 0); X popenws(WS1, 0, 0); X#endif X#if SUN X printf("Opening SunPHIGS...\n"); X popenphigs((Pchar *)NULL, PDEFAULT_MEM_SIZE); /* Open PHIGS. */ X wst = phigs_ws_type_create( phigs_ws_type_sun_tool, X`09PHIGS_VAL_PANEL_X, 650, PHIGS_VAL_PANEL_Y, 25, X`090); X popenws(WS1, (Pconnid)NULL, wst); /* Open a workstation. */ 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 psetdisplayupdatest(WS1, PWAIT, PNIVE);`20 X `20 X /* initialise hashtables */ X X ptk_inithashtables(); X ptk_createhashtable("structureid", 1, 500); X ptk_createhashtable("label", 1, 50); X ptk_createhashtable("viewindex", 1, 50); X ptk_createhashtable("windowid", 1, 50); X ptk_createhashtable("name", 1, 50); X X if (ptk_readphinterscript(SCRIPTNAME, NULL, NULL)) X `7B X pos = ptk_point(0.5, 0.5); X size = ptk_point(0.6, 0.6); `20 X ptk_createwindow(WS1, ptk_stringtoint("windowid", "lampwindow"),`20 X &size, &pos, "lamp window"); X ptk_posttowindow(ptk_stringtoint("windowid", "lampwindow"),`20 X ptk_stringtoint("structureid", "lamp")); X lamplist.number = 1; X lamplist.integers = &lampid; X lampid = ptk_stringtoint("structureid", "lamp"); X ptk_setcameraworld(ptk_stringtoint("windowid", "lampwindow"), X &lamplist); X ptk_postwindow(ptk_stringtoint("windowid", "lampwindow")); X pupdatews(WS1, PPERFORM); X X pos = ptk_point(0.1, 0.9); X ptk_seticonposition(ptk_stringtoint("windowid", "lampwindow"), &pos); X X options(); X ptk_unpostallfromwindow(ptk_stringtoint("windowid", "lampwindow")); X `7D X X pclosews(WS1); /* Close workstation. */ X pclosephigs(); /* Close PHIGS. */ X`7D X X/*-------------------------------------------------------------------------- V*/ X X/* end of windtest.c */ $ CALL UNPACK [.SOURCE.DEMO]WINDTEST.C;2 2064289504 $ create 'f' X/*-------------------------------------------------------------------------- V-- X X Module name: colour naming scheme. X X Author: W.T. Hewitt. X X Function: provides an English-based interface for defining colour values. X X Internal function list: ptk_huev, ptk_litv, ptk_satv, ptk_vsh,`20 X ptk_split, ptk_cpack, ptk_cunpack, ptk_cnp, ptk_rgbv. X X External function list: ptk_hsltorgb, ptk_rgbtohsl, ptk_hsvtorgb, X ptk_rgbtohsv, ptk_cnstorgb, ptk_setcnsdefaults, ptk_inqcnsdefaults. X X Hashtables used: "colourindex". X X Modification history: (Version), (Date), (Name), (Description). X X 1.0, ?????, W.T. Hewitt, First version. X X 2.0, 8th April 1991, J.G. Williams, Converted from FORTRAN to C. X X---------------------------------------------------------------------------- V*/ X X#include X#include X#include X#include X#include "ptk.h" X X/*-------------------------------------------------------------------------- V*/ X X#define ILOFF 0 X#define ILLEN 5 X#define ISOFF 5 X#define ISLEN 4 X#define IHOFF 9 X#define IHLEN 44 X X#define MAX(a, b) (((a) > (b)) ? (a) : (b)) X#define MIN(a, b) (((a) < (b)) ? (a) : (b)) X X/*-------------------------------------------------------------------------- V*/ X Xstatic Pchar *colwrd`5B`5D =`20 X `7B X "VERY-DARK","DARK","MEDIUM","LIGHT","VERY-LIGHT", X `09"GREYISH","MODERATE","STRONG","VIVID", X `09"RED","ORANGISH-RED", "BROWNISH-RED","ORANGE-RED", X `09"RED-ORANGE","BROWN-RED","RED-BROWN", "REDDISH-ORANGE", X "REDDISH-BROWN","ORANGE","BROWN","YELLOWISH-ORANGE", X `09"YELLOWISH-BROWN","YELLOW-ORANGE","ORANGE-YELLOW",`20 X `09"YELLOW-BROWN","BROWN-YELLOW", "ORANGISH-YELLOW",`20 X `09"BROWNISH-YELLOW", "YELLOW", X `09"GREENISH-YELLOW","GREEN-YELLOW","YELLOW-GREEN", X `09"YELLOWISH-GREEN", "GREEN", "BLUISH-GREEN", "BLUE-GREEN", X `09"GREEN-BLUE","GREENISH-BLUE", "BLUE","PURPLISH-BLUE", X `09"PURPLE-BLUE","BLUE-PURPLE","BLUISH-PURPLE", X "PURPLE","REDDISH-PURPLE","RED-PURPLE","PURPLE-RED", X `09"PURPLISH-RED", "MAGENTA", "CYAN", "BLACK", "GREY", "WHITE"`20 X `7D; X`09 Xstatic Pfloat vsh`5B44`5D`5B3`5D =`20 X `7B X `091.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.8, 0.8, 1.0, 1.0, 1.0, 2.0, X `091.0, 1.0, 2.0, 0.8, 0.8, 2.0, 0.8, 0.8, 2.0, 1.0, 1.0, 3.0, +-+-+-+-+-+-+-+- END OF PART 194 +-+-+-+-+-+-+-+-