src/hg/hgTracks/imageV2.c 1.9

1.9 2009/09/04 18:25:50 tdreszer
Changes for imgTbl withot dragReorder or dragScroll
Index: src/hg/hgTracks/imageV2.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/imageV2.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -B -U 4 -r1.8 -r1.9
--- src/hg/hgTracks/imageV2.c	27 Aug 2009 16:38:51 -0000	1.8
+++ src/hg/hgTracks/imageV2.c	4 Sep 2009 18:25:50 -0000	1.9
@@ -637,17 +637,17 @@
    the new chromStart,chromEnd and imgWidth are returned as OUTs, while the portal becomes the initial defined size
    returns TRUE if successfully defined as having a portal */
 {
 if( (int)imageMultiple == 0)
-    imageMultiple = 3;
+    imageMultiple = IMAGEv2_DRAG_SCROLL_SZ;
 
 imgBox->portalStart = imgBox->chromStart;
 imgBox->portalEnd   = imgBox->chromEnd;
 imgBox->portalWidth = imgBox->width - imgBox->sideLabelWidth;
 imgBox->showPortal  = FALSE; // Guilty until proven innocent
 
 int positionWidth = (int)((imgBox->portalEnd - imgBox->portalStart) * imageMultiple);
-*chromStart = imgBox->chromStart - (int)(positionWidth/imageMultiple);
+*chromStart = imgBox->portalStart - (int)(((imageMultiple - 1)/2) * (imgBox->portalEnd - imgBox->portalStart));
 if( *chromStart < 0)
     *chromStart = 0;
 *chromEnd = *chromStart + positionWidth;
 struct chromInfo *chrInfo = hGetChromInfo(imgBox->db,imgBox->chrom);
@@ -664,20 +664,27 @@
     if (*chromStart < 0)
         *chromStart = 0;
     }
 // TODO: Normalize to power of 10 boundary
+// Normalize portal ends
+int diff = *chromStart - imgBox->portalStart;
+if(diff < 10 && diff > -10)
+    *chromStart = imgBox->portalStart;
+diff = *chromEnd - imgBox->portalEnd;
+if(diff < 10 && diff > -10)
+    *chromEnd = imgBox->portalEnd;
+
 double growthOfImage = (*chromEnd - *chromStart)/(imgBox->portalEnd - imgBox->portalStart);
 *imgWidth = (imgBox->portalWidth * growthOfImage) + imgBox->sideLabelWidth;
 
-if(imgBox->portalStart <  *chromStart || imgBox->portalStart >= *chromEnd
-|| imgBox->portalEnd   <= *chromStart || imgBox->portalEnd   >  *chromEnd
-|| imgBox->portalWidth >= *imgWidth)
-    {
-    *imgWidth   = imgBox->width;  // Undo damage
-    *chromStart = imgBox->chromStart;
-    *chromEnd   = imgBox->chromEnd;
-    return FALSE;
-    }
+//if(imgBox->portalStart < *chromStart || imgBox->portalEnd > *chromEnd
+//|| imgBox->portalWidth > *imgWidth)
+//    {
+//    *imgWidth   = imgBox->width;  // Undo damage
+//    *chromStart = imgBox->chromStart;
+//    *chromEnd   = imgBox->chromEnd;
+//    return FALSE;
+//    }
 imgBox->width      = *imgWidth;
 imgBox->chromStart = *chromStart;
 imgBox->chromEnd   = *chromEnd;
 imgBox->basesPerPixel = ((double)imgBox->chromEnd - imgBox->chromStart)/(imgBox->width - imgBox->sideLabelWidth);
@@ -1013,23 +1020,20 @@
     width=imgBox->portalWidth;
     }
 
 hPrintf(" <div style='width:%dpx; height:%dpx; overflow:hidden;'",width,slice->height);
+#ifdef IMAGEv2_DRAG_SCROLL
 if(imgBox->showPortal && slice->type==isData)
     {
     if(scrollHandle)
         hPrintf(" class='panDiv scroller'");
     else
         hPrintf(" class='panDiv'");
     }
+#endif //def IMAGEv2_DRAG_SCROLL
 hPrintf(">\n");
 
 struct mapSet *map = sliceGetMap(slice,FALSE); // Could be the image map or slice specific
-//#define NO_MAP_SCROLLER
-#ifdef NO_MAP_SCROLLER
-if(imgBox->showPortal && scrollHandle)
-    map = NULL;
-#endif//def NO_MAP_SCROLLER
 if(map)
     imageMapDraw(map,name);
 
 hPrintf("  <IMG id='img_%s' src='%s' style='position:relative; left:-%dpx; top: -%dpx; border:0;'",
@@ -1040,10 +1044,12 @@
 if(slice->type==isSide)
     hPrintf(" class='sideLab'");
 else if(slice->type==isCenter)
     hPrintf(" class='centerLab'");
+#ifdef IMAGEv2_DRAG_SCROLL
 else if(slice->type==isData && imgBox->showPortal)
     hPrintf(" class='panImg' ondrag='{return false;}'");
+#endif //def IMAGEv2_DRAG_SCROLL
 //hPrintf(" title='[%s] width:%d  height: %d  offsetX: %d  offsetY: %d'",
 //        sliceTypeToString(slice->type),slice->width,slice->height,slice->offsetX,slice->offsetY);
 if(slice->title != NULL)
     hPrintf(" title='%s'",slice->title);           // Adds slice wide title
@@ -1073,8 +1079,9 @@
 #endif//def IMAGEv2_DRAG_REORDER
 hPrintf("div.dragZoom {cursor: text;}\n");
 hPrintf("</style>\n");
 
+#ifdef IMAGEv2_DRAG_SCROLL
 if(imgBox->showPortal)
     {
     hPrintf("<script type='text/javascript'>var imgBoxPortal=true;");
     hPrintf("var imgBoxChromStart=%d;var imgBoxChromEnd=%d;var imgBoxWidth=%d;",
@@ -1083,14 +1090,10 @@
             imgBox->portalStart, imgBox->portalEnd, imgBox->portalWidth);
     hPrintf("var imgBoxLeftLabel=%d;var imgBoxPortalOffsetX=%d;var imgBoxBasesPerPixel=%lf;</script>\n",
             (imgBox->plusStrand?imgBox->sideLabelWidth:0),
             (int)((imgBox->portalStart - imgBox->chromStart) / imgBox->basesPerPixel),imgBox->basesPerPixel);
-    //warn("image(%d-%d,%d)\nportal(%d-%d,%d)\nleftLimit:%d offsetX:%d basesPerPixel:%g",
-    //        imgBox->chromStart, imgBox->chromEnd,(imgBox->width - imgBox->sideLabelWidth),
-    //        imgBox->portalStart, imgBox->portalEnd, imgBox->portalWidth,
-    //        (imgBox->plusStrand?imgBox->sideLabelWidth:0),
-    //        (int)((imgBox->portalStart - imgBox->chromStart) / imgBox->basesPerPixel),imgBox->basesPerPixel);
     }
+#endif//def IMAGEv2_DRAG_SCROLL
 
 hPrintf("<TABLE id='imgTbl' border=0 cellspacing=0 cellpadding=0");
 hPrintf(" width=%d",imgBox->showPortal?(imgBox->portalWidth+imgBox->sideLabelWidth):imgBox->width);
 #ifdef IMAGEv2_DRAG_REORDER