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.
Files changed (41) hide show
  1. data/Tioga_README +35 -10
  2. data/split/Dvector/dvector.c +264 -22
  3. data/split/Dvector/lib/Dvector_extras.rb +30 -2
  4. data/split/Flate/extconf.rb +1 -1
  5. data/split/Function/function.c +112 -2
  6. data/split/Tioga/figures.c +76 -77
  7. data/split/Tioga/figures.h +375 -490
  8. data/split/Tioga/generic.c +254 -0
  9. data/split/Tioga/generic.h +236 -0
  10. data/split/Tioga/init.c +434 -320
  11. data/split/Tioga/lib/Creating_Paths.rb +11 -1
  12. data/split/Tioga/lib/FigMkr.rb +263 -65
  13. data/split/Tioga/lib/Legends.rb +4 -2
  14. data/split/Tioga/lib/Markers.rb +3 -2
  15. data/split/Tioga/lib/Special_Paths.rb +22 -23
  16. data/split/Tioga/lib/TeX_Text.rb +79 -1
  17. data/split/Tioga/lib/TexPreamble.rb +14 -0
  18. data/split/Tioga/lib/Utils.rb +5 -1
  19. data/split/Tioga/pdfs.h +7 -45
  20. data/split/Tioga/{axes.c → shared/axes.c} +210 -197
  21. data/split/Tioga/{makers.c → shared/makers.c} +442 -211
  22. data/split/Tioga/{pdf_font_dicts.c → shared/pdf_font_dicts.c} +0 -0
  23. data/split/Tioga/shared/pdfcolor.c +628 -0
  24. data/split/Tioga/shared/pdfcoords.c +443 -0
  25. data/split/Tioga/{pdffile.c → shared/pdffile.c} +56 -52
  26. data/split/Tioga/{pdfimage.c → shared/pdfimage.c} +103 -211
  27. data/split/Tioga/shared/pdfpath.c +766 -0
  28. data/split/Tioga/{pdftext.c → shared/pdftext.c} +121 -99
  29. data/split/Tioga/shared/texout.c +524 -0
  30. data/split/Tioga/wrappers.c +489 -0
  31. data/split/Tioga/wrappers.h +259 -0
  32. data/split/extconf.rb +4 -0
  33. data/split/mkmf2.rb +12 -1
  34. data/tests/benchmark_dvector_reads.rb +112 -0
  35. data/tests/tc_Dvector.rb +35 -3
  36. data/tests/tc_Function.rb +32 -0
  37. metadata +65 -52
  38. data/split/Tioga/pdfcolor.c +0 -486
  39. data/split/Tioga/pdfcoords.c +0 -523
  40. data/split/Tioga/pdfpath.c +0 -913
  41. data/split/Tioga/texout.c +0 -380
@@ -56,6 +56,33 @@ module Dobjects
56
56
  'remove_space' => true ,# removes spaces at the beginning of the lines
57
57
  }
58
58
 
59
+ # This function is a wrapper for #fast_fancy_read that reflects the
60
+ # look-and-feel of #old_fancy_read
61
+ def Dvector.fancy_read(stream, cols = nil, opts = {}) # :doc:
62
+ o = FANCY_READ_DEFAULTS.dup
63
+ o.update(opts)
64
+
65
+ if stream.is_a?(String)
66
+ stream = File.open(stream)
67
+ end
68
+ raise ArgumentError.new("'stream' should have a gets method") unless
69
+ stream.respond_to? :gets
70
+
71
+ o['sep'] = Regexp.new(o['sep']) unless o['sep'].is_a? Regexp
72
+
73
+ res = Dvector.fast_fancy_read(stream, o)
74
+
75
+ # Adding the index columns if necessary
76
+ if o["index_col"]
77
+ res.unshift(Dvector.new(res[0].length) { |i| i})
78
+ end
79
+
80
+ if cols
81
+ return cols.map {|i| res[i] }
82
+ else
83
+ return res
84
+ end
85
+ end
59
86
 
60
87
  # This function reads in +stream+ (can an IO object or a String,
61
88
  # in which case it represents the name of a file to be opened)
@@ -70,9 +97,10 @@ module Dobjects
70
97
  # 'skip_first':: how many lines to skip at the beginning of the file,
