9a387b56009aa84b206a9d980580c7f21a8e2a01
galt
  Wed Apr 6 12:10:48 2016 -0700
Fixing gtexGene for limitedVis full->pack->squish->dense

diff --git src/hg/hgTracks/gtexTracks.c src/hg/hgTracks/gtexTracks.c
index 9a31a53..ba4d152 100644
--- src/hg/hgTracks/gtexTracks.c
+++ src/hg/hgTracks/gtexTracks.c
@@ -811,34 +811,39 @@
     int height = valToClippedHeight(expScore, maxMedian, viewMax, gtexMaxGraphHeight(), 
                                         extras->doLogTransform);
     if (graphPadding == 0 || sameString(colorScheme, GTEX_COLORS_GTEX))
         hvGfxBox(hvg, x1, yZero, barWidth, height, fillColorIx);
     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)
 {
+// It seems that this can be called early or late
+enum trackVisibility vis = tg->visibility;
+if (tg->limitedVisSet)
+    vis = tg->limitedVis;
+
 int height;
-if (tg->visibility == tvSquish || tg->visibility == tvDense)
+if (vis == tvSquish || vis == tvDense)
     {
-    if (tg->visibility == tvSquish)
+    if (vis == tvSquish)
         {
         tg->lineHeight = gtexSquishItemHeight();
         tg->heightPer = tg->lineHeight;
         }
     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;
     height= gtexMaxGraphHeight() + gtexGeneMargin() + gtexGeneModelHeight(extras) + extra;
     return height;
@@ -883,39 +888,39 @@
 {
 static char buf[128];
 safef(buf, sizeof(buf), "%s (%.1f %s%s%sRPKM)", tissue->description, 
                                 doLogTransform ? log10(expScore+1.0) : expScore,
                                 qualifier != NULL ? qualifier : "",
                                 qualifier != NULL ? " " : "",
                                 doLogTransform ? "log " : "");
 return buf;
 }
 
 static void gtexGeneMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, 
                         char *mapItemName, int start, int end, int x, int y, int width, int height)
 /* Create a map box on gene model and label, and one for each tissue (bar in the graph) in
  * pack or full mode.  Just single map for squish/dense modes */
 {
-if (tg->visibility == tvDense)
+if (tg->limitedVis == tvDense)
     {
     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)
+if (tg->limitedVis == 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(geneBed->chromStart, geneBed->chromEnd, &x1, &x2);
     int width = x2-x1;
     mapBoxHc(hvg, geneBed->chromStart, geneBed->chromEnd, x1, y, width, height, 
                 tg->track, mapItemName, buf);
     return;
     }
 int topGraphHeight = gtexGeneGraphHeight(tg, geneInfo, TRUE);
@@ -998,48 +1003,47 @@
 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 == tvDense)
+if (vis == tvDense)
     { 
     height = tgFixedTotalHeightOptionalOverflow(tg, vis, tl.fontHeight+1, tl.fontHeight, FALSE);
     }
-else if (tg->visibility == tvSquish)
+else if (vis == 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)
+else if ((vis == tvPack) || (vis == tvFull))
     {
     // layout -- initially as fixed height
-        int height = gtexGeneMaxHeight(tg);
-        tgFixedTotalHeightOptionalOverflow(tg, vis, height, height, FALSE); // TODO: allow oflow ?
-        }
+    //int height = gtexGeneMaxHeight(tg);  // TODO KATE
+    int height = tl.fontHeight;
+    tgFixedTotalHeightOptionalOverflow(tg, vis, height, height, FALSE);
+
     // 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
 	    assert(tg->ss->vis == vis); // viz matches, we have the right one
 	    struct spaceSaver *ssHold; 
 	    AllocVar(ssHold);
 	    struct track *tgSave = tg;
 	    for(tg=tgSave; tg; tg=tg->nextWindow)
 		{
 		assert(tgSave->ss->vis == tg->ss->vis); // viz matches, we have the right one
 		spaceSaverSetRowHeights(tg->ss, ssHold, gtexGeneHeight);