a47364d48ccd5b8ee8cdf7b47b7ba9edcfd66f1f braney Wed Apr 16 10:58:32 2014 -0700 fix a crashing bug in hgCustom if the description field is empty on anassembly hub diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c index ba43a29..149794c 100644 --- src/hg/hgTracks/wigTrack.c +++ src/hg/hgTracks/wigTrack.c @@ -802,44 +802,57 @@ Color somewhatLighterColor32(Color color) /* Get a somewhat lighter shade of a color - 1/3 of the way towards white. * Specialized here to bypass image parameter requirement.*/ { #ifndef COLOR32 #error COLOR32 must be defined these days, transparency depends on it. #endif /* COLOR32 */ struct rgbColor rgbColor = mgColorIxToRgb(NULL, color); rgbColor.r = (2*rgbColor.r+255)/3; rgbColor.g = (2*rgbColor.g+255)/3; rgbColor.b = (2*rgbColor.b+255)/3; return MAKECOLOR_32(rgbColor.r, rgbColor.g, rgbColor.b); } +struct wigGraphOutput *wigGraphOutputStack(int xOff, int yOff, int width, int numTracks, struct hvGfx *image) +/* Get appropriate wigGraphOutput for non-transparent stacked rendering */ +{ +struct wigGraphOutput *wgo; +AllocVar(wgo); +wgo->image = image; +wgo->vLine = vLineViaHvg; +wgo->xOff = xOff; +wgo->yOff = yOff; +wgo->yOffsets = needHugeMem(width * numTracks * sizeof(unsigned)); +return wgo; +} + struct wigGraphOutput *wigGraphOutputSolid(int xOff, int yOff, struct hvGfx *image) /* Get appropriate wigGraphOutput for non-transparent rendering */ { struct wigGraphOutput *wgo; AllocVar(wgo); wgo->image = image; wgo->vLine = vLineViaHvg; wgo->xOff = xOff; wgo->yOff = yOff; return wgo; } static void graphPreDraw(struct preDrawElement *preDraw, int preDrawZero, int width, - struct track *tg, void *image, WigVerticalLineVirtual vLine, int xOff, int yOff, + struct track *tg, void *image, WigVerticalLineVirtual vLine, int xOff, int yOff, double *yOffsets, int numTrack, double graphUpperLimit, double graphLowerLimit, double graphRange, double epsilon, Color *colorArray, enum trackVisibility vis, struct wigCartOptions *wigCart) /* graph the preDraw array */ { int x1; int h = tg->lineHeight; /* the height of our drawing window */ double scaleFactor = h/graphRange; Color oldDrawColor = colorArray[0] + 1; /* Just to be different from 1st drawColor. */ Color mediumColor = MG_BLACK; // Will be overriden Color lightColor = MG_BLACK; // Will be overriden Color clipColor = MG_MAGENTA; enum wiggleTransformFuncEnum transformFunc = wigCart->transformFunc; enum wiggleGraphOptEnum lineBar = wigCart->lineBar; boolean whiskers = (wigCart->windowingFunction == wiggleWindowingWhiskers @@ -972,31 +985,37 @@ int y0 = graphUpperLimit * scaleFactor; int y1 = (graphUpperLimit - dataValue)*scaleFactor; int boxHeight = max(1,abs(y1 - y0)); int boxTop = min(y1,y0); // positive data value exactly equal to Bottom pixel // make sure it draws at least a pixel there if (boxTop == h) boxTop = h - 1; // negative data value exactly equal to top pixel // make sure it draws something if ((boxTop+boxHeight) == 0) boxHeight += 1; - vLine(image,x, yOff+boxTop, boxHeight, drawColor); + int stackY = 0; + if (yOffsets) + { + stackY = yOffsets[numTrack * width + x1]; + printf("%d ", stackY); + } + vLine(image,x, stackY+yOff+boxTop, boxHeight, drawColor); } } else { /* draw a 3 pixel height box */ if (whiskers) { int scaledMin = scaleHeightToPixels(doTransform(p->min, transformFunc)); int scaledMax = scaleHeightToPixels(doTransform(p->max, transformFunc)); double mean = p->sumData/p->count; int boxHeight = max(1,scaledMin - scaledMax); vLine(image, x, scaledMax, boxHeight, lightColor); int scaledMean = scaleHeightToPixels(dataValue); double std = calcStdFromSums(p->sumData, p->sumSquares, p->count); if (!isnan(std)) // Test needed because of bug in version 1.5 bigWiles { @@ -1035,31 +1054,31 @@ } /* if (preDraw[].count) */ } /* for (x1 = 0; x1 < width; ++x1) */ } /* graphPreDraw() */ static void graphPreDrawContainer(struct preDrawContainer *preDrawContainer, int preDrawZero, int width, struct track *tg, struct hvGfx *hvg, int xOff, int yOff, double graphUpperLimit, double graphLowerLimit, double graphRange, enum trackVisibility vis, struct wigCartOptions *wigCart) /* Draw the graphs for all tracks in container. */ { double epsilon = graphRange / tg->lineHeight; struct preDrawElement *preDraw = preDrawContainer->preDraw; Color *colorArray = makeColorArray(preDraw, width, preDrawZero, wigCart, tg, hvg); struct wigGraphOutput *wgo = tg->wigGraphOutput; graphPreDraw(preDraw, preDrawZero, width, - tg, wgo->image, wgo->vLine, wgo->xOff, wgo->yOff, + tg, wgo->image, wgo->vLine, wgo->xOff, wgo->yOff, wgo->yOffsets, wgo->numTrack, graphUpperLimit, graphLowerLimit, graphRange, epsilon, colorArray, vis, wigCart); freez(&colorArray); } void drawZeroLine(enum trackVisibility vis, enum wiggleGridOptEnum horizontalGrid, double graphUpperLimit, double graphLowerLimit, struct hvGfx *hvg, int xOff, int yOff, int width, int lineHeight) /* draw a line at y=0 on the graph */ { /* Do we need to draw a zero line ? * This is to be generalized in the future to allow horizontal grid @@ -1638,36 +1657,40 @@ wigCart->alwaysZero = (enum wiggleAlwaysZeroEnum)wigFetchAlwaysZeroWithCart(cart,tdb,tdb->track, (char **) NULL); wigCart->transformFunc = (enum wiggleTransformFuncEnum)wigFetchTransformFuncWithCart(cart,tdb,tdb->track, (char **) NULL); wigCart->maxHeight = maxHeight; wigCart->defaultHeight = defaultHeight; wigCart->minHeight = minHeight; wigFetchMinMaxYWithCart(cart,tdb,tdb->track, &wigCart->minY, &wigCart->maxY, NULL, NULL, wordCount, words); wigCart->colorTrack = trackDbSetting(tdb, "wigColorBy"); char *containerType = trackDbSetting(tdb, "container"); if (containerType != NULL && sameString(containerType, "multiWig")) wigCart->isMultiWig = TRUE; +wigCart->aggregateFunction = wigFetchAggregateFunctionWithCart(cart,tdb,tdb->track, (char **) NULL); + +/* char *aggregate = wigFetchAggregateValWithCart(cart, tdb); if (aggregate != NULL) { wigCart->overlay = wigIsOverlayTypeAggregate(aggregate); wigCart->transparent = sameString(WIG_AGGREGATE_TRANSPARENT, aggregate); } +*/ return wigCart; } /* Make track group for wig multiple alignment. * WARNING ! - track->visibility is merely the default value * from the trackDb entry at this time. It will be set after this * by hgTracks from its cart UI setting. When called in * TotalHeight it will then be the requested visibility. */ void wigMethods(struct track *track, struct trackDb *tdb, int wordCount, char *words[]) { struct wigCartOptions *wigCart = wigCartOptionsNew(cart, tdb, wordCount, words); track->minRange = wigCart->minY; track->maxRange = wigCart->maxY;