71
98
  # 'default':: the value taken for missing elements
72
99
  # 'index_col':: if set to true, the first column contains the
73
- # indices of the corresponding lines (0 for first and so on)
100
+ # indices of the elements (starting from 0 for
101
+ # first and so on)
74
102
 
75
- def Dvector.fancy_read(stream, cols = nil, opts = {}) # :doc:
103
+ def Dvector.old_fancy_read(stream, cols = nil, opts = {}) # :doc:
76
104
  # first, we turn the stream into a real IO stream
77
105
  if stream.is_a?(String)
78
106
  stream = File.open(stream)
@@ -1,4 +1,4 @@
1
- # Dtable installation file
1
+ # Flate installation file
2
2
  require 'mkmf'
3
3
 
4
4
  unless have_header("zlib.h") and have_library("z", "compress", "zlib.h")
@@ -687,8 +687,13 @@ static VALUE function_split_monotonic(VALUE self)
687
687
  rb_ary_push(ret, f);
688
688
  cur_x = Dvector_Create();
689
689
  cur_y = Dvector_Create();
690
- Dvector_Push_Double(cur_x, x[i-1]);
691
- Dvector_Push_Double(cur_y, y[i-1]);
690
+ /* We don't store the previous point if
691
+ the X value is the same*/
692
+ if(x[i] != last_x)
693
+ {
694
+ Dvector_Push_Double(cur_x, x[i-1]);
695
+ Dvector_Push_Double(cur_y, y[i-1]);
696
+ }
692
697
  direction *= -1;
693
698
  }
694
699
  /* store the current point */
@@ -927,6 +932,99 @@ static VALUE function_size(VALUE self)
927
932
  return LONG2NUM(size);
928
933
  }
929
934
 
935
+ /*
936
+ Fuzzy substraction of two curves. Substracts the Y values of _op_ to
937
+ the current Function, by making sure that the Y value substracted to
938
+ a given point corresponds to the closest X_ value of the point in _op_.
939
+ This function somehow assumes that the data is reasonably organised,
940
+ and will never go backwards to find a matching X value in _op_.
941
+
942
+ In any case, you really should consider using split_monotonic on it first.
943
+ */
944
+
945
+ static VALUE function_fuzzy_substract(VALUE self, VALUE op)
946
+ {
947
+ long ss = function_sanity_check(self);
948
+ const double *xs = Dvector_Data_for_Read(get_x_vector(self),NULL);
949
+ double *ys = Dvector_Data_for_Write(get_y_vector(self),NULL);
950
+ long so = function_sanity_check(op);
951
+ const double *xo = Dvector_Data_for_Read(get_x_vector(op),NULL);
952
+ const double *yo = Dvector_Data_for_Read(get_y_vector(op),NULL);
953
+ long i,j = 0;
954
+ double diff;
955
+ double fuzz = 0; /* The actual sum of the terms */
956
+
957
+ for(i = 0; i < ss; i++)
958
+ {
959
+ /* We first look for the closest point */
960
+ diff = fabs(xs[i] - xo[j]);
961
+ while((j < (so - 1)) && (fabs(xs[i] - xo[j+1]) < diff))
962
+ diff = fabs(xs[i] - xo[++j]);
963
+ fuzz += diff;
964
+ ys[i] -= yo[j];
965
+ }
966
+ return rb_float_new(fuzz);
967
+ }
968
+
969
+ /*
970
+ call-seq:
971
+ f.bound_values(xmin, xmax, ymin, ymax)
972
+
973
+ This function browses the points inside the Function and stores in
974
+ the resulting new function only points which are within boundaries,
975
+ and the points just next to them (so the general direction on the sides
976
+ looks fine).
977
+
978
+ Make sure _xmin_ < _xmax_ and _ymin_ < _ymax_, else you simply won't
979
+ get any output.
980
+ */
981
+ static VALUE function_bound_values(VALUE self,
982
+ VALUE vxmin, VALUE vxmax,
983
+ VALUE vymin, VALUE vymax)
984
+ {
985
+ long ss = function_sanity_check(self);
986
+ const double *xs = Dvector_Data_for_Read(get_x_vector(self),NULL);
987
+ const double *ys = Dvector_Data_for_Read(get_y_vector(self),NULL);
988
+ double xmin = NUM2DBL(vxmin);
989
+ double xmax = NUM2DBL(vxmax);
990
+ double ymin = NUM2DBL(vymin);
991
+ double ymax = NUM2DBL(vymax);
992
+
993
+ /* Now, two dvectors for writing: */
994
+ VALUE x_out = rb_funcall(cDvector, idNew, 0);
995
+ VALUE y_out = rb_funcall(cDvector, idNew, 0);
996
+
997
+ /* No forward computation of the size of the targets, meaning
998
+ memory allocation penalty.
999
+ */
1000
+
1001
+ int last_point_in = 0; /* Whether the last point was in */
1002
+ long i;
1003
+ for(i = 0; i < ss; i++) {
1004
+ double x = xs[i];
1005
+ double y = ys[i];
1006
+ if( (xmin <= x) && (xmax >= x) && (ymin <= y) && (ymax >= y)) {
1007
+ if(! last_point_in) {
1008
+ last_point_in = 1;
1009
+ if(i) { /* Not for the first element */
1010
+ Dvector_Push_Double(x_out, xs[i-1]);
1011
+ Dvector_Push_Double(y_out, ys[i-1]);
1012
+ }
1013
+ }
1014
+ Dvector_Push_Double(x_out, x);
1015
+ Dvector_Push_Double(y_out, y);
1016
+ }
1017
+ else { /* Outside boundaries */
1018
+ if(last_point_in) {
1019
+ last_point_in = 0;
1020
+ Dvector_Push_Double(x_out, x);
1021
+ Dvector_Push_Double(y_out, y);
1022
+ }
1023
+ }
1024
+ }
1025
+ return Function_Create(x_out, y_out);
1026
+ }
1027
+
930
1028
  /*
931
1029
  Document-class: Dobjects::Function
932
1030
 
@@ -941,6 +1039,9 @@ static VALUE function_size(VALUE self)
941
1039
  - some utiliy functions: #split_monotonic, #strip_nan;
942
1040
  - data inspection: #min, #max;
943
1041
  - some computational functions: #integrate, #primitive, #derivative.
1042
+ - utility for fuzzy operations, when the X values of two functions
1043
+ differ, but only slightly, of when points are missing:
1044
+ #fuzzy_sub!
944
1045
 
945
1046
  And getting bigger everyday...
946
1047
  */
