src/hg/hgTracks/hgTracks.c 1.1589
1.1589 2009/08/17 21:27:43 angie
Added support for new trackDb setting maxWindowToDraw: if winEnd-winStart>maxWindowToDraw, don't load or draw items, just print out a message telling the user how close they must zoom in to see items.
Index: src/hg/hgTracks/hgTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/hgTracks.c,v
retrieving revision 1.1588
retrieving revision 1.1589
diff -b -B -U 4 -r1.1588 -r1.1589
--- src/hg/hgTracks/hgTracks.c 14 Aug 2009 07:18:53 -0000 1.1588
+++ src/hg/hgTracks/hgTracks.c 17 Aug 2009 21:27:43 -0000 1.1589
@@ -3786,8 +3786,56 @@
uglyTime("Pruned redundant vis from cart");
}
}
+static int getMaxWindowToDraw(struct trackDb *tdb)
+/* If trackDb setting maxWindowToDraw exists and is a sensible size, return it, else 0. */
+{
+if (tdb == NULL)
+ return 0;
+char *maxWinToDraw = trackDbSetting(tdb, "maxWindowToDraw");
+if (isNotEmpty(maxWinToDraw))
+ {
+ unsigned maxWTD = sqlUnsigned(maxWinToDraw);
+ if (maxWTD > 1)
+ return maxWTD;
+ }
+return 0;
+}
+
+static void drawMaxWindowWarning(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg,
+ int xOff, int yOff, int width, MgFont *font, Color color,
+ enum trackVisibility vis)
+/* This is a stub drawItems handler to be swapped in for the usual drawItems when the window
+ * size is larger than the threshold specified by trackDb setting maxWindowToDraw. */
+{
+// draw no-data-yellow single-height box
+int maxWinToDraw = getMaxWindowToDraw(tg->tdb);
+char commafied[256];
+sprintLongWithCommas(commafied, maxWinToDraw);
+char message[512];
+safef(message, sizeof(message), "zoom in to <= %s bases to view items", commafied);
+Color yellow = hvGfxFindRgb(hvg, &undefinedYellowColor);
+hvGfxBox(hvg, xOff, yOff, width, tg->heightPer, yellow);
+hvGfxTextCentered(hvg, xOff, yOff, width, tg->heightPer, MG_BLACK, font, message);
+}
+
+static boolean maxWindowSizeExceeded(struct track *tg)
+/* If (winEnd - winStart) > trackDb setting maxWindowToDraw, force track to a dense line
+ * that will ask the user to zoom in closer to see track items and return TRUE so caller
+ * can skip loading items. */
+{
+int maxWinToDraw = getMaxWindowToDraw(tg->tdb);
+if (maxWinToDraw > 1 && (winEnd - winStart) > maxWinToDraw)
+ {
+ tg->drawItems = drawMaxWindowWarning;
+ tg->limitedVis = tvDense;
+ tg->limitedVisSet = TRUE;
+ return TRUE;
+ }
+return FALSE;
+}
+
void doTrackForm(char *psOutput, struct tempName *ideoTn)
/* Make the tracks display form with the zoom/scroll buttons and the active
* image. If the ideoTn parameter is not NULL, it is filled in if the
* ideogram is created. */
@@ -3884,8 +3932,9 @@
else if (track->visibility != tvHide)
{
if (measureTiming)
lastTime = clock1000();
+ if (! maxWindowSizeExceeded(track))
track->loadItems(track);
if (measureTiming)
{
@@ -3963,12 +4012,12 @@
hPrintf("<INPUT TYPE=IMAGE BORDER=0 NAME=\"hgt.dummyEnterButton\" src=\"../images/DOT.gif\">");
/* Put up scroll and zoom controls. */
hWrites("move ");
hButtonWithMsg("hgt.left3", "<<<", "move 95% to the left");
- hButtonWithMsg("hgt.left2", " <<", "move 45% to the left");
+ hButtonWithMsg("hgt.left2", " <<", "move 47.5% to the left");
hButtonWithMsg("hgt.left1", " < ", "move 10% to the left");
hButtonWithMsg("hgt.right1", " > ", "move 10% to the right");
- hButtonWithMsg("hgt.right2", ">> ", "move 45% to the right");
+ hButtonWithMsg("hgt.right2", ">> ", "move 47.5% to the right");
hButtonWithMsg("hgt.right3", ">>>", "move 95% to the right");
hWrites(" zoom in ");
/* use button maker that determines padding, so we can share constants */
topButton("hgt.in1", ZOOM_1PT5X);