int g_rgb_read(Engine *eng, GpColor *rgb, long *nx, long *ny) { XEngine *xeng = GisXEngine(eng); if (!xeng || !xeng->w || !xeng->win) return 1; GpPreempt(eng); GdDraw(1); /* make sure screen updated */ GpPreempt(0); if (xeng->w == xeng->win) { /* not in animate mode */ if (!rgb) { *nx = xeng->wtop; *ny = xeng->htop; } else { p_rgb_read(xeng->win, rgb, xeng->leftMargin, xeng->topMargin, xeng->leftMargin+xeng->wtop, xeng->topMargin+xeng->htop); } } else { /* in animate mode, read offscreen pixmap */ if (!rgb) { *nx = xeng->a_width; *ny = xeng->a_height; } else { p_rgb_read(xeng->w, rgb, 0, 0, xeng->a_width, xeng->a_height); } } return 0; }
/* 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 GxStrobe(Engine *engine, int clear) { XEngine *xeng = GisXEngine(engine); if (!xeng || !xeng->w || xeng->w==xeng->win) return 1; p_bitblt(xeng->win, xeng->a_x, xeng->a_y, xeng->w, 0, 0, xeng->a_width, xeng->a_height); if (clear) p_clear(xeng->w); return 0; }
int g_rgb_read(Engine *eng, GpColor *rgb, long *nx, long *ny) { XEngine *xeng = GisXEngine(eng); if (!xeng || !xeng->w || !xeng->win) return 1; if (!rgb) { *nx = xeng->wtop; *ny = xeng->htop; } else { p_rgb_read(xeng->win, rgb, xeng->leftMargin, xeng->topMargin, xeng->leftMargin+xeng->wtop, xeng->topMargin+xeng->htop); } return 0; }
int GxInput(Engine *engine, void (*HandleExpose)(Engine *, Drauing *, int *), void (*HandleClick)(Engine *,int,int,int,int,unsigned long), void (*HandleMotion)(Engine *,int,int,int), void (*HandleKey)(Engine *,int,int)) { XEngine *xeng = GisXEngine(engine); if (!xeng) return 1; xeng->HandleExpose = HandleExpose; xeng->HandleClick = HandleClick; xeng->HandleMotion = HandleMotion; xeng->HandleKey = HandleKey; return 0; }
int gist_expose_wait(Engine *eng, void (*e_callback)(void)) { if (waiting_for) { waiting_for = 0; wait_callback = 0; return 1; } else { XEngine *xeng = GisXEngine(eng); if (!xeng || !xeng->w) return 1; if (xeng->mapped) return 2; waiting_for = eng; wait_callback = e_callback; return 0; } }
static void g_on_panic(p_scr *screen) { Engine *eng = 0; XEngine *xeng = 0; do { for (eng=GpNextEngine(eng) ; eng ; eng=GpNextEngine(eng)) { xeng= GisXEngine(eng); if (xeng && xeng->s==screen) break; } if (eng) { xeng->s = 0; /* be sure not to call p_disconnect */ Kill(eng); } } while (eng); XErrHandler("play on_panic called (screen graphics engines killed)"); }
int GxDirect(Engine *engine) { XEngine *xeng = GisXEngine(engine); if (!xeng || !xeng->w || xeng->w==xeng->win) return 1; p_destroy(xeng->w); xeng->w = xeng->win; /* set coordinate map and clipping to values for graphics window */ xeng->e.transform = xeng->swapped; GpDeviceMap((Engine *)xeng); ChangeMap((Engine *)xeng); return 0; }
/* ARGSUSED */ static void HandleExpose(Engine *engine, Drauing *drauing, int xy[]) { XEngine *xEngine= GisXEngine(engine); if (!xEngine) return; /* Redraw current picture on this engine only */ GpPreempt(engine); nPage[0]= mPage[0]= CGMRelative(0); sPage[0]= 1; nPageGroups= 1; ReadCGM(mPage, nPage, sPage, nPageGroups); GpPreempt(0); GxExpose(engine, drauing, xy); }
static void ShutDown(XEngine *xeng) { p_scr *s = xeng->s; p_win *w = xeng->w; p_win *win = xeng->win; xeng->mapped= 0; /* destroy any hlevel references without further ado */ if (HLevelHook) HLevelHook((Engine *)xeng); xeng->w = xeng->win = 0; xeng->s = 0; if (w && w!=win) p_destroy(w); GpDelEngine(&xeng->e); if (s) { Engine *eng; XEngine *xe2; for (eng=GpNextEngine(0) ; eng ; eng=GpNextEngine(eng)) { xe2 = GisXEngine(eng); if (xe2 && xe2->s==s) break; } if (!eng) { int i; if (g_pending_task == g_do_disconnect) { for (i=0 ; i<=G_N_PENDING ; i++) if (g_pending_scr[i] == s) break; if (i >= G_N_PENDING) { for (i=0 ; i<=G_N_PENDING ; i++) if (!g_pending_scr[i]) break; if (i < G_N_PENDING) g_pending_scr[i] = s; } } else { g_pending_scr[0] = s; for (i=1 ; i<=G_N_PENDING ; i++) g_pending_scr[i] = 0; g_pending_task = g_do_disconnect; } } } }
int GxAnimate(Engine *engine, GpBox *viewport) { XEngine *xeng = GisXEngine(engine); int x, y, x1, y1; GpBox *v, *w; GpReal xmin, xmax, ymin, ymax; GpReal scalx, offx, scaly, offy; if (!xeng || !xeng->w) return 1; if (xeng->w!=xeng->win) GxDirect(engine); v = &xeng->e.transform.viewport; /* NDC */ w = &xeng->e.transform.window; /* pixels */ /* get NDC-->pixel mapping coefficients */ scalx = xeng->e.devMap.x.scale; offx = xeng->e.devMap.x.offset; scaly = xeng->e.devMap.y.scale; offy = xeng->e.devMap.y.offset; /* clip given viewport to portion of NDC space which is actually * visible now -- note that v is either gLandscape or gPortrait, * so that min<max for v; must also be true for input viewport */ GetVisibleNDC(xeng, &xmin, &xmax, &ymin, &ymax); if (viewport->xmin>xmin) xmin = viewport->xmin; if (viewport->xmax<xmax) xmax = viewport->xmax; if (viewport->ymin>ymin) ymin = viewport->ymin; if (viewport->ymax<ymax) ymax = viewport->ymax; /* install NDC-->pixel transform for animation pixmap */ v->xmin = xmin; v->xmax = xmax; v->ymin = ymin; v->ymax = ymax; /* set the engine transform to map the specified viewport into * offscreen pixels, and get (x,y) offset from full window pixels * to offscreen pixels */ w->xmin = scalx*xmin+offx; w->xmax = scalx*xmax+offx; if (w->xmax > w->xmin) { x = (int)w->xmin; w->xmax -= w->xmin; w->xmin = 0.0; } else { x = (int)w->xmax; w->xmin -= w->xmax; w->xmax = 0.0; } w->ymin = scaly*ymin+offy; w->ymax = scaly*ymax+offy; if (w->ymax > w->ymin) { y = (int)w->ymin; w->ymax -= w->ymin; w->ymin = 0.0; } else { y = (int)w->ymax; w->ymin -= w->ymax; w->ymax = 0.0; } GpDeviceMap((Engine *)xeng); /* GetXRectangle(&xeng->e.devMap, v, &x0, &y0, &x1, &y1); x1 -= x0; y1 -= y0; */ x1 = xeng->wtop; y1 = xeng->htop; /* create the offscreen pixmap */ xeng->w = p_offscreen(xeng->win, x1, y1); if (!xeng->w) { xeng->w = xeng->win; xeng->e.transform = xeng->swapped; GpDeviceMap((Engine *)xeng); return 2; } xeng->a_width = x1; xeng->a_height = y1; xeng->a_x = x; xeng->a_y = y; /* set coordinate mapping for offscreen */ ChangeMap((Engine *)xeng); /* reset mapping clip to whole visible window */ if (xeng->wtop>0) x1 = xeng->wtop+xeng->leftMargin; else x1 = xeng->leftMargin+1; if (xeng->htop>0) y1 = xeng->htop+xeng->topMargin; else y1 = xeng->topMargin+1; xeng->clipping = 1; p_clip(xeng->win, xeng->leftMargin, xeng->topMargin, x1, y1); p_clear(xeng->w); return 0; }