src/hg/hgTracks/imageV2.c 1.16
1.16 2009/12/05 01:29:01 larrym
CONTEXT_MENU stuff; mostly turned off, except map area id's are live
Index: src/hg/hgTracks/imageV2.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/imageV2.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -b -B -U 4 -r1.15 -r1.16
--- src/hg/hgTracks/imageV2.c 2 Dec 2009 21:19:45 -0000 1.15
+++ src/hg/hgTracks/imageV2.c 5 Dec 2009 01:29:01 -0000 1.16
@@ -70,9 +70,9 @@
}
return NULL;
}
-struct mapItem *mapSetItemUpdate(struct mapSet *map,struct mapItem *item,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY)
+struct mapItem *mapSetItemUpdate(struct mapSet *map,struct mapItem *item,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY,char *id)
/* Update a single mapItem */
{
if(title != NULL)
item->title = cloneString(title);
@@ -86,12 +86,14 @@
item->topLeftX = topLeftX;
item->topLeftY = topLeftY;
item->bottomRightX = bottomRightX;
item->bottomRightY = bottomRightY;
+freeMem(item->id);
+item->id = cloneString(id);
return item;
}
-struct mapItem *mapSetItemAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY)
+struct mapItem *mapSetItemAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id)
/* Add a single mapItem to a growing mapSet */
{
struct mapItem *item;
AllocVar(item);
@@ -107,31 +109,32 @@
item->topLeftX = topLeftX;
item->topLeftY = topLeftY;
item->bottomRightX = bottomRightX;
item->bottomRightY = bottomRightY;
+item->id = cloneString(id);
slAddHead(&(map->items),item);
//warn("Added map(%s) item '%s' count:%d",map->name,title,slCount(map->items));
return map->items;
}
-struct mapItem *mapSetItemUpdateOrAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY)
+struct mapItem *mapSetItemUpdateOrAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id)
/* Update or add a single mapItem */
{
struct mapItem *item = mapSetItemFind(map,topLeftX,topLeftY,bottomRightX,bottomRightY);
if(item != NULL)
- return mapSetItemUpdate(map,item,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY);
+ return mapSetItemUpdate(map,item,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY, id);
else
- return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY);
+ return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY, id);
}
-struct mapItem *mapSetItemFindOrAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY)
+struct mapItem *mapSetItemFindOrAdd(struct mapSet *map,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id)
/* Finds or adds the map item */
{
struct mapItem *item = mapSetItemFind(map,topLeftX,topLeftY,bottomRightX,bottomRightY);
if(item != NULL)
return item;
else
- return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY);
+ return mapSetItemAdd(map,link,title,topLeftX,topLeftY,bottomRightX,bottomRightY,id);
}
void mapItemFree(struct mapItem **pItem)
/* frees all memory assocated with a single mapItem */
@@ -142,8 +145,10 @@
if(item->title != NULL)
freeMem(item->title);
if(item->linkVar != NULL)
freeMem(item->linkVar);
+ if(item->id != NULL)
+ freeMem(item->id);
freeMem(item);
*pItem = NULL;
}
}
@@ -567,9 +572,9 @@
return NULL;
return sliceGetMap(slice,FALSE); // Map could belong to image or could be slice specific
}
-int imgTrackAddMapItem(struct imgTrack *imgTrack,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY)
+int imgTrackAddMapItem(struct imgTrack *imgTrack,char *link,char *title,int topLeftX,int topLeftY,int bottomRightX,int bottomRightY, char *id)
/* Will add a map item it an imgTrack's appropriate slice's map
Since a map item may span slices, the imgTrack is in the best position to determine where to put the map item
returns count of map items added, which could be 0, 1 or more than one if item spans slices
NOTE: Precedence is given to first map item when adding items with same coordinates! */
@@ -594,9 +599,9 @@
{
struct mapSet *map = sliceGetMap(slice,FALSE);
if(map!=NULL)
{ // NOTE: using find or add gives precedence to first of same coordinate map items added
- mapSetItemFindOrAdd(map,link,title,max(topLeftX,slice->offsetX),max(topLeftY,slice->offsetY),min(bottomRightX,slice->offsetX + slice->width),min(bottomRightY,slice->offsetY + slice->height));
+ mapSetItemFindOrAdd(map,link,title,max(topLeftX,slice->offsetX),max(topLeftY,slice->offsetY),min(bottomRightX,slice->offsetX + slice->width),min(bottomRightY,slice->offsetY + slice->height), id);
count++;
}
}
}
@@ -1100,8 +1105,10 @@
warn("map item has no url!");
if(item->title != NULL)
hPrintf(" TITLE='%s'", item->title );
+ if(item->id != NULL)
+ hPrintf(" id='%s'", item->id);
hPrintf(">\n" );
}
hPrintf(" </MAP>\n");
}