406740c2dc67f2bb8e217627dcbbe00a204fd594 kate Mon Dec 4 15:37:32 2017 -0800 Add support for item color, using Ensembl extension (RGB instead of value). http://www.ensembl.org/info/website/upload/pairwise.html diff --git src/hg/hgTracks/longRangeTrack.c src/hg/hgTracks/longRangeTrack.c index 35b3be1..383c7d0 100644 --- src/hg/hgTracks/longRangeTrack.c +++ src/hg/hgTracks/longRangeTrack.c @@ -3,72 +3,86 @@ #include "hgTracks.h" #include "longRange.h" static int longRangeHeight(struct track *tg, enum trackVisibility vis) /* calculate height of all the snakes being displayed */ { if ( tg->visibility == tvDense) return tl.fontHeight; int min, max, deflt, current; cartTdbFetchMinMaxPixels(cart, tg->tdb, LONG_MINHEIGHT, LONG_MAXHEIGHT, atoi(LONG_DEFHEIGHT), &min, &max, &deflt, ¤t); return tg->height = current; } +static Color longRangeItemColor(struct track *tg, void *item, struct hvGfx *hvg) +/* Return color to draw a long range item */ +{ +struct longRange *lr = item; +if (lr->hasColor) + { + struct rgbColor itemRgb; + itemRgb.r = (lr->rgb & 0xff0000) >> 16; + itemRgb.g = (lr->rgb & 0xff00) >> 8; + itemRgb.b = lr->rgb & 0xff; + return hvGfxFindColorIx(hvg, itemRgb.r, itemRgb.g, itemRgb.b); + } +return tg->ixColor; +} 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); - + color = longRangeItemColor(tg, longRange, hvg); 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); + hvGfxLine(hvg, sx - footWidth, yOff, sx + footWidth, yOff, color); int height = tg->height/2; if (tg->visibility == tvDense) height = tg->height; unsigned yPos = yOff + height; - hvGfxLine(hvg, sx, yOff, sx, yPos, MG_BLUE); + hvGfxLine(hvg, sx, yOff, sx, yPos, color); 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 {