int GhSetPlotter(int number) { if (number<0 || number>=GH_NDEVS) return 1; if (currentDevice>=0) { if (ghDevices[currentDevice].display) { GdSetDrawing(ghDevices[currentDevice].drawing); GhBeforeWait(); GpDeactivate(ghDevices[currentDevice].display); } if (ghDevices[currentDevice].hcp) GpDeactivate(ghDevices[currentDevice].hcp); } if (hcpDefault) GpDeactivate(hcpDefault); currentDevice= number; if (ghDevices[number].display) GpActivate(ghDevices[number].display); return GdSetDrawing(ghDevices[number].drawing); }
/* ARGSUSED */ static void HandleOther(Engine *engine, int k, int md) { XEngine *xEngine= GisXEngine(engine); int go, bad; if (!xEngine) return; go= bad= 0; if (k == '0') xPrefix= 10*xPrefix; else if (k == '1') xPrefix= 10*xPrefix+1; else if (k == '2') xPrefix= 10*xPrefix+2; else if (k == '3') xPrefix= 10*xPrefix+3; else if (k == '4') xPrefix= 10*xPrefix+4; else if (k == '5') xPrefix= 10*xPrefix+5; else if (k == '6') xPrefix= 10*xPrefix+6; else if (k == '7') xPrefix= 10*xPrefix+7; else if (k == '8') xPrefix= 10*xPrefix+8; else if (k == '9') xPrefix= 10*xPrefix+9; else if (k=='f' || k=='F' || (k=='+' && (md&P_KEYPAD))) go= 1; else if (k=='b' || k=='B' || (k=='-' && (md&P_KEYPAD))) go= 2; else if (k=='g' || k=='G' || k=='\r') go= 3; else if (k=='s' || k=='S' || (k=='=' && (md&P_KEYPAD))) go= 4; else if (k=='q' || k=='Q') go= 5; else bad= 1; if ((go==4||go==5) && xPrefix!=0) bad= 1; if (go && !bad) { if (go<4) { if (xPrefix==0) xPrefix= 1; DoSpecial(xPrefix, cSuffices[go-1]); } else if (go==4) { int i, n= 0; for (i=0 ; i<8 ; i++) { if (!outSend[i]) GpDeactivate(outEngines[i]); if (outSend[i] && !GpActivate(outEngines[i])) n++; } nPage[0]= mPage[0]= CGMRelative(0); sPage[0]= 1; nPageGroups= 1; if (n) ReadCGM(mPage, nPage, sPage, nPageGroups); else Warning("no devices active for send command", ""); } else if (go==5) { p_quit(); } xPrefix= 0; warningCount= 0; } else if (bad) { p_feep(xEngine->win); xPrefix= 0; } }
int on_quit(void) { int i; for (i=0 ; i<8 ; i++) { if (outEngines[i]) { GpDeactivate(outEngines[i]); GpKillEngine(outEngines[i]); } } return 0; }
static int Draw(int help) { int i, n; char *token; if (help) { p_stderr("gist: draw command syntax:\n draw [page list]\n"); p_stderr( " Copy the page(s) (default current page) from the current CGM input\n"); p_stderr(" to all display output devices.\n"); p_stderr(" By default, these are all X windows.\n"); p_stderr(" Use alternate syntax:\n draw to [device#1 ...]\n"); p_stderr(" to specify a particular list of devices to be used\n"); p_stderr(" by the draw command. Without any device numbers,\n"); p_stderr(" draw to restores the default list of devices.\n"); p_stderr(" (Use the info command to describe current device numbers.)\n"); p_stderr(" Page list syntax: group1 [group2 ...]\n"); p_stderr(" Page group syntax: n - just page n\n"); p_stderr(" m-n - pages n thru m\n"); p_stderr(" m-n-s - pages n thru m, step s\n"); return 0; } token= strtok(0, " \t\n"); if (token && strcmp(token, "to")==0) { DrawSend(1, token); return 0; } n= 0; for (i=0 ; i<8 ; i++) { if (!outDraw[i]) GpDeactivate(outEngines[i]); if (outDraw[i] && !GpActivate(outEngines[i])) n++; } if (!n && (i= FindDevice())<8) { if (!CreateX(i, 0) && !GpActivate(outEngines[i])) n++; } if (n) DrawSend(0, token); else Warning("no devices active for draw command", ""); return 0; }
static void DoSpecial(int nPrefix, int cSuffix) { int i, n; n= 0; for (i=0 ; i<8 ; i++) { if (!outDraw[i]) GpDeactivate(outEngines[i]); if (outDraw[i] && !GpActivate(outEngines[i])) n++; } if (cSuffix=='f') mPage[0]= CGMRelative(nPrefix); else if (cSuffix=='b') mPage[0]= CGMRelative(-nPrefix); else mPage[0]= nPrefix; nPage[0]= mPage[0]; sPage[0]= 1; nPageGroups= 1; if (n) ReadCGM(mPage, nPage, sPage, nPageGroups); else Warning("no devices active for nf, nb, or ng command", ""); }
void GpDelEngine(Engine *engine) { Engine *eng= gistEngines; if (!engine) return; /* Unlink from gistEngines list */ if (engine->active) GpDeactivate(engine); if (eng==engine) gistEngines= engine->next; else { /* Because of recursive deletes necessary to deal with X window deletions (see xbasic.c:ShutDown, hlevel.c:ShutDownDev), if the engine has already been removed from the list, it means that this routine is being called for the second time for this engine, and p_free must NOT be called. Fix this someday. */ while (eng && eng->next!=engine) eng= eng->next; if (!eng) return; eng->next= engine->next; } p_free(engine); }
void GhFMA(void) { Engine *display; Engine *hcp= 0; if (currentDevice<0) return; display= ghDevices[currentDevice].display; if (animateOn && !display) animateOn= 0; if (hcpOn) { hcp= ghDevices[currentDevice].hcp; if (!hcp) hcp= hcpDefault; if (hcp) GpActivate(hcp); } if (gdraw_hook) gdraw_hook(display, 2); GdDraw(1); if (hcpOn && hcp && ghDevices[currentDevice].doLegends) GdDrawLegends(hcp); if (animateOn) GxStrobe(display, 1); GpFlush(0); if (animateOn!=1) GdClear(0); else GdClearSystem(); if (gdraw_hook) gdraw_hook(display, 3); if (hcpOn && hcp) { GpClear(hcp, CONDITIONALLY); GpDeactivate(hcp); } ghDevices[currentDevice].fmaCount++; if (++fmaCount > 100) { /* clean house once in a while */ fmaCount= 0; GaFreeScratch(); } }
int on_launch(int argc, char *argv[]) { int i, j; char *arg; nOut= 0; for (i=0 ; i<8 ; i++) { outNames[i]= 0; outEngines[i]= 0; outDraw[i]= outSend[i]= outLengths[i]= 0; } noDisplay= amBatch= x_only= 0; defaultDPI= 100; inName= 0; p_quitter(&on_quit); p_idler(&on_idle); p_stdinit(&on_stdin); g_stdout = p_stdout; for (i=1 ; i<argc ; i++) { arg= argv[i]; if (arg[0]=='-') { int fileType= -1; arg++; if (strcmp(arg, "cgm")==0) { fileType= 0; i++; if (i>=argc) return MessageAndExit("Missing file or display name"); arg= argv[i]; } else if (strcmp(arg, "ps")==0) { fileType= 1; i++; if (i>=argc) return MessageAndExit("Missing file or display name"); arg= argv[i]; } else if (strcmp(arg, "in")==0) { i++; if (i>=argc) return MessageAndExit("Missing file or display name"); if (inName) return HelpAndExit(); else inName= argv[i]; } else if (strcmp(arg, "display")==0 || strcmp(arg, "d")==0) { fileType= 2; i++; if (i>=argc) return MessageAndExit("Missing file or display name"); arg= argv[i]; } else if (strcmp(arg, "f")==0) { amBatch= 1; fileType= 1; arg= "*stdout*"; } else if (strcmp(arg, "nd")==0) noDisplay= 1; else if (strcmp(arg, "b")==0) amBatch= 1; else if (strcmp(arg, "nowarn")==0) no_warnings= 1; else if (strcmp(arg, "geometry")==0) { char *suffix; int w=0,h=0; i++; if (i>=argc) MessageAndExit("Missing geometry"); arg = argv[i]; w = (int)strtol(arg, &suffix, 10); if (suffix!=arg && *suffix=='x') { arg = suffix+1; h = (int)strtol(arg, &suffix, 10); } if (w < 10 || h < 10) MessageAndExit("Invalid geometry"); gx75width = gx100width = w; gx75height = gx100height = h; } else if (strcmp(arg, "75")==0) defaultDPI= 75; else if (strcmp(arg, "100")==0) defaultDPI= 100; else if (strcmp(arg, "gks")==0) { gx75width= gx75height= 600; /* 8x8 X window size */ gx100width= gx100height= 800; /* 8x8 X window size */ cgmScaleToFit= 1; /* 8x8 PostScript plotting area */ gtDoEscapes= 0; } else if (strcmp(arg, "x")==0) x_only= 1; else if (strcmp(arg, "gks")==0) { cgmScaleToFit= 1; gtDoEscapes= 0; } else if (strcmp(arg, "fmbug")==0) epsFMbug= 1; else if (strcmp(arg, "bg0fg1")==0) bg0fg1= 1; else if (strcmp(arg, "esc0")==0) gtDoEscapes= 0; else if (strcmp(arg, "esc1")==0) gtDoEscapes= 1; else return HelpAndExit(); if (fileType>=0) { if (nOut>=8) return MessageAndExit("At most 8 output files/displays allowed"); for (j=0 ; j<nOut ; j++) if (strcmp(outNames[j], arg)==0) return MessageAndExit("Duplicate output filenames not allowed"); outNames[nOut]= arg; outTypes[nOut]= fileType; nOut++; } } else if (arg[0]<='9' && arg[0]>='0') { if (GetPageGroup(arg)) return MessageAndExit("Try again"); } else if (!inName) { inName= arg; } else { return HelpAndExit(); } } if (inName && OpenCGM(inName)) inName= 0; if (amBatch) { if (!inName) return MessageAndExit("Must specify an input CGM file to use -b or -f"); if (!nOut) return MessageAndExit("Must specify some output file to use -b"); noDisplay= 1; } /* Create CGM and PostScript engines */ for (i=0 ; i<nOut ; i++) { if (outTypes[i]==0) CreateCGM(i, outNames[i]); else if (outTypes[i]==1) CreatePS(i, outNames[i]); } /* If page list specified, do implied send command */ if (amBatch && nPageGroups<=0) { mPage[0]= 1; nPage[0]= 32767; sPage[0]= 1; nPageGroups= 1; } if (nPageGroups>0) { for (i=0 ; i<8 ; i++) { if (!outSend[i]) GpDeactivate(outEngines[i]); if (outSend[i] && !GpActivate(outEngines[i])) n_active_groups++; } } g_initializer(&argc, argv); return 0; }