da2e00021362a366f2f3b17b238305ca7981c7d2
tdreszer
  Thu Dec 15 12:44:34 2011 -0800
Some older composites have packable children which are seen in rightClick as unpackable.  The mixed case that gives rise to this should not be allowed now, but we can support it for those older composites.  The rule is, if any single subtrack is packable, then the whole tree is.
diff --git src/hg/lib/trackDbCustom.c src/hg/lib/trackDbCustom.c
index 11e0730..a227491 100644
--- src/hg/lib/trackDbCustom.c
+++ src/hg/lib/trackDbCustom.c
@@ -1312,30 +1312,64 @@
 tdbExtrasGet(tdb)->membership = membership;
 }
 
 char *tdbBigFileName(struct sqlConnection *conn, struct trackDb *tdb)
 // Return file name associated with bigWig.  Do a freeMem on returned string when done.
 {
 char *fileName = trackDbSetting(tdb, "bigDataUrl"); // always takes precedence
 if (fileName != NULL)
     return cloneString(fileName);
 
 char query[256];
 safef(query, sizeof(query), "select fileName from %s", tdb->table);
 return sqlQuickString(conn, query);
 }
 
+static void rTdbTreeAllowPack(struct trackDb *tdb)
+// Force this tdb and all children to allow pack/squish
+{
+tdb->canPack = TRUE;
+struct trackDb *childTdb = tdb->subtracks;
+for ( ;childTdb!=NULL;childTdb=childTdb->next)
+    rTdbTreeAllowPack(childTdb);
+}
+
+boolean rTdbTreeCanPack(struct trackDb *tdb)
+// Trees can pack as all or none, since they can share vis.
+{
+if (tdb->canPack == FALSE)
+    {
+    // If a single child of a composite can pack, then the entire composite can
+    if (tdbIsComposite(tdb) || tdbIsCompositeView(tdb))
+        {
+        struct trackDb *childTdb = tdb->subtracks;
+        for ( ;childTdb!=NULL;childTdb=childTdb->next)
+            {
+            if (rTdbTreeCanPack(childTdb))
+                {
+                tdb->canPack = TRUE;
+                break;
+                }
+            }
+        }
+    // At the composite level if one was found then set the whole tree.
+    if (tdb->canPack && tdbIsComposite(tdb))
+        rTdbTreeAllowPack(tdb);
+    }
+return tdb->canPack;
+}
+
 void tdbSetCartVisibility(struct trackDb *tdb, struct cart *cart, char *vis)
 {
 // Set visibility in the cart. Handles all the complications necessary for subtracks.
 char buf[512];
 cartSetString(cart, tdb->track, vis);
 if (tdbIsSubtrack(tdb))
     {
     safef(buf,sizeof buf, "%s_sel", tdb->track);
     cartSetString(cart, buf, "1");   // Will reshape composite
     struct trackDb *composite = tdbGetComposite(tdb);
     if (composite && tdbIsSuperTrackChild(composite))
         {
         safef(buf,sizeof buf, "%s_sel", composite->track);
         cartSetString(cart, buf, "1");   // Will reshape supertrack
         }