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 /* For FigPlotter objects, we place all user-defined colors [``color
20    pseudo-objects''], which must appear first in the .fig file, in a header
21    for the page.
22 
23    Note that a Fig file may contain no more than a single page of graphics.
24    Later pages are simply deallocated by closepl(), even though we go to
25    som trouble to prepare them. */
26 
27 #include "sys-defines.h"
28 #include "extern.h"
29 
30 bool
_pl_f_end_page(S___ (Plotter * _plotter))31 _pl_f_end_page (S___(Plotter *_plotter))
32 {
33   int i;
34   const char *units;
35   plOutbuf *fig_header;
36 
37   /* prepare Fig header, write it to a plOutbuf */
38   fig_header = _new_outbuf ();
39 
40   units = (_plotter->data->page_data->metric ? "Metric" : "Inches");
41   sprintf (fig_header->point,
42 	   "#FIG 3.2\n%s\n%s\n%s\n%s\n%.2f\n%s\n%d\n%d %d\n",
43 	   "Portrait",		/* portrait mode, not landscape */
44 	   "Flush Left",	/* justification */
45 	   units,		/* "Metric" or "Inches" */
46 	   _plotter->data->page_data->fig_name, /* paper size */
47 	   100.00,		/* export and print magnification */
48 	   "Single",		/* "Single" or "Multiple" pages */
49 	   -2,			/* color number for transparent color */
50 	   IROUND(FIG_UNITS_PER_INCH), /* Fig units per inch */
51 	   2			/* origin in lower left corner (ignored) */
52 	   );
53   _update_buffer (fig_header);
54 
55   /* output user-defined colors if any */
56   for (i = 0; i < _plotter->fig_num_usercolors; i++)
57     {
58       sprintf (fig_header->point,
59 	       "#COLOR\n%d %d #%06lx\n",
60 	       0,	               /* color pseudo-object */
61 	       FIG_USER_COLOR_MIN + i, /* color num, in xfig's range */
62 	       _plotter->fig_usercolors[i] /* 24-bit RGB value */
63 	       );
64       _update_buffer (fig_header);
65     }
66 
67   /* place header in the plOutbuf for the page */
68   _plotter->data->page->header = fig_header;
69 
70   return true;
71 }
72