21bf4f713e944af4e8810544d68c441510ea85a3 kate Wed Jul 26 16:31:01 2017 -0700 Add support for maxHeightPixels in trackDb and UI of barChart type tracks. refs #19872 diff --git src/hg/lib/wiggleCart.c src/hg/lib/wiggleCart.c index 714158e..50dbafc 100644 --- src/hg/lib/wiggleCart.c +++ src/hg/lib/wiggleCart.c @@ -245,44 +245,45 @@ 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 wigFetchMinMaxPixelsWithCart(struct cart *theCart, struct trackDb *tdb, char *name,int *Min, int *Max, int *Default) -/* Min, Max, Default Pixel height of track +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 * 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 maxHeightPixels = atoi(DEFAULT_HEIGHT_PER); -int defaultHeightPixels = maxHeightPixels; +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 */ -int minHeightPixels = MIN_HEIGHT_PER; 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); @@ -328,41 +329,52 @@ 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; +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(cart, tdb, name, Min, Max, Default, &settingsDefault); +} + 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; ret = Default; /* the answer, unless found to be otherwise */