home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 344b.lha / plplot_v2.6 / src / plstrl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-27  |  1020 b   |  48 lines

  1. /* Computes the length of a string in mm, including escape sequences  */
  2.  
  3. #include "plplot.h"
  4. #include <math.h>
  5.  
  6. PLFLT plstrl(string)
  7. char *string;
  8. {
  9.    short int *symbol;
  10.    SCHAR *xygrid;
  11.    PLINT ch, i, length, level;
  12.    PLFLT width, xorg, dscale, scale, def, ht;
  13.    PLFLT xscl, xoff, yscl, yoff;
  14.  
  15.    width = 0.0;
  16.    gchr(&def,&ht);
  17.    dscale = 0.05*ht;
  18.    scale = dscale;
  19.    gmp(&xscl,&xoff,&yscl,&yoff);
  20.  
  21.    pldeco(&symbol,&length,string);
  22.    xorg = 0.0;
  23.    level = 0;
  24.  
  25.    for (i=0; i<length; i++) {
  26.      ch = symbol[i];
  27.      if (ch == -1) {
  28.        level = level + 1;
  29.        scale = dscale * pow(0.75,(double)abs(level));
  30.      }
  31.      else if (ch == -2) {
  32.        level = level - 1;
  33.        scale = dscale * pow(0.75,(double)abs(level));
  34.      }
  35.      else if (ch == -3)
  36.        xorg = xorg - width * scale;
  37.      else if (ch == -4 || ch == -5)
  38.        ;
  39.      else {
  40.        if (plcvec(ch,&xygrid)) {
  41.          width = xygrid[3] - xygrid[2];
  42.          xorg = xorg + width*scale;
  43.        }
  44.      }
  45.    }
  46.    return((PLFLT)xorg);
  47. }
  48.