/contrib/groff/src/preproc/pic/object.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 225 lines · 177 code · 27 blank · 21 comment · 0 complexity · adf20dc40319b15f73eb272de185a3c1 MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
  3. Free Software Foundation, Inc.
  4. Written by James Clark (jjc@jclark.com)
  5. This file is part of groff.
  6. groff is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with groff; see the file COPYING. If not, write to the Free Software
  16. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  17. struct place;
  18. enum object_type {
  19. OTHER_OBJECT,
  20. BOX_OBJECT,
  21. CIRCLE_OBJECT,
  22. ELLIPSE_OBJECT,
  23. ARC_OBJECT,
  24. SPLINE_OBJECT,
  25. LINE_OBJECT,
  26. ARROW_OBJECT,
  27. MOVE_OBJECT,
  28. TEXT_OBJECT,
  29. BLOCK_OBJECT,
  30. MARK_OBJECT
  31. };
  32. struct bounding_box;
  33. struct object {
  34. object *prev;
  35. object *next;
  36. object();
  37. virtual ~object();
  38. virtual position origin();
  39. virtual double width();
  40. virtual double radius();
  41. virtual double height();
  42. virtual position north();
  43. virtual position south();
  44. virtual position east();
  45. virtual position west();
  46. virtual position north_east();
  47. virtual position north_west();
  48. virtual position south_east();
  49. virtual position south_west();
  50. virtual position start();
  51. virtual position end();
  52. virtual position center();
  53. virtual place *find_label(const char *);
  54. virtual void move_by(const position &);
  55. virtual int blank();
  56. virtual void update_bounding_box(bounding_box *);
  57. virtual object_type type() = 0;
  58. virtual void print();
  59. virtual void print_text();
  60. };
  61. typedef position (object::*corner)();
  62. struct place {
  63. object *obj;
  64. double x, y;
  65. };
  66. struct string_list;
  67. class path {
  68. position pos;
  69. corner crn;
  70. string_list *label_list;
  71. path *ypath;
  72. int is_position;
  73. public:
  74. path(corner = 0);
  75. path(position);
  76. path(char *, corner = 0);
  77. ~path();
  78. void append(corner);
  79. void append(char *);
  80. void set_ypath(path *);
  81. int follow(const place &, place *) const;
  82. };
  83. struct object_list {
  84. object *head;
  85. object *tail;
  86. object_list();
  87. void append(object *);
  88. void wrap_up_block(object_list *);
  89. };
  90. declare_ptable(place)
  91. // these go counterclockwise
  92. enum direction {
  93. RIGHT_DIRECTION,
  94. UP_DIRECTION,
  95. LEFT_DIRECTION,
  96. DOWN_DIRECTION
  97. };
  98. struct graphics_state {
  99. double x, y;
  100. direction dir;
  101. };
  102. struct saved_state : public graphics_state {
  103. saved_state *prev;
  104. PTABLE(place) *tbl;
  105. };
  106. struct text_item {
  107. text_item *next;
  108. char *text;
  109. adjustment adj;
  110. const char *filename;
  111. int lineno;
  112. text_item(char *, const char *, int);
  113. ~text_item();
  114. };
  115. const unsigned long IS_DOTTED = 01;
  116. const unsigned long IS_DASHED = 02;
  117. const unsigned long IS_CLOCKWISE = 04;
  118. const unsigned long IS_INVISIBLE = 020;
  119. const unsigned long HAS_LEFT_ARROW_HEAD = 040;
  120. const unsigned long HAS_RIGHT_ARROW_HEAD = 0100;
  121. const unsigned long HAS_SEGMENT = 0200;
  122. const unsigned long IS_SAME = 0400;
  123. const unsigned long HAS_FROM = 01000;
  124. const unsigned long HAS_AT = 02000;
  125. const unsigned long HAS_WITH = 04000;
  126. const unsigned long HAS_HEIGHT = 010000;
  127. const unsigned long HAS_WIDTH = 020000;
  128. const unsigned long HAS_RADIUS = 040000;
  129. const unsigned long HAS_TO = 0100000;
  130. const unsigned long IS_CHOPPED = 0200000;
  131. const unsigned long IS_DEFAULT_CHOPPED = 0400000;
  132. const unsigned long HAS_THICKNESS = 01000000;
  133. const unsigned long IS_FILLED = 02000000;
  134. const unsigned long IS_DEFAULT_FILLED = 04000000;
  135. const unsigned long IS_ALIGNED = 010000000;
  136. const unsigned long IS_SHADED = 020000000;
  137. const unsigned long IS_OUTLINED = 040000000;
  138. struct segment {
  139. int is_absolute;
  140. position pos;
  141. segment *next;
  142. segment(const position &, int, segment *);
  143. };
  144. class rectangle_object;
  145. class graphic_object;
  146. class linear_object;
  147. struct object_spec {
  148. unsigned long flags;
  149. object_type type;
  150. object_list oblist;
  151. PTABLE(place) *tbl;
  152. double dash_width;
  153. position from;
  154. position to;
  155. position at;
  156. position by;
  157. path *with;
  158. text_item *text;
  159. double height;
  160. double radius;
  161. double width;
  162. double segment_width;
  163. double segment_height;
  164. double start_chop;
  165. double end_chop;
  166. double thickness;
  167. double fill;
  168. char *shaded;
  169. char *outlined;
  170. direction dir;
  171. segment *segment_list;
  172. position segment_pos;
  173. int segment_is_absolute;
  174. object_spec(object_type);
  175. ~object_spec();
  176. object *make_object(position *, direction *);
  177. graphic_object *make_box(position *, direction *);
  178. graphic_object *make_block(position *, direction *);
  179. graphic_object *make_text(position *, direction *);
  180. graphic_object *make_ellipse(position *, direction *);
  181. graphic_object *make_circle(position *, direction *);
  182. linear_object *make_line(position *, direction *);
  183. linear_object *make_arc(position *, direction *);
  184. graphic_object *make_linear(position *, direction *);
  185. graphic_object *make_move(position *, direction *);
  186. int position_rectangle(rectangle_object *p, position *curpos,
  187. direction *dirp);
  188. };
  189. object *make_object(object_spec *, position *, direction *);
  190. object *make_mark_object();
  191. object *make_command_object(char *, const char *, int);
  192. int lookup_variable(const char *name, double *val);
  193. void define_variable(const char *name, double val);
  194. void print_picture(object *);