~ubuntu-branches/ubuntu/gutsy/plotutils/gutsy

« back to all changes in this revision

Viewing changes to libplot/g_miscmi.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 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 */
9
27
 
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 };
13
31
 
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 };
17
35
 
18
36
void
19
 
#ifdef _HAVE_PROTOS
20
 
_set_common_mi_attributes (plDrawState *drawstate, voidptr_t ptr)
21
 
#else
22
 
_set_common_mi_attributes (drawstate, ptr)
23
 
     plDrawState *drawstate;
24
 
     voidptr_t ptr;
25
 
#endif
 
37
_set_common_mi_attributes (plDrawState *drawstate, void * ptr)
26
38
{
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];
31
43
  int values [5];
32
 
  unsigned int local_dashbuf[MAX_DASH_ARRAY_LEN];
 
44
  unsigned int local_dashbuf[PL_MAX_DASH_ARRAY_LEN];
33
45
  miGC *pGC;
34
46
 
35
47
  pGC = (miGC *)ptr;            /* recover passed libxmi GC */
38
50
 
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;
80
92
            int array_len;
81
93
            
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 */
85
97
            else
86
98
              {
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;
89
101
              }
90
102
          }
131
143
  else
132
144
    /* have one of the canonical line types */
133
145
    {
134
 
      if (drawstate->line_type == L_SOLID)
 
146
      if (drawstate->line_type == PL_L_SOLID)
135
147
        {
136
148
          line_style = MI_LINE_SOLID;
137
149
          num_dashes = 0;
145
157
          
146
158
          line_style = MI_LINE_ON_OFF_DASH;
147
159
          num_dashes =
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 */
151
163
          offset = 0;
152
164