src/hg/hgTracks/hgTracks.c 1.1595
1.1595 2009/08/27 00:10:15 tdreszer
Fixed a couple bugs and ensured ps-pdf code still works with IMAGEv2
Index: src/hg/hgTracks/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1594
retrieving revision 1.1595
diff -b -B -U 4 -r1.1594 -r1.1595
--- src/hg/hgTracks/hgTracks.c 25 Aug 2009 05:58:18 -0000 1.1594
+++ src/hg/hgTracks/hgTracks.c 27 Aug 2009 00:10:15 -0000 1.1595
@@ -288,13 +288,12 @@
#ifdef IMAGEv2_UI
if(curMap != NULL)
{
char link[512];
- safef(link,sizeof(link),"%s?%s=%u&c=%s&g=%s",
- hgTrackUiName(), cartSessionVarName(),cartSessionId(cart), chromName, encodedName);
+ safef(link,sizeof(link),"%s?%s=%u&g=%s",
+ hgTrackUiName(), cartSessionVarName(),cartSessionId(cart), encodedName);
char title[128];
safef(title,sizeof(title),"%s controls", shortLabel);
- // Add map item to currnent map (TODO: pass in map)
mapSetItemAdd(curMap,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);
@@ -319,9 +318,8 @@
{
char link[512];
safef(link,sizeof(link),"%s?complement_%s=%d&%s",
hgTracksName(), database, !cartUsualBooleanDb(cart, database, COMPLEMENT_BASES_VAR, FALSE),ui->string);
- // Add map item to currnent map (TODO: pass in map)
mapSetItemAdd(curMap,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);
@@ -1582,29 +1580,39 @@
int sideSliceOffsetX = 0;
int dataSliceOffsetX = 0;
int sliceHeight = 0;
int sliceOffsetY = 0;
-if (withLeftLabels)
+char *rulerTtl = NULL;
+// theImgBox is a global for now to avoid huge rewrite of hgTracks. It is started prior to this in doTrackForm()
+//theImgBox = imgBoxStart(database,chromName,winStart,winEnd,(!revCmplDisp),sideSliceWidth,pixWidth);
+if(theImgBox)
+ {
+ if (withLeftLabels)
{
sideSliceWidth = leftLabelWidth + 2;
sideSliceOffsetX = (revCmplDisp?(tl.picWidth - sideSliceWidth): 0);
}
-dataSliceOffsetX = (revCmplDisp?0:sideSliceWidth);
-char *rulerTtl = (dragZooming?"drag select or click to zoom":"click to zoom 3x");//"click or drag mouse in base position track to zoom in" : NULL);
-// theImgBox is a global for now to avoid huge rewrite of hgTracks. It is started prior to this in doTrackForm()
-//theImgBox = imgBoxStart(database,chromName,winStart,winEnd,(!revCmplDisp),sideSliceWidth,pixWidth);
-#ifdef IMAGEv2_USE_PORTAL
-// If a portal was established, then set the global dimensions to the entire image size
-if(imgBoxPortalDimensions(theImgBox,&winStart,&winEnd,&(tl.picWidth),NULL,NULL,NULL,NULL,NULL))
+ dataSliceOffsetX = (revCmplDisp?0:sideSliceWidth);
+
+ rulerTtl = (dragZooming?"drag select or click to zoom":"click to zoom 3x");//"click or drag mouse in base position track to zoom in" : NULL);
+ hPrintf("<input type='hidden' name='db' value='%s'>\n", database);
+ hPrintf("<input type='hidden' name='c' value='%s'>\n", chromName);
+ hPrintf("<input type='hidden' name='l' value='%d'>\n", winStart);
+ hPrintf("<input type='hidden' name='r' value='%d'>\n", winEnd);
+ hPrintf("<input type='hidden' name='pix' value='%d'>\n", tl.picWidth);
+ #ifdef IMAGEv2_USE_PORTAL
+ // If a portal was established, then set the global dimensions to the entire image size
+ if(imgBoxPortalDimensions(theImgBox,&winStart,&winEnd,&(tl.picWidth),NULL,NULL,NULL,NULL,NULL))
{
pixWidth = tl.picWidth;
winBaseCount = winEnd - winStart;
insideWidth = tl.picWidth-gfxBorder-insideX;
if (withLeftLabels)
sideSliceOffsetX = (revCmplDisp?(tl.picWidth - sideSliceWidth): 0);
}
-#endif//def IMAGEv2_USE_PORTAL
-dataSliceWidth = tl.picWidth - sideSliceWidth;
+ #endif//def IMAGEv2_USE_PORTAL
+ dataSliceWidth = tl.picWidth - sideSliceWidth;
+ }
#endif//def IMAGEv2_UI
if (rulerMode != tvFull)
{
@@ -1719,11 +1727,14 @@
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)
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);
@@ -1747,8 +1758,9 @@
int height = basePositionHeight;
if (rulerCds)
height += rulerTranslationHeight;
#ifdef IMAGEv2_UI
+ if(theImgBox)
{
// Mini-buttons (side label slice) for ruler
sliceHeight = height + 1;
sliceOffsetY = 0;
@@ -1783,14 +1795,17 @@
h, track->hasUi);
if (track->hasUi)
{
#ifdef IMAGEv2_UI
+ if(theImgBox)
+ {
// Mini-buttons (side label slice) for tracks
sliceHeight = h;
sliceOffsetY = yStart;
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);
}
@@ -1810,8 +1825,9 @@
y = gfxBorder;
if (rulerMode != tvHide)
{
#ifdef IMAGEv2_UI
+ if(theImgBox)
{
// side label slice for ruler
sliceHeight = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
sliceOffsetY = 0;
@@ -1877,8 +1893,9 @@
{
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
// This will need to change to allow drag and drop. Until then the subtrack center labels will drag scroll while the composte will not.
@@ -1916,8 +1933,9 @@
/* 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,
@@ -1939,8 +1957,9 @@
/* Show ruler at top. */
if (rulerMode != tvHide)
{
#ifdef IMAGEv2_UI
+ if(theImgBox)
{
// data slice for ruler
sliceHeight = basePositionHeight + (rulerCds ? rulerTranslationHeight : 0) + 1;
sliceOffsetY = 0;
@@ -2167,8 +2186,9 @@
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)
{
// 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.
@@ -2184,8 +2204,9 @@
{
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
// When subtracks are carved up into individual imgTracks, then this will not be necessary
@@ -2222,8 +2243,9 @@
{
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
// This will need to change to allow drag and drop. Until then the subtrack center labels will drag scroll while the composte will not.
@@ -2267,8 +2289,9 @@
{
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
// This will need to change to allow drag and drop. Until then the subtrack center labels will drag scroll while the composte will not.
@@ -2311,10 +2334,23 @@
y = yAfterRuler;
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);
+ sliceOffsetY = y;
+ 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);
}
+ }
/* Finish map. */
hPrintf("</MAP>\n");
@@ -2330,25 +2366,30 @@
/* Save out picture and tell html file about it. */
hvGfxClose(&hvg);
#ifdef IMAGEv2_UI
-imageBoxDraw(theImgBox);
-#ifdef IMAGEv2_USE_PORTAL
-// If a portal was established, then set the global dimensions back to the portal size
-if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL))
+if(theImgBox)
+ {
+ imageBoxDraw(theImgBox);
+ #ifdef IMAGEv2_USE_PORTAL
+ // If a portal was established, then set the global dimensions back to the portal size
+ if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL))
{
pixWidth = tl.picWidth;
winBaseCount = winEnd - winStart;
insideWidth = tl.picWidth-gfxBorder-insideX;
}
-#endif//def IMAGEv2_USE_PORTAL
-imgBoxFree(&theImgBox);
-#else//ifndef 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'",
+ #endif//def IMAGEv2_USE_PORTAL
+ 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);
-hPrintf("><BR>\n");
-#endif//ndef IMAGEv2_UI
+ hPrintf("><BR>\n");
+ }
}
static void printEnsemblAnchor(char *database, char* archive,
char *chrName, int start, int end)
@@ -3924,23 +3965,26 @@
else if (cgiVarExists("hgt.prevItem"))
doNextPrevItem(FALSE, cgiUsualString("hgt.prevItem", NULL));
#ifdef IMAGEv2_UI
-// Start an imagebox (global for now to avoid huge rewrite of hgTracks)
-// Set up imgBox dimensions
-int sideSliceWidth = 0; // Just being explicit
-if (withLeftLabels)
+if(!psOutput)
+ {
+ // Start an imagebox (global for now to avoid huge rewrite of hgTracks)
+ // Set up imgBox dimensions
+ int sideSliceWidth = 0; // Just being explicit
+ if (withLeftLabels)
sideSliceWidth = (insideX - gfxBorder*3) + 2;
-theImgBox = imgBoxStart(database,chromName,winStart,winEnd,(!revCmplDisp),sideSliceWidth,tl.picWidth);
-#ifdef IMAGEv2_USE_PORTAL
-// Define a portal with a default expansion size, then set the global dimensions to the full image size
-if(imgBoxPortalDefine(theImgBox,&winStart,&winEnd,&(tl.picWidth),0))
+ theImgBox = imgBoxStart(database,chromName,winStart,winEnd,(!revCmplDisp),sideSliceWidth,tl.picWidth);
+ #ifdef IMAGEv2_USE_PORTAL
+ // Define a portal with a default expansion size, then set the global dimensions to the full image size
+ if(imgBoxPortalDefine(theImgBox,&winStart,&winEnd,&(tl.picWidth),0))
{
winBaseCount = winEnd - winStart;
insideWidth = tl.picWidth-gfxBorder-insideX;
}
-#endif//def IMAGEv2_USE_PORTAL
-#endif//def IMAGEv2_UI
+ #endif//def IMAGEv2_USE_PORTAL
+ }
+ #endif//def IMAGEv2_UI
/* Tell tracks to load their items. */
for (track = trackList; track != NULL; track = track->next)
{
/* adjust track visibility based on supertrack just before load loop */
@@ -3991,14 +4035,17 @@
}
#ifdef IMAGEv2_UI
#ifdef IMAGEv2_USE_PORTAL
-// If a portal was established, then set the global dimensions back to the portal size
-if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL))
+if(theImgBox)
+ {
+ // If a portal was established, then set the global dimensions back to the portal size
+ if(imgBoxPortalDimensions(theImgBox,NULL,NULL,NULL,NULL,&winStart,&winEnd,&(tl.picWidth),NULL))
{
winBaseCount = winEnd - winStart;
insideWidth = tl.picWidth-gfxBorder-insideX;
}
+ }
#endif//def IMAGEv2_USE_PORTAL
#endif//def IMAGEv2_UI
/* Center everything from now on. */
hPrintf("<CENTER>\n");