8dc2f2a3bfe8d47e02a94ca4d9f62063df86b15c
braney
  Thu Oct 5 14:56:25 2017 -0700
ongoing work on hgCollection.  Add the ability to add tracks in hgTracks
to a collection.   Turn "overlay method" back on for custom collections.
Fix panning bug in hgTracks with custom collections

diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c
index 9a5d01b..5d8f2bb 100644
--- src/hg/hgTracks/hgTracks.c
+++ src/hg/hgTracks/hgTracks.c
@@ -463,30 +463,35 @@
     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;
 
+for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
+    {
+    subtrack->mapsSelf = FALSE;	/* Round about way to tell wig not to do own mapping. */
+    }
+
 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;
 }
 
 static int trackPlusLabelHeight(struct track *track, int fontHeight)
 /* Return the sum of heights of items in this track (or subtrack as it may be)
@@ -7486,50 +7491,57 @@
     {
     for (tg=track; tg; tg=tg->nextWindow)
 	{
 	tg->networkErrMsg = sharedErrMsg;
 	tg->drawItems = bigDrawWarning;
 	tg->totalHeight = bigWarnTotalHeight;
 	}
     }
 }
 
 
 void outCollectionsToJson()
 /* Output the current collections to the hgTracks JSON block. */
 {
 struct grp *groupList = NULL;
-struct trackDb *hubTdbs = hubCollectTracks( database,  &groupList);
 char buffer[4096];
 safef(buffer, sizeof buffer, "%s-%s", customCompositeCartName, database);
 char *hubFile = cartOptionalString(cart, buffer);
+
+if (hubFile != NULL)
+    {
     char *hubName = hubNameFromUrl(hubFile);
+    struct trackDb *hubTdbs = hubCollectTracks( database,  &groupList);
     struct trackDb *tdb;
     struct jsonElement *jsonList = NULL;
     for(tdb = hubTdbs; tdb;  tdb = tdb->next)
         {
         if (sameString(tdb->grp, hubName))
             {
             if (jsonList == NULL)
                 jsonList = newJsonList(NULL);
 
-        jsonListAdd(jsonList, newJsonString(tdb->shortLabel));
+            struct jsonElement *collection = newJsonObject(newHash(4));
+            jsonObjectAdd(collection, "track", newJsonString(tdb->track));
+            jsonObjectAdd(collection, "shortLabel", newJsonString(tdb->shortLabel));
+            jsonListAdd(jsonList, collection);
             }
         }
-if (jsonList)
+    if (jsonList != NULL)
         jsonObjectAdd(jsonForClient, "collections", jsonList);
     }
+}
 
 void doTrackForm(char *psOutput, struct tempName *ideoTn)
 /* Make the tracks display form with the zoom/scroll buttons and the active
  * image.  If the ideoTn parameter is not NULL, it is filled in if the
  * ideogram is created.  */
 {
 struct group *group;
 struct track *track;
 char *freezeName = NULL;
 boolean hideAll = cgiVarExists("hgt.hideAll");
 boolean defaultTracks = cgiVarExists("hgt.reset");
 boolean showedRuler = FALSE;
 boolean showTrackControls = cartUsualBoolean(cart, "trackControlsOnMain", TRUE);
 long thisTime = 0, lastTime = 0;
 
@@ -7876,31 +7888,31 @@
         }
     }
 
 if (theImgBox)
     {
     // If a portal was established, then set the global dimensions back to the portal size
     if (imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&virtWinStart,&virtWinEnd,&(tl.picWidth),NULL))
         {
         virtWinBaseCount = virtWinEnd - virtWinStart;
         fullInsideWidth = tl.picWidth-gfxBorder-fullInsideX;
         }
     }
 /* Center everything from now on. */
 hPrintf("<CENTER>\n");
 
-//outCollectionsToJson();
+outCollectionsToJson();
 
 jsonObjectAdd(jsonForClient, "winStart", newJsonNumber(virtWinStart));
 jsonObjectAdd(jsonForClient, "winEnd", newJsonNumber(virtWinEnd));
 jsonObjectAdd(jsonForClient, "chromName", newJsonString(virtChromName));
 
 // Tell javascript about multiple windows info
 if (virtMode)
     {
     // pre windows
     long preVWinStart = virtWinStart - virtWinBaseCount;
     if (preVWinStart < 0)
 	preVWinStart = 0;
     long preVWinEnd = virtWinStart;
     struct window *preWindows = makeWindowListFromVirtChrom(preVWinStart, preVWinEnd);
     struct jsonElement *jsonForList = newJsonList(NULL);