示例#1
0
void drawUseBamWarning(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg,
                 int xOff, int yOff, int width, MgFont *font, Color color,
                 enum trackVisibility vis)
/* Draw a message saying that the code needs to be built with USE_BAM=1. */
{
char message[512];
safef(message, sizeof(message),
      "Get samtools(.sourceforge.net) and recompile kent/src with USE_BAM=1");
Color yellow = hvGfxFindRgb(hvg, &undefinedYellowColor);
hvGfxBox(hvg, xOff, yOff, width, tg->heightPer, yellow);
hvGfxTextCentered(hvg, xOff, yOff, width, tg->heightPer, MG_BLACK, font, message);
}
示例#2
0
文件: bigWarn.c 项目: bowhan/kent
void bigDrawWarning(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg,
                 int xOff, int yOff, int width, MgFont *font, Color color,
                 enum trackVisibility vis)
/* Draw the network error message */
{
char message[1024];
Color yellow = hvGfxFindRgb(hvg, &undefinedYellowColor);
char *errMsg = bigWarnReformat(tg->networkErrMsg);
char *nl = errMsg;
int sl = strlen(errMsg);
// in some cases, cannot use tg-> values, so recalc local equivalents. 
int heightPer = tl.fontHeight;        /* Height per item line minus border. */
int lineHeight = heightPer+4;         /* Height per item line including border. */ 
if (lineHeight > tg->height)
    lineHeight = tg->height;
int n = bigWarnNumLines(errMsg);      /* Lines of warning text */
int m = tg->height / lineHeight;      /* Lines of text space available */
if (m < 1) 
    m = 1;
// make yellow background to draw user's attention to the err msg
if (!sameOk(parentContainerType(tg), "multiWig")) // unless multiwig has already done it.
    hvGfxBox(hvg, xOff, yOff, width, tg->height, yellow);
// leading blank lines if any
int bl = (m-n)/2;   
int i;
for(i=0;i<bl;++i)
    yOff += lineHeight;
int l = 0;
while (TRUE)
    {
    char *msg = nl;
    nl = strchr(nl,'\n');
    if (nl)
	nl[0] = 0;
    if (nl || ((sl > 0) && (errMsg[sl-1]!='\n')))
	{  
	safef(message, sizeof(message), "%s", msg);
	hvGfxTextCentered(hvg, xOff, yOff, width, lineHeight, MG_BLACK, font, message);
	yOff += lineHeight;
        ++l;
        if (l > n)
	    break;
        if (l > m)
	    break;
	}
    if (!nl)
	break;
    ++nl;
    }
freeMem(errMsg);
}
示例#3
0
文件: hvGfx.c 项目: blumroy/kentUtils
void hvGfxDrawRulerBumpText(struct hvGfx *hvg, int xOff, int yOff, 
	int height, int width,
        Color color, MgFont *font,
        int startNum, int range, int bumpX, int bumpY)
/* Draw a ruler inside the indicated part of mg with numbers that start at
 * startNum and span range.  Bump text positions slightly. */
{
int tickSpan;
int tickPos;
double scale;
int firstTick;
int remainder;
int end = startNum + range;
int x;
char tbuf[18];
int numWid;
int goodNumTicks;
int niceNumTicks = width/35;

sprintLongWithCommas(tbuf, startNum+range);
numWid = mgFontStringWidth(font, tbuf)+4+bumpX;
goodNumTicks = width/numWid;
if (goodNumTicks < 1) goodNumTicks = 1;
if (goodNumTicks > niceNumTicks) goodNumTicks = niceNumTicks;

tickSpan = figureTickSpan(range, goodNumTicks);

scale = (double)width / range;

firstTick = startNum + tickSpan;
remainder = firstTick % tickSpan;
firstTick -= remainder;
for (tickPos=firstTick; tickPos<end; tickPos += tickSpan)
    {
    sprintLongWithCommas(tbuf, tickPos);
    numWid = mgFontStringWidth(font, tbuf)+4;
    x = (int)((tickPos-startNum) * scale) + xOff;
    hvGfxBox(hvg, x, yOff, 1, height, color);
    if (x - numWid >= xOff)
        {
        hvGfxTextCentered(hvg, x-numWid + bumpX, yOff + bumpY, numWid, 
                          height, color, font, tbuf);
        }
    }
}
void hCytoBandDrawAt(struct cytoBand *band, struct hvGfx *hvg,
	int x, int y, int width, int height, boolean isDmel,
	MgFont *font, int fontPixelHeight, Color aColor, Color bColor,
	Color *shades, int maxShade)
