9944d8c4a72a426a07ed2d33a5ea535811dd4461
galt
  Sun Feb 7 23:26:52 2016 -0800
Issue 16666. Makes autoscale work with multi-region for wig, bedGraph, bigWig, and multiWig. doWiggle still TODO.

diff --git src/hg/hgTracks/wigCommon.h src/hg/hgTracks/wigCommon.h
index 8a38069..296da4f 100644
--- src/hg/hgTracks/wigCommon.h
+++ src/hg/hgTracks/wigCommon.h
@@ -36,31 +36,31 @@
     };
 
 struct wigCartOptions *wigCartOptionsNew(struct cart *cart, struct trackDb *tdb, int wordCount, char *words[]);
 /* Create a wigCartOptions from cart contents and tdb. */
 
 struct preDrawContainer
 /* A preDraw array with a little bit of extra info */
     {
     struct preDrawContainer *nextPlaceholder;   /* Refactoring code so not in list really. */
     struct preDrawElement *preDraw;     /* Array of values. */
     int preDrawSize;		/* Size of preDraw */
     int preDrawZero;		/* Offset from start of predraw array to data requested.  We
                                  * get more because of smoothing */
     int width;			/* Passed in width, number of pixels to display without smooth */
     double graphUpperLimit, graphLowerLimit; /* limits to the smoothed value */
-    boolean smoothingDone;      /* did we already do the smoothing? */
+    boolean skipAutoscale;      /* multiWig does its own autoscale */
     };
 
 struct preDrawElement
     {
     double	max;	/*	maximum value seen for this point	*/
     double	min;	/*	minimum value seen for this point	*/
     unsigned long long	count;	/* number of datum at this point */
     double	sumData;	/*	sum of all values at this point	*/
     double  sumSquares;	/* sum of (values squared) at this point */
     double  plotValue;	/*	raw data to plot	*/
     double  smooth;	/*	smooth data values	*/
     };
 
 struct bedGraphItem
 /* A bedGraph track item. */
@@ -137,34 +137,44 @@
 /*	if self mapping, create the mapping box	*/
 
 void wigLeftLabels(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);
 /*	drawing left labels	*/
 
 char *wigNameCallback(struct track *tg, void *item);
 /* Return name of wig level track. */
 
 void wigFindItemLimits(void *items,
     double *graphUpperLimit, double *graphLowerLimit);
 /*	find upper and lower limits of graphed items (wigItem)	*/
 
+void wigMultiRegionGraphLimits(struct track *tg);
+/* Set common graphLimits across all windows */
+
+void wigPreDrawPredraw(struct track *tg, int seqStart, int seqEnd,
+                    struct hvGfx *hvg, int xOff, int yOff, int width,
+                    MgFont *font, Color color, enum trackVisibility vis,
+                    struct preDrawContainer *preContainer, int preDrawZero,
+                    int preDrawSize, double *retGraphUpperLimit, double *retGraphLowerLimit);
+/* Figure out graph limits after running windowingFunction and smoothing if needed. */
+
 void wigDrawPredraw(struct track *tg, int seqStart, int seqEnd,
 	struct hvGfx *hvg, int xOff, int yOff, int width,
 	MgFont *font, Color color, enum trackVisibility vis, struct preDrawContainer *preDrawContainer,
-	int preDrawZero, int preDrawSize, double *retGraphUpperLimit, double *retGraphLowerLimit);
+	int preDrawZero, int preDrawSize, double graphUpperLimit, double graphLowerLimit);
 /* Draw once we've figured out predraw. */
 
 void wigLeftAxisLabels(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, char *shortLabel, double graphUpperLimit, double graphLowerLimit,
 	boolean showNumbers);
 /* Draw labels on left for a wiggle-type track. */
 
 double wiggleLogish(double x);
 /* Return log-like transform without singularity at 0. */
 
 /******************  in source file bedGraph.c ************************/
 void wigBedGraphFindItemLimits(void *items,
     double *graphUpperLimit, double *graphLowerLimit);