10856033c3d0f2ec024b90b3a29a4af692e86e6a braney Sun Apr 20 20:26:56 2014 -0700 stacked bars in multiwig working diff --git src/hg/hgTracks/wigTrack.c src/hg/hgTracks/wigTrack.c index e483cc6..05afa3c 100644 --- src/hg/hgTracks/wigTrack.c +++ src/hg/hgTracks/wigTrack.c @@ -811,31 +811,31 @@ 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)); +wgo->yOffsets = needHugeMem(width * numTracks * sizeof(double)); 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; } @@ -972,49 +972,52 @@ scaledMax = (h+yOff) - 1; boxHeight = max(1,zeroPos-scaledMax); int lightTop = scaledMax, lightHeight = boxHeight; /* Draw, making sure not to overwrite pixels since * would mess up transparent drawing. */ vLine(image,x,darkTop, darkHeight, drawColor); vLine(image, x, mediumTop, mediumHeight-darkHeight, mediumColor); vLine(image,x,lightTop,lightHeight-mediumHeight, lightColor); } } else { int y0 = graphUpperLimit * scaleFactor; int y1 = (graphUpperLimit - dataValue)*scaleFactor; + if (yOffsets) + { + if (numTrack > 0) + { + y0 = (graphUpperLimit - yOffsets[(numTrack-1) * width + x1]) *scaleFactor; + y1 = (graphUpperLimit - dataValue - yOffsets[(numTrack-1) * width + x1])*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; - int stackY = 0; - if (yOffsets) - { - stackY = yOffsets[numTrack * width + x1]; - } - vLine(image,x, stackY+yOff+boxTop, boxHeight, drawColor); + vLine(image,x, 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 {