605dfc510159bb43e25176563c7b86e6439d3776 kate Thu Mar 31 18:09:50 2016 -0700 Shenanigans to get squish mode working. refs #15645 diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c index 65b981b..15d3a87 100644 --- src/hg/hgTracks/gtexTracks.c +++ src/hg/hgTracks/gtexTracks.c @@ -253,30 +253,36 @@ medians1[i] -= medians2[i]; medians2[i] = 0; } else { medians2[i] -= medians1[i]; medians1[i] = 0; } } } geneInfo->medians1 = medians1; geneInfo->medians2 = medians2; } } +static int gtexSquishItemHeight() +/* Height of squished item (request to have it larger than usual) */ +{ +return tl.fontHeight - tl.fontHeight/2; +} + static int gtexGeneItemHeight(struct track *tg, void *item); static void filterTissues(struct track *tg) /* Check cart for tissue selection. NULL out unselected tissues in tissue list */ { struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexTissue *tis = NULL; extras->tissues = getTissues(extras->version); extras->tissueFilter = hashNew(0); if (cartListVarExistsAnyLevel(cart, tg->tdb, FALSE, GTEX_TISSUE_SELECT)) { struct slName *selectedValues = cartOptionalSlNameListClosestToHome(cart, tg->tdb, FALSE, GTEX_TISSUE_SELECT); if (selectedValues != NULL) { @@ -636,31 +642,32 @@ struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; // Color in squish mode using geneClass Color statusColor = getGeneClassColor(hvg, geneBed); if (vis == tvDense) { bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, statusColor, vis); return; } if (vis == tvSquish) { int x1, x2; getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2); Color color = gtexGeneItemColor(tg, geneBed, hvg); - hvGfxBox(hvg, x1, y, x2-x1, tl.fontHeight/2 + 2, color); + int height = gtexSquishItemHeight(); + hvGfxBox(hvg, x1, y, x2-x1, height, color); return; } int heightPer = tg->heightPer; int graphX = gtexGraphX(geneBed); if (graphX < 0) return; // draw gene model int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE); topGraphHeight = max(topGraphHeight, tl.fontHeight); int yZero = topGraphHeight + y - 1; // yZero is bottom of graph int yGene = yZero + gtexGeneMargin() - 1; tg->heightPer = gtexGeneModelHeight(extras) + 1; if (geneInfo->geneModel) // some BEDs do not have a corresponding geneModel record @@ -780,34 +787,35 @@ else hvGfxOutlinedBox(hvg, x1, yZero, barWidth, height, fillColorIx, lineColorIx); // mark clipped bar with magenta tip if (!extras->doLogTransform && expScore > viewMax) hvGfxBox(hvg, x1, yZero + height-1, barWidth, 2, clipColor); x1 = x1 + barWidth + graphPadding; } } static int gtexGeneItemHeightOptionalMax(struct track *tg, void *item, boolean isMax) { if (tg->visibility == tvSquish || tg->visibility == tvDense) { if (tg->visibility == tvSquish) { - tg->lineHeight = trunc(tl.fontHeight/2) + 1; + tg->lineHeight = gtexSquishItemHeight(); tg->heightPer = tg->lineHeight; } - return tgFixedItemHeight(tg, item); + int height = tgFixedItemHeight(tg, item); + return height; } struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData; if (isMax) { int extra = 0; if (((struct gtexGeneExtras *)tg->extraUiData)->isComparison) extra = gtexMaxGraphHeight() + 2; return gtexMaxGraphHeight() + gtexGeneMargin() + gtexGeneModelHeight(extras) + extra; } if (item == NULL) return 0; struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; if (geneInfo->height != 0) return geneInfo->height; @@ -956,34 +964,40 @@ return geneBed->name; } static int gtexGeneHeight(void *item) { struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; assert(geneInfo->height != 0); return geneInfo->height; } static int gtexGeneTotalHeight(struct track *tg, enum trackVisibility vis) /* Figure out total height of track. Set in track and also return it */ { int height = 0; -if (tg->visibility == tvSquish || tg->visibility == tvDense) +if (tg->visibility == tvDense) { height = tgFixedTotalHeightOptionalOverflow(tg, vis, tl.fontHeight+1, tl.fontHeight, FALSE); } +else if (tg->visibility == tvSquish) + { + // for visibility, set larger than the usual squish, which is half font height + height = gtexSquishItemHeight() * 2; // the squish packer halves this + height = tgFixedTotalHeightOptionalOverflow(tg, vis, height+1, height, FALSE); + } else if ((tg->visibility == tvPack) || (tg->visibility == tvFull)) { if (!tg->ss) { // layout -- initially as fixed height int height = gtexGeneMaxHeight(tg); tgFixedTotalHeightOptionalOverflow(tg, vis, height, height, FALSE); // TODO: allow oflow ? } // set variable height rows if (tg->ss->rowCount != 0) { if (!tg->ss->rowSizes) { // collect the rowSizes data across all windows assert(currentWindow==windows); // first window @@ -1017,32 +1031,40 @@ struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; return geneBed->chromStart; } static int gtexGeneItemEnd(struct track *tg, void *item) /* Return end chromosome coordinate of item, including graph */ { struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item; struct gtexGeneBed *geneBed = geneInfo->geneBed; double scale = scaleForWindow(insideWidth, winStart, winEnd); int graphWidth = gtexGraphWidth(tg, geneInfo); return max(geneBed->chromEnd, max(winStart, geneBed->chromStart) + graphWidth/scale); } +static void gtexGenePreDrawItems(struct track *tg, int seqStart, int seqEnd, + struct hvGfx *hvg, int xOff, int yOff, int width, + MgFont *font, Color color, enum trackVisibility vis) +{ +if (vis == tvPack || vis == tvFull) + { + tg->nonPropDrawItemAt = gtexGeneNonPropDrawAt; + tg->nonPropPixelWidth = gtexGeneNonPropPixelWidth; + } +} + void gtexGeneMethods(struct track *tg) { tg->drawItemAt = gtexGeneDrawAt; +tg->preDrawItems = gtexGenePreDrawItems; tg->loadItems = gtexGeneLoadItems; tg->mapItem = gtexGeneMapItem; tg->itemName = gtexGeneItemName; tg->mapItemName = gtexGeneItemName; tg->itemHeight = gtexGeneItemHeight; tg->itemStart = gtexGeneItemStart; tg->itemEnd = gtexGeneItemEnd; tg->totalHeight = gtexGeneTotalHeight; -tg->nonPropDrawItemAt = gtexGeneNonPropDrawAt; -tg->nonPropPixelWidth = gtexGeneNonPropPixelWidth; } - -