553646876b1ff0b9085ca32b95e16b0b6ee1a8e0
kate
  Mon Apr 4 10:42:51 2016 -0700
Fix squish mode problem missing items (falsely 0-length) by using proper scaling function. refs #15645

diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c
index 1b4f749..9a31a53 100644
--- src/hg/hgTracks/gtexTracks.c
+++ src/hg/hgTracks/gtexTracks.c
@@ -649,89 +649,73 @@
 }
 
 static void getItemX(int start, int end, int *x1, int *x2)
 /* Return startX, endX based on item coordinates and current window */
 // TODO: Should be using simpleTracks.c scaledBoxToPixelCoords
 {
 int s = max(start, winStart);
 int e = min(end, winEnd);
 double scale = scaleForWindow(insideWidth, winStart, winEnd);
 assert(x1);
 *x1 = round((double)((int)s-winStart)*scale + insideX);
 assert(x2);
 *x2 = round((double)((int)e-winStart)*scale + insideX);
 }
 
-static void drawGeneExprBox(struct track *tg, struct gtexGeneBed *geneBed, struct hvGfx *hvg, int y)
-/* Draw box colored by max expressed tissue (if any), for use in squish mode */
-// TODO: Should be using simpleTracks.c:drawScaledBox
-{
-int x1, x2;
-getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2);
-Color color = gtexGeneItemColor(tg, geneBed, hvg);
-hvGfxBox(hvg, x1, y, x2-x1, gtexSquishItemHeight(), color);
-}
-
-static void drawGeneModelBox(struct track *tg, struct gtexGeneBed *geneBed, struct hvGfx *hvg, int y, Color color)
-/* Draw indicator bar under graph, covering extent of gene */
-// TODO: Should be using simpleTracks.c:drawScaledBox
-{
-int x1, x2;
-getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2);
-hvGfxBox(hvg, x1, y, x2-x1, gtexGeneBoxModelHeight(), color);
-}
-
 static void gtexGeneDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y, 
                 double scale, MgFont *font, Color color, enum trackVisibility vis)
 /* Draw tissue expression bar graph over gene model. 
    Optionally, draw a second graph under gene, to compare sample sets */
 {
 struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData;
 struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
 struct gtexGeneBed *geneBed = geneInfo->geneBed;
 if (vis == tvDense)
     {
     bedDrawSimpleAt(tg, geneBed, hvg, xOff, y, scale, font, MG_WHITE, vis);     // color ignored (using grayscale)
     return;
     }
 if (vis == tvSquish)
     {
-    drawGeneExprBox(tg, geneBed, hvg, y);
+    Color color = gtexGeneItemColor(tg, geneBed, hvg);
+    int height = gtexSquishItemHeight();
+    drawScaledBox(hvg, geneBed->chromStart, geneBed->chromEnd, scale, xOff, y, height, color);
     return;
     }
 
 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;
 int heightPer = tg->heightPer;
 tg->heightPer = gtexGeneModelHeight(extras) + 1;
 Color statusColor = getGeneClassColor(hvg, geneBed);
 if (geneInfo->geneModel && extras->showExons)
     {
     struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, geneInfo->geneModel, FALSE);
     lf->filterColor = statusColor;
     linkedFeaturesDrawAt(tg, lf, hvg, xOff, yGene, scale, font, color, gtexGeneModelVis(extras));
     }
 else
     {
-    drawGeneModelBox(tg, geneBed, hvg, yGene+2, statusColor);
+    int height = gtexGeneBoxModelHeight();
+    drawScaledBox(hvg, geneBed->chromStart, geneBed->chromEnd, scale, xOff, yGene+2, height, statusColor);
     }
 tg->heightPer = heightPer;
 }
 
 static int gtexGeneNonPropPixelWidth(struct track *tg, void *item)
 /* Return end chromosome coordinate of item, including graph */
 {
 struct gtexGeneInfo *geneInfo = (struct gtexGeneInfo *)item;
 int graphWidth = gtexGraphWidth(tg, geneInfo);
 return graphWidth;
 }
 
 static void gtexGeneNonPropDrawAt(struct track *tg, void *item, struct hvGfx *hvg, int xOff, int y,
                 double scale, MgFont *font, Color color, enum trackVisibility vis)
 {
@@ -916,33 +900,34 @@
     genericMapItem(tg, hvg, item, itemName, itemName, start, end, x, y, width, height);
     return;
     }
 struct gtexGeneInfo *geneInfo = item;
 struct gtexGeneBed *geneBed = geneInfo->geneBed;
 struct gtexGeneExtras *extras = (struct gtexGeneExtras *)tg->extraUiData;
 if (tg->visibility == tvSquish)
     {
     int tisId = maxTissueForGene(geneBed);
     char *maxTissue = "";
     if (tisId > 1)
         maxTissue = getTissueDescription(tisId, extras->version);
     char buf[128];
     safef(buf, sizeof buf, "%s %s", geneBed->name, maxTissue);
     int x1, x2;
-    getItemX(start, end, &x1, &x2);
+    getItemX(geneBed->chromStart, geneBed->chromEnd, &x1, &x2);
     int width = x2-x1;
-    mapBoxHc(hvg, start, end, x1, y, width, height, tg->track, mapItemName, buf);
+    mapBoxHc(hvg, geneBed->chromStart, geneBed->chromEnd, x1, y, width, height, 
+                tg->track, mapItemName, buf);
     return;
     }
 int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE);
 topGraphHeight = max(topGraphHeight, tl.fontHeight);        // label
 int yZero = topGraphHeight + y - 1;  // yZero is bottom of graph
 //int yGene = yZero + gtexGeneMargin() - 1;
 int x1 = insideX;
 
 
 // add maps to tissue bars in expresion graph
 struct gtexTissue *tissues = getTissues(extras->version);
 struct gtexTissue *tissue = NULL;
 int barWidth = gtexBarWidth();
 int padding = gtexGraphPadding();
 double maxMedian = ((struct gtexGeneExtras *)tg->extraUiData)->maxMedian;