inc/pscmGfx.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pscmGfx

Functions

pscmGfxpscmOpen (int width, int height, char *file)
void pscmClose (struct pscmGfx **ppscm)
void pscmSetClip (struct pscmGfx *pscm, int x, int y, int width, int height)
void pscmUnclip (struct pscmGfx *pscm)
int pscmFindColorIx (struct pscmGfx *pscm, int r, int g, int b)
void pscmBox (struct pscmGfx *pscm, int x, int y, int width, int height, int colorIx)
void pscmLine (struct pscmGfx *pscm, int x1, int y1, int x2, int y2, int colorIx)
void pscmText (struct pscmGfx *pscm, int x, int y, int colorIx, MgFont *font, char *text)
void pscmTextRight (struct pscmGfx *pscm, int x, int y, int width, int height, int color, MgFont *font, char *text)
void pscmTextCentered (struct pscmGfx *pscm, int x, int y, int width, int height, int color, MgFont *font, char *text)


Function Documentation

void pscmBox ( struct pscmGfx pscm,
int  x,
int  y,
int  width,
int  height,
int  colorIx 
)

Definition at line 222 of file pscmGfx.c.

References boxPscm, pscmBoxToPs(), and pscmSetColor().

Referenced by pscmDrawPoly(), and vgOpenPostScript().

