095484bc616cbbec0345db69e7e6b7f410676e40 galt Fri Dec 2 18:20:49 2011 -0800 added monospace font option to phyloGif diff --git src/hg/phyloGif/phyloGif.c src/hg/phyloGif/phyloGif.c index b1f8723..7db7a57 100644 --- src/hg/phyloGif/phyloGif.c +++ src/hg/phyloGif/phyloGif.c @@ -66,30 +66,31 @@ #include "errabort.h" #include "errCatch.h" struct cart *cart=NULL; /* The user's ui state. */ struct hash *oldVars = NULL; boolean onWeb = FALSE; int width=240,height=512; boolean branchLengths = FALSE; /* branch lengths */ boolean lengthLegend = FALSE; /* length ruler*/ boolean branchLabels = FALSE; /* labelled branch lengths */ boolean htmlPageWrapper = FALSE; /* wrap output in an html page */ boolean preserveUnderscores = FALSE; /* preserve underscores in input as spaces in output */ +boolean monospace = FALSE; /* use monospace font */ int branchDecimals = 2; /* show branch label length to two decimals by default */ int branchMultiplier = 1; /* multiply branch length by factor */ char *escapePattern = NULL; /* use to escape dash '-' char in input */ char layoutErrMsg[1024] = ""; /* Null terminated list of CGI Variables we don't want to save * permanently. */ char *excludeVars[] = {"Submit", "submit", "phyloGif_submit", "phyloGif_restore", NULL}; void usage(char *msg) /* Explain usage and exit. */ { errAbort( "%s\n\n" "phyloGif - parse and display phyloGenetic tree\n" @@ -104,30 +105,31 @@ " http://someserver.com/cgi-bin/phyloGif?phyloGif_tree=(A:0.1,B:0.1)\n" "Options/CGI-vars:\n" " -phyloGif_width=N - width of output GIF, default %d\n" " -phyloGif_height=N - height of output GIF, default %d\n" " -phyloGif_tree= - data in format (nodeA:0.5,nodeB:0.6):1.2;\n" " If running at the command-line, can put filename here or stdin\n" " (this is actually required)\n" " -phyloGif_branchLengths - use branch lengths for layout\n" " -phyloGif_lengthLegend - show length ruler at bottom\n" " -phyloGif_branchLabels - show length of branch as label\n" " (used with -phyloGif_branchLengths)\n" " -phyloGif_branchDecimals=N - show length of branch to N decimals, default %d\n" " -phyloGif_branchMultiplier=N - multiply branch length by N default %d\n" " -phyloGif_htmlPage - wrap the output in an html page (cgi only)\n" " -phyloGif_underscores - preserve underscores in input as spaces in output\n" + " -phyloGif_monospace - use a monospace proportional font\n" , msg, width, height, branchDecimals, branchMultiplier); } struct phyloLayout { int depth; /* leaves have depth=0 */ double vPos; /* vertical position */ double hPos; /* horizontal position */ }; void stripUnderscoreSuffixes(char *s) /* Strip out underscores in labels, modifies s. */ { @@ -351,92 +353,94 @@ htmlSetBackground(hBackgroundImage()); /* uses cfgOption */ /* this will cause it to kick out the set-cookie: http response header line */ cart = cartAndCookieNoContent(hUserCookie(), excludeVars, oldVars); } else { if (!cgiOptionalString("phyloGif_tree")) usage("-phyloGif_tree is a required 'option' or cgi variable."); } //cartWarnCatcher(doMiddle, cart, cartEarlyWarningHandler); useCart = (!cgiOptionalString("phyloGif_tree") || cgiVarExists("phyloGif_restore")); -MgFont *font = mgMediumBoldFont(); htmlPageWrapper = cgiVarExists("phyloGif_htmlPage"); /* wrap output in a page */ if (onWeb && sameString(getenv("REQUEST_METHOD"),"HEAD")) { /* tell browser it's static just so it can save it */ if (htmlPageWrapper) printf("Content-type: text/html\r\n"); else printf("Content-type: image/gif\r\n"); printf("\r\n"); return 0; } if (useCart) { width = cartUsualInt(cart,"phyloGif_width",width); height = cartUsualInt(cart,"phyloGif_height",height); phyloData = cloneString(cartOptionalString(cart,"phyloGif_tree")); branchLengths = cartVarExists(cart,"phyloGif_branchLengths"); lengthLegend = cartVarExists(cart,"phyloGif_lengthLegend"); branchLabels = cartVarExists(cart,"phyloGif_branchLabels"); branchDecimals = cartUsualInt(cart,"phyloGif_branchDecimals", branchDecimals); branchMultiplier = cartUsualInt(cart,"phyloGif_branchMultiplier", branchMultiplier); preserveUnderscores = cartVarExists(cart,"phyloGif_underscores"); + monospace = cartVarExists(cart, "phyloGif_monospace"); } else { width = cgiUsualInt("phyloGif_width",width); height = cgiUsualInt("phyloGif_height",height); phyloData = cloneString(cgiOptionalString("phyloGif_tree")); branchLengths = cgiVarExists("phyloGif_branchLengths"); lengthLegend = cgiVarExists("phyloGif_lengthLegend"); branchLabels = cgiVarExists("phyloGif_branchLabels"); branchDecimals = cgiUsualInt("phyloGif_branchDecimals", branchDecimals); branchMultiplier = cgiUsualInt("phyloGif_branchMultiplier", branchMultiplier); preserveUnderscores = cgiVarExists("phyloGif_underscores"); + monospace = cgiVarExists("phyloGif_monospace"); } if (useCart) { if (onWeb) { printf("Content-type: text/html\r\n"); printf("\r\n"); cartWebStart(cart, NULL, "%s", "phyloGif Interactive Phylogenetic Tree Gif Maker"); if (isMSIE) /* cannot handle long urls */ puts("