tioga 1.4 → 1.5

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 (54) hide show
  1. data/Tioga_README +177 -139
  2. data/split/Dtable/dtable.c +3 -0
  3. data/split/Dtable/namespace.h +7 -3
  4. data/split/Dtable/symbols.h +2 -2
  5. data/split/Dvector/dvector.c +3 -2
  6. data/split/Dvector/namespace.h +7 -3
  7. data/split/Dvector/symbols.h +2 -2
  8. data/split/Flate/flate.c +2 -1
  9. data/split/Flate/namespace.h +7 -3
  10. data/split/Flate/symbols.h +2 -2
  11. data/split/Function/extconf.rb +1 -1
  12. data/split/Function/function.c +38 -6
  13. data/split/Function/joint_qsort.c +1 -2
  14. data/split/Function/namespace.h +7 -3
  15. data/split/Function/symbols.h +2 -2
  16. data/split/Tioga/axes.c +4 -5
  17. data/split/Tioga/figures.c +1 -0
  18. data/split/Tioga/figures.h +5 -3
  19. data/split/Tioga/lib/Arcs_and_Circles.rb +1 -1
  20. data/split/Tioga/lib/ColorConstants.rb +9 -9
  21. data/split/Tioga/lib/Creating_Paths.rb +1 -1
  22. data/split/Tioga/lib/FigMkr.rb +25 -23
  23. data/split/Tioga/lib/FigureConstants.rb +2 -2
  24. data/split/Tioga/lib/Figures_and_Plots.rb +6 -6
  25. data/split/Tioga/lib/Images.rb +2 -2
  26. data/split/Tioga/lib/MarkerConstants.rb +3 -3
  27. data/split/Tioga/lib/Markers.rb +6 -6
  28. data/split/Tioga/lib/Page_Frame_Bounds.rb +1 -1
  29. data/split/Tioga/lib/Rectangles.rb +1 -1
  30. data/split/Tioga/lib/Shading.rb +2 -2
  31. data/split/Tioga/lib/Special_Paths.rb +5 -5
  32. data/split/Tioga/lib/Strokes.rb +2 -2
  33. data/split/Tioga/lib/TeX_Text.rb +5 -5
  34. data/split/Tioga/lib/TexPreamble.rb +116 -116
  35. data/split/Tioga/lib/Transparency.rb +2 -2
  36. data/split/Tioga/lib/Using_Paths.rb +1 -1
  37. data/split/Tioga/lib/X_and_Y_Axes.rb +19 -15
  38. data/split/Tioga/lib/irb_tioga.rb +36 -11
  39. data/split/Tioga/lib/maker.rb +201 -0
  40. data/split/Tioga/lib/tioga_ui_cmds.rb +6 -2
  41. data/split/Tioga/namespace.h +7 -3
  42. data/split/Tioga/pdfcoords.c +20 -2
  43. data/split/Tioga/pdfs.h +1 -1
  44. data/split/Tioga/symbols.h +2 -2
  45. data/split/extconf.rb +7 -5
  46. data/split/namespace.h +7 -3
  47. data/split/symbols.c +1 -9
  48. data/split/symbols.h +2 -2
  49. metadata +19 -23
  50. data/split/Dtable/symbols.c +0 -92
  51. data/split/Dvector/symbols.c +0 -92
  52. data/split/Flate/symbols.c +0 -92
  53. data/split/Function/symbols.c +0 -92
  54. data/split/Tioga/symbols.c +0 -92
@@ -32,7 +32,7 @@ class Transparency < Doc < FigureMaker
32
32
  #
33
33
  # Example: on left, fill_opacity = 1.0; on right fill_opacity = 0.6
34
34
  #
35
- # http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Squares.jpg
35
+ # link:images/Squares.png
36
36
  def fill_opacity
37
37
  end
38
38
 
@@ -72,7 +72,7 @@ class Transparency < Doc < FigureMaker
72
72
  #
