src/hg/hgTracks/hgTracks.c 1.1582

1.1582 2009/07/10 19:48:17 tdreszer
Next rouund of imageV2 development. dragScroll is working.
Index: src/hg/hgTracks/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1581
retrieving revision 1.1582
diff -b -B -U 4 -r1.1581 -r1.1582
--- src/hg/hgTracks/hgTracks.c	10 Jul 2009 01:42:21 -0000	1.1581
+++ src/hg/hgTracks/hgTracks.c	10 Jul 2009 19:48:17 -0000	1.1582
@@ -1563,18 +1563,43 @@
 trackHash = newHash(8);
 /* Figure out dimensions and allocate drawing space. */
 pixWidth = tl.picWidth;
 
+leftLabelX = gfxBorder;
+leftLabelWidth = insideX - gfxBorder*3;
+
 #ifdef IMAGEv2_UI
-// Start an imagebox (temproarily global in order to avoid massive changes)
-theImgBox = imgBoxStart(database,chromName,winStart,winEnd,(!revCmplDisp),withLeftLabels,pixWidth);
+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
+// Set up imgBox dimensions
 int sideSliceWidth  = 0;   // Just being explicit
 int dataSliceWidth  = 0;
 int sideSliceOffsetX = 0;
 int dataSliceOffsetX = 0;
 int sliceHeight  = 0;
 int sliceOffsetY = 0;
+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))
+    {
+    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_UI
 
 if (rulerMode != tvFull)
     {
@@ -1685,12 +1710,10 @@
     trashDirFile(&gifTn, "hgt", "hgt", ".gif");
     hvg = hvGfxOpenGif(pixWidth, pixHeight, gifTn.forCgi);
     #ifdef IMAGEv2_UI
     // Adds one single image for all tracks (TODO: build the track by track images)
-    theOneImg = imgBoxImageAdd(theImgBox,gifTn.forHtml,NULL,
-       // (char *)(dragZooming?"click or drag mouse in base position track to zoom in" : NULL),
-        pixWidth, pixHeight,FALSE);
-    //curMap = imgMapStart(theOneImg,"theOne",NULL); // No common linkRoot (TODO: Drop image map in favor of slice maps)
+    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);
@@ -1700,23 +1723,8 @@
 
 /* Find colors to draw in. */
 findTrackColors(hvg, trackList);
 
-leftLabelX = gfxBorder;
-leftLabelWidth = insideX - gfxBorder*3;
-
-#ifdef IMAGEv2_UI
-if (withLeftLabels)
-    {
-    sideSliceWidth   = leftLabelWidth + 2;   // Just being explicit
-    sideSliceOffsetX = (revCmplDisp?(tl.picWidth - sideSliceWidth): 0);
-    }
-dataSliceWidth   = tl.picWidth - sideSliceWidth;
-dataSliceOffsetX = (revCmplDisp?0:sideSliceWidth);
-// FIXME: Up top I could create new beg/end and then widen winStart, winEnd and pixWidth. It will take some playing with.
-imgBoxDefinePortal(theImgBox,winStart,winEnd,dataSliceWidth);
-#endif//def IMAGEv2_UI
-
 /* Draw mini-buttons. */
 if (withLeftLabels && psOutput == NULL)
     {
     int butOff;
@@ -2313,8 +2321,17 @@
 /* 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))
+    {
+    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'",
@@ -3827,8 +3844,24 @@
     doNextPrevItem(TRUE, cgiUsualString("hgt.nextItem", NULL));
 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)
+    sideSliceWidth   = leftLabelWidth + 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))
+    {
+    winBaseCount = winEnd - winStart;
+    insideWidth = tl.picWidth-gfxBorder-insideX;
+    }
+#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 */
@@ -3876,8 +3909,18 @@
             }
         }
     }
 
+#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))
+    {
+    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");