@@ -1003,6 +1104,15 @@ void Init_Function()
1003
1104
  /* distance to a point */
1004
1105
  rb_define_method(cFunction, "distance", function_distance, -1);
1005
1106
 
1107
+ /* Fuzzy operations */
1108
+ rb_define_method(cFunction, "fuzzy_sub!",
1109
+ function_fuzzy_substract, 1); /* Substraction */
1110
+
1111
+
1112
+ /* Boundary operations */
1113
+ rb_define_method(cFunction, "bound_values",
1114
+ function_bound_values, 4); /* Substraction */
1115
+
1006
1116
 
1007
1117
  /* a few more methods better written in pure Ruby */
1008
1118
  rb_require("Dobjects/Function_extras.rb");
@@ -25,6 +25,9 @@
25
25
 
26
26
  #include "figures.h"
27
27
  #include "pdfs.h"
28
+ #include "wrappers.h"
29
+ #include "dvector.h"
30
+ #include "dtable.h"
28
31
  #include "flate.h"
29
32
 
30
33
  #include <symbols.h>
@@ -32,46 +35,47 @@
32
35
 
33
36
  #include <stdio.h>
34
37
 
35
- char *data_dir = NULL;
36
38
 
37
- VALUE cFM; /* the Tioga/FigureMaker class object */
38
-
39
- static void FM_mark(FM *p) { /* all of the VALUEs in the FM struct should be marked */
40
- rb_gc_mark(p->stroke_color);
41
- rb_gc_mark(p->fill_color);
42
- rb_gc_mark(p->line_type);
43
- rb_gc_mark(p->title);
44
- rb_gc_mark(p->title_color);
45
- rb_gc_mark(p->xlabel);
46
- rb_gc_mark(p->xlabel_color);
47
- rb_gc_mark(p->ylabel);
48
- rb_gc_mark(p->ylabel_color);
49
- rb_gc_mark(p->xaxis_stroke_color);
50
- rb_gc_mark(p->xaxis_locations_for_major_ticks);
51
- rb_gc_mark(p->xaxis_locations_for_minor_ticks);
52
- rb_gc_mark(p->yaxis_stroke_color);
53
- rb_gc_mark(p->yaxis_locations_for_major_ticks);
54
- rb_gc_mark(p->yaxis_locations_for_minor_ticks);
55
- rb_gc_mark(p->fm);
56
- }
39
+ #define DBL_ATTR(attr) \
40
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : rb_float_new(p->attr); } \
41
+ static VALUE FM_##attr##_set(VALUE fmkr, VALUE val) { \
42
+ int ierr=0; FM *p = Get_FM(fmkr,&ierr); if (ierr != 0) RETURN_NIL; VALUE v = rb_Float(val); p->attr = NUM2DBL(v); return val; }
57
43
 
