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 file contains a function called by Bitmap Plotters (including PNM
2
20
Plotters), and GIF Plotters, just before drawing. It sets the
3
21
attributes in the graphics context (of type `miGC') used by the libxmi
8
26
#include "xmi.h" /* use libxmi scan conversion module */
10
28
/* libxmi joinstyles, indexed by internal number (miter/rd./bevel/triangular)*/
11
static const int _mi_join_style[] =
29
static const int mi_join_style[] =
12
30
{ MI_JOIN_MITER, MI_JOIN_ROUND, MI_JOIN_BEVEL, MI_JOIN_TRIANGULAR };
14
32
/* libxmi capstyles, indexed by internal number (butt/rd./project/triangular)*/
15
static const int _mi_cap_style[] =
33
static const int mi_cap_style[] =
16
34
{ MI_CAP_BUTT, MI_CAP_ROUND, MI_CAP_PROJECTING, MI_CAP_TRIANGULAR };
20
_set_common_mi_attributes (plDrawState *drawstate, voidptr_t ptr)
22
_set_common_mi_attributes (drawstate, ptr)
23
plDrawState *drawstate;
37
_set_common_mi_attributes (plDrawState *drawstate, void * ptr)
27
39
int line_style, num_dashes, offset;
28
40
unsigned int *dashbuf;
29
41
bool dash_array_allocated = false;
30
42
miGCAttribute attributes[5];
32
unsigned int local_dashbuf[MAX_DASH_ARRAY_LEN];
44
unsigned int local_dashbuf[PL_MAX_DASH_ARRAY_LEN];
35
47
pGC = (miGC *)ptr; /* recover passed libxmi GC */
39
51
/* set five integer-valued miGC attributes */
40
52
attributes[0] = MI_GC_FILL_RULE;
41
values[0] = (drawstate->fill_rule_type == FILL_NONZERO_WINDING ?
53
values[0] = (drawstate->fill_rule_type == PL_FILL_NONZERO_WINDING ?
42
54
MI_WINDING_RULE : MI_EVEN_ODD_RULE);
43
55
attributes[1] = MI_GC_JOIN_STYLE;
44
values[1] = _mi_join_style[drawstate->join_type];
56
values[1] = mi_join_style[drawstate->join_type];
45
57
attributes[2] = MI_GC_CAP_STYLE;
46
values[2] = _mi_cap_style[drawstate->cap_type];
58
values[2] = mi_cap_style[drawstate->cap_type];
47
59
attributes[3] = MI_GC_ARC_MODE;
48
60
values[3] = MI_ARC_CHORD; /* libplot convention */
49
61
attributes[4] = MI_GC_LINE_WIDTH;
82
94
array_len = (odd_length ? 2 : 1) * num_dashes;
83
if (array_len <= MAX_DASH_ARRAY_LEN)
95
if (array_len <= PL_MAX_DASH_ARRAY_LEN)
84
96
dashbuf = local_dashbuf; /* use dash buffer on stack */
87
dashbuf = (unsigned int *)_plot_xmalloc (array_len * sizeof(unsigned int));
99
dashbuf = (unsigned int *)_pl_xmalloc (array_len * sizeof(unsigned int));
88
100
dash_array_allocated = true;
146
158
line_style = MI_LINE_ON_OFF_DASH;
148
_line_styles[drawstate->line_type].dash_array_len;
149
dash_array = _line_styles[drawstate->line_type].dash_array;
160
_pl_g_line_styles[drawstate->line_type].dash_array_len;
161
dash_array = _pl_g_line_styles[drawstate->line_type].dash_array;
150
162
dashbuf = local_dashbuf; /* it is large enough */