home *** CD-ROM | disk | FTP | other *** search
- /* Computes the length of a string in mm, including escape sequences */
-
- #include "plplot.h"
- #include <math.h>
-
- float plstrl(string)
- char *string;
- {
- int symbol[256];
- short int xygrid[300];
- int ch, i, length, level;
- float width, xorg, dscale, scale, def, ht;
- float xscl, xoff, yscl, yoff;
-
- width = 0.0;
- gchr(&def,&ht);
- dscale = 0.05*ht;
- scale = dscale;
- gmp(&xscl,&xoff,&yscl,&yoff);
-
- pldeco(symbol,&length,string);
- xorg = 0.0;
- level = 0;
-
- for (i=0; i<length; i++) {
- ch = symbol[i];
- if (ch == -1) {
- level = level + 1;
- scale = dscale * pow(0.75,(double)abs(level));
- }
- else if (ch == -2) {
- level = level - 1;
- scale = dscale * pow(0.75,(double)abs(level));
- }
- else if (ch == -3)
- xorg = xorg - width * scale;
- else if (ch == -4 || ch == -5)
- ;
- else {
- if (plcvec(ch,xygrid)) {
- width = xygrid[4] - xygrid[3];
- xorg = xorg + width*scale;
- }
- }
- }
- return(xorg);
- }
-