f63a718960b6a66276d579e7cd3fbb107f2cfd78
tdreszer
  Tue Nov 16 16:37:13 2010 -0800
Removed obsolete ifdef for SUBTRACKS_HAVE_VIS. Streamlined some composite vis code. Added support for remote tracks being rendered by AJAX callback.  Currently ifdefed out.
diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index cf6c114..1c9faae 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -9164,103 +9164,104 @@
  * composite tdb's):  */
 struct trackDb *subTdb= getSubtrackTdb(subtrack);
 if ((setting = trackDbLocalSetting(subTdb, "parent")) != NULL)
     {
     if (chopLine(cloneString(setting), words) >= 2)
         if (sameString(words[1], "off"))
             enabled = FALSE;
     }
 return enabled;
 }
 
 bool isSubtrackVisible(struct track *subtrack)
 /* Has this subtrack not been deselected in hgTrackUi or declared with
  * "subTrack ... off"?  -- assumes composite track is visible. */
 {
-#ifdef SUBTRACKS_HAVE_VIS
 boolean overrideComposite = (NULL != cartOptionalString(cart, subtrack->track));
-#endif///def SUBTRACKS_HAVE_VIS
 if (subtrack->limitedVisSet && subtrack->limitedVis == tvHide)
     return FALSE;
 bool enabledInTdb = subtrackEnabledInTdb(subtrack);
 char option[SMALLBUF];
 safef(option, sizeof(option), "%s_sel", subtrack->track);
 boolean enabled = cartUsualBoolean(cart, option, enabledInTdb);
-#ifndef SUBTRACKS_HAVE_VIS
-/* Remove redundant cart settings to avoid cart bloat. */
-if (enabled == enabledInTdb)
-    {
-    char *var = cartOptionalString(cart, option);
-    if(var != NULL && (sameString(var,"on") || atoi(var) >= 0))
-        cartRemove(cart, option);     // Because disabled CBs need to remain in the cart.
-    }
-#endif///def SUBTRACKS_HAVE_VIS
-#ifdef SUBTRACKS_HAVE_VIS
 if(overrideComposite)
     enabled = TRUE;
-#endif///def SUBTRACKS_HAVE_VIS
 return enabled;
 }
 
 static int subtrackCount(struct track *trackList)
 /* Count the number of visible subtracks in (sub)trackList. */
 {
 struct track *subtrack;
 int ct = 0;
 for (subtrack = trackList; subtrack; subtrack = subtrack->next)
     if (isSubtrackVisible(subtrack))
         ct++;
 return ct;
 }
 
 enum trackVisibility limitVisibility(struct track *tg)
 /* Return default visibility limited by number of items and
  * by parent visibility if part of a coposite track.
  * This also sets tg->height. */
 {
 if (!tg->limitedVisSet)
     {
+    tg->limitedVisSet = TRUE;
+    if (trackShouldUseAjaxRetrieval(tg))
+        {
+        tg->limitedVis = tg->visibility;
+        tg->height = REMOTE_TRACK_HEIGHT;
+        }
+    else
+        {
     enum trackVisibility vis = tg->visibility;
     int h;
     int maxHeight = maximumTrackHeight(tg);
-    tg->limitedVisSet = TRUE;
+
+        // rightClick change vis should not fail quite so often.  Let larger tracks be displayed.
+        // TODO: Alternatively, give some feedback to user why rightclick failed to change visibility.
+        if (trackImgOnly && cgiVarExists("hgt.trackNameFilter"))
+            maxHeight *= 2;
+
     if (vis == tvHide)
 	{
 	tg->height = 0;
 	tg->limitedVis = tvHide;
 	return tvHide;
 	}
     if (tg->subtracks != NULL)
 	{
 	struct track *subtrack;
 	int subCnt = subtrackCount(tg->subtracks);
 	maxHeight = maxHeight * max(subCnt,1);
 	for (subtrack = tg->subtracks;  subtrack != NULL; subtrack = subtrack->next)
 	    limitVisibility(subtrack);
 	}
     while((h = tg->totalHeight(tg, vis)) > maxHeight && vis != tvDense)
         {
         if (vis == tvFull && tg->canPack)
             vis = tvPack;
         else if (vis == tvPack)
             vis = tvSquish;
         else
             vis = tvDense;
         }
     tg->height = h;
     tg->limitedVis = vis;
     }
+    }
 return tg->limitedVis;
 }
 
 void compositeTrackVis(struct track *track)
 /* set visibilities of subtracks */
 {
 struct track *subtrack;
 
 if (track->visibility == tvHide)
     return;
 
 /* Count visible subtracks. */
 for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
     if (!subtrack->limitedVisSet)
 	{
@@ -11211,38 +11212,42 @@
     return;
 type = words[0];
 
 #ifndef GBROWSE
 if (sameWord(type, "bed"))
     {
     complexBedMethods(track, tdb, FALSE, wordCount, words);
     /* bed.h includes genePred.h so should be able to use these trackDb
        settings. */
     if (trackDbSetting(track->tdb, GENEPRED_CLASS_TBL) !=NULL)
         track->itemColor = genePredItemClassColor;
     }
 else if (sameWord(type, "bigBed"))
     {
     bigBedMethods(track, tdb, wordCount, words);
+    if (trackShouldUseAjaxRetrieval(track))
+        track->loadItems = dontLoadItems;
     }
 else if (sameWord(type, "bedGraph"))
     {
     bedGraphMethods(track, tdb, wordCount, words);
     }
 else if (sameWord(type, "bigWig"))
     {
     bigWigMethods(track, tdb, wordCount, words);
+    if (trackShouldUseAjaxRetrieval(track))
+        track->loadItems = dontLoadItems;  // TODO: Dummy drawItems as well?
     }
 else
 #endif /* GBROWSE */
 if (sameWord(type, "wig"))
     {
     wigMethods(track, tdb, wordCount, words);
     }
 else if (startsWith("wigMaf", type))
     {
     wigMafMethods(track, tdb, wordCount, words);
     }
 #ifndef GBROWSE
 else if (sameWord(type, "sample"))
     {
     sampleMethods(track, tdb, wordCount, words);
@@ -11269,30 +11274,32 @@
 else if (sameWord(type, "chain"))
     {
     chainMethods(track, tdb, wordCount, words);
     }
 else if (sameWord(type, "netAlign"))
     {
     netMethods(track);
     }
 else if (sameWord(type, "maf"))
     {
     mafMethods(track);
     }
 else if (sameWord(type, "bam"))
     {
     bamMethods(track);
+    if (trackShouldUseAjaxRetrieval(track))
+        track->loadItems = dontLoadItems;
     }
 else if (startsWith(type, "bedDetail"))
     {
     bedDetailMethods(track);
     }
 else if (sameWord(type, "pgSnp"))
     {
     pgSnpCtMethods(track);
     }
 #ifndef GBROWSE
 else if (sameWord(type, "coloredExon"))
     {
     coloredExonMethods(track);
     }
 else if (sameWord(type, "axt"))