src/hg/lib/hui.c 1.199

1.199 2009/05/21 20:30:50 tdreszer
Added multiViewCount(), support for boxedCfg setting, moved multiView call up a level.
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.198
retrieving revision 1.199
diff -b -B -U 4 -r1.198 -r1.199
--- src/hg/lib/hui.c	21 May 2009 19:00:00 -0000	1.198
+++ src/hg/lib/hui.c	21 May 2009 20:30:50 -0000	1.199
@@ -2060,8 +2060,23 @@
     freez(members);
     }
 }
 
+int multViewCount(struct trackDb *parentTdb)
+/* returns the number of multiView views declared */
+{
+char *setting = subgroupSettingByTagOrName(parentTdb,"view");
+if(setting == NULL)
+    return 0;
+
+setting = cloneString(setting);
+int cnt;
+char *words[32];
+cnt = chopLine(setting, words);
+freeMem(setting);
+return (cnt - 1);
+}
+
 #ifdef ADD_MULT_SELECT_DIMENSIONS
 // This is the beginning of work on allowing subtrack selection by multi-select drop downs
 typedef struct _selectables {
     int count;
@@ -3175,11 +3190,17 @@
 #define MANY_SUBTRACKS  8
 
 #define WIGGLE_HELP_PAGE  "../goldenPath/help/hgWiggleTrackHelp.html"
 
-static void cfgBeginBoxAndTitle(boolean boxed, char *title)
+static boolean cfgBeginBoxAndTitle(struct trackDb *tdb, boolean boxed, char *title)
 /* Handle start of box and title for individual track type settings */
 {
+if(!boxed)
+    {
+    boxed = trackDbSettingOn(tdb,"boxedCfg");
+    if(boxed)
+        printf("<BR>");
+    }
 if (boxed)
     {
     printf("<TABLE class='blueBox' bgcolor=\"%s\" borderColor=\"%s\"><TR><TD align='RIGHT'>", COLOR_BG_ALTDEFAULT, COLOR_BG_ALTDEFAULT);
     if (title)
@@ -3188,8 +3209,9 @@
 else if (title)
     printf("<p><B>%s &nbsp;</b>", title );
 else
     printf("<p>");
+return boxed;
 }
 
 static void cfgEndBox(boolean boxed)
 /* Handle end of box and title for individual track type settings */
@@ -3219,9 +3241,9 @@
 double yLineMark;       /*  from trackDb or cart    */
 int maxHeightPixels = atoi(DEFAULT_HEIGHT_PER);
 int minHeightPixels = MIN_HEIGHT_PER;
 
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 wigFetchMinMaxPixelsWithCart(cart,tdb,name,&minHeightPixels, &maxHeightPixels, &defaultHeight);
 typeLine = cloneString(tdb->type);
 wordCount = chopLine(typeLine,words);
@@ -3527,9 +3549,9 @@
 boolean glvlScoreMin = (trackDbSettingClosestToHome(tdb, GRAY_LEVEL_SCORE_MIN) != NULL);
 if (! (scoreFilterOk || glvlScoreMin))
     return;
 
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 if (scoreFilterOk)
     {
     int minLimit=0,maxLimit=maxScore,minVal=0,maxVal=maxScore;
@@ -3588,9 +3610,9 @@
 
 void netAlignCfgUi(char *db, struct cart *cart, struct trackDb *tdb, char *prefix, char *title, boolean boxed)
 /* Put up UI for net tracks */
 {
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 boolean compositeLevel = isNameAtCompositeLevel(tdb,prefix);
 
 enum netColorEnum netColor = netFetchColorOption(cart, tdb, compositeLevel);
@@ -3613,9 +3635,9 @@
 
 void chainCfgUi(char *db, struct cart *cart, struct trackDb *tdb, char *prefix, char *title, boolean boxed)
 /* Put up UI for chain tracks */
 {
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 boolean compositeLevel = isNameAtCompositeLevel(tdb,prefix);
 
 enum chainColorEnum chainColor =
@@ -3647,9 +3669,9 @@
 if(setting)
     {
     if(*opened == FALSE)
         {
-        cfgBeginBoxAndTitle(boxed, title);
+        boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
         puts("<TABLE>");
         *opened = TRUE;
         }
     printf("<TR><TD align='right'><B>%s:</B><TD align='left'>",label);
@@ -3841,9 +3863,9 @@
 if(setting)
     {
     if(!opened)
         {
-        cfgBeginBoxAndTitle(boxed, title);
+        boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
         puts("<TABLE>");
         opened = TRUE;
         }
     char varName[256];
@@ -3887,9 +3909,9 @@
 char varName[64];
 boolean compositeLevel = isNameAtCompositeLevel(tdb,name);
 char *geneLabel = cartUsualStringClosestToHome(cart, tdb,compositeLevel, "label", "gene");
 
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 if (sameString(name, "acembly"))
     {
     char *acemblyClass = cartUsualStringClosestToHome(cart,tdb,compositeLevel,"type", acemblyEnumToString(0));
@@ -4202,9 +4224,9 @@
 bool lowerFirstChar = TRUE;
 int i;
 char option[MAX_SP_SIZE];
 
-cfgBeginBoxAndTitle(boxed, title);
+boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 
 char *defaultCodonSpecies = trackDbSetting(tdb, SPECIES_CODON_DEFAULT);
 char *framesTable = trackDbSetting(tdb, "frames");
 char *firstCase = trackDbSetting(tdb, ITEM_FIRST_CHAR_CASE);
@@ -4550,10 +4572,8 @@
 
 if(!dimensionsExist(parentTdb))
     return FALSE;
 
-hCompositeDisplayViewDropDowns(db, cart,parentTdb);  // If there is a view dimension, it is at top
-
 int ixX,ixY,ixZ;
 members_t *dimensionX = subgroupMembersGetByDimension(parentTdb,'X');
 members_t *dimensionY = subgroupMembersGetByDimension(parentTdb,'Y');
 members_t *dimensionZ = subgroupMembersGetByDimension(parentTdb,'Z');
@@ -4810,15 +4830,8 @@
 
 if(dimensionsExist(parentTdb))
     return FALSE;
 
-if(subgroupingExists(parentTdb,"view"))
-    {
-    hCompositeDisplayViewDropDowns(db, cart,parentTdb);
-    if(subgroupCount(parentTdb) <= 1)
-        return TRUE;
-    }
-
 puts ("<TABLE>");
 if (hasSubgroups)
     {
     puts("<TR><B>Select subtracks:</B></TR>");
@@ -4956,8 +4969,9 @@
 bool hasSubgroups = (trackDbSetting(tdb, "subGroup1") != NULL);
 boolean displayAll =
     sameString(cartUsualString(cart, "displaySubtracks", "all"), "all");
 boolean isMatrix = dimensionsExist(tdb);
+boolean viewsOnly = FALSE;
 
 if(trackDbSetting(tdb, "dragAndDrop") != NULL)
     jsIncludeFile("jquery.tablednd.js", NULL);
 jsIncludeFile("hui.js",NULL);
@@ -4970,13 +4984,21 @@
     }
 if (fakeSubmit)
     cgiMakeHiddenVar(fakeSubmit, "submit");
 
-if (!hasSubgroups || !isMatrix || primarySubtrack)
+if(subgroupingExists(tdb,"view"))
+    {
+    hCompositeDisplayViewDropDowns(db, cart,tdb);
+    if(subgroupCount(tdb) <= 1)
+        viewsOnly = TRUE;
+    }
+if(!viewsOnly)
+    {
+    if (!hasSubgroups || !isMatrix || primarySubtrack)
     hCompositeUiNoMatrix(db, cart,tdb,primarySubtrack,formName);
-else
+    else
     hCompositeUiByMatrix(db, cart,tdb,formName);
-
+    }
 cartSaveSession(cart);
 cgiContinueHiddenVar("g");
 if (displayAll)
     compositeUiAllSubtracks(db, cart, tdb, primarySubtrack);