bb7c285d51eabd45fe7fbb3ae297acd0324915b7 kent Tue Apr 19 15:09:50 2011 -0700 Refactoring in hopes of making auto-scale work as you'd hope with multiwigs. That still isn't there, this is just preliminaries. diff --git src/hg/hgTracks/multiWig.c src/hg/hgTracks/multiWig.c index 3503c28..ed979f3 100644 --- src/hg/hgTracks/multiWig.c +++ src/hg/hgTracks/multiWig.c @@ -1,51 +1,38 @@ /* 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 char *aggregateFromCartOrDefault(struct cart *cart, struct track *tg) -/* Return aggregate value for track. */ -{ -return cartOrTdbString(cart, tg->tdb, "aggregate", WIG_AGGREGATE_TRANSPARENT); -} - -static boolean isOverlayTypeAggregate(char *aggregate) -/* Return TRUE if aggregater type is one of the overlay ones. */ -{ -if (aggregate == NULL) - return FALSE; -return differentString(aggregate, WIG_AGGREGATE_NONE); -} - 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 = aggregateFromCartOrDefault(cart, tg); -boolean overlay = isOverlayTypeAggregate(aggregate); +char *aggregate = wigFetchAggregateValWithCart(cart, tg->tdb); +boolean overlay = wigIsOverlayTypeAggregate(aggregate); boolean errMsgShown = FALSE; int y = yOff; boolean errMsgFound = FALSE; // determine if any subtracks had errors for (subtrack = tg->subtracks; subtrack != NULL; subtrack = subtrack->next) { if (isSubtrackVisible(subtrack) && subtrack->networkErrMsg) errMsgFound = TRUE; } if (errMsgFound) { Color yellow = hvGfxFindRgb(hvg, &undefinedYellowColor); hvGfxBox(hvg, xOff, yOff, width, tg->height, yellow); } @@ -67,32 +54,32 @@ if (!overlay) y += height + 1; hvGfxSetWriteMode(hvg, MG_WRITE_MODE_NORMAL); hvGfxUnclip(hvg); } } } char *url = trackUrl(tg->track, chromName); mapBoxHgcOrHgGene(hvg, seqStart, seqEnd, xOff, y, width, tg->height, tg->track, tg->track, NULL, url, TRUE, NULL); } static int multiWigTotalHeight(struct track *tg, enum trackVisibility vis) /* Return total height of multiWigcontainer. */ { -char *aggregate = aggregateFromCartOrDefault(cart, tg); -boolean overlay = isOverlayTypeAggregate(aggregate); +char *aggregate = wigFetchAggregateValWithCart(cart, tg->tdb); +boolean overlay = wigIsOverlayTypeAggregate(aggregate); int totalHeight = 0; if (overlay) totalHeight = wigTotalHeight(tg, vis); struct track *subtrack; for (subtrack = tg->subtracks; subtrack != NULL; subtrack = subtrack->next) { if (isSubtrackVisible(subtrack)) { // Logic is slightly complicated by fact we want to call the totalHeight // method for each subtrack even if in overlay mode. int oneHeight = subtrack->totalHeight(subtrack, vis); if (!overlay) { if (totalHeight != 0) totalHeight += 1; @@ -117,32 +104,32 @@ *retFirstTrack = firstTrack = track; else if (track->graphUpperLimit != firstTrack->graphUpperLimit || track->graphLowerLimit != firstTrack->graphLowerLimit) return FALSE; } } return firstTrack != NULL; } static void multiWigLeftLabels(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, int height, boolean withCenterLabels, MgFont *font, Color color, enum trackVisibility vis) /* Draw left labels - by deferring to first subtrack. */ { -char *aggregate = aggregateFromCartOrDefault(cart, tg); -boolean overlay = isOverlayTypeAggregate(aggregate); +char *aggregate = wigFetchAggregateValWithCart(cart, tg->tdb); +boolean overlay = wigIsOverlayTypeAggregate(aggregate); if (overlay) { struct track *firstVisibleSubtrack = NULL; boolean showNumbers = graphLimitsAllSame(tg->subtracks, &firstVisibleSubtrack); struct track *subtrack = (showNumbers ? firstVisibleSubtrack : tg->subtracks); wigLeftAxisLabels(tg, seqStart, seqEnd, hvg, xOff, yOff, width, height, withCenterLabels, font, color, vis, tg->shortLabel, subtrack->graphUpperLimit, subtrack->graphLowerLimit, showNumbers); } else { struct track *subtrack; int y = yOff; if (withCenterLabels) y += tl.fontHeight+1;