tioga 1.6 → 1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Tioga_README +35 -10
- data/split/Dvector/dvector.c +264 -22
- data/split/Dvector/lib/Dvector_extras.rb +30 -2
- data/split/Flate/extconf.rb +1 -1
- data/split/Function/function.c +112 -2
- data/split/Tioga/figures.c +76 -77
- data/split/Tioga/figures.h +375 -490
- data/split/Tioga/generic.c +254 -0
- data/split/Tioga/generic.h +236 -0
- data/split/Tioga/init.c +434 -320
- data/split/Tioga/lib/Creating_Paths.rb +11 -1
- data/split/Tioga/lib/FigMkr.rb +263 -65
- data/split/Tioga/lib/Legends.rb +4 -2
- data/split/Tioga/lib/Markers.rb +3 -2
- data/split/Tioga/lib/Special_Paths.rb +22 -23
- data/split/Tioga/lib/TeX_Text.rb +79 -1
- data/split/Tioga/lib/TexPreamble.rb +14 -0
- data/split/Tioga/lib/Utils.rb +5 -1
- data/split/Tioga/pdfs.h +7 -45
- data/split/Tioga/{axes.c → shared/axes.c} +210 -197
- data/split/Tioga/{makers.c → shared/makers.c} +442 -211
- data/split/Tioga/{pdf_font_dicts.c → shared/pdf_font_dicts.c} +0 -0
- data/split/Tioga/shared/pdfcolor.c +628 -0
- data/split/Tioga/shared/pdfcoords.c +443 -0
- data/split/Tioga/{pdffile.c → shared/pdffile.c} +56 -52
- data/split/Tioga/{pdfimage.c → shared/pdfimage.c} +103 -211
- data/split/Tioga/shared/pdfpath.c +766 -0
- data/split/Tioga/{pdftext.c → shared/pdftext.c} +121 -99
- data/split/Tioga/shared/texout.c +524 -0
- data/split/Tioga/wrappers.c +489 -0
- data/split/Tioga/wrappers.h +259 -0
- data/split/extconf.rb +4 -0
- data/split/mkmf2.rb +12 -1
- data/tests/benchmark_dvector_reads.rb +112 -0
- data/tests/tc_Dvector.rb +35 -3
- data/tests/tc_Function.rb +32 -0
- metadata +65 -52
- data/split/Tioga/pdfcolor.c +0 -486
- data/split/Tioga/pdfcoords.c +0 -523
- data/split/Tioga/pdfpath.c +0 -913
- data/split/Tioga/texout.c +0 -380
data/split/Tioga/texout.c
DELETED
@@ -1,380 +0,0 @@
|
|
1
|
-
/* texout.c */
|
2
|
-
/*
|
3
|
-
Copyright (C) 2005 Bill Paxton
|
4
|
-
|
5
|
-
This file is part of Tioga.
|
6
|
-
|
7
|
-
Tioga is free software; you can redistribute it and/or modify
|
8
|
-
it under the terms of the GNU General Library Public License as published
|
9
|
-
by the Free Software Foundation; either version 2 of the License, or
|
10
|
-
(at your option) any later version.
|
11
|
-
|
12
|
-
Tioga is distributed in the hope that it will be useful,
|
13
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
-
GNU Library General Public License for more details.
|
16
|
-
|
17
|
-
You should have received a copy of the GNU Library General Public License
|
18
|
-
along with Tioga; if not, write to the Free Software
|
19
|
-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
-
*/
|
21
|
-
|
22
|
-
#include "figures.h"
|
23
|
-
|
24
|
-
#define RADIANS_TO_DEGREES (180.0 / PI)
|
25
|
-
|
26
|
-
static FILE *fp; // for the TeX file
|
27
|
-
|
28
|
-
/* TeX text */
|
29
|
-
|
30
|
-
void c_text_scale_set(FM *p, double scale)
|
31
|
-
{
|
32
|
-
double factor = scale / p->default_text_scale;
|
33
|
-
if (factor <= 0) rb_raise(rb_eArgError, "Sorry: text scaling must be positive");
|
34
|
-
p->default_text_height_dx *= factor;
|
35
|
-
p->default_text_height_dy *= factor;
|
36
|
-
p->default_text_scale = scale;
|
37
|
-
}
|
38
|
-
|
39
|
-
VALUE FM_rescale_text(VALUE fmkr, VALUE scaling_factor) // updates default text heights too
|
40
|
-
{
|
41
|
-
FM *p = Get_FM(fmkr);
|
42
|
-
scaling_factor = rb_Float(scaling_factor);
|
43
|
-
c_text_scale_set(p, NUM2DBL(scaling_factor) * p->default_text_scale);
|
44
|
-
return fmkr;
|
45
|
-
}
|
46
|
-
|
47
|
-
int String_Is_Blank(char *str) {
|
48
|
-
char c;
|
49
|
-
if (str == NULL) return 1;
|
50
|
-
while (1) {
|
51
|
-
c = *str++;
|
52
|
-
if (c == '\0') return 1;
|
53
|
-
if (!isspace(c)) break;
|
54
|
-
}
|
55
|
-
return 0;
|
56
|
-
}
|
57
|
-
|
58
|
-
void tex_show_rotated_text(FM *p, char *text, double x, double y, double scale, double angle, int justification, int alignment)
|
59
|
-
{ // x and y are the device coords for the reference point of the text
|
60
|
-
char ref, jst;
|
61
|
-
double ft_ht, sz;
|
62
|
-
if (String_Is_Blank(text)) return; /* blank strings break TeX! */
|
63
|
-
scale *= p->default_text_scale;
|
64
|
-
ft_ht = scale * p->default_font_size;
|
65
|
-
sz = ft_ht * ENLARGE;
|
66
|
-
ref = (alignment == ALIGNED_AT_BASELINE)? 'B' :
|
67
|
-
(alignment == ALIGNED_AT_BOTTOM)? 'b' :
|
68
|
-
(alignment == ALIGNED_AT_TOP)? 't' : 'c';
|
69
|
-
if (justification == 0) jst = 'c';
|
70
|
-
else if (justification > 0) jst = 'r';
|
71
|
-
else jst = 'l';
|
72
|
-
bbox_llx = MIN(bbox_llx, x - sz);
|
73
|
-
bbox_lly = MIN(bbox_lly, y - sz);
|
74
|
-
bbox_urx = MAX(bbox_urx, x + sz);
|
75
|
-
bbox_ury = MAX(bbox_ury, y + sz);
|
76
|
-
if (angle != 0.0)
|
77
|
-
fprintf(fp,"\\put(%d,%d){\\rotatebox{%.1f}{\\scalebox{%.2f}{\\makebox(0,0)[%c%c]{\\tiogasetfont",
|
78
|
-
ROUND(x), ROUND(y), angle, scale, jst, ref);
|
79
|
-
else
|
80
|
-
fprintf(fp,"\\put(%d,%d){\\scalebox{%.2f}{\\makebox(0,0)[%c%c]{\\tiogasetfont",
|
81
|
-
ROUND(x), ROUND(y), scale, jst, ref);
|
82
|
-
fprintf(fp, (alignment == ALIGNED_AT_BASELINE)? "{%s\\BS" : "{%s", text);
|
83
|
-
fprintf(fp, angle != 0? "}}}}}\n" : "}}}}\n");
|
84
|
-
}
|
85
|
-
|
86
|
-
static void Convert_Frame_Text_Position_To_Output_Location(FM *p, int frame_side, double offset,
|
87
|
-
double fraction, double *xp, double *yp, double *base_angle, char *text)
|
88
|
-
{
|
89
|
-
double page_x, page_y;
|
90
|
-
switch (frame_side) {
|
91
|
-
case LEFT:
|
92
|
-
page_x = p->page_width * p->frame_left - offset;
|
93
|
-
page_y = p->page_height * (p->frame_bottom + fraction * p->frame_height);
|
94
|
-
*base_angle = 90;
|
95
|
-
break;
|
96
|
-
case RIGHT:
|
97
|
-
page_x = p->page_width * p->frame_right + offset;
|
98
|
-
page_y = p->page_height * (p->frame_bottom + fraction * p->frame_height);
|
99
|
-
*base_angle = 90;
|
100
|
-
break;
|
101
|
-
case AT_X_ORIGIN:
|
102
|
-
if (0.0 > p->bounds_xmax || 0.0 < p->bounds_xmin)
|
103
|
-
rb_raise(rb_eArgError, "Sorry: x origin is not part of plot for (%s)", text);
|
104
|
-
page_x = convert_figure_to_output_x(p, 0.0);
|
105
|
-
if (p->xaxis_reversed) offset = -offset;
|
106
|
-
page_x += offset;
|
107
|
-
page_y = p->page_height * (p->frame_bottom + fraction * p->frame_height);
|
108
|
-
*base_angle = 90;
|
109
|
-
break;
|
110
|
-
case TOP:
|
111
|
-
page_y = p->page_height * p->frame_top + offset;
|
112
|
-
page_x = p->page_width * (p->frame_left + fraction * p->frame_width);
|
113
|
-
*base_angle = 0;
|
114
|
-
break;
|
115
|
-
case BOTTOM:
|
116
|
-
page_y = p->page_height * p->frame_bottom - offset;
|
117
|
-
page_x = p->page_width * (p->frame_left + fraction * p->frame_width);
|
118
|
-
*base_angle = 0;
|
119
|
-
break;
|
120
|
-
case AT_Y_ORIGIN:
|
121
|
-
if (0.0 > p->bounds_ymax || 0.0 < p->bounds_ymin)
|
122
|
-
rb_raise(rb_eArgError, "Sorry: y origin is not part of plot for (%s)", text);
|
123
|
-
page_y = convert_figure_to_output_y(p, 0.0);
|
124
|
-
if (p->yaxis_reversed) offset = -offset;
|
125
|
-
page_y += offset;
|
126
|
-
page_x = p->page_width * (p->frame_left + fraction * p->frame_width);
|
127
|
-
*base_angle = 0;
|
128
|
-
break;
|
129
|
-
default: rb_raise(rb_eArgError, "Sorry: invalid parameter for frame side in show text (%s)", text);
|
130
|
-
}
|
131
|
-
*xp = p->page_left + page_x; *yp = p->page_bottom + page_y;
|
132
|
-
}
|
133
|
-
|
134
|
-
void c_show_rotated_text(FM *p, char *text, int frame_side, double shift, double fraction,
|
135
|
-
double scale, double angle, int justification, int alignment)
|
136
|
-
{
|
137
|
-
double x, y, base_angle, ft_ht = p->default_text_scale * scale * p->default_font_size;
|
138
|
-
Convert_Frame_Text_Position_To_Output_Location(p, frame_side, shift*ft_ht*ENLARGE, fraction, &x, &y, &base_angle, text);
|
139
|
-
tex_show_rotated_text(p, text, x, y, scale, angle + base_angle, justification, alignment);
|
140
|
-
}
|
141
|
-
|
142
|
-
VALUE FM_show_rotated_text(VALUE fmkr, VALUE text, VALUE frame_side, VALUE shift,
|
143
|
-
VALUE fraction, VALUE scale, VALUE angle, VALUE justification, VALUE alignment)
|
144
|
-
{
|
145
|
-
FM *p = Get_FM(fmkr);
|
146
|
-
text = rb_String(text);
|
147
|
-
frame_side = rb_Integer(frame_side);
|
148
|
-
shift = rb_Float(shift);
|
149
|
-
fraction = rb_Float(fraction);
|
150
|
-
scale = rb_Float(scale);
|
151
|
-
angle = rb_Float(angle);
|
152
|
-
justification = rb_Integer(justification);
|
153
|
-
alignment = rb_Integer(alignment);
|
154
|
-
c_show_rotated_text(p, RSTRING_PTR(text), NUM2INT(frame_side), NUM2DBL(shift),
|
155
|
-
NUM2DBL(fraction), NUM2DBL(scale), NUM2DBL(angle), NUM2INT(justification), NUM2INT(alignment));
|
156
|
-
return fmkr;
|
157
|
-
}
|
158
|
-
|
159
|
-
void c_show_rotated_label(FM *p, char *text,
|
160
|
-
double xloc, double yloc, double scale, double angle, int justification, int alignment)
|
161
|
-
{
|
162
|
-
tex_show_rotated_text(p, text, convert_figure_to_output_x(p, xloc), convert_figure_to_output_y(p, yloc),
|
163
|
-
scale, angle, justification, alignment);
|
164
|
-
}
|
165
|
-
|
166
|
-
VALUE FM_show_rotated_label(VALUE fmkr, VALUE text,
|
167
|
-
VALUE xloc, VALUE yloc, VALUE scale, VALUE angle, VALUE justification, VALUE alignment)
|
168
|
-
{
|
169
|
-
FM *p = Get_FM(fmkr);
|
170
|
-
text = rb_String(text);
|
171
|
-
xloc = rb_Float(xloc);
|
172
|
-
yloc = rb_Float(yloc);
|
173
|
-
scale = rb_Float(scale);
|
174
|
-
angle = rb_Float(angle);
|
175
|
-
justification = rb_Integer(justification);
|
176
|
-
alignment = rb_Integer(alignment);
|
177
|
-
c_show_rotated_label(p, RSTRING_PTR(text), NUM2DBL(xloc), NUM2DBL(yloc),
|
178
|
-
NUM2DBL(scale), NUM2DBL(angle), NUM2INT(justification), NUM2INT(alignment));
|
179
|
-
return fmkr;
|
180
|
-
}
|
181
|
-
|
182
|
-
VALUE FM_check_label_clip(VALUE fmkr, VALUE xloc, VALUE yloc)
|
183
|
-
{
|
184
|
-
FM *p = Get_FM(fmkr);
|
185
|
-
xloc = rb_Float(xloc);
|
186
|
-
yloc = rb_Float(yloc);
|
187
|
-
double x = NUM2DBL(xloc), y = NUM2DBL(yloc);
|
188
|
-
x = convert_figure_to_frame_x(p,x);
|
189
|
-
y = convert_figure_to_frame_y(p,y);
|
190
|
-
if (x < p->label_left_margin || y < p->label_bottom_margin ||
|
191
|
-
1.0 - x < p->label_right_margin || 1.0 - y < p->label_top_margin) return Qfalse;
|
192
|
-
return Qtrue;
|
193
|
-
}
|
194
|
-
|
195
|
-
/* TeX File Management */
|
196
|
-
|
197
|
-
static long cur_pos;
|
198
|
-
|
199
|
-
static void Get_tex_name(char *ofile, char *filename, int maxlen)
|
200
|
-
{
|
201
|
-
char *dot;
|
202
|
-
strncpy(ofile, filename, maxlen);
|
203
|
-
dot = strrchr(ofile,'.');
|
204
|
-
if (dot != NULL) dot[0] = '\0';
|
205
|
-
strcat(ofile, "_figure.txt");
|
206
|
-
}
|
207
|
-
|
208
|
-
void Open_tex(VALUE fmkr, char *filename, bool quiet_mode)
|
209
|
-
{
|
210
|
-
char ofile[300];
|
211
|
-
Get_tex_name(ofile, filename, 300);
|
212
|
-
fp = fopen(ofile, "w");
|
213
|
-
fprintf(fp,"\\setlength{\\unitlength}{%fbp}%%\n", 1.0/ENLARGE);
|
214
|
-
cur_pos = ftell(fp);
|
215
|
-
fprintf(fp,"\\begin{picture}(xxxxxx,xxxxxx) %% (width,height)(xoffset,yoffset) -- Adjust the 2nd pair for registration adjustments\n"); /* this line is rewritten at the end */
|
216
|
-
fprintf(fp,"\\def\\BS{\\phantom{\\Huge\\scalebox{0}[2]{\\hbox{\\rotatebox{180}{O}O}}}}\n");
|
217
|
-
// graphicx seems to vertically align baseline (B) like center (c),
|
218
|
-
// so we add BS (Big Strut) to make them look the same
|
219
|
-
fmkr = Qnil; // unused
|
220
|
-
}
|
221
|
-
|
222
|
-
void Close_tex(VALUE fmkr, bool quiet_mode)
|
223
|
-
{
|
224
|
-
double x, y, xoff, yoff;
|
225
|
-
x = bbox_urx - bbox_llx; if (x < 0) x = bbox_urx = bbox_llx = 0;
|
226
|
-
y = bbox_ury - bbox_lly; if (y < 0) y = bbox_ury = bbox_lly = 0;
|
227
|
-
xoff = bbox_llx + Get_tex_xoffset(fmkr)*ENLARGE;
|
228
|
-
yoff = bbox_lly + Get_tex_yoffset(fmkr)*ENLARGE;
|
229
|
-
fprintf(fp,"\\end{picture}");
|
230
|
-
fseek(fp, cur_pos, SEEK_SET);
|
231
|
-
fprintf(fp,"\\begin{picture}(%03d,%03d)(%02d,%d)", ROUND(x), ROUND(y), ROUND(xoff), ROUND(yoff));
|
232
|
-
fclose(fp);
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
void Write_preview_header(VALUE fmkr, FILE *file) {
|
237
|
-
VALUE tmp;
|
238
|
-
fprintf(file, "\\documentclass{%s}\n\n", Get_tex_preview_documentclass(fmkr));
|
239
|
-
/* we print out the preamble generated from tioga.sty.in */
|
240
|
-
fprintf(file, "%% Tioga preamble generated from tioga.sty.in\n");
|
241
|
-
fprintf(file, "%s\n", Get_tex_preview_generated_preamble(fmkr));
|
242
|
-
fprintf(file, "%% User-specified preamble\n");
|
243
|
-
fprintf(file, "%s\n\n", Get_tex_preamble(fmkr));
|
244
|
-
fprintf(file, "%% Command to format numeric labels on xaxis\n");
|
245
|
-
fprintf(file, "\\newcommand{\\tiogaxaxisnumericlabel}[1]{%s}\n\n", Get_xaxis_numeric_label_tex(fmkr));
|
246
|
-
fprintf(file, "%% Command to format numeric labels on yaxis\n");
|
247
|
-
fprintf(file, "\\newcommand{\\tiogayaxisnumericlabel}[1]{%s}\n\n", Get_yaxis_numeric_label_tex(fmkr));
|
248
|
-
fprintf(file, "%% Color constants definitions\n");
|
249
|
-
tmp = rb_const_get(CLASS_OF(fmkr), rb_intern("COLOR_PREAMBLE"));
|
250
|
-
fprintf(file, "%s\n\n", StringValueCStr(tmp));
|
251
|
-
fprintf(file, "%% Set page margins, page size and orientation.\n");
|
252
|
-
fprintf(file, "\t\\usepackage[pdftex,tmargin=0pt,lmargin=0pt,"
|
253
|
-
"rmargin=0pt,bmargin=0pt,\n");
|
254
|
-
fprintf(file, "\tpaperwidth=%s,paperheight=%s,\n",
|
255
|
-
Get_tex_preview_paper_width(fmkr),
|
256
|
-
Get_tex_preview_paper_height(fmkr));
|
257
|
-
fprintf(file, "\thoffset=%s,voffset=%s\n",
|
258
|
-
Get_tex_preview_hoffset(fmkr),
|
259
|
-
Get_tex_preview_voffset(fmkr));
|
260
|
-
fprintf(file, "\t]{geometry}\n");
|
261
|
-
|
262
|
-
fprintf(file, "\n%% We need the graphicx package and the calc package.\n");
|
263
|
-
fprintf(file, "\t\\usepackage{graphicx}\n");
|
264
|
-
fprintf(file, "\t\\usepackage{calc}\n\n");
|
265
|
-
fprintf(file, "\t%% This is necessary to avoid getting the picture on the second page\n");
|
266
|
-
fprintf(file, "\t\\topskip=0pt\n\n");
|
267
|
-
|
268
|
-
/* now, the commands to customize the font used */
|
269
|
-
fprintf(file, "\\settiogafontsize[10pt]{%s}\n", Get_tex_fontsize(fmkr));
|
270
|
-
fprintf(file, "\\settiogafontfamily{\\%s}\n", Get_tex_fontfamily(fmkr));
|
271
|
-
fprintf(file, "\\settiogafontseries{\\%s}\n", Get_tex_fontseries(fmkr));
|
272
|
-
fprintf(file, "\\settiogafontshape{\\%s}\n", Get_tex_fontshape(fmkr));
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
void Write_figure_command(VALUE fmkr, char *simple_name, FILE *file) {
|
277
|
-
char *minwhitespace;
|
278
|
-
|
279
|
-
if (Get_tex_preview_fullpage(fmkr)) {
|
280
|
-
minwhitespace = Get_tex_preview_minwhitespace(fmkr);
|
281
|
-
if (minwhitespace == NULL) {
|
282
|
-
fprintf(file, "\\tiogafigurefullpage{%s}\n", simple_name);
|
283
|
-
} else {
|
284
|
-
fprintf(file, "\\tiogafigurefullpage[%s]{%s}\n", minwhitespace, simple_name);
|
285
|
-
}
|
286
|
-
} else {
|
287
|
-
const char * command = Get_tex_preview_tiogafigure_command(fmkr);
|
288
|
-
if(strcmp(command, "tiogafigureshow")) {
|
289
|
-
fprintf(file, "\\%s{%s}{%s}{%s}\n", Get_tex_preview_tiogafigure_command(fmkr), simple_name,
|
290
|
-
Get_tex_preview_figure_width(fmkr), Get_tex_preview_figure_height(fmkr));
|
291
|
-
} else { /* no need for extra arguments for tiogafigureshow */
|
292
|
-
fprintf(file, "\\%s{%s}\n", Get_tex_preview_tiogafigure_command(fmkr), simple_name);
|
293
|
-
}
|
294
|
-
}
|
295
|
-
}
|
296
|
-
|
297
|
-
|
298
|
-
void Create_wrapper(VALUE fmkr, char *fname, bool quiet_mode)
|
299
|
-
{ // create the wrapper TeX file to combine the text and graphics to make a figure
|
300
|
-
char *dot;
|
301
|
-
char tex_fname[100], base_name[100], simple_name[100];
|
302
|
-
FILE *file;
|
303
|
-
if ((dot=strrchr(fname,'.')) != NULL) {
|
304
|
-
strncpy(base_name, fname, dot-fname); base_name[dot-fname] = '\0';
|
305
|
-
sprintf(tex_fname, "%s.tex", base_name);
|
306
|
-
}
|
307
|
-
else {
|
308
|
-
strcpy(base_name, fname);
|
309
|
-
sprintf(tex_fname, "%s.tex", fname);
|
310
|
-
}
|
311
|
-
if ((dot=strrchr(base_name,'/')) != NULL) {
|
312
|
-
strcpy(simple_name, dot+1);
|
313
|
-
}
|
314
|
-
else {
|
315
|
-
strcpy(simple_name, base_name);
|
316
|
-
}
|
317
|
-
file = fopen(tex_fname, "w");
|
318
|
-
fprintf(file, "%% Tioga preview LaTeX file for %s_figure.pdf and %s_figure.txt\n\n", base_name, base_name);
|
319
|
-
|
320
|
-
Write_preview_header(fmkr, file);
|
321
|
-
|
322
|
-
fprintf(file, "\n%% Here's the page with the figure.\n");
|
323
|
-
fprintf(file, "\\begin{document}\n");
|
324
|
-
fprintf(file, "\\pagestyle{%s}\n", Get_tex_preview_pagestyle(fmkr));
|
325
|
-
/* necessary to get the position right */
|
326
|
-
fprintf(file, "\\noindent");
|
327
|
-
Write_figure_command(fmkr, simple_name, file);
|
328
|
-
fprintf(file, "\\end{document}\n");
|
329
|
-
fclose(file);
|
330
|
-
}
|
331
|
-
|
332
|
-
void Init_tex(void)
|
333
|
-
{
|
334
|
-
}
|
335
|
-
|
336
|
-
void Rename_tex(char *oldname, char *newname)
|
337
|
-
{
|
338
|
-
char old_ofile[300], new_ofile[300];
|
339
|
-
Get_tex_name(old_ofile, oldname, 300);
|
340
|
-
Get_tex_name(new_ofile, newname, 300);
|
341
|
-
rename(old_ofile, new_ofile); // from stdio.h
|
342
|
-
}
|
343
|
-
|
344
|
-
void private_make_portfolio(char *name, VALUE fignums, VALUE fignames)
|
345
|
-
{
|
346
|
-
FILE *file;
|
347
|
-
int i, len, numfigs, j;
|
348
|
-
char tex_fname[256];
|
349
|
-
sprintf(tex_fname, "%s.tex", name);
|
350
|
-
file = fopen(tex_fname, "w");
|
351
|
-
if (file == NULL)
|
352
|
-
rb_raise(rb_eArgError, "Sorry: can't open %s.\n", tex_fname);
|
353
|
-
fprintf(file, "%% Tioga Portfolio %s\n\n", name);
|
354
|
-
fprintf(file, "\\documentclass{article}\n");
|
355
|
-
fprintf(file, "\\usepackage{pdfpages}\n");
|
356
|
-
fprintf(file, "\\begin{document}\n");
|
357
|
-
fprintf(file, "%% Start of figures, one per page\n\n");
|
358
|
-
fignames = rb_Array(fignames);
|
359
|
-
len = RARRAY(fignames)->len;
|
360
|
-
if (fignums == Qnil) {
|
361
|
-
for (i=0; i < len; i++) {
|
362
|
-
fprintf(file, "\\includepdf{%s.pdf}\n", Get_String(fignames, i));
|
363
|
-
}
|
364
|
-
} else {
|
365
|
-
fignums = rb_Array(fignums);
|
366
|
-
numfigs = RARRAY(fignums)->len;
|
367
|
-
for (i=0; i < numfigs; i++) {
|
368
|
-
j = NUM2INT(RARRAY(fignums)->ptr[i]);
|
369
|
-
if (j >= 0 && j < len) fprintf(file, "\\includepdf{%s.pdf}\n", Get_String(fignames, j));
|
370
|
-
else {
|
371
|
-
fclose(file);
|
372
|
-
rb_raise(rb_eArgError, "Requested figure numbers must be >= 0 and < num_figures.");
|
373
|
-
}
|
374
|
-
}
|
375
|
-
}
|
376
|
-
fprintf(file, "\n\\end{document}\n");
|
377
|
-
fclose(file);
|
378
|
-
}
|
379
|
-
|
380
|
-
|