00225 {
00226 /* When viewing whole chromosomes the browser tends
00227  * to draw the same little vertical tick over and
00228  * over again.  This tries to remove the worst of
00229  * the redundancy anyway. */
00230 
00231 static int lx, ly, lw, lh, lc=-1;
00232 if (x != lx || y != ly || width != lw || height != lh || color != lc || 
00233         pscm != boxPscm)
00234     {
00235     pscmSetColor(pscm, color);
00236     pscmBoxToPs(pscm, x, y, width, height);
00237     lx = x;
00238     ly = y;
00239     lw = width;
00240     lh = height;
00241     lc = color;
00242     boxPscm = pscm;
00243     }
00244 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmClose ( struct pscmGfx **  ppscm  ) 

Definition at line 172 of file pscmGfx.c.

References colHashFree(), pscmGfx::colorHash, freez(), pscmGfx::ps, and psClose().

Referenced by vgOpenPostScript().

00174 {
00175 struct pscmGfx *pscm = *pPscm;
00176 if (pscm != NULL)
00177     {
00178     psClose(&pscm->ps);
00179     colHashFree(&pscm->colorHash);
00180     freez(pPscm);
00181     }
00182 }

Here is the call graph for this function:

Here is the caller graph for this function:

int pscmFindColorIx ( struct pscmGfx pscm,
int  r,
int  g,
int  b 
)

Definition at line 121 of file pscmGfx.c.

References colHashLookup(), pscmGfx::colorHash, pscmGfx::colorsUsed, errAbort(), colHashEl::ix, pscmAddColor(), and pscmClosestColor().

Referenced by pscmSetDefaultColorMap(), and vgOpenPostScript().

00125 {
00126 struct colHashEl *che;
00127 if (r>255||g>255||b>255) 
00128     errAbort("RGB values out of range (0-255).  r:%d g:%d b:%d", r, g, b);
00129 if ((che = colHashLookup(pscm->colorHash, r, g, b)) != NULL)
00130     return che->ix;
00131 if (pscm->colorsUsed < 256)
00132     return pscmAddColor(pscm, r, g, b);
00133 return pscmClosestColor(pscm, r, g, b);
00134 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmLine ( struct pscmGfx pscm,
int  x1,
int  y1,
int  x2,
int  y2,
int  colorIx 
)

Definition at line 253 of file pscmGfx.c.

References boxPscm, pscmGfx::ps, pscmSetColor(), psDrawBox(), and psDrawLine().

Referenced by pscmDrawPoly(), and vgOpenPostScript().

00256 {
00257 pscmSetColor(pscm, color);
00258 if ((x1==x2) || (y1 == y2))
00259     {
00260     /* pad a half-pixel at each end */
00261     psDrawBox(pscm->ps, x1-0.5, y1-0.5, x2-x1+1, y2-y1+1);
00262     }
00263 else
00264     {
00265     psDrawLine(pscm->ps, x1, y1, x2, y2);
00266     }
00267 boxPscm = NULL;
00268 }

Here is the call graph for this function:

Here is the caller graph for this function:

struct pscmGfx* pscmOpen ( int  width,
int  height,
char *  file 
) [read]

Definition at line 155 of file pscmGfx.c.

References AllocVar, pscmGfx::clipMaxX, pscmGfx::clipMaxY, pscmGfx::clipMinX, pscmGfx::clipMinY, colHashNew(), pscmGfx::colorHash, hashNew, pscmGfx::hints, pscmGfx::ps, pscmSetDefaultColorMap(), psOpen(), and psTranslate().

Referenced by vgOpenPostScript().

00157 {
00158 struct pscmGfx *pscm;
00159 
00160 AllocVar(pscm);
00161 pscm->ps = psOpen(file, width, height, 72.0 * 7.5, 0, 0);
00162 psTranslate(pscm->ps,0.5,0.5);  /* translate all coordinates to pixel centers */
00163 pscm->colorHash = colHashNew();
00164 pscmSetDefaultColorMap(pscm);
00165 pscm->clipMinX = pscm->clipMinY = 0;
00166 pscm->clipMaxX = width;     
00167 pscm->clipMaxY = height;
00168 pscm->hints = hashNew(6);
00169 return pscm;
00170 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmSetClip ( struct pscmGfx pscm,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 51 of file pscmGfx.c.

References pscmGfx::clipMaxX, pscmGfx::clipMaxY, pscmGfx::clipMinX, pscmGfx::clipMinY, pscmGfx::ps, and psClipRect().

Referenced by vgOpenPostScript().

00053 {
00054 double x2 = x + width;
00055 double y2 = y + height;
00056 pscm->clipMinX = x;
00057 pscm->clipMinY = y;
00058 pscm->clipMaxX = x2;     /* one beyond actual last pixel */
00059 pscm->clipMaxY = y2;
00060 /* adjust to pixel-centered coordinates */
00061 x2 -= 1;
00062 y2 -= 1;
00063 double x1 = x;
00064 double y1 = y;
00065 /* pad a half-pixel all the way around the box */
00066 x1 -= 0.5;
00067 y1 -= 0.5;
00068 x2 += 0.5;
00069 y2 += 0.5;
00070 psClipRect(pscm->ps, x1, y1, x2-x1, y2-y1);
00071 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmText ( struct pscmGfx pscm,
int  x,
int  y,
int  colorIx,
MgFont font,
char *  text 
)

Definition at line 305 of file pscmGfx.c.

References boxPscm, pscmGfx::ps, pscmSetColor(), pscmSetFont(), and psTextAt().

Referenced by vgOpenPostScript().

00308 {
00309 pscmSetColor(pscm, color);
00310 pscmSetFont(pscm, font);
00311 psTextAt(pscm->ps, x, y, text);
00312 boxPscm = NULL;
00313 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmTextCentered ( struct pscmGfx pscm,
int  x,
int  y,
int  width,
int  height,
int  color,
MgFont font,
char *  text 
)

Definition at line 325 of file pscmGfx.c.

References boxPscm, pscmGfx::ps, pscmSetColor(), pscmSetFont(), and psTextCentered().

Referenced by vgOpenPostScript().

00328 {
00329 pscmSetColor(pscm, color);
00330 pscmSetFont(pscm, font);
00331 psTextCentered(pscm->ps, x, y, width, height, text);
00332 boxPscm = NULL;
00333 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmTextRight ( struct pscmGfx pscm,
int  x,
int  y,
int  width,
int  height,
int  color,
MgFont font,
char *  text 
)

Definition at line 315 of file pscmGfx.c.

References boxPscm, pscmGfx::ps, pscmSetColor(), pscmSetFont(), and psTextRight().

Referenced by vgOpenPostScript().

00318 {
00319 pscmSetColor(pscm, color);
00320 pscmSetFont(pscm, font);
00321 psTextRight(pscm->ps, x, y, width, height, text);
00322 boxPscm = NULL;
00323 }

Here is the call graph for this function:

Here is the caller graph for this function:

void pscmUnclip ( struct pscmGfx pscm  ) 

Definition at line 73 of file pscmGfx.c.

References pscmGfx::ps, psClipRect(), psGfx::userHeight, and psGfx::userWidth.

Referenced by vgOpenPostScript().

00075 {
00076 psClipRect(pscm->ps, 0, 0, pscm->ps->userWidth, pscm->ps->userHeight);
00077 }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated on Tue Dec 25 19:11:20 2007 for blat by  doxygen 1.5.2