4be926ed0bad33edd51f1a24e0e436ff8db0c14f braney Wed May 9 17:33:23 2012 -0700 add alwaysZero support to multiWig (#7851) diff --git src/hg/hgTracks/multiWig.c src/hg/hgTracks/multiWig.c index 62abd07..65f4500 100644 --- src/hg/hgTracks/multiWig.c +++ src/hg/hgTracks/multiWig.c @@ -1,55 +1,63 @@ /* A container for multiple wiggles with a couple of options for combining them. */ #include "common.h" #include "hash.h" #include "linefile.h" #include "jksql.h" #include "dystring.h" #include "hdb.h" #include "hgTracks.h" #include "container.h" #include "wiggle.h" #include "wigCommon.h" #include "hui.h" -static void minMaxVals(struct slRef *refList, double *retMin, double *retMax) +static void minMaxVals(struct slRef *refList, double *retMin, double *retMax, + enum wiggleAlwaysZeroEnum alwaysZero) /* Figure out min/max of everything in list. The refList contains pointers to * preDrawContainers */ { /* Turns out to be *much* shorter to rewrite than to reuse preDrawAutoScale */ double max = -BIGDOUBLE, min = BIGDOUBLE; struct slRef *ref; for (ref = refList; ref != NULL; ref = ref->next) { struct preDrawContainer *pre; for (pre = ref->val; pre != NULL; pre = pre->next) { struct preDrawElement *p = pre->preDraw + pre->preDrawZero; int width = pre->width; int i; for (i=0; icount) { if (min > p->min) min = p->min; if (max < p->max) max = p->max; } ++p; } } } +if (alwaysZero == wiggleAlwaysZeroOn) + { + if ( max < 0) + max = 0.0; + else if ( min > 0) + min = 0.0; + } *retMax = max; *retMin = min; } static void multiWigDraw(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis) /* Draw items in multiWig container. */ { struct track *subtrack; char *aggregate = wigFetchAggregateValWithCart(cart, tg->tdb); boolean overlay = wigIsOverlayTypeAggregate(aggregate); boolean errMsgShown = FALSE; int y = yOff; boolean errMsgFound = FALSE; @@ -71,31 +79,31 @@ if (wigCart->autoScale) { /* Force load of all predraw arrays so can do calcs. Build up list, and then * figure out max/min. No worries about multiple loading, the loaders protect * themselves. */ struct slRef *refList = NULL; for (subtrack = tg->subtracks; subtrack != NULL; subtrack = subtrack->next) { if (isSubtrackVisible(subtrack)) { struct preDrawContainer *pre = subtrack->loadPreDraw(subtrack, seqStart, seqEnd, width); refAdd(&refList, pre); } } double minVal, maxVal; - minMaxVals(refList, &minVal, &maxVal); + minMaxVals(refList, &minVal, &maxVal, wigCart->alwaysZero); slFreeList(&refList); /* Cope with log transform if need be */ if (wigCart->transformFunc == wiggleTransformFuncLog) { minVal = wiggleLogish(minVal); maxVal = wiggleLogish(maxVal); } /* Loop through again setting up the wigCarts of the children to have minY/maxY for * our limits and autoScale off. */ for (subtrack = tg->subtracks; subtrack != NULL; subtrack = subtrack->next) { struct wigCartOptions *wigCart = subtrack->extraUiData; wigCart->minY = minVal;