58
- static void FM_free(FM *p) {
59
- free(p);
60
- }
44
+ #define INT_ATTR(attr) \
45
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : INT2FIX(p->attr); } \
46
+ static VALUE FM_##attr##_set(VALUE fmkr, VALUE val) { \
47
+ int ierr=0; FM *p = Get_FM(fmkr,&ierr); if (ierr != 0) RETURN_NIL; VALUE v = rb_Integer(val); p->attr = NUM2INT(v); return val; }
61
48
 
62
- static VALUE FM_alloc(VALUE klass) {
63
- FM *p;
64
- VALUE ary = Data_Make_Struct(klass, FM, FM_mark, FM_free, p);
65
- Initialize_Figure(ary);
66
- p->fm = ary;
67
- return ary;
68
- }
49
+ #define VAL_ATTR(attr) \
50
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : p->attr; } \
51
+ static VALUE FM_##attr##_set(VALUE fmkr, VALUE val) { \
52
+ int ierr=0; FM *p = Get_FM(fmkr,&ierr); if (ierr != 0) RETURN_NIL; p->attr = val; return val; }
53
+
54
+ #define BOOL_ATTR(attr) \
55
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : ((p->attr)? Qtrue : Qfalse); } \
56
+ static VALUE FM_##attr##_set(VALUE fmkr, VALUE val) { \
57
+ int ierr=0; FM *p = Get_FM(fmkr,&ierr); if (ierr != 0) RETURN_NIL; p->attr = (val != Qfalse); return val; }
58
+
59
+ #define RO_DBL_ATTR(attr) \
60
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : rb_float_new(p->attr); }
69
61
 
70
- bool Is_FM(VALUE fmkr) { return ( TYPE(fmkr) == T_DATA && RDATA(fmkr)->dfree == (RUBY_DATA_FUNC)FM_free ); }
62
+ #define RO_INT_ATTR(attr) \
63
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : INT2FIX(p->attr); }
64
+
65
+ #define RO_VAL_ATTR(attr) \
66
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : p->attr; }
67
+
68
+ #define RO_BOOL_ATTR(attr) \
69
+ static VALUE FM_##attr##_get(VALUE fmkr) { int ierr=0; FM *p = Get_FM(fmkr,&ierr); return (ierr != 0)? OBJ_NIL : ((p->attr)? Qtrue : Qfalse); }
70
+
71
+
72
+ char *data_dir = NULL;
71
73
 
