output.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // The output class: almost pure virtual (a protocol class), but
  2. // see some definitions in object.cc.
  3. struct line_type
  4. {
  5. enum { invisible, solid, dotted, dashed } type;
  6. double dash_width; // or inter-dot spacing, for dotted lines
  7. double thickness; // line thickness in points
  8. // ctor
  9. line_type();
  10. };
  11. class output
  12. {
  13. public:
  14. // ctor, dtor
  15. output();
  16. virtual ~output();
  17. // interface: implemented in toto in each concrete output class
  18. virtual void start_picture (double sc, const position &ll, const position &ur) = 0;
  19. virtual void finish_picture (void) = 0;
  20. virtual void arc (const position &start, const position &cent,
  21. const position &end, const line_type &lt) = 0;
  22. virtual void circle (const position &cent, double rad,
  23. const line_type &lt, double fill) = 0;
  24. virtual void ellipse (const position &cent, const distance &dim,
  25. const line_type &lt, double fill) = 0;
  26. virtual void line (const position &start, const position *v, int n,
  27. const line_type &lt) = 0;
  28. virtual void polygon (const position *v, int n,
  29. const line_type &lt, double fill) = 0;
  30. virtual void spline (const position &start, const position *v, int n,
  31. const line_type &lt) = 0;
  32. virtual void text (const position &center, text_piece *v, int n,
  33. double angle) = 0;
  34. virtual void rounded_box (const position &cent, const distance &dim,
  35. double rad, const line_type &lt, double fill) = 0;
  36. // no-ops, can optionally be overridden
  37. virtual void command (const char *s, const char *filename, int lineno);
  38. virtual void set_location (const char *filename, int lineno);
  39. // returns 0 (false), can optionally be overridden
  40. virtual int supports_filled_polygons (void);
  41. // no-ops; can optionally be overridden
  42. virtual void begin_block (const position &ll, const position &ur);
  43. virtual void end_block (void);
  44. // not overridable; related to scaling
  45. void set_desired_width_height (double wid, double ht);
  46. void set_args (const char *);
  47. protected:
  48. char *args;
  49. double desired_height; // zero if no height specified
  50. double desired_width; // zero if no depth specified
  51. double compute_scale (double sc, const position &ll, const position &ur);
  52. };
  53. // A global; we have only one of these. Its member function are what do
  54. // the output of objects of various kinds (they're invoked by the
  55. // objects' `print' operations). Defined in main.cc.
  56. extern output *out;
  57. #define TROFF_SUPPORT 0
  58. #define TEX_SUPPORT 0
  59. #define PLOT_SUPPORT 1
  60. #ifdef TROFF_SUPPORT
  61. output *make_troff_output (void);
  62. #endif
  63. #ifdef TEX_SUPPORT
  64. output *make_tex_output (void);
  65. output *make_tpic_output (void);
  66. #endif
  67. #ifdef PLOT_SUPPORT
  68. output *make_plot_output (void);
  69. extern char *output_format;
  70. extern char *font_name;
  71. extern char *pen_color_name;
  72. extern double font_size;
  73. extern double line_width;
  74. extern int precision_dashing;
  75. #endif