73
73
  # Example: on left, fill_transparency = 0.0; on right fill_transparency = 0.4
74
74
  #
75
- # http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Squares.jpg
75
+ # link:images/Squares.png
76
76
  def fill_transparency
77
77
  end
78
78
 
@@ -94,7 +94,7 @@ class Using_Paths < Doc < FigureMaker
94
94
  # If the squares are drawn in opposite directions, only the area between them is inside,
95
95
  # according to the nonzero winding number rule. See also #eofill.
96
96
  #
97
- # http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Fill_Rules.jpg
97
+ # link:images/Fill_Rules.png
98
98
  def fill
99
99
  end
100
100
 
@@ -269,8 +269,10 @@ class X_and_Y_Axes < Doc < FigureMaker
269
269
  # xaxis_digits_max
270
270
  # xaxis_digits_max = an_integer_value
271
271
  #
272
- # If non-zero and tioga is creating numeric labels for the x axis, then numeric label
273
- # will be switched to exponential format if it requires more than this number of digits.
272
+ # If non-zero (and xaxis_use_fixed_pt is not true), then x axis numeric labels
273
+ # will be switched to exponential format if they require more than this number of digits.
274
+ # If yaxis_digits_max is set to zero, then a system-choosen default value is used instead.
275
+ # See also xaxis_use_fixed_pt.
274
276
  def xaxis_digits_max
275
277
  end
276
278
 
@@ -278,11 +280,11 @@ class X_and_Y_Axes < Doc < FigureMaker
278
280
  # xaxis_use_fixed_pt
279
281
  # xaxis_use_fixed_pt = true_or_false
280
282
  #
281
- # If this flag is +true+, and tioga is creating numeric labels for the x axis,
282
- # and the xaxis_log_values flag is also +true+,
283
- # then the labels will be shown using fixed point notation rather than exponential.
284
- # For example, a label at x location 3.0 will display as "1000" rather than as "10^3",
285
- # and a label at x == -2.0 will display as "0.01" rather than as "10^-2".
283
+ # If this flag is +true+, then numeric labels for the x axis
284
+ # will always use fixed point notation rather than exponential.
285
+ # If +false+, then the value of xaxis_digits_max will be used to decide between
286
+ # fixed point or exponential notation.
287
+ # See also xaxis_digits_max.
286
288
  def xaxis_use_fixed_pt
287
289
  end
288
290
 
@@ -515,8 +517,10 @@ class X_and_Y_Axes < Doc < FigureMaker
515
517
  # yaxis_digits_max
516
518
  # yaxis_digits_max = an_integer_value
517
519
  #
518
- # If non-zero and tioga is creating numeric labels for the y axis, then numeric label
519
- # will be switched to exponential format if it requires more than this number of digits.
520
+ # If non-zero (and yaxis_use_fixed_pt is not true), then y axis numeric labels
521
+ # will be switched to exponential format if they require more than this number of digits.
522
+ # If yaxis_digits_max is set to zero, then a system-choosen default value is used instead.
523
+ # See also yaxis_use_fixed_pt.
520
524
  def yaxis_digits_max
521
525
  end
522
526
 
@@ -524,11 +528,11 @@ class X_and_Y_Axes < Doc < FigureMaker
524
528
  # yaxis_use_fixed_pt
525
529
  # yaxis_use_fixed_pt = true_or_false
526
530
  #
527
- # If this flag is +true+, and tioga is creating numeric labels for the y axis,
528
- # and the yaxis_log_values flag is also +true+,
529
- # then the labels will be shown using fixed point notation rather than exponential.
530
- # For example, a label at y location 3.0 will display as "1000" rather than as "10^3",
531
- # and a label at y == -2.0 will display as "0.01" rather than as "10^-2".
531
+ # If this flag is +true+, then numeric labels for the y axis
532
+ # will always use fixed point notation rather than exponential.
533
+ # If +false+, then the value of yaxis_digits_max will be used to decide between
534
+ # fixed point or exponential notation.
535
+ # See also yaxis_digits_max.
532
536
  def yaxis_use_fixed_pt