/* Draw a single band in appropriate color at given position.  If there's
 * room put in band label. */
{
Color col = hCytoBandColor(band, hvg, isDmel, aColor, bColor, shades, maxShade);
hvGfxBox(hvg, x, y, width, height, col);
if (height >= mgFontLineHeight(font))
    {
    char *s = abbreviatedBandName(band, font, width, isDmel);
    if (s != NULL)
	{
	Color textCol = hvGfxContrastingColor(hvg, col);
	hvGfxTextCentered(hvg, x, y, width, height, textCol, font, s);
	}
    }
}
示例#5
0
文件: contigTrack.c 项目: bowhan/kent
static void contigDraw(struct track *tg, int seqStart, int seqEnd,
        struct hvGfx *hvg, int xOff, int yOff, int width, 
        MgFont *font, Color color, enum trackVisibility vis)
/* Draw contig items. */
{
struct ctgPos *ctg;
int y = yOff;
int heightPer = tg->heightPer;
int lineHeight = tg->lineHeight;
int x1,x2,w;
boolean isFull = (vis == tvFull);
int ix = 0;
char *s;
double scale = scaleForPixels(width);
for (ctg = tg->items; ctg != NULL; ctg = ctg->next)
    {
    x1 = round((double)((int)ctg->chromStart-winStart)*scale) + xOff;
    x2 = round((double)((int)ctg->chromEnd-winStart)*scale) + xOff;
    /* Clip here so that text will tend to be more visible... */
    if (x1 < xOff)
	x1 = xOff;
    if (x2 > xOff + width)
	x2 = xOff + width;
    w = x2-x1;
    if (w < 1)
	w = 1;
    hvGfxBox(hvg, x1, y, w, heightPer, color);
    s = abbreviateContig(ctg->contig, tl.font, w);
    if (s != NULL)
	hvGfxTextCentered(hvg, x1, y, w, heightPer, MG_WHITE, tl.font, s);
    if (isFull)
	y += lineHeight;
    else 
	{
	mapBoxHc(hvg, ctg->chromStart, ctg->chromEnd, x1,y,w,heightPer, tg->track, 
	    tg->mapItemName(tg, ctg), 
	    tg->itemName(tg, ctg));
	}
    ++ix;
    }
}
void genoLayDrawChromLabels(struct genoLay *gl, struct hvGfx *hvg, int color)
/* Draw chromosomes labels in image */
{
struct slRef *ref;
struct genoLayChrom *chrom;
int pixelHeight = mgFontPixelHeight(gl->font);
if (gl->allOneLine)
    {
    int yOffset = gl->chromOffsetY + gl->chromHeight + 1;

    for (ref = gl->bottomList; ref != NULL; ref = ref->next)
	{
	chrom = ref->val;
	hvGfxTextCentered(hvg, chrom->x, yOffset, chrom->width, pixelHeight, color, gl->font,
		chrom->shortName);
	}
    }
else
    {
    int yOffset = gl->chromOffsetY + gl->chromHeight - pixelHeight;

    /* Draw chromosome labels. */
    for (ref = gl->leftList; ref != NULL; ref = ref->next)
	leftLabel(hvg, gl, ref->val, yOffset, pixelHeight, color);
    for (ref = gl->rightList; ref != NULL; ref = ref->next)
	rightLabel(hvg, gl, ref->val, yOffset, pixelHeight, color);
    for (ref = gl->bottomList; ref != NULL; ref = ref->next)
	{
	chrom = ref->val;
	if (ref == gl->bottomList)
	    leftLabel(hvg, gl, chrom, yOffset, pixelHeight, color);
	else if (ref->next == NULL)
	    rightLabel(hvg, gl, chrom, yOffset, pixelHeight, color);
	else
	    midLabel(hvg, gl, chrom, yOffset, pixelHeight, color);
	}
    }
}
示例#7
0
static void longRangeDraw(struct track *tg, int seqStart, int seqEnd,
        struct hvGfx *hvg, int xOff, int yOff, int width, 
        MgFont *font, Color color, enum trackVisibility vis)
