src/hg/hgTracks/simpleTracks.c 1.111

1.111 2009/11/11 20:41:29 tdreszer
Cleanup before checkin of imageV2 framework without features. Also made track toggle work better for composites, but only in imageV2
Index: src/hg/hgTracks/simpleTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/simpleTracks.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -b -B -U 4 -r1.110 -r1.111
--- src/hg/hgTracks/simpleTracks.c	10 Nov 2009 05:48:18 -0000	1.110
+++ src/hg/hgTracks/simpleTracks.c	11 Nov 2009 20:41:29 -0000	1.111
@@ -440,36 +440,34 @@
  * format.  If toggleGroup is non-null the visibility of that
  * track will be toggled in the string. */
 {
 struct dyString *dy = newDyString(512);
-struct track *tg;
 
 dyStringPrintf(dy, "%s=%u", cartSessionVarName(), cartSessionId(cart));
-//#define TOGGLE_SUBTRACKS
+#define TOGGLE_SUBTRACKS
 #ifdef TOGGLE_SUBTRACKS
 if(toggleGroup != NULL && tdbIsCompositeChild(toggleGroup->tdb))
     {
-    tg = toggleGroup;
-    int vis = tg->visibility;
+    int vis = toggleGroup->visibility;
     // Find parent track
     struct track *tgParent = trackList;
     for (;tgParent != NULL; tgParent = tgParent->next)
         {
-        if(sameString(tgParent->mapName,tg->tdb->parent->tableName))
+        if(sameString(tgParent->mapName,toggleGroup->tdb->parent->tableName))
             break;
         }
     // should be assertable assert(tgParent!=NULL);
-    char *encodedTableName = cgiEncode(tg->tdb->parent->tableName);
+    char *encodedTableName = cgiEncode(toggleGroup->tdb->parent->tableName);
     char *view = NULL;
-    boolean setView = subgroupFind(tg->tdb,"view",&view);
+    boolean setView = subgroupFind(toggleGroup->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)
+        if(!toggleGroup->canPack || view != NULL)
             vis = tvFull;
         else
             vis = tvPack;
         }
@@ -491,18 +489,15 @@
     }
 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)
+    if (toggleGroup != NULL)
         {
-        char *encodedMapName = cgiEncode(tg->mapName);
+        int vis = toggleGroup->visibility;
+        char *encodedMapName = cgiEncode(toggleGroup->mapName);
         if (vis == tvDense)
             {
-            if(!tg->canPack || (tdbIsComposite(tg->tdb) && subgroupingExists(tg->tdb,"view")))
+            if(!toggleGroup->canPack || (tdbIsComposite(toggleGroup->tdb) && subgroupingExists(toggleGroup->tdb,"view")))
                 vis = tvFull;
             else
                 vis = tvPack;
             }
@@ -511,9 +506,8 @@
         dyStringPrintf(dy, "&%s=%s", encodedMapName, hStringFromTv(vis));
         freeMem(encodedMapName);
         }
     }
-    }
 return dy;
 }
 
 boolean isWithCenterLabels(struct track *track)
@@ -569,22 +563,19 @@
     chrom = chromName;
     start = winStart;
     end = winEnd;
     }
-#ifdef IMAGEv2_UI
-if(theImgBox && curMap)
+if(theImgBox && curImgTrack)
     {
     char link[512];
     safef(link,sizeof(link),"%s?position=%s:%d-%d&%s",hgTracksName(), chrom, start+1, end, ui->string); // NOTE: position may need removing due to portal
     //#ifdef IMAGEv2_SHORT_MAPITEMS
     //    if(x < insideX && x+width > insideX)
     //        warn("mapBoxReinvoke(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",hStringFromTv(toggleGroup->visibility),x, y, x+width, y+height, link);
     //#endif//def IMAGEv2_SHORT_MAPITEMS
     imgTrackAddMapItem(curImgTrack,link,(char *)(message != NULL?message:NULL),x, y, x+width, y+height);
-    //mapSetItemAdd(curMap,link,(char *)(message != NULL?message:NULL),x, y, x+width, y+height);
     }
 else
-#endif//def IMAGEv2_UI
     {
     hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
     hPrintf("HREF=\"%s?position=%s:%d-%d",
         hgTracksName(), chrom, start+1, end);
@@ -601,11 +592,16 @@
 /* Print out image map rectangle that would invoke this program again.
  * program with the current track expanded. */
 {
 char buf[256];
-safef(buf, sizeof(buf),
-	"Toggle the display density of %s", curGroup->shortLabel);
-mapBoxReinvoke(hvg, x, y, width, height, curGroup, NULL, 0, 0, buf, NULL);
+if(curGroup->tdb->parent != NULL)
+    safef(buf, sizeof(buf),"Toggle the display density of %s and similar subtracks", curGroup->shortLabel);
+else if(curGroup->tdb->subtracks != NULL)
+    safef(buf, sizeof(buf),"Toggle the maximum display mode density for all %s subtracks", curGroup->shortLabel);
+else
+    safef(buf, sizeof(buf),"Toggle the display density of %s", curGroup->shortLabel);
+
+    mapBoxReinvoke(hvg, x, y, width, height, curGroup, NULL, 0, 0, buf, NULL);
 }
 
 void mapBoxJumpTo(struct hvGfx *hvg, int x, int y, int width, int height,
 	char *newChrom, int newStart, int newEnd, char *message)
@@ -645,10 +641,9 @@
     {
     char *encodedItem = cgiEncode(item);
     char *encodedTrack = cgiEncode(track);
 
-    #ifdef IMAGEv2_UI
-    if(theImgBox && curMap)
+    if(theImgBox && curImgTrack)
         {
         char link[512];
         if (directUrl)
             {
@@ -668,12 +663,10 @@
             if(x < insideX && xEnd > insideX)
                 warn("mapBoxHgcOrHgGene(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",track,x, y, xEnd, yEnd, link);
         #endif//def IMAGEv2_SHORT_MAPITEMS
         imgTrackAddMapItem(curImgTrack,link,(char *)(statusLine!=NULL?statusLine:NULL),x, y, xEnd, yEnd);
-        //mapSetItemAdd(curMap,link,(char *)(statusLine!=NULL?statusLine:NULL),x, y, xEnd, yEnd);
         }
     else
-    #endif//def IMAGEv2_UI
         {
         hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, xEnd, yEnd);
         if (directUrl)
             {