1
/* This file is part of the GNU plotutils package. Copyright (C) 1995,
2
1996, 1997, 1998, 1999, 2000, 2005, Free Software Foundation, Inc.
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.
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.
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. */
1
19
/* This internal method is invoked by an Illustrator Plotter before drawing
2
20
any object. It sets the relevant attributes (fill rule [if filling],
3
21
cap type, join type, miter limit, line width) to what they should be. */
8
26
/* Pseudo line type, which we use internally when AI's line type,
9
27
i.e. dashing style, is set to agree with what the user specifies with
10
28
linedash(), rather than with what the user specifies with linemod().
11
Should not equal any of our canonical line types, i.e. L_SOLID etc. */
29
Should not equal any of our canonical line types, i.e. PL_L_SOLID etc. */
12
30
#define SPECIAL_AI_LINE_TYPE 100
14
/* AI fill rule types (in version 5 and later), indexed into by our
15
internal fill rule number (FILL_ODD_WINDING/FILL_NONZERO_WINDING) */
16
const int _ai_fill_rule[] = { AI_FILL_ODD_WINDING, AI_FILL_NONZERO_WINDING };
32
/* AI fill rule types (in version 5 and later), indexed by our internal
33
fill rule number (PL_FILL_ODD_WINDING/PL_FILL_NONZERO_WINDING) */
34
static const int _ai_fill_rule[PL_NUM_FILL_RULES] =
35
{ AI_FILL_ODD_WINDING, AI_FILL_NONZERO_WINDING };
37
/* AI (i.e. PS) join styles, indexed by internal number
38
(miter/rd./bevel/triangular) */
39
static const int _ai_join_style[PL_NUM_JOIN_TYPES] =
40
{ AI_LINE_JOIN_MITER, AI_LINE_JOIN_ROUND, AI_LINE_JOIN_BEVEL, AI_LINE_JOIN_ROUND };
42
/* AI (i.e. PS) cap styles, indexed by internal number
43
(butt/rd./project/triangular) */
44
static const int _ai_cap_style[PL_NUM_CAP_TYPES] =
45
{ AI_LINE_CAP_BUTT, AI_LINE_CAP_ROUND, AI_LINE_CAP_PROJECT, AI_LINE_CAP_ROUND };
20
_a_set_attributes (S___(Plotter *_plotter))
22
_a_set_attributes (S___(_plotter))
23
S___(Plotter *_plotter;)
48
_pl_a_set_attributes (S___(Plotter *_plotter))
26
50
bool changed_width = false;
27
51
int desired_fill_rule = _ai_fill_rule[_plotter->drawstate->fill_rule_type];
28
52
double desired_ai_line_width = _plotter->drawstate->device_line_width;
29
int desired_ai_cap_style = _ps_cap_style[_plotter->drawstate->cap_type];
30
int desired_ai_join_style = _ps_join_style[_plotter->drawstate->join_type];
53
int desired_ai_cap_style = _ai_cap_style[_plotter->drawstate->cap_type];
54
int desired_ai_join_style = _ai_join_style[_plotter->drawstate->join_type];
31
55
double desired_ai_miter_limit = _plotter->drawstate->miter_limit;
32
56
int desired_ai_line_type = _plotter->drawstate->line_type;
56
80
_plotter->ai_join_style = desired_ai_join_style;
59
if (_plotter->drawstate->join_type == JOIN_MITER
83
if (_plotter->drawstate->join_type == PL_JOIN_MITER
60
84
&& _plotter->ai_miter_limit != desired_ai_miter_limit)
62
86
sprintf (_plotter->data->page->point, "%.4g M\n", desired_ai_miter_limit);
97
121
_matrix_sing_vals (_plotter->drawstate->transform.m,
98
122
&min_sing_val, &max_sing_val);
100
dashbuf = (double *)_plot_xmalloc (num_dashes * sizeof(double));
124
dashbuf = (double *)_pl_xmalloc (num_dashes * sizeof(double));
102
126
for (i = 0; i < num_dashes; i++)
139
_line_styles[_plotter->drawstate->line_type].dash_array_len;
140
dashbuf = (double *)_plot_xmalloc (num_dashes * sizeof(double));
163
_pl_g_line_styles[_plotter->drawstate->line_type].dash_array_len;
164
dashbuf = (double *)_pl_xmalloc (num_dashes * sizeof(double));
142
166
/* compute PS dash array for this line type */
143
dash_array = _line_styles[_plotter->drawstate->line_type].dash_array;
167
dash_array = _pl_g_line_styles[_plotter->drawstate->line_type].dash_array;
144
168
/* scale the array of integers by line width (actually by
145
169
floored line width; see comments at head of file) */
146
170
display_size_in_points =
147
171
DMIN(_plotter->data->xmax - _plotter->data->xmin,
148
172
_plotter->data->ymax - _plotter->data->ymin);
149
min_dash_unit = (MIN_DASH_UNIT_AS_FRACTION_OF_DISPLAY_SIZE
173
min_dash_unit = (PL_MIN_DASH_UNIT_AS_FRACTION_OF_DISPLAY_SIZE
150
174
* display_size_in_points);
151
175
scale = DMAX(min_dash_unit,
152
176
_plotter->drawstate->device_line_width);
172
196
_update_buffer (_plotter->data->page);
174
198
/* Update our knowledge of AI's line type (i.e. dashing style).
175
This new value will be one of L_SOLID etc., or the pseudo value
199
This new value will be one of PL_L_SOLID etc., or the pseudo value
176
200
SPECIAL_AI_LINE_TYPE. */
177
201
_plotter->ai_line_type = desired_ai_line_type;