src/hg/hgTracks/hgTracks.c 1.1605
1.1605 2009/11/11 20:41:28 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/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1604
retrieving revision 1.1605
diff -b -B -U 4 -r1.1604 -r1.1605
--- src/hg/hgTracks/hgTracks.c 10 Nov 2009 05:48:17 -0000 1.1604
+++ src/hg/hgTracks/hgTracks.c 11 Nov 2009 20:41:28 -0000 1.1605
@@ -285,25 +285,25 @@
{
x = hvGfxAdjXW(hvg, x, width);
char *encodedName = cgiEncode(name);
-#ifdef IMAGEv2_UI
-if(curMap != NULL)
+if(theImgBox && curImgTrack)
{
char link[512];
safef(link,sizeof(link),"%s?%s=%u&g=%s",
hgTrackUiName(), cartSessionVarName(),cartSessionId(cart), encodedName);
char title[128];
safef(title,sizeof(title),"%s controls", shortLabel);
- mapSetItemAdd(curMap,link,title,x, y, x+width, y+height);
+ imgTrackAddMapItem(curImgTrack,link,title,x, y, x+width, y+height);
}
-#else//ifndef IMAGEv2_UI
-hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
-hPrintf("HREF=\"%s?%s=%u&c=%s&g=%s\"", hgTrackUiName(), cartSessionVarName(),
+else
+ {
+ hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
+ hPrintf("HREF=\"%s?%s=%u&c=%s&g=%s\"", hgTrackUiName(), cartSessionVarName(),
cartSessionId(cart), chromName, encodedName);
-mapStatusMessage("%s controls", shortLabel);
-hPrintf(">\n");
-#endif//ndef IMAGEv2_UI
+ mapStatusMessage("%s controls", shortLabel);
+ hPrintf(">\n");
+ }
freeMem(encodedName);
}
static void mapBoxToggleComplement(struct hvGfx *hvg, int x, int y, int width, int height,
@@ -313,26 +313,26 @@
* "complement" to complement the DNA bases at the top by the ruler*/
{
struct dyString *ui = uiStateUrlPart(toggleGroup);
x = hvGfxAdjXW(hvg, x, width);
-#ifdef IMAGEv2_UI
-if(curMap != NULL)
+if(theImgBox && curImgTrack)
{
char link[512];
safef(link,sizeof(link),"%s?complement_%s=%d&%s",
hgTracksName(), database, !cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE),ui->string);
- mapSetItemAdd(curMap,link,(char *)(message != NULL?message:NULL),x, y, x+width, y+height);
+ imgTrackAddMapItem(curImgTrack,link,(char *)(message != NULL?message:NULL),x, y, x+width, y+height);
}
-#else//ifndef IMAGEv2_UI
-hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
-hPrintf("HREF=\"%s?complement_%s=%d",
+else
+ {
+ hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
+ hPrintf("HREF=\"%s?complement_%s=%d",
hgTracksName(), database, !cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE));
-hPrintf("&%s\"", ui->string);
-freeDyString(&ui);
-if (message != NULL)
+ hPrintf("&%s\"", ui->string);
+ freeDyString(&ui);
+ if (message != NULL)
mapStatusMessage("%s", message);
-hPrintf(">\n");
-#endif//ndef IMAGEv2_UI
+ hPrintf(">\n");
+ }
}
void smallBreak()
/* Draw small horizontal break */
@@ -1243,9 +1243,10 @@
hvGfxNextItemButton(hvg, insideX + NEXT_ITEM_ARROW_BUFFER, y, arrowWidth, arrowWidth, labelColor, fillColor, FALSE);
safef(buttonText, ArraySize(buttonText), "hgt.prevItem=%s", track->mapName);
mapBoxReinvoke(hvg, insideX, y + 1, arrowButtonWidth, insideHeight, NULL,
NULL, 0, 0, (revCmplDisp ? "Next item" : "Prev item"), buttonText);
-mapBoxToggleVis(hvg, insideX + arrowButtonWidth, y + 1, insideWidth - (2 * arrowButtonWidth), insideHeight, parentTrack);
+mapBoxToggleVis(hvg, insideX + arrowButtonWidth, y + 1, insideWidth - (2 * arrowButtonWidth),
+ insideHeight, (theImgBox ? track : parentTrack));
safef(buttonText, ArraySize(buttonText), "hgt.nextItem=%s", track->mapName);
mapBoxReinvoke(hvg, insideX + insideWidth - arrowButtonWidth, y + 1, arrowButtonWidth, insideHeight, NULL,
NULL, 0, 0, (revCmplDisp ? "Prev item" : "Next item"), buttonText);
}
@@ -1270,10 +1271,10 @@
doLabelNextItemButtons(track, parentTrack, hvg, font, y, trackPastTabX,
trackPastTabWidth, fontHeight, insideHeight, labelColor);
}
else
- mapBoxToggleVis(hvg, trackPastTabX, y+1,
- trackPastTabWidth, insideHeight, parentTrack);
+ mapBoxToggleVis(hvg, trackPastTabX, y+1,trackPastTabWidth, insideHeight,
+ (theImgBox ? track : parentTrack));
y += fontHeight;
y += track->totalHeight(track, track->limitedVis);
}
return y;
@@ -1444,8 +1445,10 @@
else
{
if (isWithCenterLabels(subtrack))
y += fontHeight;
+ if(theImgBox && subtrack->limitedVis == tvDense)
+ mapBoxToggleVis(hvg, trackPastTabX, y, trackPastTabWidth, track->lineHeight, subtrack);
y += subtrack->totalHeight(subtrack, subtrack->limitedVis);
}
}
}
@@ -1573,12 +1576,12 @@
leftLabelX = gfxBorder;
leftLabelWidth = insideX - gfxBorder*3;
-#ifdef IMAGEv2_UI
struct image *theOneImg = NULL; // No need to be global, only the map needs to be global
//struct imgTrack *curImgTrack = NULL; // Make this global for now to avoid huge rewrite
struct imgSlice *curSlice = NULL; // No need to be global, only the map needs to be global
+struct mapSet *curMap = NULL; // Make this global for now to avoid huge rewrite
// Set up imgBox dimensions
int sideSliceWidth = 0; // Just being explicit
int dataSliceWidth = 0;
int sideSliceOffsetX = 0;
@@ -1615,9 +1618,8 @@
}
#endif//def IMAGEv2_DRAG_SCROLL
dataSliceWidth = tl.picWidth - sideSliceWidth;
}
-#endif//def IMAGEv2_UI
if (rulerMode != tvFull)
{
rulerCds = FALSE;
@@ -1730,16 +1732,13 @@
#else
trashDirFile(&gifTn, "hgt", "hgt", ".gif");
hvg = hvGfxOpenGif(pixWidth, pixHeight, gifTn.forCgi, FALSE);
#endif // USE_PNG
- #ifdef IMAGEv2_UI
if(theImgBox)
{
- // Adds one single image for all tracks (TODO: build the track by track images)
+ // Adds one single image for all tracks (COULD: build the track by track images)
theOneImg = imgBoxImageAdd(theImgBox,gifTn.forHtml,NULL,pixWidth, pixHeight,FALSE);
- //curMap = imgMapStart(theOneImg,"theOne",NULL); // TODO: Not using image map in favor of slice maps, so get rid of hPrintf(<MAP... below
}
- #endif//def IMAGEv2_UI
}
hvg->rc = revCmplDisp;
initColors(hvg);
@@ -1761,9 +1760,8 @@
/* draw button for Base Position pseudo-track */
int height = basePositionHeight;
if (rulerCds)
height += rulerTranslationHeight;
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// Mini-buttons (side label slice) for ruler
sliceHeight = height + 1;
@@ -1771,9 +1769,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel, not reorderable
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
drawGrayButtonBox(hvg, trackTabX, y, trackTabWidth, height, TRUE);
mapBoxTrackUi(hvg, trackTabX, y, trackTabWidth, height,
RULER_TRACK_NAME, RULER_TRACK_LABEL);
y += height + 1;
@@ -1798,9 +1795,8 @@
drawBlueButtonBox(hvg, trackTabX, yStart, trackTabWidth,
h, track->hasUi);
if (track->hasUi)
{
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// Mini-buttons (side label slice) for tracks
sliceHeight = h;
@@ -1808,9 +1804,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
mapBoxTrackUi(hvg, trackTabX, yStart, trackTabWidth, h,
track->mapName, track->shortLabel);
}
}
@@ -1828,9 +1823,8 @@
gfxBorder, pixHeight, lightRed);
y = gfxBorder;
if (rulerMode != tvHide)
{
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// side label slice for ruler
sliceHeight = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
@@ -1838,9 +1832,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel,not reorderable
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
if (baseTitle)
{
hvGfxTextRight(hvg, leftLabelX, y, leftLabelWidth-1, titleHeight,
MG_BLACK, font, WIN_TITLE_LABEL);
@@ -1896,9 +1889,8 @@
for (track = trackList; track != NULL; track = track->next)
{
if (track->limitedVis == tvHide)
continue;
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// side label slice for tracks
// FIXME: Notice I am treating all subtracks as indivisible from their composite
@@ -1909,9 +1901,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite
{
struct track *subtrack;
if (isWithCenterLabels(track))
@@ -1936,17 +1927,15 @@
/* Draw guidelines. */
if (withGuidelines)
{
- #ifdef IMAGEv2_UI
//if(theImgBox)
// TODO: We should be making transparent data images and a separate background img for guidelines.
// This will allow the guidelines to dragscroll while the center labels are static.
// NOTE: The background image could easily be a reusable file, based upon zoom level and width. Height could propbaby easily be stretched.
// struct image *bgImg = imgBoxImageAdd(theImgBox,gifBg.forHtml,
// (char *)(dragZooming?"click or drag mouse in base position track to zoom in" : NULL),
// pixWidth, pixHeight,FALSE);
- #endif//def IMAGEv2_UI
int height = pixHeight - 2*gfxBorder;
int x;
Color lightBlue = hvGfxFindRgb(hvg, &guidelineColor);
@@ -1960,9 +1949,8 @@
/* Show ruler at top. */
if (rulerMode != tvHide)
{
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// data slice for ruler
sliceHeight = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
@@ -1970,9 +1958,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,NULL,RULER_TRACK_NAME,rulerMode,FALSE,IMG_FIXEDPOS); // No tdb, no centerlabel,not reorderable
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,rulerTtl,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,RULER_TRACK_NAME,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
struct dnaSeq *seq = NULL;
int rulerClickY = 0;
rulerClickHeight = rulerHeight;
@@ -2188,12 +2175,11 @@
{
struct track *subtrack;
if (track->limitedVis == tvHide)
continue;
- #ifdef IMAGEv2_UI
- //if (isWithCenterLabels(track)) // NOTE: Since track may not have centerlabel but subtrack may (How?), then must always make this slice!
if(theImgBox)
{
+ //if (isWithCenterLabels(track)) // NOTE: Since track may not have centerlabel but subtrack may (How?), then must always make this slice!
// center label slice of tracks
// FIXME: Notice I am treating all subtracks as indivisible from their composite
// This will need to change to allow drag and drop. Until then the subtrack center labels will drag scroll while the composte will not.
// But as soon as subtracks are individual image tracks: problems with buttons, left labels, center labels, drag and drop, etc.
@@ -2202,14 +2188,12 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isCenter,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite
{
if (isWithCenterLabels(track))
y = doCenterLabels(track, track, hvg, font, y) - track->height; /* subtrack heights tallied below: */
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// Special case: data slice of tracks
// FIXME: This special case allows the subtrack center label map items to be put into the data slice
@@ -2218,9 +2202,8 @@
sliceOffsetY = y;
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
for (subtrack = track->subtracks; subtrack != NULL; subtrack = subtrack->next)
{
if (isSubtrackVisible(subtrack))
{
@@ -2246,9 +2229,8 @@
for (track = trackList; track != NULL; track = track->next)
{
if (track->limitedVis == tvHide)
continue;
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// data slice of tracks
// FIXME: Notice I am treating all subtracks as indivisible from their composite
@@ -2258,17 +2240,15 @@
sliceOffsetY = y + (isWithCenterLabels(track) ? fontHeight : 0);
char var[128]; // FIXME: The cart var should update the tracks and the sort should be on the tracks. This would allow printing the image
safef(var,sizeof(var),"%s_%s",track->tdb->tableName,IMG_ORDER_VAR);
int order = cartUsualInt(cart, var,IMG_ANYORDER);
- //warn("Found:%s has order:%d",var,order);
curImgTrack = imgBoxTrackUpdateOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),order);
if(sliceHeight > 0)
{
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isData,theOneImg,NULL,dataSliceWidth,sliceHeight,dataSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
}
- #endif//def IMAGEv2_UI
if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite
{
struct track *subtrack;
if (isWithCenterLabels(track))
@@ -2292,9 +2272,8 @@
for (track = trackList; track != NULL; track = track->next)
{
if (track->limitedVis == tvHide)
continue;
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// side label slice of tracks
// FIXME: Notice I am treating all subtracks as indivisible from their composite
@@ -2305,9 +2284,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
if (trackIsCompositeWithSubtracks(track)) //TODO: Change when tracks->subtracks are always set for composite
{
struct track *subtrack;
if (isWithCenterLabels(track))
@@ -2339,9 +2317,8 @@
for (track = trackList; track != NULL; track = track->next)
{
if (track->limitedVis != tvHide)
{
- #ifdef IMAGEv2_UI
if(theImgBox)
{
// Seems there are some left over side labels which need to be added here!
sliceHeight = trackPlusLabelHeight(track, fontHeight);
@@ -2349,9 +2326,8 @@
curImgTrack = imgBoxTrackFindOrAdd(theImgBox,track->tdb,NULL,track->limitedVis,isWithCenterLabels(track),IMG_ANYORDER);
curSlice = imgTrackSliceUpdateOrAdd(curImgTrack,isSide,theOneImg,NULL,sideSliceWidth,sliceHeight,sideSliceOffsetX,sliceOffsetY);
curMap = sliceMapFindOrStart(curSlice,track->tdb->tableName,NULL); // No common linkRoot
}
- #endif//def IMAGEv2_UI
y = doTrackMap(track, hvg, y, fontHeight, trackPastTabX, trackPastTabWidth);
}
}
@@ -2369,9 +2345,8 @@
}
/* Save out picture and tell html file about it. */
hvGfxClose(&hvg);
-#ifdef IMAGEv2_UI
if(theImgBox)
{
imageBoxDraw(theImgBox);
#ifdef IMAGEv2_DRAG_SCROLL
@@ -2385,9 +2360,8 @@
#endif//def IMAGEv2_DRAG_SCROLL
imgBoxFree(&theImgBox);
}
else
-#endif//def IMAGEv2_UI
{
char *titleAttr = dragZooming ? "title='click or drag mouse in base position track to zoom in'" : "";
hPrintf("<IMG SRC = \"%s\" BORDER=1 WIDTH=%d HEIGHT=%d USEMAP=#%s %s id='trackMap'",
gifTn.forHtml, pixWidth, pixHeight, mapName, titleAttr);
@@ -4008,8 +3982,9 @@
else if (cgiVarExists("hgt.prevItem"))
doNextPrevItem(FALSE, cgiUsualString("hgt.prevItem", NULL));
#ifdef IMAGEv2_UI
+// TODO: Check a cart variable to avoid creating theImgBox
if(!psOutput)
{
// Start an imagebox (global for now to avoid huge rewrite of hgTracks)
// Set up imgBox dimensions
@@ -4076,9 +4051,8 @@
}
}
}
-#ifdef IMAGEv2_UI
#ifdef IMAGEv2_DRAG_SCROLL
if(theImgBox)
{
// If a portal was established, then set the global dimensions back to the portal size
@@ -4088,9 +4062,8 @@
insideWidth = tl.picWidth-gfxBorder-insideX;
}
}
#endif//def IMAGEv2_DRAG_SCROLL
-#endif//def IMAGEv2_UI
/* Center everything from now on. */
hPrintf("<CENTER>\n");