~ubuntu-branches/ubuntu/jaunty/plotutils/jaunty

« back to all changes in this revision

Viewing changes to libplot/a_attribs.c

  • Committer: Bazaar Package Importer
  • Author(s): Floris Bruynooghe
  • Date: 2007-05-10 19:48:54 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070510194854-mrr3lgwzpxd8hovo
Tags: 2.5-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the GNU plotutils package.  Copyright (C) 1995,
 
2
   1996, 1997, 1998, 1999, 2000, 2005, 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
 
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
13
31
 
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 };
 
36
 
 
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 };
 
41
 
 
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 };
17
46
 
18
47
void
19
 
#ifdef _HAVE_PROTOS
20
 
_a_set_attributes (S___(Plotter *_plotter))
21
 
#else
22
 
_a_set_attributes (S___(_plotter))
23
 
     S___(Plotter *_plotter;)
24
 
#endif
 
48
_pl_a_set_attributes (S___(Plotter *_plotter))
25
49
{
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;  
33
57
  int i;
56
80
      _plotter->ai_join_style = desired_ai_join_style;
57
81
    }
58
82
 
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)
61
85
    {
62
86
      sprintf (_plotter->data->page->point, "%.4g M\n", desired_ai_miter_limit);
74
98
 
75
99
  if (_plotter->drawstate->dash_array_in_effect
76
100
      || _plotter->ai_line_type != desired_ai_line_type
77
 
      || (changed_width && desired_ai_line_type != L_SOLID))
 
101
      || (changed_width && desired_ai_line_type != PL_L_SOLID))
78
102
    /* must tell AI which dash array to use */
79
103
    {
80
104
      double *dashbuf;
97
121
              _matrix_sing_vals (_plotter->drawstate->transform.m, 
98
122
                                 &min_sing_val, &max_sing_val);
99
123
              
100
 
              dashbuf = (double *)_plot_xmalloc (num_dashes * sizeof(double));
 
124
              dashbuf = (double *)_pl_xmalloc (num_dashes * sizeof(double));
101
125
 
102
126
              for (i = 0; i < num_dashes; i++)
103
127
                {
124
148
      else
125
149
        /* dash array not in effect, have a canonical line type instead */
126
150
        {
127
 
          if (desired_ai_line_type == L_SOLID)
 
151
          if (desired_ai_line_type == PL_L_SOLID)
128
152
            {
129
153
              num_dashes = 0;
130
154
              dashbuf = NULL;
136
160
              double scale;
137
161
              
138
162
              num_dashes =
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));
141
165
 
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);
173
197
 
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;
178
202