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
4 The GNU plotutils package is free software. You may redistribute it
5 and/or modify it under the terms of the GNU General Public License as
6 published by the Free Software foundation; either version 2, or (at your
7 option) any later version.
8
9 The GNU plotutils package is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with the GNU plotutils package; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
17 Boston, MA 02110-1301, USA. */
18
19 /* This version is used for CGMPlotters, which emit graphics only after all
20 pages of graphics have been drawn, and the Plotter is deleted. Such
21 Plotters maintain a linked list of pages (graphics are only written to
22 the output stream when a Plotter is deleted, and the appropriate
23 `terminate' method is invoked). */
24
25 #include "sys-defines.h"
26 #include "extern.h"
27
28 bool
_pl_c_end_page(S___ (Plotter * _plotter))29 _pl_c_end_page (S___(Plotter *_plotter))
30 {
31 int i, fullstrength, red, green, blue;
32
33 /* update CGM profile for this page to take into account number of
34 user-defined line types (nonzero only if output file can include
35 version-3 constructs; see c_attribs.c) */
36 {
37 plCGMCustomLineType *line_type_ptr = (plCGMCustomLineType *)_plotter->data->page->extra;
38 int num_line_types = 0;
39 bool violates_profile = false;
40
41 while (line_type_ptr != (plCGMCustomLineType *)NULL)
42 {
43 if (line_type_ptr->dash_array_len > CGM_PL_MAX_DASH_ARRAY_LENGTH)
44 violates_profile = true;
45 line_type_ptr = line_type_ptr->next;
46 num_line_types++;
47 }
48 if (num_line_types > CGM_MAX_CUSTOM_LINE_TYPES)
49 violates_profile = true;
50
51 if (violates_profile)
52 _plotter->cgm_page_profile =
53 IMAX(_plotter->cgm_page_profile, CGM_PROFILE_NONE);
54 }
55
56 /* update CGM version number for this page to take into account whether
57 fonts were used on it; if allowed version is >=3 then we'll emit
58 version-3 "FONT PROPERTIES" commands for every font (see c_defplot.c) */
59 if (_plotter->cgm_max_version >= 3)
60 {
61 for (i = 0; i < PL_NUM_PS_FONTS; i++)
62 {
63 if (_plotter->data->page->ps_font_used[i] == true)
64 {
65 _plotter->cgm_page_version = IMAX(_plotter->cgm_page_version, 3);
66 break;
67 }
68 }
69 }
70
71 /* update the CGM version number of the output file, and its profile
72 type, to take this page into account */
73 _plotter->cgm_version =
74 IMAX(_plotter->cgm_version, _plotter->cgm_page_version);
75 _plotter->cgm_profile =
76 IMAX(_plotter->cgm_profile, _plotter->cgm_page_profile);
77
78 /* Check whether a color other than black or white has been used on this
79 page: check the background color in particular (all other colors have
80 already been taken into account). */
81 red = _plotter->cgm_bgcolor.red;
82 green = _plotter->cgm_bgcolor.green;
83 blue = _plotter->cgm_bgcolor.blue;
84 fullstrength = (1 << (8 * CGM_BINARY_BYTES_PER_COLOR_COMPONENT)) - 1;
85 if ((red != 0 || green != 0 || blue != 0)
86 && (red != fullstrength || green != fullstrength || blue != fullstrength))
87 _plotter->cgm_page_need_color = true;
88
89 /* update `color needed' flag to take this page into account */
90 if (_plotter->cgm_page_need_color)
91 _plotter->cgm_need_color = true;
92
93 /* copy the background color from the CGM Plotter into the `bgcolor'
94 element of the plOutbuf for this page (we'll use it when writing the
95 page header into the CGM output file, see c_defplot.c) */
96 _plotter->data->page->bg_color = _plotter->cgm_bgcolor;
97 _plotter->data->page->bg_color_suppressed =
98 _plotter->cgm_bgcolor_suppressed; /* color is really "none"? */
99
100 return true;
101 }
102