c46be5cebadbe532ca7f7fc2a5cde930554c7ae7
braney
  Tue May 2 11:20:34 2017 -0700
first check in of hgComposite code.

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 539caa6..dedd65a 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -60,30 +60,31 @@
 #include "suggest.h"
 #include "search.h"
 #include "errCatch.h"
 #include "iupac.h"
 #include "botDelay.h"
 #include "chromInfo.h"
 #include "extTools.h"
 #include "basicBed.h"
 #include "customFactory.h"
 #include "genbank.h"
 #include "bigWarn.h"
 #include "wigCommon.h"
 #include "knetUdc.h"
 #include "hex.h"
 #include <openssl/sha.h>
+#include "customComposite.h"
 
 /* Other than submit and Submit all these vars should start with hgt.
  * to avoid weeding things out of other program's namespaces.
  * Because the browser is a central program, most of its cart
  * variables are not hgt. qualified.  It's a good idea if other
  * program's unique variables be qualified with a prefix though. */
 char *excludeVars[] = { "submit", "Submit", "dirty", "hgt.reset",
             "hgt.in1", "hgt.in2", "hgt.in3", "hgt.inBase",
             "hgt.out1", "hgt.out2", "hgt.out3", "hgt.out4",
             "hgt.left1", "hgt.left2", "hgt.left3",
             "hgt.right1", "hgt.right2", "hgt.right3",
             "hgt.dinkLL", "hgt.dinkLR", "hgt.dinkRL", "hgt.dinkRR",
             "hgt.tui", "hgt.hideAll", "hgt.visAllFromCt",
 	    "hgt.psOutput", "hideControls", "hgt.toggleRevCmplDisp",
 	    "hgt.collapseGroups", "hgt.expandGroups", "hgt.suggest",
@@ -4513,30 +4514,62 @@
 struct window *window;
 for (window=windows, winTrack=track; window; window=window->next, winTrack=winTrack->nextWindow)
     {
     setGlobalsFromWindow(window);
 
     int trackHeight =  trackPlusLabelHeight(winTrack, fontHeight);
 
     if (trackHeight > maxHeight)
 	maxHeight = trackHeight;
     }
 setGlobalsFromWindow(windows); // first window
 
 flatTrack->maxHeight = maxHeight;
 }
 
+static boolean isCompositeInAggregate(struct track *track)
+// Check to see if this is a custom composite in aggregate mode.
+{
+if (!isCustomComposite(track->tdb))
+    return FALSE;
+
+char *aggregateVal = cartOrTdbString(cart, track->tdb, "aggregate", NULL);
+if ((aggregateVal == NULL) || sameString(aggregateVal, "none"))
+    return FALSE;
+
+struct track *subtrack = NULL;
+for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
+    {
+    if (isSubtrackVisible(subtrack))
+        break;
+    }
+if (subtrack == NULL)
+    return FALSE;
+
+multiWigContainerMethods(track);
+struct wigCartOptions *wigCart = wigCartOptionsNew(cart, track->tdb, 0, NULL);
+track->wigCartData = (void *) wigCart;
+//track->lineHeight = wigCart->defaultHeight;
+wigCart->isMultiWig = TRUE;
+wigCart->autoScale = wiggleScaleAuto;
+//wigCart->defaultHeight = track->lineHeight;
+//struct wigGraphOutput *wgo = setUpWgo(xOff, yOff, width, tg->height, numTracks, wigCart, hvg);
+//tg->wigGraphOutput = wgo;
+
+return TRUE;
+}
+
 void makeActiveImage(struct track *trackList, char *psOutput)
 /* Make image and image map. */
 {
 struct track *track;
 MgFont *font = tl.font;
 struct hvGfx *hvg;
 struct tempName pngTn;
 char *mapName = "map";
 int fontHeight = mgFontLineHeight(font);
 int trackPastTabX = (withLeftLabels ? trackTabWidth : 0);
 int trackTabX = gfxBorder;
 int trackPastTabWidth = tl.picWidth - trackPastTabX;
 int pixWidth, pixHeight;
 int y=0;
 int titleHeight = fontHeight;
@@ -4703,41 +4736,46 @@
 		    subtrack->hasUi = track->hasUi;
 		    }
 		}
 	    }
 	}
     }
 trackList = windows->trackList;
 setGlobalsFromWindow(windows); // first window
 
 // Construct flatTracks 
 for (track = trackList; track != NULL; track = track->next)
     {
     if (tdbIsComposite(track->tdb))
         {
         struct track *subtrack;
+        if (isCompositeInAggregate(track))
+            flatTracksAdd(&flatTracks,track,cart);
+        else
+            {
             for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
                 {
                 if (!isSubtrackVisible(subtrack))
                     continue;
 
                 if (!isLimitedVisHiddenForAllWindows(subtrack))
                     {
                     flatTracksAdd(&flatTracks,subtrack,cart);
                     }
                 }
             }
+        }
     else
 	{	
 	if (!isLimitedVisHiddenForAllWindows(track))
 	    {
 	    flatTracksAdd(&flatTracks,track,cart);
 	    }
 	}
     }
 flatTracksSort(&flatTracks); // Now we should have a perfectly good flat track list!
 
 
 // for each track, figure out maximum height needed from all windows
 for (flatTrack = flatTracks; flatTrack != NULL; flatTrack = flatTrack->next)
     {
     track = flatTrack->track;