533
537
  end
534
538
 
@@ -583,7 +587,7 @@ Examples
583
587
  end
584
588
  end
585
589
 
586
- http://theory.kitp.ucsb.edu/~paxton/tioga_jpegs/Special_Y.jpg
590
+ link:images/Special_Y.png
587
591
 
588
592
  =end
589
593
  def yaxis_tick_labels
@@ -5,9 +5,17 @@ module IRB_Tioga
5
5
 
6
6
  $tioga_figure_filename = nil
7
7
  $tioga_figure_num = nil
8
+
9
+
10
+ def check_have_loaded
11
+ return true unless ($tioga_figure_filename == nil) || ($tioga_figure_filename.length == 0)
12
+ puts "Must open a file first."
13
+ return false
14
+ end
8
15
 
9
16
  def o(filename=nil)
10
17
  filename = $tioga_figure_filename if filename == nil
18
+ return if filename == nil || filename.length == 0 # this happens if just give shell command irb_tioga with no filename
11
19
  filename = $tioga_ui.fix_filename(filename)
12
20
  result = $tioga_ui.setdir_and_load(filename)
13
21
  return false if result == nil
@@ -22,22 +30,26 @@ def do_figs(fignums,view)
22
30
  end
23
31
  if fignums == nil
24
32
  $tioga_ui.make_all_pdfs(view)
25
- elsif fignums.kind_of?Integer
26
- fignums += FigureMaker.default.num_figures if fignums < 0
27
- $tioga_ui.do_fignums([fignums],view)
33
+ set_figure_num(0)
28
34
  else
35
+ if fignums.kind_of?Integer
36
+ fignums += FigureMaker.default.num_figures if fignums < 0
37
+ fignums = [fignums]
38
+ end
29
39
  $tioga_ui.do_fignums(fignums,view)
40
+ set_figure_num(fignums[-1])
30
41
  end
31
- set_figure_num(fignums[-1]) unless fignums == nil
32
42
  return true
33
43
  end
34
44
 
35
45
  def s(fignums=nil)
46
+ return unless check_have_loaded
36
47
  do_figs(fignums,true)
37
48
  return true
38
49
  end
39
50
 
40
51
  def m(fignums=nil)
52
+ return unless check_have_loaded
41
53
  do_figs(fignums,false)
42
54
  return true
43
55
  end
@@ -48,6 +60,7 @@ def set_figure_num(num)
48
60
  end
49
61
 
50
62
  def p(fignums=nil)
63
+ return unless check_have_loaded
51
64
  if fignums.kind_of?String
52
65
  fignums = $tioga_ui.parse_figs(fignums)
53
66
  end
@@ -64,6 +77,7 @@ def p(fignums=nil)
64
77
  end
65
78
 
66
79
  def r
80
+ return unless check_have_loaded
67
81
  if $tioga_figure_num != nil
68
82
  figname = FigureMaker.default.figure_names[$tioga_figure_num]
69
83
  else
@@ -79,6 +93,16 @@ def r
79
93
  end
80
94
 
81
95
 
96
+ def cmds
97
+ l
98
+ end
99
+
100
+
101
+ def list_cmds
102
+ l
103
+ end
104
+
105
+
82
106
  def l
83
107
  $tioga_ui.list_figures
84
108
  return true
@@ -87,13 +111,14 @@ end
87
111
  def h
88
112
  puts ''
89
113
  puts " Command description"