72
- FM *Get_FM(VALUE fmkr) {
73
- FM *p;
74
- Data_Get_Struct(fmkr, FM, p);
74
+ OBJ_PTR cFM; /* the Tioga/FigureMaker class object */
75
+
76
+ FM *Get_FM(OBJ_PTR fmkr, int *ierr) {
77
+ FM *p = (FM *)Dvector_Data_for_Write(Get_fm_data_attr(fmkr, ierr), NULL);
78
+ if (*ierr != 0) RAISE_ERROR("FigMkr is missing @fm_data", ierr);
75
79
  return p;
76
80
  }
77
81
 
@@ -129,19 +133,15 @@ FM *Get_FM(VALUE fmkr) {
129
133
 
130
134
  /* graphics attribute accessors */
131
135
  RO_DBL_ATTR(default_line_scale)
132
- RO_VAL_ATTR(stroke_color)
133
- RO_VAL_ATTR(fill_color)
134
136
  RO_DBL_ATTR(line_width)
135
137
  RO_INT_ATTR(line_cap)
136
138
  RO_INT_ATTR(line_join)
137
139
  RO_DBL_ATTR(miter_limit)
138
140
  RO_DBL_ATTR(stroke_opacity)
139
141
  RO_DBL_ATTR(fill_opacity)
140
- RO_VAL_ATTR(line_type)
141
142
 
142
143
  /* Title */
143
144
  RO_BOOL_ATTR(title_visible)
144
- VAL_ATTR(title)
145
145
  INT_ATTR(title_side)
146
146
  DBL_ATTR(title_position)
147
147
  DBL_ATTR(title_scale)
@@ -149,11 +149,10 @@ FM *Get_FM(VALUE fmkr) {
149
149
  DBL_ATTR(title_angle)
150
150
  INT_ATTR(title_alignment)
151
151
  INT_ATTR(title_justification)
152
- VAL_ATTR(title_color)
152
+ //VAL_ATTR(title_color)
153
153
 
154
154
  /* X label */
155
155
  RO_BOOL_ATTR(xlabel_visible)
156
- VAL_ATTR(xlabel)
157
156
  DBL_ATTR(xlabel_position)
158
157
  DBL_ATTR(xlabel_scale)
159
158
  DBL_ATTR(xlabel_shift)
@@ -161,11 +160,9 @@ FM *Get_FM(VALUE fmkr) {
161
160
  INT_ATTR(xlabel_side)
162
161
  INT_ATTR(xlabel_alignment)
163
162
  INT_ATTR(xlabel_justification)
164
- VAL_ATTR(xlabel_color)
165
163
 
166
164
  /* Y label */
167
165
  RO_BOOL_ATTR(ylabel_visible)
168
- VAL_ATTR(ylabel)
169
166
  DBL_ATTR(ylabel_position)
170
167
  DBL_ATTR(ylabel_scale)
171
168
  DBL_ATTR(ylabel_shift)
@@ -173,14 +170,12 @@ FM *Get_FM(VALUE fmkr) {
173
170
  INT_ATTR(ylabel_side)
174
171
  INT_ATTR(ylabel_alignment)
175
172
  INT_ATTR(ylabel_justification)
176
- VAL_ATTR(ylabel_color)
177
173
 
178
174
  /* X axis */
179
175
  RO_BOOL_ATTR(xaxis_visible)
180
176
  INT_ATTR(xaxis_loc)
181
177
  INT_ATTR(xaxis_type)
182
178
  DBL_ATTR(xaxis_line_width)
183
- VAL_ATTR(xaxis_stroke_color)
184
179
  DBL_ATTR(xaxis_major_tick_width)
185
180
  DBL_ATTR(xaxis_minor_tick_width)
186
181
  DBL_ATTR(xaxis_major_tick_length)
@@ -191,11 +186,8 @@ FM *Get_FM(VALUE fmkr) {
191
186
  DBL_ATTR(xaxis_tick_interval)
192
187
  DBL_ATTR(xaxis_min_between_major_ticks)
193
188
  INT_ATTR(xaxis_number_of_minor_intervals)
194
- VAL_ATTR(xaxis_locations_for_major_ticks)
195
- VAL_ATTR(xaxis_locations_for_minor_ticks)
196
189
  BOOL_ATTR(xaxis_use_fixed_pt)
197
190
  INT_ATTR(xaxis_digits_max)
198
- VAL_ATTR(xaxis_tick_labels)
199
191
  INT_ATTR(xaxis_numeric_label_decimal_digits)
200
192
  DBL_ATTR(xaxis_numeric_label_scale)
201
193
  DBL_ATTR(xaxis_numeric_label_shift)
@@ -214,7 +206,6 @@ FM *Get_FM(VALUE fmkr) {
214
206
  INT_ATTR(yaxis_loc)
215
207
  INT_ATTR(yaxis_type)
216
208
  DBL_ATTR(yaxis_line_width)
217
- VAL_ATTR(yaxis_stroke_color)
218
209
  DBL_ATTR(yaxis_major_tick_width)
219
210
  DBL_ATTR(yaxis_minor_tick_width)
220
211
  DBL_ATTR(yaxis_major_tick_length)
@@ -225,11 +216,8 @@ FM *Get_FM(VALUE fmkr) {
225
216
  DBL_ATTR(yaxis_tick_interval)
226
217
  DBL_ATTR(yaxis_min_between_major_ticks)
227
218
  INT_ATTR(yaxis_number_of_minor_intervals)
228
- VAL_ATTR(yaxis_locations_for_major_ticks)
229
- VAL_ATTR(yaxis_locations_for_minor_ticks)
230
219
  BOOL_ATTR(yaxis_use_fixed_pt)
231
220
  INT_ATTR(yaxis_digits_max)
232
- VAL_ATTR(yaxis_tick_labels)
233
221
  INT_ATTR(yaxis_numeric_label_decimal_digits)
234
222
  DBL_ATTR(yaxis_numeric_label_scale)
235
223
  DBL_ATTR(yaxis_numeric_label_shift)
@@ -262,12 +250,26 @@ FM *Get_FM(VALUE fmkr) {
262
250
  /* Warning on non-ok numbers */
263
251
  BOOL_ATTR(croak_on_nonok_numbers)
264
252
 
253
+ bool Get_initialized() {
254
+ OBJ_PTR v = rb_cv_get(cFM, "@@initialized");
255
+ return v != OBJ_FALSE && v != OBJ_NIL;
256
+ }
257
+
258
+ void Set_initialized() {
259
+ rb_cv_set(cFM, "@@initialized", OBJ_TRUE);
260
+ }
261
+
262
+ static void Set_fm_data_size() {
263
+ rb_cv_set(cFM, "@@fm_data_size", Integer_New(1 + (sizeof(FM) / sizeof(double))));
264
+ // size is number of doubles needed to hold FM data
265
+ }
266
+
265
267
  #define attr_reader(attr) rb_define_method(cFM, #attr , FM_##attr##_get, 0);
266
268
  #define attr_writer(attr) rb_define_method(cFM, #attr "=", FM_##attr##_set, 1);
267
269
  #define attr_accessors(attr) attr_reader(attr) attr_writer(attr)
268
270
 
269
271
  void Init_FigureMaker(void) {
270
- /* called by Ruby when the extension is loaded */
272
+ /* called by Ruby when the extension is loaded */
271
273
 
272
274
  /* this function has been modified by Vincent Fourmond for the splitting
273
275
  out of libraries more general than Tioga */
@@ -286,12 +288,12 @@ void Init_FigureMaker(void) {
286
288
  rb_require("Flate");
287
289
 
288
290
 
289
- VALUE mTioga = rb_define_module("Tioga");
291
+ OBJ_PTR mTioga = rb_define_module("Tioga");
290
292
 
291
293
 
292
294
  /* and now, we need to import Dobjects and Flate modules*/
293
- VALUE mDobjects = rb_define_module("Dobjects");
294
- VALUE mFlate = rb_define_module("Flate");
295
+ OBJ_PTR mDobjects = rb_define_module("Dobjects");
296
+ OBJ_PTR mFlate = rb_define_module("Flate");
295
297
  rb_include_module(mTioga, mDobjects);
296
298
  rb_include_module(mTioga, mFlate);
297
299
 
@@ -304,13 +306,13 @@ void Init_FigureMaker(void) {
304
306
  rb_include_module(cFM, mDobjects);
305
307
  rb_include_module(cFM, mFlate);
306
308
 
307
- rb_define_alloc_func(cFM, FM_alloc);
308
309
  Init_IDs();
309
310
  Init_Font_Dictionary();
310
311
  rb_define_method(cFM, "private_make", FM_private_make, 2);
311
312
  rb_define_method(cFM, "get_save_filename", FM_get_save_filename, 1);
312
313
  rb_define_method(cFM, "private_make_portfolio", FM_private_make_portfolio, 3);
313
-
314
+ rb_define_method(cFM, "private_init_fm_data", FM_private_init_fm_data, 0);
315
+
314
316
  /* page attribute accessors */
315
317
  attr_reader(root_figure)
316
318
  attr_reader(in_subplot)
@@ -364,15 +366,16 @@ void Init_FigureMaker(void) {
364
366
  attr_accessors(line_width)
365
367
  attr_accessors(line_cap)
366
368
  attr_accessors(line_join)
369
+ rb_define_method(cFM, "line_type_set", FM_line_type_set, 1);
367
370
  attr_accessors(miter_limit)
368
371
  attr_accessors(stroke_opacity)
369
372
  attr_accessors(fill_opacity)
370
- attr_accessors(line_type)
371
373
  /* croak on non ok */
372
374
  attr_accessors(croak_on_nonok_numbers)
373
375
 
374
376
  /* methods */
375
- rb_define_method(cFM, "private_context", FM_private_context, 1);
377
+ rb_define_method(cFM, "pdf_gsave", FM_pdf_gsave, 0);
378
+ rb_define_method(cFM, "pdf_grestore", FM_pdf_grestore, 0);
376
379
  rb_define_method(cFM, "private_set_bounds", FM_private_set_bounds, 4);
377
380
  rb_define_method(cFM, "private_set_subframe", FM_private_set_subframe, 4);
378
381
  rb_define_method(cFM, "doing_subfigure", FM_doing_subfigure, 0);
@@ -415,17 +418,20 @@ void Init_FigureMaker(void) {
415
418
  rb_define_method(cFM, "convert_output_to_figure_x", FM_convert_output_to_figure_x, 1);
416
419
  rb_define_method(cFM, "convert_output_to_figure_y", FM_convert_output_to_figure_y, 1);
417
420
  rb_define_method(cFM, "convert_output_to_figure_dx", FM_convert_output_to_figure_dx, 1);
418
- rb_define_method(cFM, "convert_output_to_figuret_dy", FM_convert_output_to_figure_dy, 1);
421
+ rb_define_method(cFM, "convert_output_to_figure_dy", FM_convert_output_to_figure_dy, 1);
419
422
  rb_define_method(cFM, "convert_to_degrees", FM_convert_to_degrees, 2);
420
423
  /* text */
421
424
  rb_define_method(cFM, "private_set_default_font_size", FM_private_set_default_font_size, 1);
422
425
  rb_define_method(cFM, "rescale_text", FM_rescale_text, 1);
423
- rb_define_method(cFM, "show_rotated_text", FM_show_rotated_text, 8);
424
- rb_define_method(cFM, "show_rotated_label", FM_show_rotated_label, 7);
426
+ rb_define_method(cFM, "show_rotated_text", FM_show_rotated_text, 9);
427
+ rb_define_method(cFM, "show_rotated_label", FM_show_rotated_label, 8);
425
428
  rb_define_method(cFM, "check_label_clip", FM_check_label_clip, 2);
429
+ /* text measurements */
430
+ rb_define_method(cFM, "private_save_measure", FM_save_measure, 4);
426
431
  /* path construction */
427
432
  rb_define_method(cFM, "move_to_point", FM_move_to_point, 2);
428
433
  rb_define_method(cFM, "append_point_to_path", FM_append_point_to_path, 2);
434
+ rb_define_method(cFM, "bezier_control_points", FM_bezier_control_points, 6);
429
435
  rb_define_method(cFM, "append_curve_to_path", FM_append_curve_to_path, 6);
430
436
  rb_define_method(cFM, "close_path", FM_close_path, 0);
431
437
  rb_define_method(cFM, "append_points_to_path", FM_append_points_to_path, 2);
@@ -512,13 +518,12 @@ void Init_FigureMaker(void) {
512
518
  rb_define_method(cFM, "no_top_edge", FM_no_top_edge, 0);
513
519
  rb_define_method(cFM, "no_bottom_edge", FM_no_bottom_edge, 0);
514
520
  /* makers */
515
- rb_define_method(cFM, "private_make_contour", FM_private_make_contour, 9);
516
- rb_define_method(cFM, "private_make_spline_interpolated_points", FM_private_make_spline_interpolated_points, 6);
517
- rb_define_method(cFM, "private_make_steps", FM_private_make_steps, 8);
521
+ rb_define_method(cFM, "private_make_contour", FM_private_make_contour, 7);
522
+ rb_define_method(cFM, "private_make_spline_interpolated_points", FM_private_make_spline_interpolated_points, 5);
523
+ rb_define_method(cFM, "private_make_steps", FM_private_make_steps, 6);
518
524
 
519
525
  /* Title */
520
526
  attr_reader(title_visible)
521
- attr_accessors(title)
522
527
  attr_accessors(title_side)
523
528
  attr_accessors(title_position)
524
529
  attr_accessors(title_scale)
@@ -530,7 +535,6 @@ void Init_FigureMaker(void) {
530
535
 
531
536
  /* X label */
532
537
  attr_reader(xlabel_visible)
533
- attr_accessors(xlabel)
534
538
  attr_accessors(xlabel_position)
535
539
  attr_accessors(xlabel_scale)
536
540
  attr_accessors(xlabel_shift)
@@ -542,7 +546,6 @@ void Init_FigureMaker(void) {
542
546
 
543
547
  /* Y label */
544
548
  attr_reader(ylabel_visible)
545
- attr_accessors(ylabel)
546
549
  attr_accessors(ylabel_position)
547
550
  attr_accessors(ylabel_scale)
548
551
  attr_accessors(ylabel_shift)
@@ -568,11 +571,8 @@ void Init_FigureMaker(void) {
568
571
  attr_accessors(xaxis_tick_interval)
569
572
  attr_accessors(xaxis_min_between_major_ticks)
570
573
  attr_accessors(xaxis_number_of_minor_intervals)
571
- attr_accessors(xaxis_locations_for_major_ticks)
572
- attr_accessors(xaxis_locations_for_minor_ticks)
573
574
  attr_accessors(xaxis_use_fixed_pt)
574
575
  attr_accessors(xaxis_digits_max)
575
- attr_accessors(xaxis_tick_labels)
576
576
  attr_accessors(xaxis_numeric_label_decimal_digits)
577
577
  attr_accessors(xaxis_numeric_label_scale)
578
578
  attr_accessors(xaxis_numeric_label_shift)
@@ -602,11 +602,8 @@ void Init_FigureMaker(void) {
602
602
  attr_accessors(yaxis_tick_interval)
603
603
  attr_accessors(yaxis_min_between_major_ticks)
604
604
  attr_accessors(yaxis_number_of_minor_intervals)
605
- attr_accessors(yaxis_locations_for_major_ticks)
606
- attr_accessors(yaxis_locations_for_minor_ticks)
607
605
  attr_accessors(yaxis_use_fixed_pt)
608
606
  attr_accessors(yaxis_digits_max)
609
- attr_accessors(yaxis_tick_labels)
610
607
  attr_accessors(yaxis_numeric_label_decimal_digits)
611
608
  attr_accessors(yaxis_numeric_label_scale)
612
609
  attr_accessors(yaxis_numeric_label_shift)
@@ -636,11 +633,13 @@ void Init_FigureMaker(void) {
636
633
  /* Debugging */
637
634
  attr_accessors(debug_verbosity_level)
638
635
 
636
+
637
+ Set_fm_data_size(); // must set this before create a FigureMaker instance
639
638
  rb_require("Tioga/FigMkr.rb");
640
639
  /* We now need to import the symbols */
641
640
 
642
641
  /* imports from Dvector */
643
- VALUE cDvector = rb_define_class_under(mDobjects, "Dvector", rb_cObject);
642
+ OBJ_PTR cDvector = rb_define_class_under(mDobjects, "Dvector", rb_cObject);
644
643
  RB_IMPORT_SYMBOL(cDvector, Dvector_Create);
645
644
  RB_IMPORT_SYMBOL(cDvector, Dvector_Data_Resize);
646
645
  RB_IMPORT_SYMBOL(cDvector, Dvector_Data_Replace);
@@ -656,7 +655,7 @@ void Init_FigureMaker(void) {
656
655
  RB_IMPORT_SYMBOL(mFlate, flate_expand);
657
656
 
658
657
  /* imports from Dtable */
659
- VALUE cDtable = rb_define_class_under(mDobjects, "Dtable", rb_cObject);
658
+ OBJ_PTR cDtable = rb_define_class_under(mDobjects, "Dtable", rb_cObject);
660
659
  RB_IMPORT_SYMBOL(cDtable, Dtable_Ptr);
661
660
  RB_IMPORT_SYMBOL(cDtable, Read_Dtable);
662
661
  }