home *** CD-ROM | disk | FTP | other *** search
- /* Computes the length of a string in mm, including escape sequences */
-
- #include "plplot.h"
- #include <math.h>
-
- PLFLT plstrl(string)
- char *string;
- {
- short int *symbol;
- SCHAR *xygrid;
- PLINT ch, i, length, level;
- PLFLT width, xorg, dscale, scale, def, ht;
- PLFLT 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[3] - xygrid[2];
- xorg = xorg + width*scale;
- }
- }
- }
- return((PLFLT)xorg);
- }
-