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/bamTrack.c src/hg/hgTracks/bamTrack.c
index 892ddac..f632d57 100644
--- src/hg/hgTracks/bamTrack.c
+++ src/hg/hgTracks/bamTrack.c
@@ -972,46 +972,60 @@
 
 /* fill in rest of predraw */
 int preDrawZero = pre->preDrawZero;
 int i;
 for (i=0; i<insideWidth; ++i)
     {
     struct preDrawElement *pe = &bwData->preDraw[i + preDrawZero];
     pe->min = pe->count;
     pe->max = pe->count;
     pe->sumData = pe->count / scale;
     pe->sumSquares = (pe->count * pe->count)/scale;
     }
 
 }
 
+
+static void bamWigPreDrawItems(struct track *tg, int seqStart, int seqEnd,
+	struct hvGfx *hvg, int xOff, int yOff, int width,
+	MgFont *font, Color color, enum trackVisibility vis)
+{
+/* Call pre graphing routine. */
+wigPreDrawPredraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis,
+	       tg->preDrawContainer, tg->preDrawContainer->preDrawZero, tg->preDrawContainer->preDrawSize, &tg->graphUpperLimit, &tg->graphLowerLimit);
+
+}
+
+
 static void bamWigDrawItems(struct track *tg, int seqStart, int seqEnd,
 	struct hvGfx *hvg, int xOff, int yOff, int width,
 	MgFont *font, Color color, enum trackVisibility vis)
 {
 /* Call actual graphing routine. */
 wigDrawPredraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis,
-	       tg->preDrawContainer, tg->preDrawContainer->preDrawZero, tg->preDrawContainer->preDrawSize, &tg->graphUpperLimit, &tg->graphLowerLimit);
+	       tg->preDrawContainer, tg->preDrawContainer->preDrawZero, tg->preDrawContainer->preDrawSize, tg->graphUpperLimit, tg->graphLowerLimit);
 
 }
 
 void bamWigMethods(struct track *track, struct trackDb *tdb,
 	int wordCount, char *words[])
 /* Set up bamWig methods. */
 {
 bedGraphMethods(track, tdb, wordCount, words);
 track->loadItems = bamWigLoadItems;
+track->preDrawItems = bamWigPreDrawItems;
+track->preDrawMultiRegion = wigMultiRegionGraphLimits;
 track->drawItems = bamWigDrawItems;
 }
 #else /* no USE_BAM */
 
 #include "common.h"
 #include "hgTracks.h"
 // If code was not built with USE_BAM=1, but there are bam tracks, display a message
 // in place of the tracks (instead of annoying "No track handler" warning messages).
 
 void drawUseBamWarning(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg,
                  int xOff, int yOff, int width, MgFont *font, Color color,
                  enum trackVisibility vis)
 /* Draw a message saying that the code needs to be built with USE_BAM=1. */
 {
 char message[512];