71b592154f2821cc5148993588e93e773915e084 angie Tue Apr 23 12:00:05 2019 -0700 Fix the way that scaledBoxToPixelCoords treats 0-length insertion items. refs #23283 This didn't affect the snp tracks because they have their own drawItemAt, nor bigBed because bedDrawSimpleAt uses hvGfxBox and linkedFeaturesDrawAt has a special case for start==end. But now the bigDbSnp drawing code will use scaledBoxToPixelCoords. diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index 45a92d8..c957451 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -1518,45 +1518,49 @@ } } freez(&inMotif); } void spreadBasesString(struct hvGfx *hvg, int x, int y, int width, int height, Color color, MgFont *font, char *s, int count, bool isCodon) /* Draw evenly spaced letters in string. */ { spreadAlignString(hvg, x, y, width, height, color, font, s, NULL, count, FALSE, isCodon); } boolean scaledBoxToPixelCoords(int chromStart, int chromEnd, double scale, int xOff, int *pX1, int *pX2) /* Convert chrom coordinates to pixels. Clip to window to prevent integer overflow. - * For special case of a SNP insert location with width==0, set width=1. + * For special case of a SNP insert location with item width==0, set pixel width=1 and include + * insertions at window boundaries. * Returns FALSE if it does not intersect the window, or if it would have a negative width. */ { +// Treat 0-length insertions a little differently: include insertions at boundary of window +// and make them 1 pixel wide. +boolean isIns = (chromStart == chromEnd); if (chromEnd < chromStart) // Invalid coordinates return FALSE; // Ignore. -if (chromStart == chromEnd) // SNP insert position - ++chromEnd; // set width to 1 -if (chromStart >= winEnd || winStart >= chromEnd) // overlaps window? +if (chromStart > winEnd || winStart > chromEnd || + (!isIns && chromStart == winEnd) || + (!isIns && chromEnd == winStart)) // doesn't overlap window? return FALSE; // nothing to do if (chromStart < winStart) // clip to part overlapping window chromStart = winStart; if (chromEnd > winEnd) // which prevents x1,x2 from overflowing when zooming-in makes scale large. chromEnd = winEnd; *pX1 = round((double)(chromStart-winStart)*scale) + xOff; -*pX2 = round((double)(chromEnd-winStart)*scale) + xOff; +*pX2 = isIns ? (*pX1 + 1) : round((double)(chromEnd-winStart)*scale) + xOff; return TRUE; } void drawScaledBox(struct hvGfx *hvg, int chromStart, int chromEnd, double scale, int xOff, int y, int height, Color color) /* Draw a box scaled from chromosome to window coordinates. * Get scale first with scaleForPixels. */ { int x1, x2; if (scaledBoxToPixelCoords(chromStart, chromEnd, scale, xOff, &x1, &x2)) { int w = x2-x1; if (w == 0) // when zoomed out, avoid shinking to nothing w = 1;