src/hg/hgTracks/simpleTracks.c 1.93

1.93 2009/07/22 00:01:31 tdreszer
Fix for B0b's toggle problem, but ifdef'd out since I am leaving on vacation. Look for TOGGLE_SUBTRACKS
Index: src/hg/hgTracks/simpleTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/simpleTracks.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -b -B -U 4 -r1.92 -r1.93
--- src/hg/hgTracks/simpleTracks.c	17 Jul 2009 18:57:52 -0000	1.92
+++ src/hg/hgTracks/simpleTracks.c	22 Jul 2009 00:01:31 -0000	1.93
@@ -443,8 +443,57 @@
 struct dyString *dy = newDyString(512);
 struct track *tg;
 
 dyStringPrintf(dy, "%s=%u", cartSessionVarName(), cartSessionId(cart));
+//#define TOGGLE_SUBTRACKS
+#ifdef TOGGLE_SUBTRACKS
+if(toggleGroup != NULL && tdbIsCompositeChild(toggleGroup->tdb))
+    {
+    tg = toggleGroup;
+    int vis = tg->visibility;
+    // Find parent track
+    struct track *tgParent = trackList;
+    for (;tgParent != NULL; tgParent = tgParent->next)
+        {
+        if(sameString(tgParent->mapName,tg->tdb->parent->tableName))
+            break;
+        }
+    // should be assertable assert(tgParent!=NULL);
+    char *encodedTableName = cgiEncode(tg->tdb->parent->tableName);
+    char *view = NULL;
+    boolean setView = subgroupFind(tg->tdb,"view",&view);
+    if(tgParent!=NULL && tvCompare(tgParent->visibility,vis) > 0)
+        {
+        setView = FALSE; // Must open parent to see opened child
+        vis = tgParent->visibility;
+        }
+    if (vis == tvDense)
+        {
+        if(!tg->canPack || view != NULL)
+            vis = tvFull;
+        else
+            vis = tvPack;
+        }
+    else if (vis != tvHide)
+        vis = tvDense;
+
+    if(setView)
+        {
+        char *encodeView = cgiEncode(view);
+        dyStringPrintf(dy, "&%s.%s.vis=%s", encodedTableName,encodeView, hStringFromTv(vis));
+        freeMem(encodeView);
+        }
+    else
+        {
+        dyStringPrintf(dy, "&%s=%s", encodedTableName, hStringFromTv(vis));
+        }
+    subgroupFree(&view);
+    freeMem(encodedTableName);
+    }
+else
+#endif//def TOGGLE_SUBTRACKS
+    {
+// This loop makes no sense.  What is it accomplishing?  AVOIDING subtracks?  AND subtracks do not point to their parents!
 for (tg = trackList; tg != NULL; tg = tg->next)
     {
     int vis = tg->visibility;
     if (tg == toggleGroup)
@@ -462,8 +511,9 @@
 	dyStringPrintf(dy, "&%s=%s", encodedMapName, hStringFromTv(vis));
 	freeMem(encodedMapName);
 	}
     }
+    }
 return dy;
 }
 
 boolean isWithCenterLabels(struct track *track)