90
- puts " o 'filename' open tioga file (with extension .rb)."
91
- puts " l output a list of the defined figures by number and name."
92
- puts " m <figs> make PDFs without showing them in the viewer."
93
- puts " s <figs> make and show PDFs, each in a separate viewer window."
94
- puts " p <figs> make PDFs and show the portfolio as a multi-page document."
95
- puts " r reloads the current tioga file and reshows the current figure."
96
- puts " h helpfully print this list of commands."
114
+ puts " o 'filename' opens the named tioga file (with extension .rb)."
115
+ puts " o opens the current tioga file (i.e., reload)."
116
+ puts " l lists the defined figures by number and name."
117
+ puts " m <figs> makes PDFs without showing them in the viewer."
118
+ puts " s <figs> makes and shows PDFs, each in a separate viewer window."
119
+ puts " p <figs> makes PDFs and shows the portfolio as a multi-page document."
120
+ puts " r reloads the current file and reshows the current figure."
121
+ puts " h helpfully prints this list of commands."
97
122
  puts "\n Since the filename extension is known, you can skip typing it if you like."
98
123
  puts "\n If <figs> is omitted, then tioga does all the figures defined in the file"
99
124
  puts " ordered by their definition index numbers."
@@ -0,0 +1,201 @@
1
+ =begin
2
+ Copyright (C) 2005 Bill Paxton
3
+
4
+ This file is part of Tioga.
5
+
6
+ Tioga is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Library Public License as published
8
+ by the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ Tioga is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Library General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Library General Public License
17
+ along with Tioga; if not, write to the Free Software
18
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ =end
20
+
21
+ require 'Tioga/tioga.rb'
22
+ require 'scanf'
23
+
24
+ include Tioga
25
+
26
+ require 'readline'
27
+ include Readline
28
+ # for some reason, the pipes don't work unless I use the Readline package
29
+
30
+ def report_error(er, msg)
31
+ fm = FigureMaker.default
32
+ puts msg
33
+ puts ""
34
+ puts " " + "#{er.message}"
35
+ line_count = 0
36
+ er.backtrace.each do |line|
37
+ if line_count < fm.num_error_lines
38
+ puts " " + line
39
+ end
40
+ line_count = line_count + 1
41
+ end
42
+ puts "ERROR" # GUI uses this
43
+ end
44
+
45
+ def loadfile(fname, cmd)
46
+ fm = FigureMaker.default
47
+ have_loaded = false
48
+ fm.reset_state
49
+ begin
50
+ puts "load #{fname}"
51
+ load(fname) # this should define the TiogaFigures class
52
+ refresh_fname = fm.auto_refresh_filename
53
+ if refresh_fname != nil
54
+ refresh_fname = "#{fm.run_dir}/#{refresh_fname}" if fm.run_dir != nil && refresh_fname[0..0] != '/'
55
+ puts "####03OK #{refresh_fname}" # GUI uses this
56
+ end
57
+ have_loaded = true
58
+ if cmd == "load_and_list"
59
+ num_fig = fm.num_figures
60
+ if num_fig == 0
61
+ puts "ERROR: Failed to define any figures. Remember to invoke 'new' for the class containing the figure definitions"
62
+ end
63
+ response = "####01OK " + num_fig.to_s
64
+ num_fig.times { |i| response = response + ' ' + fm.figure_name(i) }
65
+ puts response # GUI uses this
66
+ end
67
+ rescue Exception => er
68
+ report_error(er, "ERROR: load failed for #{fname}\n####01")
69
+ end
70
+ return have_loaded
71
+ end
72
+
73
+ def command_loop
74
+ fm = FigureMaker.default
75
+ fname = nil
76
+ pname = nil
77
+ have_loaded = false
78
+
79
+ loop do
80
+ cmd_line = readline("\n")
81
+ #cmd_line = gets
82
+ break if cmd_line.nil?
83
+ cmd = cmd_line.scanf("%s")
84
+ cmd = cmd.to_s
85
+ puts "\n\n"
86
+ if cmd == "exit"
87
+ puts "exiting"
88
+ puts "###\n" # this marks end of command -- DON'T change it since the GUI depends on it!
89
+ exit
90
+ elsif (cmd == "need_to_reload_data")
91
+ fm.need_to_reload_data = true
92
+ elsif (cmd == "eval_function")
93
+ skip = "eval_function".length
94
+ string = cmd_line[skip+1..-1]
95
+ begin
96
+ result = fm.eval_function(string)
97
+ puts result.to_s
98
+ rescue
99
+ end
100
+ puts "####00" # GUI uses this
101
+ elsif (cmd == "load" || cmd == "load_and_list")
102
+ cmd, fname = cmd_line.scanf("%s %s")
103
+ if fname == nil
104
+ puts "must give file name as argument for load command"
105
+ else
106
+ have_loaded = loadfile(fname, cmd)
107
+ end
108
+ elsif (cmd == "make_portfolio")
109
+ if !have_loaded
110
+ puts "must load a file before make a portfolio"
111
+ else
112
+ cmd, fname = cmd_line.scanf("%s %s")
113
+ if fname == nil
114
+ puts "must give file name as argument for make_portfolio command"
115
+ else
116
+ fm.require_all
117
+ fm.make_portfolio_pdf(fname)
118
+ puts "####00" # GUI uses this
119
+ end
120
+ end
121
+ elsif (cmd == "make" || cmd == "need_to_reload_data_and_make")
122
+ if cmd == "need_to_reload_data_and_make"
123
+ fm.need_to_reload_data = true
124
+ end
125
+ if !have_loaded
126
+ puts "must load a file before make a figure"
127
+ else
128
+ cmd, num = cmd_line.scanf("%s %s")
129
+ if num == nil || (num.to_i == 0 && num != "0")
130
+ puts "must provide integer figure index as arg make"
131
+ else
132
+ result = fm.make_pdf(num.to_i)
133
+ if result == false
134
+ puts "####02FAILED" # GUI uses this
135
+ else
136
+ puts "####02OK #{result}"
137
+ end
138
+ puts "#{result}"
139
+ end
140
+ end
141
+ elsif cmd == "make_all"
142
+ if !have_loaded
143
+ puts "must load a file before make_all"
144
+ else
145
+ puts "make_all"
146
+ fm.num_figures.times {|i| fm.make_preview_pdf(i) }
147
+ end
148
+ puts "####00" # GUI uses this
149
+ elsif cmd == "name"
150
+ if !have_loaded
151
+ puts "must load a file before ask for figure names"
152
+ else
153
+ cmd, num = cmd_line.scanf("%s %s")
154
+ if (num == nil)
155
+ puts "must give index of figure as argument for name command"
156
+ else
157
+ eval_str = "fm.figure_name(#{num})"
158
+ begin
159
+ puts eval(eval_str)
160
+ rescue Exception
161
+ puts "invalid figure number #{num}"
162
+ end
163
+ end
164
+ end
165
+ elsif cmd == "names"
166
+ if !have_loaded
167
+ puts "must load a file before ask for figure names"
168
+ else
169
+ puts fm.figure_names
170
+ end
171
+ elsif cmd == "list"
172
+ if !have_loaded
173
+ puts "must load a file before ask to list figure names"
174
+ else
175
+ fm.figure_names.each_with_index { |name,i| STDOUT.printf("%3i %s\n",i,name) }
176
+ end
177
+ elsif cmd == "num_figures"
178
+ if !have_loaded
179
+ puts "must load a file before ask how many figures"
180
+ else
181
+ eval_str = "fm.num_figures"
182
+ begin
183
+ puts eval(eval_str).to_s
184
+ rescue Exception
185
+ end
186
+ end
187
+ elsif cmd == "set_which_pdflatex"
188
+ cmd, fname = cmd_line.scanf("%s %s")
189
+ if fname == nil
190
+ puts "must give pdflatex name as argument for set_which_pdflatex command"
191
+ else
192
+ FigureMaker.pdflatex = fname
193
+ puts "use #{fname}"
194
+ end
195
+ else
196
+ puts "invalid command <#{cmd}> in command line <#{cmd_line}>"
197
+ end
198
+ end
199
+ end
200
+
201
+ command_loop
@@ -169,8 +169,12 @@ class TiogaUI
169
169
 
