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

« back to all changes in this revision

Viewing changes to libplot/g_outbuf.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 routines for creating, manipulating, and deleting a
2
20
   special sort of output buffer: a plOutbuf.  They are invoked by drawing
3
21
   methods for Plotters that do not do real-time output.  Such Plotters
36
54
#define NEW_OUTBUF_LEN(old_outbuf_len) ((old_outbuf_len) < 10000000 ? 2 * (old_outbuf_len) : (old_outbuf_len) + 10000000)
37
55
 
38
56
plOutbuf *
39
 
#ifdef _HAVE_PROTOS
40
57
_new_outbuf (void)
41
 
#else
42
 
_new_outbuf ()
43
 
#endif
44
58
{
45
59
  plOutbuf *bufp;
46
60
 
47
 
  bufp = (plOutbuf *)_plot_xmalloc(sizeof(plOutbuf));
 
61
  bufp = (plOutbuf *)_pl_xmalloc(sizeof(plOutbuf));
48
62
  bufp->header = (plOutbuf *)NULL;
49
63
  bufp->trailer = (plOutbuf *)NULL;
50
 
  bufp->base = (char *)_plot_xmalloc(INITIAL_OUTBUF_LEN * sizeof(char));
 
64
  bufp->base = (char *)_pl_xmalloc(INITIAL_OUTBUF_LEN * sizeof(char));
51
65
  bufp->len = (unsigned long)INITIAL_OUTBUF_LEN;
52
66
  bufp->next = NULL;
53
67
  bufp->reset_point = bufp->base;
58
72
}
59
73
 
60
74
void
61
 
#ifdef _HAVE_PROTOS
62
75
_reset_outbuf (plOutbuf *bufp)
63
 
#else
64
 
_reset_outbuf (bufp)
65
 
     plOutbuf *bufp;
66
 
#endif
67
76
{
68
77
  int i;
69
78
 
80
89
  bufp->yrange_max = -(DBL_MAX);
81
90
 
82
91
  /* initialize `font used' arrays for the page */
83
 
  for (i = 0; i < NUM_PS_FONTS; i++)
 
92
  for (i = 0; i < PL_NUM_PS_FONTS; i++)
84
93
    bufp->ps_font_used[i] = false;
85
 
  for (i = 0; i < NUM_PCL_FONTS; i++)
 
94
  for (i = 0; i < PL_NUM_PCL_FONTS; i++)
86
95
    bufp->pcl_font_used[i] = false;
87
96
}
88
97
 
89
98
void
90
 
#ifdef _HAVE_PROTOS
91
99
_freeze_outbuf (plOutbuf *bufp)
92
 
#else
93
 
_freeze_outbuf (bufp)
94
 
     plOutbuf *bufp;
95
 
#endif
96
100
{
97
101
  bufp->reset_point = bufp->point;
98
102
  bufp->reset_contents = bufp->contents;
99
103
}
100
104
 
101
105
void
102
 
#ifdef _HAVE_PROTOS
103
106
_delete_outbuf (plOutbuf *bufp)
104
 
#else
105
 
_delete_outbuf (bufp)
106
 
     plOutbuf *bufp;
107
 
#endif
108
107
{
109
108
  if (bufp)
110
109
    {
119
118
   characters were added.  */
120
119
 
121
120
void
122
 
#ifdef _HAVE_PROTOS
123
121
_update_buffer (plOutbuf *bufp)
124
 
#else
125
 
_update_buffer (bufp)
126
 
     plOutbuf *bufp;
127
 
#endif
128
122
{
129
123
  int additional;
130
124
 
148
142
      newlen = NEW_OUTBUF_LEN(oldlen);
149
143
 
150
144
      bufp->base = 
151
 
        (char *)_plot_xrealloc (bufp->base, newlen * sizeof(char));
 
145
        (char *)_pl_xrealloc (bufp->base, newlen * sizeof(char));
152
146
      bufp->len = newlen;
153
147
      bufp->point = bufp->base + bufp->contents;
154
148
      bufp->reset_point = bufp->base + bufp->reset_contents;
160
154
   than a null-terminated string (e.g., raw binary bytes). */
161
155
 
162
156
void
163
 
#ifdef _HAVE_PROTOS
164
157
_update_buffer_by_added_bytes (plOutbuf *bufp, int additional)
165
 
#else
166
 
_update_buffer_by_added_bytes (bufp, additional)
167
 
     plOutbuf *bufp;
168
 
     int additional;
169
 
#endif
170
158
{
171
159
  bufp->point += additional;
172
160
  bufp->contents += additional;
186
174
      newlen = NEW_OUTBUF_LEN(oldlen);
187
175
 
188
176
      bufp->base = 
189
 
        (char *)_plot_xrealloc (bufp->base, newlen * sizeof(char));
 
177
        (char *)_pl_xrealloc (bufp->base, newlen * sizeof(char));
190
178
      bufp->len = newlen;
191
179
      bufp->point = bufp->base + bufp->contents;
192
180
      bufp->reset_point = bufp->base + bufp->reset_contents;
196
184
/* update bounding box information for a plOutbuf, to take account of a
197
185
   point being plotted on the associated page */
198
186
void 
199
 
#ifdef _HAVE_PROTOS
200
187
_update_bbox (plOutbuf *bufp, double x, double y)
201
 
#else
202
 
_update_bbox (bufp, x, y)
203
 
     plOutbuf *bufp;
204
 
     double x, y;
205
 
#endif
206
188
{
207
189
  if (x > bufp->xrange_max) bufp->xrange_max = x;
208
190
  if (x < bufp->xrange_min) bufp->xrange_min = x;
212
194
 
213
195
/* return bounding box information for a plOutbuf */
214
196
void 
215
 
#ifdef _HAVE_PROTOS
216
197
_bbox_of_outbuf (plOutbuf *bufp, double *xmin, double *xmax, double *ymin, double *ymax)
217
 
#else
218
 
_bbox_of_outbuf (bufp, xmin, xmax, ymin, ymax)
219
 
     plOutbuf *bufp;
220
 
     double *xmin, *xmax, *ymin, *ymax;
221
 
#endif
222
198
{
223
199
  double page_x_min = DBL_MAX;
224
200
  double page_y_min = DBL_MAX;  
242
218
/* compute bounding box information for a linked list of plOutbufs
243
219
   (i.e. pages), starting with a specified plOutbuf (i.e., page) */
244
220
void 
245
 
#ifdef _HAVE_PROTOS
246
221
_bbox_of_outbufs (plOutbuf *bufp, double *xmin, double *xmax, double *ymin, double *ymax)
247
 
#else
248
 
_bbox_of_outbufs (bufp, xmin, xmax, ymin, ymax)
249
 
     plOutbuf *bufp;
250
 
     double *xmin, *xmax, *ymin, *ymax;
251
 
#endif
252
222
{
253
223
  double doc_x_min = DBL_MAX;
254
224
  double doc_y_min = DBL_MAX;