aa82ced1f07ddc93917a4e70f269241283cbe84b braney Tue Aug 25 10:45:34 2020 -0700 add mouseovers to clinsub diff --git src/hg/hgTracks/lollyTrack.c src/hg/hgTracks/lollyTrack.c index b22b7ee..c4429f4 100644 --- src/hg/hgTracks/lollyTrack.c +++ src/hg/hgTracks/lollyTrack.c @@ -13,30 +13,31 @@ #include "float.h" #include "bigBedFilter.h" #define LOLLY_DIAMETER 2 * (lollyCart->radius + 2) struct lolly { struct lolly *next; char *name; /* the mouseover name */ double val; /* value in the data file */ unsigned start; /* genomic start address */ unsigned end; /* genomic end address */ unsigned radius; /* radius of the top of the lolly */ unsigned height; /* height of the lolly */ Color color; /* color of the lolly */ +char *mouseOver; }; static unsigned getLollyColor( struct hvGfx *hvg, unsigned color) /* Get the device color from our internal definition. */ { struct rgbColor itemRgb; itemRgb.r = (color & 0xff0000) >> 16; itemRgb.g = (color & 0xff00) >> 8; itemRgb.b = color & 0xff; return hvGfxFindColorIx(hvg, itemRgb.r, itemRgb.g, itemRgb.b); } void doYLabels(struct track *tg, struct hvGfx *hvg, int width, int height, struct lollyCartOptions *lollyCart, int xOff, int yOff, Color color, MgFont *font, boolean doLabels ) /* Draw labels or lines for labels. */ { @@ -114,31 +115,31 @@ { int sx = ((pop->start - seqStart) + .5) * scale + xOff; // x coord of center (lower region) hvGfxLine(hvg, sx, yOff + trackHeight, sx , yOff+(usableHeight - pop->height), MG_GRAY); } // now draw the sucker part! for (pop = popList; pop; pop = pop->next) { int sx = ((pop->start - seqStart) + .5) * scale + xOff; // x coord of center (lower region) unsigned color = getLollyColor(hvg, pop->color); hvGfxCircle(hvg, sx, yOff + (usableHeight - (pop->height )), pop->radius, color, TRUE); if ( tg->visibility != tvSquish) hvGfxCircle(hvg, sx, yOff + (usableHeight - (pop->height )), pop->radius, MG_BLACK, FALSE); if (!noMapBoxes) mapBoxHgcOrHgGene(hvg, pop->start, pop->end, sx - pop->radius, yOff + usableHeight - pop->radius - pop->height, 2 * pop->radius,2 * pop->radius, - tg->track, pop->name, pop->name, NULL, TRUE, NULL); + tg->track, pop->mouseOver, pop->mouseOver, NULL, TRUE, NULL); } } void lollyLeftLabels(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, int height, boolean withCenterLabels, MgFont *font, Color color, enum trackVisibility vis) // draw the labels on the left margin { struct lollyCartOptions *lollyCart = tg->lollyCart; int fontHeight = tl.fontHeight+1; int centerLabel = (height/2)-(fontHeight/2); if ( tg->visibility == tvDense) { hvGfxTextRight(hvg, xOff, yOff+fontHeight, width - 1, fontHeight, color, font, tg->shortLabel); @@ -217,30 +218,32 @@ char *setting = trackDbSetting(tg->tdb, "lollyField"); if (setting != NULL) lollyField = atoi(setting); int lollySizeField = -1 ; setting = trackDbSetting(tg->tdb, "lollySizeField"); if (setting != NULL) lollySizeField = atoi(setting); double minVal = DBL_MAX, maxVal = -DBL_MAX; //double sumData = 0.0, sumSquares = 0.0; unsigned count = 0; int trackHeight = tg->lollyCart->height; struct bigBedFilter *filters = bigBedBuildFilters(cart, bbi, tg->tdb); +char *mouseOverField = cartOrTdbString(cart, tg->tdb, "mouseOverField", NULL); +int mouseOverIdx = bbExtraFieldIndex(bbi, mouseOverField) ; for (bb = bbList; bb != NULL; bb = bb->next) { bigBedIntervalToRow(bb, chromName, startBuf, endBuf, bedRow, ArraySize(bedRow)); // throw away items that don't pass the filters if (!bigBedFilterInterval(bedRow, filters)) continue; // clip out lollies that aren't in our display range double val = atof(bedRow[lollyField - 1]); if (!((lollyCart->autoScale == wiggleScaleAuto) || ((val >= lollyCart->minY) && (val <= lollyCart->maxY) ))) continue; // don't draw lollies off the screen @@ -249,30 +252,35 @@ AllocVar(pop); slAddHead(&popList, pop); pop->val = val; pop->start = atoi(bedRow[1]); pop->end = atoi(bedRow[2]); pop->name = cloneString(bedRow[3]); pop->radius = -1; if (lollySizeField > 0) { double radius = atoi(bedRow[lollySizeField - 1]) * trackHeight / 100.0; pop->radius = radius; } pop->color = 0; + pop->mouseOver = pop->name; + extern char* restField(struct bigBedInterval *bb, int fieldIdx) ; + if (mouseOverIdx > 0) + pop->mouseOver = restField(bb, mouseOverIdx); + if (bbi->fieldCount > 8) pop->color = itemRgbColumn(bedRow[8]); count++; if (val > maxVal) maxVal = val; if (val < minVal) minVal = val; } if (count == 0) lollyCart->upperLimit = lollyCart->lowerLimit = NAN; // no lollies in range else if (lollyCart->autoScale == wiggleScaleAuto) { lollyCart->upperLimit = maxVal; lollyCart->lowerLimit = minVal;