170
170
  return filename unless $change_working_directory
171
171
 
172
- # if necessary, add the current directory to the front of the filename
173
- filename = Dir.getwd + '/' + filename if filename[0..0] != '/'
172
+ if (filename.length > 2) && (filename[0..1] == '~/')
173
+ filename = ENV['HOME'] + filename[1..-1]
174
+ elsif filename[0..0] != '/'
175
+ # if necessary, add the current directory to the front of the filename
176
+ filename = Dir.getwd + '/' + filename
177
+ end
174
178
 
175
179
  parts = filename.split('/')
176
180
  if parts[-1].length < 2 || parts[-1][-2..-1] != "rb"
@@ -34,14 +34,18 @@
34
34
  */
35
35
 
36
36
  #ifdef __APPLE__
37
- # define PRIVATE __private_extern__
37
+ # define INTERN __private_extern__
38
38
  # define PUBLIC
39
39
  #elif __GNUC__ >= 4 /* we have the visibility attribute */
40
- # define PRIVATE __attribute__ ((visibility ("hidden")))
40
+ # define INTERN __attribute__ ((visibility ("hidden")))
41
41
  # define PUBLIC __attribute__ ((visibility ("default")))
42
42
  #else /* not really good */
43
- # define PRIVATE
43
+ # define INTERN
44
44
  # define PUBLIC
