c_closepl.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. /* This version is used for CGMPlotters, which emit graphics only after all
  16. pages of graphics have been drawn, and the Plotter is deleted. Such
  17. Plotters maintain a linked list of pages (graphics are only written to
  18. the output stream when a Plotter is deleted, and the appropriate
  19. `terminate' method is invoked). */
  20. #include "sys-defines.h"
  21. #include "extern.h"
  22. bool
  23. _pl_c_end_page (S___(Plotter *_plotter))
  24. {
  25. int i, fullstrength, red, green, blue;
  26. /* update CGM profile for this page to take into account number of
  27. user-defined line types (nonzero only if output file can include
  28. version-3 constructs; see c_attribs.c) */
  29. {
  30. plCGMCustomLineType *line_type_ptr = (plCGMCustomLineType *)_plotter->data->page->extra;
  31. int num_line_types = 0;
  32. bool violates_profile = false;
  33. while (line_type_ptr != (plCGMCustomLineType *)NULL)
  34. {
  35. if (line_type_ptr->dash_array_len > CGM_PL_MAX_DASH_ARRAY_LENGTH)
  36. violates_profile = true;
  37. line_type_ptr = line_type_ptr->next;
  38. num_line_types++;
  39. }
  40. if (num_line_types > CGM_MAX_CUSTOM_LINE_TYPES)
  41. violates_profile = true;
  42. if (violates_profile)
  43. _plotter->cgm_page_profile =
  44. IMAX(_plotter->cgm_page_profile, CGM_PROFILE_NONE);
  45. }
  46. /* update CGM version number for this page to take into account whether
  47. fonts were used on it; if allowed version is >=3 then we'll emit
  48. version-3 "FONT PROPERTIES" commands for every font (see c_defplot.c) */
  49. if (_plotter->cgm_max_version >= 3)
  50. {
  51. for (i = 0; i < PL_NUM_PS_FONTS; i++)
  52. {
  53. if (_plotter->data->page->ps_font_used[i] == true)
  54. {
  55. _plotter->cgm_page_version = IMAX(_plotter->cgm_page_version, 3);
  56. break;
  57. }
  58. }
  59. }
  60. /* update the CGM version number of the output file, and its profile
  61. type, to take this page into account */
  62. _plotter->cgm_version =
  63. IMAX(_plotter->cgm_version, _plotter->cgm_page_version);
  64. _plotter->cgm_profile =
  65. IMAX(_plotter->cgm_profile, _plotter->cgm_page_profile);
  66. /* Check whether a color other than black or white has been used on this
  67. page: check the background color in particular (all other colors have
  68. already been taken into account). */
  69. red = _plotter->cgm_bgcolor.red;
  70. green = _plotter->cgm_bgcolor.green;
  71. blue = _plotter->cgm_bgcolor.blue;
  72. fullstrength = (1 << (8 * CGM_BINARY_BYTES_PER_COLOR_COMPONENT)) - 1;
  73. if ((red != 0 || green != 0 || blue != 0)
  74. && (red != fullstrength || green != fullstrength || blue != fullstrength))
  75. _plotter->cgm_page_need_color = true;
  76. /* update `color needed' flag to take this page into account */
  77. if (_plotter->cgm_page_need_color)
  78. _plotter->cgm_need_color = true;
  79. /* copy the background color from the CGM Plotter into the `bgcolor'
  80. element of the plOutbuf for this page (we'll use it when writing the
  81. page header into the CGM output file, see c_defplot.c) */
  82. _plotter->data->page->bg_color = _plotter->cgm_bgcolor;
  83. _plotter->data->page->bg_color_suppressed =
  84. _plotter->cgm_bgcolor_suppressed; /* color is really "none"? */
  85. return true;
  86. }