Пример #1
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;
  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;
}
Пример #2
0
void
GxExpose(Engine *engine, Drauing *drawing, int *xy)
{
  XEngine *xeng = (XEngine *)engine;
  GpBox damage;
  if (!drawing || !xeng->w) return;
  /* xy=0 to redraw all, otherwise x0,y0,x1,y1 */
  if (xy) {
    GpXYMap *map = &engine->devMap;
    damage.xmin= (xy[0]-map->x.offset)/map->x.scale;
    damage.xmax= (xy[2]-map->x.offset)/map->x.scale;
    damage.ymax= (xy[1]-map->y.offset)/map->y.scale;
    damage.ymin= (xy[3]-map->y.offset)/map->y.scale;
  } else {
    damage.xmin = xeng->swapped.viewport.xmin;
    damage.xmax = xeng->swapped.viewport.xmax;
    damage.ymin = xeng->swapped.viewport.ymin;
    damage.ymax = xeng->swapped.viewport.ymax;
  }
  if (engine->damaged) {
    GpSwallow(&engine->damage, &damage);
  } else {
    engine->damage = damage;
    engine->damaged = 1;
  }
  GdSetDrawing(drawing);
  GpPreempt(engine);
  GdDraw(1);
  GpPreempt(0);        /* not correct if damaged during a preempt... */
  GdSetDrawing(0);
}
Пример #3
0
static void UpdateOrRedraw(int changesOnly)
{
  Engine *display= currentDevice<0? 0 : ghDevices[currentDevice].display;
  if (!display) return;
  GpPreempt(display);
  if (gdraw_hook) gdraw_hook(display, 0);
  GdDraw(changesOnly);
  GpFlush(0);
  if (gdraw_hook) gdraw_hook(display, 1);
  GpPreempt(0);
}
Пример #4
0
void GhHCP(void)
{
  Engine *hcp= currentDevice<0? 0 : ghDevices[currentDevice].hcp;
  if (!hcp) hcp= hcpDefault;
  if (!hcp) return;
  GpPreempt(hcp);
  if (gdraw_hook) gdraw_hook(hcp, 4);
  GdDraw(0);
  /* NB- must be very careful not to Preempt twice with GdDrawLegends */
  if (ghDevices[currentDevice].doLegends) GdDrawLegends(0);
  GpClear(0, ALWAYS);
  GpFlush(0);
  if (gdraw_hook) gdraw_hook(hcp, 5);
  GpPreempt(0);
}
Пример #5
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);
}
Пример #6
0
static int EPS(int help)
{
  char *token;
  int device;

  if (help) {
    p_stderr("gist: eps command syntax:\n     eps epsout\n");
    p_stderr("  Open an Encapsulated PostScript file epsout, write\n");
    p_stderr("  the current page to it, then close epsout.\n");
    p_stderr("  (Note that an EPS file can have only a single page.)\n");
    return 0;
  }

  token= strtok(0, " \t\n");
  if (!token) {
    p_stderr("gist: (SYNTAX) epsout name missing in eps command\n");
    return 0;
  }
  if (CheckEOL("eps")) return 0;

  device= FindDevice();
  if (device>=8) return 0;

  device= FindDevice();
  if (device>=8) return 0;

  outEngines[device]=
    GpPSEngine("CGM Viewer", cgmLandscape, 0, "_tmp.eps");
  if (!outEngines[device]) {
    Warning(gistError, "");
    Warning("Unable to create PostScript engine ", token);
    return 0;
  }

  GpPreempt(outEngines[device]);

  nPage[0]= mPage[0]= CGMRelative(0);
  sPage[0]= 1;
  nPageGroups= 1;

  /* First read does PS part, second computes EPS preview */
  if (!ReadCGM(mPage, nPage, sPage, nPageGroups)) {
    GpPreempt(0);
    outEngines[device]= EPSPreview(outEngines[device], token);
    if (outEngines[device]) {
      GpPreempt(outEngines[device]);
      ReadCGM(mPage, nPage, sPage, nPageGroups);
    } else {
      Warning("memory manager failed creating EPS engine ", token);
      return 0;
    }
  }

  if (outEngines[device]) {
    GpPreempt(0);

    GpKillEngine(outEngines[device]);
    outEngines[device]= 0;
  }

  return 0;
}