45
45
  #endif /* __APPLE__ and __GNU_C_ >= 4*/
46
46
 
47
+ /* In any case, PRIVATE is static */
48
+
49
+ #define PRIVATE static
50
+
47
51
  #endif
@@ -139,14 +139,32 @@ void c_set_bounds(FM *p, double left, double right, double top, double bottom)
139
139
  } else if (right < left) {
140
140
  p->xaxis_reversed = true;
141
141
  p->bounds_xmin = right; p->bounds_xmax = left;
142
- } else rb_raise(rb_eArgError, "Sorry: left and right bounds cannot be the same (%g)", left);
142
+ } else { // left == right
143
+ p->xaxis_reversed = false;
144
+ if (left > 0.0) {
145
+ p->bounds_xmin = left * (1.0 - 1e-6); p->bounds_xmax = left * (1.0 + 1e-6);
146
+ } else if (left < 0.0) {
147
+ p->bounds_xmin = left * (1.0 + 1e-6); p->bounds_xmax = left * (1.0 - 1e-6);
148
+ } else {
149
+ p->bounds_xmin = -1e-6; p->bounds_xmax = 1e-6;
150
+ }
151
+ }
143
152
  if (bottom < top) {
144
153
  p->yaxis_reversed = false;
145
154
  p->bounds_ymin = bottom; p->bounds_ymax = top;
146
155
  } else if (top < bottom) {
147
156
  p->yaxis_reversed = true;
148
157
  p->bounds_ymin = top; p->bounds_ymax = bottom;
149
- } else rb_raise(rb_eArgError, "Sorry: top and bottom bounds cannot be the same (%g)", top);
158
+ } else { // top == bottom
159
+ p->yaxis_reversed = false;
160
+ if (bottom > 0.0) {
161
+ p->bounds_ymin = bottom * (1.0 - 1e-6); p->bounds_ymax = bottom * (1.0 + 1e-6);
162
+ } else if (bottom < 0.0) {
163
+ p->bounds_ymin = bottom * (1.0 + 1e-6); p->bounds_ymax = bottom * (1.0 - 1e-6);
164
+ } else {
165
+ p->bounds_xmin = -1e-6; p->bounds_xmax = 1e-6;
166
+ }
167
+ }
150
168
  p->bounds_width = p->bounds_xmax - p->bounds_xmin;
151
169
  p->bounds_height = p->bounds_ymax - p->bounds_ymin;
152
170
  Recalc_Font_Hts(p);