Exemple #1
0
static int BeginClip(PSEngine *psEngine, GpTransform *trans)
{
  GpReal x[2], y[2];
  GpPoint *points;
  int xll, yll, xur, yur;
  GpBox *port= &trans->viewport;
  GpBox *box= &psEngine->clipBox;

  if (!psEngine->e.marked && BeginPage(psEngine)) return 1;

  if (psEngine->curClip) {
    if (port->xmin==box->xmin && port->xmax==box->xmax &&
        port->ymin==box->ymin && port->ymax==box->ymax) return 0;
    if (EndClip(psEngine)) return 1;
  }

  x[0]= trans->window.xmin;  x[1]= trans->window.xmax;
  y[0]= trans->window.ymin;  y[1]= trans->window.ymax;

  GpIntPoints(&psEngine->e.map, 3, 2, x, y, &points);
  if (points[0].x > points[1].x) {
    xll= points[1].x;  xur= points[0].x;
  } else {
    xll= points[0].x;  xur= points[1].x;
  }
  if (points[0].y > points[1].y) {
    yll= points[1].y;  yur= points[0].y;
  } else {
    yll= points[0].y;  yur= points[1].y;
  }

  sprintf(line, "%d %d %d %d CLON", xur-xll, yur-yll, xll, yll);
  if (Append(psEngine, line)) return 1;
  psEngine->curClip= 1;
  *box= *port;

  /* Must save state at time of CLON, since CLOF does grestore */
  psEngine->clipColor= psEngine->curColor;
  psEngine->clipType= psEngine->curType;
  psEngine->clipWidth= psEngine->curWidth;
  psEngine->clipFont= psEngine->curFont;
  psEngine->clipHeight= psEngine->curHeight;
  /* Note that text alignment/opacity is not affected by grestore */

  /* Expand page boundary to include clip boundary */
  if (xll < psEngine->pageBB.xll) psEngine->pageBB.xll= xll;
  if (yll < psEngine->pageBB.yll) psEngine->pageBB.yll= yll;
  if (xur > psEngine->pageBB.xur) psEngine->pageBB.xur= xur;
  if (yur > psEngine->pageBB.yur) psEngine->pageBB.yur= yur;
  return 0;
}
BOOL CLevelOfDetailPage::OnSetActive() 
{
	// get property sheet
	CPropertySheet *pPropertySheet;
	pPropertySheet = dynamic_cast<CPropertySheet *>(GetParent());

	// set wizard buttons and text
	DWORD buttons;
	buttons = PSWIZB_NEXT;

	if(m_stepIndex == m_stepTotal) buttons |= PSWIZB_FINISH;
	if(m_stepIndex > 1) buttons |= PSWIZB_BACK;

	pPropertySheet->SetWizardButtons(buttons);

	// initialize page data
	if(!BeginPage()) return FALSE;

	return CPropertyPage::OnSetActive();
}
Exemple #3
0
static int SetupColor(PSEngine *psEngine, unsigned long color)
{
  int nColors= psEngine->nColors;

  if (!psEngine->e.marked && BeginPage(psEngine)) return 1;
  if (color==psEngine->curColor) return 0;

  if (color<240UL) {
    /* "CI index C"-- "CI" omitted if current color is indexed */
    unsigned long c;
    GpColorCell *palette= psEngine->e.palette;
    if (nColors>0) {
      if (color>=(unsigned long)nColors) color= nColors-1;
      if (psEngine->colorMode) c= color;  /* this page has a color table */
      else c= (P_R(palette[color])+
               P_G(palette[color])+P_B(palette[color]))/3;  /* mono page */
    } else {
      if (color>255) color= 255;
      c= color;         /* No palette ==> no color table on page */
    }
    if (psEngine->curColor>=240UL) {
      if (Append(psEngine, "CI")) return 1;
    }
    sprintf(line, "%ld C", c);
    if (Append(psEngine, line)) return 1;
  } else if (color<256UL) {
    /* standard color command FG, RED, etc. */
    if (color<P_GRAYA) color= P_FG;
    if (Append(psEngine, colorCommands[255UL-color])) return 1;
  } else {
    sprintf(line, "16#%lx C", color);
    if (Append(psEngine, line)) return 1;
  }
  psEngine->curColor= color;

  return 0;
}
int TessDllAPI::BeginPage(uinT32 xsize,uinT32 ysize,unsigned char *buf)
{
    return BeginPage(xsize,ysize,buf,1);
}
Exemple #5
0
static int PutPoints(PSEngine *psEngine, GpPoint *points, long nPoints,
                     int margin)
{
  int ix, iy, i;
  int xll= 0x7ff0, yll= 0x7ff0, xur= 0, yur= 0;
  char *now, *line= psEngine->line;
  int perLine, nchars= psEngine->nchars;

  if (!psEngine->e.marked && BeginPage(psEngine)) return 1;

  if (nchars<=0) {
    now= line;
    perLine= 9;
  } else if (nchars<70) {
    now= line+nchars;
    perLine= (78-nchars)/8;
  } else {
    if (PutLine(psEngine)) return 1;
    nchars= 0;
    now= line;
    perLine= 9;
  }

  /* Dump the points in hex 9 (72 chars) to a line */
  while (nPoints>0) {
    for (i=0 ; i<perLine ; i++) {
      ix= points->x;
      iy= points->y;
      points++;
      if (ix<0) ix= xll;           /* be sure x in range, set xll, xur */
      else if (ix>0x7ff0) ix= xur;
      else if (ix<xll) xll= ix;
      else if (ix>xur) xur= ix;
      if (iy<0) iy= yll;           /* be sure y in range, set yll, yur */
      else if (iy>0x7ff0) iy= yur;
      else if (iy<yll) yll= iy;
      else if (iy>yur) yur= iy;
      *now++= hexChar[ix>>12];
      *now++= hexChar[(ix>>8)&0xf];
      *now++= hexChar[(ix>>4)&0xf];
      *now++= hexChar[ix&0xf];
      *now++= hexChar[iy>>12];
      *now++= hexChar[(iy>>8)&0xf];
      *now++= hexChar[(iy>>4)&0xf];
      *now++= hexChar[iy&0xf];
      nchars+= 8;
      nPoints--;
      if (nPoints==0) break;
    }
    psEngine->nchars= nchars;
    if (PutLine(psEngine)) return 1;
    nchars= 0;
    now= line;
    perLine= 9;
  }

  /* Adjust the bounding box for the current page */
  if (xll<xur && !psEngine->curClip) {
    xll-= margin;
    xur+= margin;
    yll-= margin;
    yur+= margin;
    if (xll<psEngine->pageBB.xll) psEngine->pageBB.xll= xll;
    if (xur>psEngine->pageBB.xur) psEngine->pageBB.xur= xur;
    if (yll<psEngine->pageBB.yll) psEngine->pageBB.yll= yll;
    if (yur>psEngine->pageBB.yur) psEngine->pageBB.yur= yur;
  }

  return 0;
}
Exemple #6
0
static int DrawCells(Engine *engine, GpReal px, GpReal py, GpReal qx,
                     GpReal qy, long width, long height, long nColumns,
                     const GpColor *colors)
{
  PSEngine *psEngine= (PSEngine *)engine;
  GpXYMap *map= &psEngine->e.map;
  int nColors= psEngine->nColors;
  GpColorCell *palette;
  int ix, iy, idx, idy, depth;
  long i, j, off;
  int markEnd= 0;
  long nLines;
  char *now= psEngine->line;
  int nc, ncmax, color, colorMode;

  if (!psEngine->e.marked && BeginPage(psEngine)) return 1;
  if (CheckClip(psEngine)) return 1;

  /* Transform corner coordinates, clipping and adjusting width,
     height, nColumns, and colors as necessary.  */
  width = GpClipCells(&map->x, &px, &qx,
                      gistT.window.xmin, gistT.window.xmax, width, &off);
  colors += gistA.rgb? 3*off : off;
  height = GpClipCells(&map->y, &py, &qy,
                       gistT.window.ymin, gistT.window.ymax, height, &off);
  colors += gistA.rgb? 3*nColumns*off : nColumns*off;

  if (width<=0 || height<=0) return 0;
  ix= (int)px;
  iy= (int)py;
  idx= (int)(qx-px);
  idy= (int)(qy-py);

  /* Set bounding box for image if necessary */
  if (!psEngine->curClip) {
    GpBox *wind= &engine->transform.window;
    GpReal xmin, xmax, ymin, ymax;
    int xll, yll, xur, yur;
    if (wind->xmax>wind->xmin) { xmin= wind->xmin; xmax= wind->xmax; }
    else { xmin= wind->xmax; xmax= wind->xmin; }
    if (wind->ymax>wind->ymin) { ymin= wind->ymin; ymax= wind->ymax; }
    else { ymin= wind->ymax; ymax= wind->ymin; }

    if (px<qx) {
      if (px>xmin) xmin= px;
      if (qx<xmax) xmax= qx;
    } else {
      if (qx>xmin) xmin= qx;
      if (px<xmax) xmax= px;
    }
    if (py<qy) {
      if (py>ymin) ymin= py;
      if (qy<ymax) ymax= qy;
    } else {
      if (qy>ymin) ymin= qy;
      if (py<ymax) ymax= py;
    }

    xll= (int)xmin;
    xur= (int)xmax;
    yll= (int)ymin;
    yur= (int)ymax;
    if (xll<psEngine->pageBB.xll) psEngine->pageBB.xll= xll;
    if (xur>psEngine->pageBB.xur) psEngine->pageBB.xur= xur;
    if (yll<psEngine->pageBB.yll) psEngine->pageBB.yll= yll;
    if (yur>psEngine->pageBB.yur) psEngine->pageBB.yur= yur;
  }

  /* Use 4 bit depth if the color table is small, otherwise use
     8 bit depth.  */
  if (nColors>0) {
    /* Image value will be either  */
    colorMode= psEngine->colorMode;
    if (colorMode) {
      palette= 0;                     /* palette already written */
      if (nColors>16) depth= 8;
      else depth= 4;
    } else {
      palette= psEngine->e.palette;   /* must lookup gray level now */
      depth= 8;
    }
  } else {
    /* Must assume image varies over maximum possible range */
    colorMode= 1;  /* That is, use index without trying palette lookup */
    depth= 8;
    palette= 0;
  }

  if (gistA.rgb) {
    /* Write the 6 arguments to the J procedure */
    sprintf(line, "%d %d %d %d %d %d",
            (int)width, (int)height, idx, idy, ix, iy);
  } else {
    /* Write the 7 arguments to the I procedure */
    sprintf(line, "%d %d %d %d %d %d %d",
            (int)width, (int)height, depth, idx, idy, ix, iy);
  }
  if (Append(psEngine, line)) return 1;

  if (gistA.rgb) {
    nLines= 6*width*height;
    ncmax = 72;   /* 12 cells (72 chars) per line */
  } else {
    nLines= width*height;
    depth= (depth==8);
    if (depth) nLines*= 2;
    else if (nLines&1L) nLines++;
    ncmax = 76;   /* Will put 76 or 38 cells per line */
  }
  nLines= 1+(nLines-1)/ncmax;
  if (nLines>10) {
    if (psEngine->nchars && PutLine(psEngine)) return 1;
    sprintf(line, "%%%%BeginData: %ld ASCII Lines", nLines+1);
    if (Append(psEngine, line) || PutLine(psEngine)) return 1;
    markEnd= 1;
  }
  if (Append(psEngine, gistA.rgb?"J":"I") || PutLine(psEngine)) return 1;

  i= j= 0;
  while (nLines--) {
    for (nc=0 ; nc<ncmax ; ) {
      if (i>=width) {
        height--;
        if (height<=0) break;
        i= 0;
        j+= nColumns;
      }
      if (gistA.rgb) {
        const GpColor *ccell = &colors[3*(i+j)];
        now[nc++] = hexChar[ccell[0]>>4];
        now[nc++] = hexChar[ccell[0]&0xf];
        now[nc++] = hexChar[ccell[1]>>4];
        now[nc++] = hexChar[ccell[1]&0xf];
        now[nc++] = hexChar[ccell[2]>>4];
        now[nc++] = hexChar[ccell[2]&0xf];
      } else {
        color= colors[i+j];
        if (color>=nColors && nColors>0) color= nColors-1;
        if (!colorMode) color= (P_R(palette[color])+
                                P_G(palette[color])+P_B(palette[color]))/3;
        if (depth) {  /* 2 hex chars per cell */
          now[nc++]= hexChar[color>>4];
          now[nc++]= hexChar[color&0xf];
        } else {      /* 1 hex char per cell */
          now[nc++]= hexChar[color];
        }
      }
      i++;
    }