/* Draw a list of longTabix structures. */
{
double scale = scaleForWindow(width, seqStart, seqEnd);
struct bed *beds = tg->items;
unsigned int maxWidth;
struct longRange *longRange;
char buffer[1024];
char itemBuf[2048];
char statusBuf[2048];

safef(buffer, sizeof buffer, "%s.%s", tg->tdb->track, LONG_MINSCORE);
double minScore = sqlDouble(cartUsualString(cart, buffer, LONG_DEFMINSCORE));
struct longRange *longRangeList = parseLongTabix(beds, &maxWidth, minScore);

for(longRange=longRangeList; longRange; longRange=longRange->next)
    {
    safef(itemBuf, sizeof itemBuf, "%d", longRange->id);
    safef(statusBuf, sizeof statusBuf, "%g %s:%d %s:%d", longRange->score, longRange->sChrom, longRange->s, longRange->eChrom, longRange->e);

    boolean sOnScreen = (longRange->s >= seqStart) && (longRange->s < seqEnd);
    unsigned sx = 0, ex = 0;
    if (sOnScreen)
        sx = (longRange->s - seqStart) * scale + xOff;

    if (differentString(longRange->sChrom, longRange->eChrom))
        {
        if (!sOnScreen)
            continue;

        // draw the foot
        int footWidth = scale * (longRange->sw / 2);
        hvGfxLine(hvg, sx - footWidth, yOff, sx + footWidth, yOff, MG_BLUE);

        int height = tg->height/2;
        if (tg->visibility == tvDense)
            height = tg->height;
        unsigned yPos = yOff + height;
        hvGfxLine(hvg, sx, yOff, sx, yPos, MG_BLUE);
        if (tg->visibility == tvFull)
            {
            mapBoxHgcOrHgGene(hvg, longRange->s, longRange->s, sx - 2, yOff, 4, tg->height/2,
                                   tg->track, itemBuf, statusBuf, NULL, TRUE, NULL);

            safef(buffer, sizeof buffer, "%s:%d",  longRange->eChrom, longRange->e);
            hvGfxTextCentered(hvg, sx, yPos + 2, 4, 4, MG_BLUE, font, buffer);
            int width = vgGetFontStringWidth(hvg->vg, font, buffer);
            int height = vgGetFontPixelHeight(hvg->vg, font);
            mapBoxHgcOrHgGene(hvg, longRange->s, longRange->s, sx - width/2, yPos, width, height,
                                   tg->track, itemBuf, statusBuf, NULL, TRUE, NULL);
            }
        }
    else 
        {
        boolean eOnScreen = (longRange->e >= seqStart) && (longRange->e < seqEnd);
        if (!(sOnScreen || eOnScreen))
            continue;

        if (eOnScreen)
            ex = (longRange->e - seqStart) * scale + xOff;

        double longRangeWidth = longRange->e - longRange->s;
        int peak = (tg->height - 15) * ((double)longRangeWidth / maxWidth) + yOff + 10;
        if (tg->visibility == tvDense)
            peak = yOff + tg->height;
        
        if (sOnScreen)
            {
            int footWidth = scale * (longRange->sw / 2);
            hvGfxLine(hvg, sx - footWidth, yOff, sx + footWidth, yOff, color);
            hvGfxLine(hvg, sx, yOff, sx, peak, color);
            }
        if (eOnScreen)
            {
            int footWidth = scale * (longRange->ew / 2);
            hvGfxLine(hvg, ex - footWidth, yOff, ex + footWidth, yOff, color);
            hvGfxLine(hvg, ex, yOff, ex, peak, color);
            }

        if (tg->visibility == tvFull)
            {
            unsigned sPeak = sOnScreen ? sx : xOff;
            unsigned ePeak = eOnScreen ? ex : xOff + width;

            hvGfxLine(hvg, sPeak, peak, ePeak, peak, color);
            safef(statusBuf, sizeof statusBuf, "%g %s:%d %s:%d", longRange->score, longRange->sChrom, longRange->s, longRange->eChrom, longRange->e);

            if (sOnScreen)
                mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, sx - 2, yOff, 4, peak - yOff,
                                       tg->track, itemBuf, statusBuf, NULL, TRUE, NULL);
            if (eOnScreen)
                mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, ex - 2, yOff, 4, peak - yOff,
                                       tg->track, itemBuf, statusBuf, NULL, TRUE, NULL);

            mapBoxHgcOrHgGene(hvg, longRange->s, longRange->e, sPeak, peak-2, ePeak - sPeak, 4,
                                   tg->track, itemBuf, statusBuf, NULL, TRUE, NULL);

            }
        }
    }
}