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 #include "sys-defines.h"
20 #include "extern.h"
21 
22 bool
_pl_c_erase_page(S___ (Plotter * _plotter))23 _pl_c_erase_page (S___(Plotter *_plotter))
24 {
25   int i;
26 
27   /* reinitialize `font used' array(s) for this page */
28   for (i = 0; i < PL_NUM_PS_FONTS; i++)
29     _plotter->data->page->ps_font_used[i] = false;
30 
31   /* deallocate table of user-specified line types, if any */
32   if (_plotter->data->page->extra)
33     {
34       plCGMCustomLineType *linetype_ptr = (plCGMCustomLineType *)_plotter->data->page->extra;
35       plCGMCustomLineType *old_linetype_ptr;
36 
37       while (linetype_ptr)
38 	{
39 	  if (linetype_ptr->dash_array_len > 0 /* paranoia */
40 	      && linetype_ptr->dashes)
41 	    free (linetype_ptr->dashes);
42 	  old_linetype_ptr = linetype_ptr;
43 	  linetype_ptr = linetype_ptr->next;
44 	  free (old_linetype_ptr);
45 	}
46       _plotter->data->page->extra = (void *)NULL;
47     }
48 
49   /* reset other page-specific, i.e. picture-specific, CGMPlotter
50      variables, as if the page had just been opened */
51   _plotter->cgm_page_version = 1;
52   _plotter->cgm_page_profile = CGM_PROFILE_WEB;
53   _plotter->cgm_page_need_color = false;
54 	/* colors */
55   _plotter->cgm_line_color.red = -1;
56   _plotter->cgm_line_color.green = -1;
57   _plotter->cgm_line_color.blue = -1;
58   _plotter->cgm_edge_color.red = -1;
59   _plotter->cgm_edge_color.green = -1;
60   _plotter->cgm_edge_color.blue = -1;
61   _plotter->cgm_fillcolor.red = -1;
62   _plotter->cgm_fillcolor.green = -1;
63   _plotter->cgm_fillcolor.blue = -1;
64   _plotter->cgm_marker_color.red = -1;
65   _plotter->cgm_marker_color.green = -1;
66   _plotter->cgm_marker_color.blue = -1;
67   _plotter->cgm_text_color.red = -1;
68   _plotter->cgm_text_color.green = -1;
69   _plotter->cgm_text_color.blue = -1;
70   _plotter->cgm_bgcolor.red = -1;
71   _plotter->cgm_bgcolor.green = -1;
72   _plotter->cgm_bgcolor.blue = -1;
73 	/* other dynamic variables */
74   _plotter->cgm_line_type = CGM_L_SOLID;
75   _plotter->cgm_dash_offset = 0.0;
76   _plotter->cgm_join_style = CGM_JOIN_UNSPEC;
77   _plotter->cgm_cap_style = CGM_CAP_UNSPEC;
78   _plotter->cgm_dash_cap_style = CGM_CAP_UNSPEC;
79   	/* CGM's default line width: 1/1000 times the max VDC dimension */
80   _plotter->cgm_line_width = (1 << (8*CGM_BINARY_BYTES_PER_INTEGER - 3)) / 500;
81   _plotter->cgm_interior_style = CGM_INT_STYLE_HOLLOW;
82   _plotter->cgm_edge_type = CGM_L_SOLID;
83   _plotter->cgm_edge_dash_offset = 0.0;
84   _plotter->cgm_edge_join_style = CGM_JOIN_UNSPEC;
85   _plotter->cgm_edge_cap_style = CGM_CAP_UNSPEC;
86   _plotter->cgm_edge_dash_cap_style = CGM_CAP_UNSPEC;
87   	/* CGM's default edge width: 1/1000 times the max VDC dimension */
88   _plotter->cgm_edge_width = (1 << (8*CGM_BINARY_BYTES_PER_INTEGER - 3)) / 500;
89   _plotter->cgm_edge_is_visible = false;
90   _plotter->cgm_miter_limit = 32767.0;
91   _plotter->cgm_marker_type = CGM_M_ASTERISK;
92   	/* CGM's default marker size: 1/1000 times the max VDC dimension */
93   _plotter->cgm_marker_size = (1 << (8*CGM_BINARY_BYTES_PER_INTEGER - 3)) /500;
94   	/* label-related variables */
95   _plotter->cgm_char_height = -1; /* impossible (dummy) value */
96   _plotter->cgm_char_base_vector_x = 1;
97   _plotter->cgm_char_base_vector_y = 0;
98   _plotter->cgm_char_up_vector_x = 0;
99   _plotter->cgm_char_up_vector_y = 1;
100   _plotter->cgm_horizontal_text_alignment = CGM_ALIGN_NORMAL_HORIZONTAL;
101   _plotter->cgm_vertical_text_alignment = CGM_ALIGN_NORMAL_VERTICAL;
102   _plotter->cgm_font_id = -1;	/* impossible (dummy) value */
103   _plotter->cgm_charset_lower = 0; /* dummy value (we use values 1..4) */
104   _plotter->cgm_charset_upper = 0; /* dummy value (we use values 1..4) */
105   _plotter->cgm_restricted_text_type = CGM_RESTRICTED_TEXT_TYPE_BASIC;
106 
107   /* copy the bg color currently in the drawing state to the CGM-specific
108      part of the CGMPlotter; it'll be written to the output file at the
109      head of the picture */
110   _pl_c_set_bg_color (S___(_plotter));
111 
112   return true;
113 }
114