-+-+-+-+-+-+-+-+ START OF PART 193 -+-+-+-+-+-+-+-+ X#endif X ptk_tidytopology(WS1, ptk_stringtoint("topologyid", "topology"), X PTKESINGLE, 1, 1, &pickrec, 1, 1, &locrec); X `7D `20 X else if (strncmp(commandstr, "tidygroup", lencom) == 0) X `7B X Ppickrec pickrec; X Plocrec locrec; X X#ifdef VMS X pickrec.pickpet1_datarec.aperature = 0.01; X#endif X ptk_tidytopology(WS1, ptk_stringtoint("topologyid", "topology"), X PTKEGROUP, 1, 1, &pickrec, 1, 1, &locrec); X `7D `20 X else if (strncmp(commandstr, "store", lencom) == 0) X `7B X FILE *fileptr; X X fileptr = fopen(STORENAME, "w+"); X rewind(fileptr); X printf("storing layout in %s...\n", STORENAME); X ptk_storetopologylayout(fileptr,`20 X ptk_stringtoint("topologyid", "topology")); X fclose(fileptr); X `7D `20 X else if (strncmp(commandstr, "restore", lencom) == 0) X `7B X FILE *fileptr; X X fileptr = fopen(STORENAME, "r"); X rewind(fileptr); X printf("restoring layout from %s...\n", STORENAME); X ptk_restoretopologylayout(fileptr,`20 X ptk_stringtoint("topologyid", "topology")); X fclose(fileptr); X `7D `20 X else if (strncmp(commandstr, "hardcopy", lencom) == 0) X `7B X Pint stid, lenname; X Pchar filename`5B80`5D; X X ptk_readstring(WS1, "topology",`20 X "Input filename (default = topology) >", &echoarea, X 80, filename, &lenname); 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_inqtopologystructid(ptk_stringtoint("topologyid", "topology"), X &stid, &err); X ppoststruct(2, stid, 0.0); X pupdatews(2, PPERFORM); X pclosews(2); X `7D `20 X else X if (strncmp(commandstr, "help", lencom) == 0) X `7B X printf("toptest options\n"); X printf("----------------\n"); X printf("boxtopology - display default topology type\n"); X printf("structtopology - display structtopology type\n"); X printf("structnettopology - display structnettopology type\n"); X printf("tidysingle - set position of single topology node\n"); X printf("tidygroup - set position of topology node group\n"); X printf("store - store topology layout\n"); X printf("restore - restore topology layout\n"); X printf("hardcopy - post topology to hardcopy workstation\n"); X printf("quit - exit toptest\n"); X `7D `20 X else if (strncmp(commandstr, "quit", lencom) == 0) X `7B X topquit = TRUE; X `7D `20 X else X `7B X printf("Command unknown\n"); `20 X `7D X pupdatews(WS1, PPERFORM); X `7D while (topquit == FALSE); X`7D X X/*-------------------------------------------------------------------------- V*/ X Xmain() X`7B X FILE *f; X Pchar dummystr`5B10`5D; X Pint dummylen, err, minid, maxid; X Pwstype wst; X X printf("Demonstrating the topology drawer module 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((Pchar*)NULL, PDEFAULT_MEM_SIZE); X `20 X /* create the workstation type (either tool or canvas) */ X X wst = phigs_ws_type_create( phigs_ws_type_sun_tool, 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 psetdisplayupdatest(WS1, PWAIT, PNIVE); X minid = 0; X maxid = 30; X ptk_inithashtables(); X ptk_createhashtable("structureid", 1, 500); X ptk_createhashtable("label", minid, maxid); X ptk_createhashtable("topologyid", minid, maxid); X ptk_createhashtable("name", minid, maxid); X`20 X if (ptk_readphinterscript(SCRIPTNAME, NULL, NULL)) X `7B X ptk_createtopology(ptk_stringtoint("topologyid", "topology"), X ptk_stringtoint("structureid", "lamp"), &err); X ptk_posttopology(WS1, ptk_stringtoint("topologyid", "topology"), 0.0); X predrawallstruct(WS1, PALWAYS); `20 X options(); X `7D X pclosews(1); X pclosephigs(); X exit(0); X`7D X X/*-------------------------------------------------------------------------- V*/ X X/* end of toptest.c */ $ CALL UNPACK [.SOURCE.DEMO]TOPTEST.C;2 542712706 $ create 'f' X/*-------------------------------------------------------------------------- V-- X X Module name: Utilities demo program. X X Author: Gareth Williams. X X Function: Demonstrates the PHIGS Debugger and PHIGS view editor. X X Modification history: (Version), (Date), (name), (Description). X X 2.0, 30th October 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#ifdef SUN X#define LAMPSCRIPTNAME "../scripts/lamp.scr" X#define CARDSCRIPTNAME "../scripts/postcard.scr" X#endif X#ifdef VMS X#define LAMPSCRIPTNAME "`5B-.scripts`5Dlamp.scr" X#define CARDSCRIPTNAME "`5B-.scripts`5Dpostcard.scr" X#endif X Xstatic Pchar *colwrd`5B`5D =`20 X `7B X `09"BLACK", "WHITE", "GREEN",`20 X `09"BLUE", "CYAN", "GREY", "RED"`20 X `7D; X X#define WS1 1 X Xstatic Pfloat devx, devy, devz; Xstatic ptkboolean docolour = FALSE; X X/*-------------------------------------------------------------------------- V*/ X Xmain() X`7B X Pwstype wst; X Pint minid, maxid, lampid, white, black, green, grey, stid, stcom, lightbl Vue; X Ppoint pos, size; X Pchar ststr`5B20`5D; X Plimit echoarea; X Pchar commandstr`5B20`5D, str`5B50`5D; X Pint lencom, lenstr, err; X ptkboolean quit, useattrs; X Pviewrep3 viewrep; X Pintlst stids; X Pwstables lens; X X#if VMS X printf("Opening DEC PHIGS...\n"); X popenphigs(0, 0); X popenws(WS1, 0, 0); X wst = 0; X#endif X#if 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`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#ifdef VMS X pinqwssttable(wst, &err, &lens); X if (lens.colour >= 8) X docolour = TRUE; X#endif X#ifdef SUN X#ifndef SUNMONO X docolour = TRUE; X#endif X#endif X X psetdisplayupdatest(WS1, PWAIT, PNIVE);`20 X `20 X /* initialise hashtables */ X minid = 1; X maxid = 500; X ptk_inithashtables(); X ptk_createhashtable("structureid", minid, maxid); X ptk_createhashtable("label", minid, maxid); X ptk_createhashtable("colourindex", 1, maxid); X ptk_createhashtable("viewindex", 1, maxid); X ptk_createhashtable("windowid", 1, maxid); X ptk_createhashtable("menuid", 1, maxid); X ptk_createhashtable("name", 1, maxid); X ptk_createhashtable("topologyid", 1, maxid); X X /* set colours */ X if (docolour) X `7B X ptk_setupcolourtable(WS1, 10, colwrd); X green = ptk_stringtoint("colourindex", "green"); X grey = ptk_stringtoint("colourindex", "grey"); X white = ptk_stringtoint("colourindex", "white"); X black = ptk_stringtoint("colourindex", "black"); X lightblue = ptk_stringtoint("colourindex", "blue"); X `20 X ptk_setbackgroundcolourind(WS1, white); X `7D X X /* read scripts */ X ptk_readphinterscript(LAMPSCRIPTNAME, NULL, NULL); X ptk_readphinterscript(CARDSCRIPTNAME, NULL, NULL); X X stid = ptk_stringtoint("structureid", "lamp"); X stids.number = 1; X stids.integers = &stid; X X /* select debugger/ view */ X X quit = FALSE; X useattrs = TRUE; X do X `7B X psetlocmode(WS1, 1, PREQUEST, PES_ECHO); X psetpickmode(WS1, 1, PREQUEST, PES_ECHO); X echoarea = ptk_limit(0.0, devx * 0.5, 0.0, devy * 0.05); X ptk_readstring(WS1, "debugger", "Input command (default = debugger) >" V,`20 X &echoarea, 20, commandstr, &lencom); X if (strncmp(commandstr, "debugattrs", lencom) == 0) X `7B X if (docolour) X ptk_setdebuggerattrs(-4, -4, grey, black, white, grey, black, whit Ve, X black, grey, black); X `7D X else X if (strncmp(commandstr, "debugger", lencom) == 0) X `7B X ptk_readstring(WS1, "lamp",`20 X "Input structure name (default = lamp) >",`20 X &echoarea, 50, str, &lenstr); X stid = ptk_stringtoint("structureid", str); X printf("Demonstrating the PHIGS debugger module of the PHIGS Toolkit V...\n"); X ptk_debugger(WS1, stid); X `7D X else X if (strncmp(commandstr, "view", lencom) == 0) X `7B X ptk_readstring(WS1, "lamp",`20 X "Input structure name (default = lamp) >",`20 X &echoarea, 50, str, &lenstr); X printf("Demonstrating the PHIGS view editor module of the PHIGS Tool Vkit...\n"); X stid = ptk_stringtoint("structureid", str); X ptk_vieweditor(WS1, &stids, &viewrep); X `7D X else X if (strncmp(commandstr, "viewattrs", lencom) == 0) X `7B X if (docolour) X ptk_setdebuggerattrs(-4, -4, grey, black, white, grey, black, whit Ve, X black, grey, black); X `7D X else if (strncmp(commandstr, "phinter", lencom) == 0) X `7B X ptk_callphinter(); X `7D `20 X else if (strncmp(commandstr, "help", lencom) == 0) X `7B X printf("utiltest options\n"); X printf("----------------\n"); X printf("debugger - start up PHIGS debugger\n"); X printf("view - start up PHIGS view editor\n"); X printf("debugattrs - set debugger attributes\n"); X printf("viewattrs - set view editor attributes\n"); X printf("quit - exit utiltest\n"); X `7D `20 X else 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 X pclosews(WS1); /* Close workstation. */ X pclosephigs(); /* Close PHIGS. */ X`7D X X/*-------------------------------------------------------------------------- V*/ $ CALL UNPACK [.SOURCE.DEMO]UTILTEST.C;3 2052970258 $ create 'f' X/*-------------------------------------------------------------------------- V-`20 X X Program name: Windows demo program. X X Author: Gareth Williams X X Description: demonstrates the windows module by displacing a window X with the lamp structure. X X Modification history : (Version), (Date), (Name), (Description). X X 1.0, 1st September 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 DEVICE1 1 X#define DEVICE2 2 X#define DEVICE3 3 X#define DEVICE4 4 X#define DEVICE5 5 X#define PI 3.14159 X X#ifdef SUN X#define SCRIPTNAME "../scripts/lamp.scr" X#endif X#ifdef VMS X#define SCRIPTNAME "`5B-.scripts`5Dlamp.scr" X#endif X Xstatic Pfloat devx, devy, devz; X X/*-------------------------------------------------------------------------- V*/ X Xstatic void init_input(C(void)) X/* Initializes four valuators in sample mode, and a choice X** device in event mode.`20 X*/ X`7B X Pchoicestatus initstatus = PCH_OK; X Pint initvalue = 1; X Pvalrec vrec; X Plimit ea; X Pint err; X Pdspsize dispsize; X Pchoicerec crec; X static Pchar *strs`5B`5D = `7B"Reset", "Exit"`7D; X static Pchar *winstrs`5B`5D = `7B"Spin", "Zoom", "Swivel", "Twist"`7D; X static Pchar *chtitle = "Options"; X 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 psetchoicemode(WS1, 3, PREQUEST, PES_ECHO); X X#if SUN X ea.xmin = 0.0; ea.xmax = 1.0;`20 X ea.ymin = 0.0; ea.ymax = 1.0; X vrec.uvalpet1_datarec.length = 200.0; X strcpy(vrec.uvalpet1_datarec.format, "%8.3f"); X vrec.uvalpet1_datarec.low = 0.0; X vrec.uvalpet1_datarec.high = 360.0; X strcpy(vrec.uvalpet1_datarec.label, "Spin"); X pinitval( WS1, DEVICE1, 0.0, -1, &ea, &vrec); X psetvalmode( WS1, DEVICE1, PSAMPLE, PES_ECHO); X X vrec.uvalpet1_datarec.low = 0.0; X vrec.uvalpet1_datarec.high = 2.0; X strcpy(vrec.uvalpet1_datarec.label, "Zoom"); X pinitval( WS1, DEVICE2, 1.0, -1, &ea, &vrec); X psetvalmode( WS1, DEVICE2, PSAMPLE, PES_ECHO); X X vrec.uvalpet1_datarec.low = 0.0; X vrec.uvalpet1_datarec.high = 360.0; X strcpy(vrec.uvalpet1_datarec.label, "Swivel"); X pinitval( WS1, DEVICE3, 0.0, -1, &ea, &vrec); X psetvalmode( WS1, DEVICE3, PSAMPLE, PES_ECHO); X X vrec.uvalpet1_datarec.low = 0.0; X vrec.uvalpet1_datarec.high = 360.0; +-+-+-+-+-+-+-+- END OF PART 193 +-+-+-+-+-+-+-+-