common.h 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. // The common_output class: subclassed from the output class,
  16. // providing support for dotting/dashing and for rounded boxes.
  17. // The output class is defined in output.h.
  18. class common_output : public output
  19. {
  20. public:
  21. // basic interface, implemented in concrete classes rather than here
  22. virtual void start_picture (double sc, const position &ll, const position &ur) = 0;
  23. virtual void finish_picture () = 0;
  24. // draw objects (not implemented here)
  25. virtual void arc (const position &start, const position &cent,
  26. const position &end, const line_type &lt) = 0;
  27. virtual void circle (const position &cent, double rad,
  28. const line_type &lt, double fill) = 0;
  29. virtual void ellipse (const position &cent, const distance &dim,
  30. const line_type &lt, double fill) = 0;
  31. virtual void line (const position &start, const position *v, int n,
  32. const line_type &lt) = 0;
  33. virtual void polygon (const position *v, int n,
  34. const line_type &lt, double fill) = 0;
  35. virtual void spline (const position &start, const position *v, int n,
  36. const line_type &lt) = 0;
  37. virtual void text (const position &center, text_piece *v, int n,
  38. double angle) = 0;
  39. // draw objects (implemented here)
  40. virtual void rounded_box (const position &cent, const distance &dim,
  41. double rad, const line_type &lt, double fill);
  42. protected:
  43. /* implemented in concrete classes (used for dotting lines by hand) */
  44. virtual void dot (const position &cent, const line_type &lt) = 0;
  45. /* implemented in terms of arc (); can be overridden (e.g. in tex_output) */
  46. virtual void solid_arc (const position &cent, double rad, double start_angle,
  47. double end_angle, const line_type &lt);
  48. /* dashing and dotting `by hand' (used by troff_output, not tex_output) */
  49. void dashed_circle (const position &cent, double rad, const line_type &lt);
  50. void dotted_circle (const position &cent, double rad, const line_type &lt);
  51. void dashed_arc (const position &start, const position &cent,
  52. const position &end, const line_type &lt);
  53. void dotted_arc (const position &start, const position &cent,
  54. const position &end, const line_type &lt);
  55. void dashed_rounded_box (const position &cent, const distance &dim,
  56. double rad, const line_type &lt);
  57. void dotted_rounded_box (const position &cent, const distance &dim,
  58. double rad, const line_type &lt);
  59. void solid_rounded_box (const position &cent, const distance &dim,
  60. double rad, const line_type &lt);
  61. void filled_rounded_box (const position &cent, const distance &dim,
  62. double rad, double fill);
  63. private:
  64. void dash_line (const position &start, const position &end,
  65. const line_type &lt, double dash_width, double gap_width,
  66. double *offsetp);
  67. void dash_arc (const position &cent, double rad,
  68. double start_angle, double end_angle, const line_type &lt,
  69. double dash_width, double gap_width, double *offsetp);
  70. void dot_line (const position &start, const position &end,
  71. const line_type &lt, double gap_width, double *offsetp);
  72. void dot_arc (const position &cent, double rad,
  73. double start_angle, double end_angle, const line_type &lt,
  74. double gap_width, double *offsetp);
  75. };
  76. // not private because TeX driver uses this
  77. int compute_arc_center (const position &start, const position &cent, const position &end, position *result);