a79ca8843be0fbe1b0c59167db1aa9e4b487a07e
kate
  Wed Aug 9 12:45:32 2017 -0700
Fixes to maxHeightPixels support in barChart UI. refs #19872

diff --git src/hg/lib/wiggleCart.c src/hg/lib/wiggleCart.c
index f12fede..e8709b7 100644
--- src/hg/lib/wiggleCart.c
+++ src/hg/lib/wiggleCart.c
@@ -245,134 +245,42 @@
 if (retAbsMin)
     *retAbsMin = absMin;
 if (retAbsMax)
     *retAbsMax = absMax;
 // After the dust settles from tdb's trackDb settings, now see if composite view
 // settings from tdb's parents override that stuff anyway:
 viewLimitsCompositeOverride(tdb, name, retMin, retMax, retAbsMin, retAbsMax);
 
 // And as the final word after composite override, reset retMin and retMax if from cart:
 if (cartMinStr)
     *retMin = cartMin;
 if (cartMaxStr)
     *retMax = cartMax;
 }       /*      void wigFetchMinMaxYWithCart()  */
 
-void wigFetchMinMaxPlusPixelsWithCart(struct cart *theCart, struct trackDb *tdb, 
-                                    char *name, int *Min, int *Max, int *Default, int *settingsDefault)
-/*      Min, Max, Defaults Pixel height of track
+void wigFetchMinMaxPixelsWithCart(struct cart *theCart, struct trackDb *tdb, char *name, 
+                                        int *Min, int *Max, int *Default)
+/*      Min, Max, Default Pixel height of track
  *      Limits may be defined in trackDb with the maxHeightPixels string,
  *	Or user requested limits are defined in the cart.
  *	And default opening display limits may optionally be defined with the
  *		maxHeightPixels declaration from trackDb
  *****************************************************************************/
 {
-boolean parentLevel = isNameAtParentLevel(tdb,name);
-char *heightPer = NULL; /*	string from cart	*/
-int minHeightPixels = (Min && *Min) ? *Min : MIN_HEIGHT_PER;
-int maxHeightPixels = (Max && *Max) ? *Max : atoi(DEFAULT_HEIGHT_PER);
-int defaultHeightPixels = (Default && *Default) ? *Default : maxHeightPixels;
-int defaultHeight;     /* truncated by limits */
-char *tdbDefault = cloneString(
-    trackDbSettingClosestToHomeOrDefault(tdb, MAXHEIGHTPIXELS, DEFAULT_HEIGHT_PER) );
-
-if (sameWord(DEFAULT_HEIGHT_PER,tdbDefault))
-    {
-    struct hashEl *hel;
-    /*	no maxHeightPixels from trackDb, maybe it is in tdb->settings
-     *	(custom tracks keep settings here)
-     */
-    if ((tdb->settings != (char *)NULL) &&
-	(tdb->settingsHash != (struct hash *)NULL))
-	{
-	if ((hel = hashLookup(tdb->settingsHash, MAXHEIGHTPIXELS)) != NULL)
-	    {
-	    freeMem(tdbDefault);
-	    tdbDefault = cloneString((char *)hel->val);
-	    }
-	}
-    }
-
-/*      the maxHeightPixels string can be one, two, or three words
- *      separated by :
- *      All three would be:     max:default:min
- *      When only two:          max:default
- *      When only one:          max
- *      (this works too:        min:default:max)
- *      Where min is minimum allowed, default is initial default setting
- *      and max is the maximum allowed
- *	If it isn't available, these three have already been set
- *	in their declarations above
- */
-if (differentWord(DEFAULT_HEIGHT_PER,tdbDefault))
-    {
-    char *words[3];
-    char *sep = ":";
-    int wordCount;
-    wordCount=chopString(tdbDefault,sep,words,ArraySize(words));
-    switch (wordCount)
-	{
-	case 3:
-	    minHeightPixels = atoi(words[2]);
-	    defaultHeightPixels = atoi(words[1]);
-	    maxHeightPixels = atoi(words[0]);
-	    correctOrder(minHeightPixels,maxHeightPixels);
-	    if (defaultHeightPixels > maxHeightPixels)
-		defaultHeightPixels = maxHeightPixels;
-	    if (minHeightPixels > defaultHeightPixels)
-		minHeightPixels = defaultHeightPixels;
-	    break;
-	case 2:
-	    defaultHeightPixels = atoi(words[1]);
-	    maxHeightPixels = atoi(words[0]);
-	    if (defaultHeightPixels > maxHeightPixels)
-		defaultHeightPixels = maxHeightPixels;
-	    if (minHeightPixels > defaultHeightPixels)
-		minHeightPixels = defaultHeightPixels;
-	    break;
-	case 1:
-	    maxHeightPixels = atoi(words[0]);
-	    defaultHeightPixels = maxHeightPixels;
-	    if (minHeightPixels > defaultHeightPixels)
-		minHeightPixels = defaultHeightPixels;
-	    break;
-	default:
-	    break;
-	}
-    }
-heightPer = cartOptionalStringClosestToHome(theCart, tdb, parentLevel, HEIGHTPER);
-/*      Clip the cart value to range [minHeightPixels:maxHeightPixels] */
-if (heightPer) 
-    defaultHeight = min(maxHeightPixels, atoi(heightPer));
-else 
-    defaultHeight = defaultHeightPixels;
-defaultHeight = max(minHeightPixels, defaultHeight);
-
-*Max = maxHeightPixels;
-*Default = defaultHeight;
-*Min = minHeightPixels;
-*settingsDefault = defaultHeightPixels;
-
-freeMem(tdbDefault);
-}       /* void wigFetchMinMaxPixelsWithCart()  */
-
-void wigFetchMinMaxPixelsWithCart(struct cart *theCart, struct trackDb *tdb, char *name, 
-                                        int *Min, int *Max, int *Default)
-/*      Min, Max, Default Pixel height of track */
-{
-int settingsDefault;
-wigFetchMinMaxPlusPixelsWithCart(theCart, tdb, name, Min, Max, Default, &settingsDefault);
+int settingsDefault;    // default track height
+cartTdbFetchMinMaxPixels(cart, tdb, MIN_HEIGHT_PER, atoi(DEFAULT_HEIGHT_PER), atoi(DEFAULT_HEIGHT_PER),
+                                Min, Max, &settingsDefault, Default);  // Default is actually current setting
 }
 
 static char *wigCheckBinaryOption(struct trackDb *tdb, char *Default,
     char *notDefault, char *tdbString, char *secondTdbString)
 /*      A common operation for binary options (two values possible)
  *	check for trackDb.ra, then tdb->settings values
  *	return one of the two possibilities if found
  *	(the tdbString and secondTdbString are a result of
  *		early naming conventions changing over time resulting in
  *		two possible names for the same thing ...)
  */
 {
 char *tdbDefault = trackDbSettingClosestToHomeOrDefault(tdb, tdbString, "NONE");
 char *ret;