src/hg/lib/hui.c 1.288
1.288 2010/05/17 02:28:45 kent
implementing compositeGroupLabel and compositeGroupId functions, and exposing existing static function as compositeLabelWithVocabLink
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.287
retrieving revision 1.288
diff -b -B -U 4 -r1.287 -r1.288
--- src/hg/lib/hui.c 14 May 2010 18:37:07 -0000 1.287
+++ src/hg/lib/hui.c 17 May 2010 02:28:45 -0000 1.288
@@ -2727,8 +2728,40 @@
// freez(membership);
// }
//}
+char *compositeGroupLabel(struct trackDb *tdb, char *group, char *id)
+/* Given ID from group, return corresponding label, looking through parent's subGroupN's */
+/* Given group ID, return group label, looking through parent's subGroupN's */
+{
+members_t *members = subgroupMembersGet(tdb, group);
+char *result = NULL;
+int i;
+for (i=0; i<members->count; ++i)
+ {
+ if (sameString(members->tags[i], id))
+ result = cloneString(members->titles[i]);
+ }
+subgroupMembersFree(&members);
+return result;
+}
+
+char *compositeGroupId(struct trackDb *tdb, char *group, char *label)
+/* Given label, return id, looking through parent's subGroupN's */
+{
+members_t *members = subgroupMembersGet(tdb, group);
+char *result = NULL;
+int i;
+for (i=0; i<members->count; ++i)
+ {
+ if (sameString(members->titles[i], label))
+ result = cloneString(members->tags[i]);
+ }
+subgroupMembersFree(&members);
+return result;
+}
+
+
boolean subtrackInAllCurrentABCs(struct trackDb *childTdb,membersForAll_t*membersForAll)
/* looks for a match between a membership set and ABC dimensions currently checked */
{
membership_t *membership = subgroupMembershipGet(childTdb);
@@ -5522,9 +5556,10 @@
freeMem(matchedSubtracks);
return TRUE;
}
-static char *labelWithVocabLink(char *db,struct trackDb *parentTdb, struct trackDb *childTdb, char *vocabType, char *label)
+char *compositeLabelWithVocabLink(char *db,struct trackDb *parentTdb, struct trackDb *childTdb,
+ char *vocabType, char *label)
/* If the parentTdb has a controlledVocabulary setting and the vocabType is found,
then label will be wrapped with the link to display it. Return string is cloned. */
{
char *vocab = trackDbSetting(parentTdb, "controlledVocabulary");
@@ -5620,9 +5655,9 @@
{
if(tdbsX[ixX] != NULL)
{
char *label =replaceChars(dimensionX->titles[ixX]," (","<BR>(");
- printf("<TH WIDTH='60'> %s </TH>",labelWithVocabLink(db,parentTdb,tdbsX[ixX],dimensionX->groupTag,label));
+ printf("<TH WIDTH='60'> %s </TH>",compositeLabelWithVocabLink(db,parentTdb,tdbsX[ixX],dimensionX->groupTag,label));
freeMem(label);
cntX++;
}
}
@@ -5697,13 +5732,13 @@
{
char objName[SMALLBUF];
printf("<TH ALIGN=%s nowrap colspan=2>",left?"RIGHT":"LEFT");
if(left)
- printf("%s ",labelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
+ printf("%s ",compositeLabelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
safef(objName, sizeof(objName), "plus_all_%s", dimensionY->tags[ixY]);
buttonsForOne( objName, dimensionY->tags[ixY] );
if(!left)
- printf(" %s",labelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
+ printf(" %s",compositeLabelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
puts("</TH>");
}
else if (dimensionX)
{
@@ -5711,9 +5746,9 @@
buttonsForAll();
puts("</TH>");
}
else if (left && dimensionY && childTdb != NULL)
- printf("<TH ALIGN=RIGHT nowrap>%s</TH>\n",labelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
+ printf("<TH ALIGN=RIGHT nowrap>%s</TH>\n",compositeLabelWithVocabLink(db,parentTdb,childTdb,dimensionY->groupTag,dimensionY->titles[ixY]));
}
static int displayABCdimensions(char *db,struct cart *cart, struct trackDb *parentTdb, struct slRef *subtrackRefList, membersForAll_t* membersForAll)
/* This will walk through all declared nonX&Y dimensions (X and Y is the 2D matrix of CBs.
@@ -5764,9 +5799,9 @@
safef(objName, sizeof(objName), "%s.mat_%s_dim%c_cb",parentTdb->track,membersForAll->members[ix]->tags[aIx], 'A' + (ix - dimA));
safef(javascript,sizeof(javascript),"onclick='matCbClick(this);' class=\"matCB abc %s\"",membersForAll->members[ix]->tags[aIx]);
// TODO Set classes properly (if needed!!!) The class abc works but what about a b or c?
cgiMakeCheckBoxJS(objName,alreadySet,javascript);
- printf("%s",labelWithVocabLink(db,parentTdb,tdbs[aIx],membersForAll->members[ix]->groupTag,membersForAll->members[ix]->titles[aIx]));
+ printf("%s",compositeLabelWithVocabLink(db,parentTdb,tdbs[aIx],membersForAll->members[ix]->groupTag,membersForAll->members[ix]->titles[aIx]));
puts("</TH>");
}
}
puts("</TR>");