pic.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #ifndef PI
  2. #define PI 3.1415926535897932384626433832795028841971693993751
  3. #endif
  4. #define MAXWID 8.5 /* default limits max picture to 8.5 x 11; */
  5. #define MAXHT 11 /* change to taste without peril */
  6. #define dprintf if(dbg)printf
  7. extern void yyerror(char *);
  8. extern char errbuf[200];
  9. #define ERROR sprintf(errbuf,
  10. #define FATAL ), yyerror(errbuf), exit(1)
  11. #define WARNING ), yyerror(errbuf)
  12. #define DEFAULT 0
  13. #define HEAD1 1
  14. #define HEAD2 2
  15. #define HEAD12 (HEAD1+HEAD2)
  16. #define INVIS 4
  17. #define CW_ARC 8 /* clockwise arc */
  18. #define DOTBIT 16 /* line styles */
  19. #define DASHBIT 32
  20. #define FILLBIT 64 /* gray-fill on boxes, etc. */
  21. #define NOEDGEBIT 128 /* no edge on filled object */
  22. #define CENTER 01 /* text attributes */
  23. #define LJUST 02
  24. #define RJUST 04
  25. #define ABOVE 010
  26. #define BELOW 020
  27. #define SPREAD 040
  28. #define SCALE 1.0 /* default scale: units/inch */
  29. #define WID 0.75 /* default width for boxes and ellipses */
  30. #define WID2 0.375
  31. #define HT 0.5 /* default height and line length */
  32. #define HT2 (HT/2)
  33. #define HT5 (HT/5)
  34. #define HT10 (HT/10)
  35. /* these have to be like so, so that we can write */
  36. /* things like R & V, etc. */
  37. #define H 0
  38. #define V 1
  39. #define R_DIR 0
  40. #define U_DIR 1
  41. #define L_DIR 2
  42. #define D_DIR 3
  43. #define ishor(n) (((n) & V) == 0)
  44. #define isvert(n) (((n) & V) != 0)
  45. #define isright(n) ((n) == R_DIR)
  46. #define isleft(n) ((n) == L_DIR)
  47. #define isdown(n) ((n) == D_DIR)
  48. #define isup(n) ((n) == U_DIR)
  49. typedef float ofloat; /* for o_val[] in obj; could be double */
  50. typedef struct obj { /* stores various things in variable length */
  51. int o_type;
  52. int o_count; /* number of things */
  53. int o_nobj; /* index in objlist */
  54. int o_mode; /* hor or vert */
  55. float o_x; /* coord of "center" */
  56. float o_y;
  57. int o_nt1; /* 1st index in text[] for this object */
  58. int o_nt2; /* 2nd; difference is #text strings */
  59. int o_attr; /* HEAD, CW, INVIS, etc., go here */
  60. int o_size; /* linesize */
  61. int o_nhead; /* arrowhead style */
  62. struct symtab *o_symtab; /* symtab for [...] */
  63. float o_ddval; /* value of dot/dash expression */
  64. float o_fillval; /* gray scale value */
  65. ofloat o_val[1]; /* actually this will be > 1 in general */
  66. /* type is not always FLOAT!!!! */
  67. } obj;
  68. typedef union { /* the yacc stack type */
  69. int i;
  70. char *p;
  71. obj *o;
  72. double f;
  73. struct symtab *st;
  74. } YYSTYPE;
  75. extern YYSTYPE yylval, yyval;
  76. struct symtab {
  77. char *s_name;
  78. int s_type;
  79. YYSTYPE s_val;
  80. struct symtab *s_next;
  81. };
  82. typedef struct { /* attribute of an object */
  83. int a_type;
  84. int a_sub;
  85. YYSTYPE a_val;
  86. } Attr;
  87. typedef struct {
  88. int t_type; /* CENTER, LJUST, etc. */
  89. char t_op; /* optional sign for size changes */
  90. char t_size; /* size, abs or rel */
  91. char *t_val;
  92. } Text;
  93. #define String 01
  94. #define Macro 02
  95. #define File 04
  96. #define Char 010
  97. #define Thru 020
  98. #define Free 040
  99. typedef struct { /* input source */
  100. int type; /* Macro, String, File */
  101. char *sp; /* if String or Macro */
  102. } Src;
  103. extern Src src[], *srcp; /* input source stack */
  104. typedef struct {
  105. FILE *fin;
  106. char *fname;
  107. int lineno;
  108. } Infile;
  109. extern Infile infile[], *curfile;
  110. #define MAXARGS 20
  111. typedef struct { /* argument stack */
  112. char *argstk[MAXARGS]; /* pointers to args */
  113. char *argval; /* points to space containing args */
  114. } Arg;
  115. extern int dbg;
  116. extern obj **objlist;
  117. extern int nobj, nobjlist;
  118. extern Attr *attr;
  119. extern int nattr, nattrlist;
  120. extern Text *text;
  121. extern int ntextlist;
  122. extern int ntext;
  123. extern int ntext1;
  124. extern double curx, cury;
  125. extern int hvmode;
  126. extern int codegen;
  127. extern char *PEstring;
  128. char *tostring(char *);
  129. char *grow(char *, char *, int, int);
  130. double getfval(char *), getcomp(obj *, int), getblkvar(obj *, char *);
  131. YYSTYPE getvar(char *);
  132. struct symtab *lookup(char *), *makevar(char *, int, YYSTYPE);
  133. char *ifstat(double, char *, char *), *delimstr(char *), *sprintgen(char *);
  134. void forloop(char *var, double from, double to, int op, double by, char *_str);
  135. int setdir(int), curdir(void);
  136. void resetvar(void);
  137. void checkscale(char *);
  138. void pushsrc(int, char *);
  139. void copy(void);
  140. void copyuntil(char *);
  141. void copyfile(char *);
  142. void copydef(struct symtab *);
  143. void definition(char *);
  144. struct symtab *copythru(char *);
  145. int input(void);
  146. int unput(int);
  147. void extreme(double, double);
  148. extern double deltx, delty;
  149. extern int lineno;
  150. extern int synerr;
  151. extern double xmin, ymin, xmax, ymax;
  152. obj *leftthing(int), *boxgen(void), *circgen(int), *arcgen(int);
  153. obj *linegen(int), *splinegen(void), *movegen(void);
  154. obj *textgen(void), *plotgen(void);
  155. obj *troffgen(char *), *rightthing(obj *, int), *blockgen(obj *, obj *);
  156. obj *makenode(int, int), *makepos(double, double);
  157. obj *fixpos(obj *, double, double);
  158. obj *addpos(obj *, obj *), *subpos(obj *, obj *);
  159. obj *makebetween(double, obj *, obj *);
  160. obj *getpos(obj *, int), *gethere(void), *getfirst(int, int);
  161. obj *getlast(int, int), *getblock(obj *, char *);
  162. void savetext(int, char *);
  163. void makeiattr(int, int);
  164. void makevattr(char *);
  165. void makefattr(int type, int sub, double f);
  166. void maketattr(int, char *);
  167. void makeoattr(int, obj *);
  168. void makeattr(int type, int sub, YYSTYPE val);
  169. void printexpr(double);
  170. void printpos(obj *);
  171. void exprsave(double);
  172. void addtattr(int);
  173. void printlf(int, char *);
  174. struct pushstack {
  175. double p_x;
  176. double p_y;
  177. int p_hvmode;
  178. double p_xmin;
  179. double p_ymin;
  180. double p_xmax;
  181. double p_ymax;
  182. struct symtab *p_symtab;
  183. };
  184. extern struct pushstack stack[];
  185. extern int nstack;
  186. extern int cw;
  187. extern double errcheck(double, char *);
  188. #define Log10(x) errcheck(log10(x), "log")
  189. #define Exp(x) errcheck(exp(x), "exp")
  190. #define Sqrt(x) errcheck(sqrt(x), "sqrt")