extract_curves 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CVS/Entries +4 -0
  2. data/CVS/Repository +1 -0
  3. data/CVS/Root +1 -0
  4. data/bin/CVS/Entries +5 -0
  5. data/bin/CVS/Repository +1 -0
  6. data/bin/CVS/Root +1 -0
  7. data/bin/ec_rect2polar.rb +22 -0
  8. data/bin/ec_rev_lines.rb +5 -0
  9. data/bin/ec_sph_area.rb +30 -0
  10. data/bin/extract_curves.rb +2145 -0
  11. data/ruby_ext/CVS/Entries +1 -0
  12. data/ruby_ext/CVS/Repository +1 -0
  13. data/ruby_ext/CVS/Root +1 -0
  14. data/ruby_ext/pav/CVS/Entries +14 -0
  15. data/ruby_ext/pav/CVS/Repository +1 -0
  16. data/ruby_ext/pav/CVS/Root +1 -0
  17. data/ruby_ext/pav/cstr.c +82 -0
  18. data/ruby_ext/pav/cstr.h +17 -0
  19. data/ruby_ext/pav/extconf.rb +22 -0
  20. data/ruby_ext/pav/pav.c +162 -0
  21. data/ruby_ext/pav/pgtk.c +40 -0
  22. data/ruby_ext/pav/pgtk.h +14 -0
  23. data/ruby_ext/pav/pix.c +806 -0
  24. data/ruby_ext/pav/pix.h +236 -0
  25. data/ruby_ext/pav/t.rb +35 -0
  26. data/ruby_ext/pav/t1.rb +35 -0
  27. data/ruby_libs/CVS/Entries +1 -0
  28. data/ruby_libs/CVS/Repository +1 -0
  29. data/ruby_libs/CVS/Root +1 -0
  30. data/ruby_libs/pav/CVS/Entries +20 -0
  31. data/ruby_libs/pav/CVS/Repository +1 -0
  32. data/ruby_libs/pav/CVS/Root +1 -0
  33. data/ruby_libs/pav/attr_cache.rb +211 -0
  34. data/ruby_libs/pav/attr_cache.t1.rb +32 -0
  35. data/ruby_libs/pav/cache.rb +31 -0
  36. data/ruby_libs/pav/dbg_log.rb +458 -0
  37. data/ruby_libs/pav/floatsio.rb +53 -0
  38. data/ruby_libs/pav/generator_cache.rb +165 -0
  39. data/ruby_libs/pav/gtk/CVS/Entries +4 -0
  40. data/ruby_libs/pav/gtk/CVS/Repository +1 -0
  41. data/ruby_libs/pav/gtk/CVS/Root +1 -0
  42. data/ruby_libs/pav/gtk/button.rb +130 -0
  43. data/ruby_libs/pav/gtk/icons.rb +87 -0
  44. data/ruby_libs/pav/gtk/toolbar.rb +192 -0
  45. data/ruby_libs/pav/heap.rb +54 -0
  46. data/ruby_libs/pav/icons/CVS/Entries +17 -0
  47. data/ruby_libs/pav/icons/CVS/Repository +1 -0
  48. data/ruby_libs/pav/icons/CVS/Root +1 -0
  49. data/ruby_libs/pav/icons/alt_handle.xcf +0 -0
  50. data/ruby_libs/pav/icons/alt_handle.xpm +3832 -0
  51. data/ruby_libs/pav/icons/alt_handle_hover.xcf +0 -0
  52. data/ruby_libs/pav/icons/alt_handle_hover.xpm +3368 -0
  53. data/ruby_libs/pav/icons/alt_handle_pressed.xcf +0 -0
  54. data/ruby_libs/pav/icons/alt_handle_pressed.xpm +3828 -0
  55. data/ruby_libs/pav/icons/extract_curves/CVS/Entries +6 -0
  56. data/ruby_libs/pav/icons/extract_curves/CVS/Repository +1 -0
  57. data/ruby_libs/pav/icons/extract_curves/CVS/Root +1 -0
  58. data/ruby_libs/pav/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
  59. data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
  60. data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.xcf +0 -0
  61. data/ruby_libs/pav/icons/extract_curves/trace_mark.xcf +0 -0
  62. data/ruby_libs/pav/icons/extract_curves/trace_mark.xpm +38 -0
  63. data/ruby_libs/pav/icons/handle.xcf +0 -0
  64. data/ruby_libs/pav/icons/handle.xpm +213 -0
  65. data/ruby_libs/pav/icons/next.xpm +29 -0
  66. data/ruby_libs/pav/icons/next_hover.xpm +315 -0
  67. data/ruby_libs/pav/icons/next_pressed.xpm +144 -0
  68. data/ruby_libs/pav/icons/prev.xpm +29 -0
  69. data/ruby_libs/pav/icons/prev_hover.xpm +315 -0
  70. data/ruby_libs/pav/icons/prev_pressed.xpm +144 -0
  71. data/ruby_libs/pav/icons/vnext.xpm +29 -0
  72. data/ruby_libs/pav/icons/vprev.xpm +29 -0
  73. data/ruby_libs/pav/numeric/CVS/Entries +2 -0
  74. data/ruby_libs/pav/numeric/CVS/Repository +1 -0
  75. data/ruby_libs/pav/numeric/CVS/Root +1 -0
  76. data/ruby_libs/pav/numeric/ext.rb +13 -0
  77. data/ruby_libs/pav/pav_find.rb +90 -0
  78. data/ruby_libs/pav/pix.rb +402 -0
  79. data/ruby_libs/pav/pix/CVS/Entries +11 -0
  80. data/ruby_libs/pav/pix/CVS/Repository +1 -0
  81. data/ruby_libs/pav/pix/CVS/Root +1 -0
  82. data/ruby_libs/pav/pix/aapix.rb +378 -0
  83. data/ruby_libs/pav/pix/blob.rb +543 -0
  84. data/ruby_libs/pav/pix/circle.rb +73 -0
  85. data/ruby_libs/pav/pix/contour.rb +644 -0
  86. data/ruby_libs/pav/pix/contour/CVS/Entries +5 -0
  87. data/ruby_libs/pav/pix/contour/CVS/Repository +1 -0
  88. data/ruby_libs/pav/pix/contour/CVS/Root +1 -0
  89. data/ruby_libs/pav/pix/contour/calc_situations.rb +9 -0
  90. data/ruby_libs/pav/pix/contour/carp_calc.rb +212 -0
  91. data/ruby_libs/pav/pix/contour/situations.dmp +0 -0
  92. data/ruby_libs/pav/pix/contour/situations.rb +21 -0
  93. data/ruby_libs/pav/pix/curve.rb +1508 -0
  94. data/ruby_libs/pav/pix/img_obj.rb +751 -0
  95. data/ruby_libs/pav/pix/node.rb +712 -0
  96. data/ruby_libs/pav/pix/node_grp.rb +853 -0
  97. data/ruby_libs/pav/pix/shaved_core.rb +534 -0
  98. data/ruby_libs/pav/pix/subpix.rb +212 -0
  99. data/ruby_libs/pav/rand_accessible.rb +16 -0
  100. data/ruby_libs/pav/rangeset.rb +63 -0
  101. data/ruby_libs/pav/search.rb +210 -0
  102. data/ruby_libs/pav/set.rb +20 -0
  103. data/ruby_libs/pav/string/CVS/Entries +6 -0
  104. data/ruby_libs/pav/string/CVS/Repository +1 -0
  105. data/ruby_libs/pav/string/CVS/Root +1 -0
  106. data/ruby_libs/pav/string/bits.rb +523 -0
  107. data/ruby_libs/pav/string/ext.rb +58 -0
  108. data/ruby_libs/pav/string/observable.rb +155 -0
  109. data/ruby_libs/pav/string/text.rb +79 -0
  110. data/ruby_libs/pav/string/words.rb +42 -0
  111. data/ruby_libs/pav/sub_arr.rb +55 -0
  112. data/ruby_libs/pav/traced_obj.rb +79 -0
  113. metadata +161 -0
@@ -0,0 +1,53 @@
1
+ class FloatsInp
2
+ @@float_pat = Regexp.compile(/[+-]?(?:[0-9]+[.]?[0-9]*|[0-9]*[.]?[0-9]+)(?:[eE]?[0-9]*[.]?[0-9]*|)/)
3
+
4
+ attr_reader :io, :rec_buf
5
+
6
+ def initialize(*args)
7
+ @rec_buf = []
8
+ if args[0].kind_of?(IO)
9
+ @io = args[0]
10
+ else
11
+ @io = File.new(*args)
12
+ end
13
+ end
14
+
15
+ def method_missing(id, *args, &block)
16
+ @io.send(id, *args, &block)
17
+ end
18
+
19
+ def get_float
20
+ if @rec_buf.empty? && (ln = self.gets)
21
+ ln.scan(@@float_pat) { |f| @rec_buf << f.to_f }
22
+ end
23
+ @rec_buf.shift
24
+ end
25
+
26
+ def each_float
27
+ while (f = self.get_float)
28
+ yield(f)
29
+ end
30
+ end
31
+
32
+ def get_rec
33
+ if @rec_buf.empty?
34
+ return nil unless (ln = self.gets)
35
+ ln.scan(@@float_pat) { |f| @rec_buf << f.to_f }
36
+ end
37
+ res = @rec_buf
38
+ @rec_buf = []
39
+ res
40
+ end
41
+
42
+ def each_rec
43
+ while (rec = self.get_rec)
44
+ yield(rec)
45
+ end
46
+ end
47
+
48
+ def read_recs
49
+ res = []
50
+ self.each_rec { |rec| res << rec }
51
+ res
52
+ end
53
+ end
@@ -0,0 +1,165 @@
1
+ #require 'generator'
2
+
3
+ class GeneratorCacheArr < Array
4
+ def initialize(gen_spec=nil)
5
+ if !gen_spec
6
+ @gen_func = Proc.new
7
+ elsif gen_spec.kind_of?(Proc) || gen_spec.kind_of?(Method)
8
+ @gen_func = gen_spec
9
+ else
10
+ @gen_func = gen_spec.method("each")
11
+ end
12
+ @end = false
13
+ @next_lm = nil
14
+ super()
15
+ self.rewind
16
+ end
17
+
18
+ def end?
19
+ @end
20
+ end
21
+
22
+ def next?
23
+ !@end
24
+ end
25
+
26
+ def rewind
27
+ callcc { |@ret|
28
+ @gen_func.call { |lm|
29
+ callcc { |@next_lm| @ret.call }
30
+ self << lm
31
+ }
32
+ @end = true
33
+ @next_lm = proc {
34
+ raise EOFError, "no more elements available" }
35
+ @ret.call
36
+ }
37
+ self.clear
38
+ end
39
+
40
+ def next
41
+ callcc { |@ret| @next_lm.call }
42
+ self.last
43
+ end
44
+
45
+ def current
46
+ self.last
47
+ end
48
+
49
+ def index
50
+ self.length - 1
51
+ end
52
+
53
+ def cache_upto(last_i)
54
+ if last_i
55
+ self.length.upto(last_i) {
56
+ return if @end
57
+ self.next
58
+ }
59
+ else
60
+ while !@end
61
+ self.next
62
+ end
63
+ end
64
+ end
65
+
66
+ def [](*args)
67
+ if args.length == 1
68
+ i = args[0]
69
+ if i.kind_of? Range
70
+ if i.first < 0
71
+ last_i = nil
72
+ elsif i.last >= i.first
73
+ last_i = i.last + (i.exclude_end? ? 0:1)
74
+ else
75
+ if i.last + (i.exclude_end? ? 0:-1) < 0
76
+ last_i = nil
77
+ else
78
+ last_i = i.first
79
+ end
80
+ end
81
+ elsif i.kind_of? Array
82
+ last_i = i.max
83
+ elsif i.kind_of? Integer
84
+ if i < 0
85
+ last_i = nil
86
+ else
87
+ last_i = i
88
+ end
89
+ else
90
+ raise ArgumentError,
91
+ "Wrong single argument: #{i.inspect}"
92
+ end
93
+ elsif args.length == 2
94
+ last_i = args[0] + args[1] - 1
95
+ else
96
+ raise ArgumentError,
97
+ "Wrong numbef of arguments: #{args.inspect}"
98
+ end
99
+ self.cache_upto(last_i)
100
+ super(*args)
101
+ end
102
+ end
103
+
104
+ =begin
105
+ class GeneratorCacheArr < Generator
106
+ def initialize(*args, &block)
107
+ @arr = []
108
+ super(*args, &block)
109
+ end
110
+
111
+ def cache_upto(last_i)
112
+ if last_i
113
+ self.index.upto(last_i) {
114
+ return if self.end?
115
+ @arr << self.next
116
+ }
117
+ else
118
+ while !self.end?
119
+ @arr << self.next
120
+ end
121
+ end
122
+ end
123
+
124
+ def [](*args)
125
+ if args.length == 1
126
+ i = args[0]
127
+ if i.kind_of? Range
128
+ if i.first < 0
129
+ last_i = nil
130
+ elsif i.last >= i.first
131
+ last_i = i.last + (i.exclude_end? ? 0:1)
132
+ else
133
+ if i.last + (i.exclude_end? ? 0:-1) < 0
134
+ last_i = nil
135
+ else
136
+ last_i = i.first
137
+ end
138
+ end
139
+ elsif i.kind_of? Array
140
+ last_i = i.max
141
+ elsif i.kind_of? Integer
142
+ if i < 0
143
+ last_i = -i-1
144
+ else
145
+ last_i = i
146
+ end
147
+ else
148
+ raise ArgumentError,
149
+ "Wrong single argument: #{i.inspect}"
150
+ end
151
+ elsif args.length == 2
152
+ last_i = args[0] + args[1] - 1
153
+ else
154
+ raise ArgumentError,
155
+ "Wrong numbef of arguments: #{args.inspect}"
156
+ end
157
+ self.cache_upto(last_i)
158
+ @arr[*args]
159
+ end
160
+
161
+ def []=(*args)
162
+ @arr.[]=(*args)
163
+ end
164
+ end
165
+ =end
@@ -0,0 +1,4 @@
1
+ /button.rb/1.1.1.1/Tue Nov 15 17:32:12 2005//
2
+ /icons.rb/1.1.1.1/Tue Nov 15 17:32:12 2005//
3
+ /toolbar.rb/1.1.1.1/Tue Nov 15 17:32:12 2005//
4
+ D
@@ -0,0 +1 @@
1
+ extract-curves/ruby_libs/pav/gtk
@@ -0,0 +1 @@
1
+ :ext:pavpen@rubyforge.org:/var/cvs/extract-curves
@@ -0,0 +1,130 @@
1
+ require 'gtk2'
2
+ require 'pav/gtk/icons'
3
+
4
+ module PGtk
5
+
6
+ class Button < Gtk::Viewport
7
+ attr_reader :content, :content_hover, :content_pressed, :hovered,
8
+ :pressed, :show_box, :hide_box
9
+ attr_accessor :left_click_proc, :middle_click_proc,
10
+ :right_click_proc
11
+
12
+ def initialize(cont_spec=nil, w_cont_hover=nil, h_cont_hover=nil,
13
+ cont_hover=nil, cont_pressed=nil, &left_click_proc)
14
+ if cont_pressed
15
+ @content = PGtk.stock_image_of_size(cont_spec,
16
+ w_cont_hover, h_cont_hover)
17
+ @content_hover = PGtk.stock_image_of_size(cont_hover,
18
+ w_cont_hover, h_cont_hover)
19
+ @content_pressed = PGtk.stock_image_of_size(
20
+ cont_pressed, w_cont_hover, h_cont_hover)
21
+ elsif cont_hover
22
+ @content = PGtk.stock_image_of_size(cont_spec,
23
+ w_cont_hover, h_cont_hover)
24
+ @content_hover = PGtk.stock_image_of_size(cont_hover,
25
+ w_cont_hover, h_cont_hover)
26
+ elsif h_cont_hover
27
+ if w_cont_hover.kind_of?(Integer)
28
+ @content = PGtk.stock_image_of_size(cont_spec,
29
+ w_cont_hover, h_cont_hover)
30
+ @content_hover = nil
31
+ else
32
+ @content = Gtk::Image.new(cont_spec, h_cont_hover)
33
+ @content_hover = Gtk::Image.new(w_cont_hover,
34
+ h_cont_hover)
35
+ end
36
+ elsif w_cont_hover
37
+ if w_cont_hover.kind_of?(Symbol)
38
+ @content = Gtk::Image.new(cont_spec,
39
+ Gtk::IconSize::BUTTON)
40
+ @content_hover = Gtk::Image.new(w_cont_hover,
41
+ Gtk::IconSize::BUTTON)
42
+ else
43
+ @content = Gtk::Image.new(cont_spec, w_cont_hover)
44
+ @content_hover = nil
45
+ end
46
+ elsif cont_spec
47
+ @content = Gtk::Image.new(cont_spec,
48
+ Gtk::IconSize::BUTTON)
49
+ @content_hover = nil
50
+ end
51
+ @left_click_proc = left_click_proc if block_given?
52
+ super(nil, nil)
53
+ @show_box = Gtk::HBox.new(false, 1)
54
+ @hide_box = Gtk::HBox.new(false, 1)
55
+ self << @show_box
56
+ @show_box.pack_start(@content, true, true) if @content
57
+ @hide_box.pack_start(@content_hover, true, true) if
58
+ @content_hover
59
+ @hide_box.pack_start(@content_pressed, true, true) if
60
+ @content_pressed
61
+ self.events |= Gdk::Event::BUTTON_RELEASE_MASK |
62
+ Gdk::Event::BUTTON_PRESS_MASK |
63
+ Gdk::Event::ENTER_NOTIFY_MASK |
64
+ Gdk::Event::LEAVE_NOTIFY_MASK
65
+ self.shadow_type = Gtk::SHADOW_OUT
66
+ self.signal_connect('button_press_event') { |wgt, ev|
67
+ @pressed = ev.button
68
+ if [@left_click_proc, @middle_click_proc,
69
+ @right_click_proc].at(@pressed-1) &&
70
+ @content_pressed
71
+ tmp=(@content_hover ? @content_hover : @content)
72
+ tmp.reparent(@hide_box)
73
+ tmp.hide
74
+ @content_pressed.reparent(@show_box)
75
+ @content_pressed.show
76
+ end
77
+ false
78
+ }
79
+ self.signal_connect('button_release_event') { |wgt, ev|
80
+ @pressed = nil
81
+ if @content_pressed
82
+ @content_pressed.reparent(@hide_box)
83
+ @content_pressed.hide
84
+ tmp=(@content_hover ? @content_hover : @content)
85
+ tmp.reparent(@show_box)
86
+ tmp.show
87
+ end
88
+ if @hovered &&(tmp=[@left_click_proc,@middle_click_proc,
89
+ @right_click_proc].at(ev.button-1))
90
+ tmp.call(wgt, ev)
91
+ else
92
+ false
93
+ end
94
+ }
95
+ self.signal_connect('enter_notify_event') { |wgt, ev|
96
+ @hovered = true
97
+ if @pressed && [@left_click_proc, @middle_click_proc,
98
+ @right_click_proc].at(@pressed-1) &&
99
+ @content_pressed
100
+ @content.reparent(@hide_box)
101
+ @content.hide
102
+ @content_pressed.reparent(@show_box)
103
+ @content_pressed.show
104
+ elsif @content_hover
105
+ @content.reparent(@hide_box)
106
+ @content.hide
107
+ @content_hover.reparent(@show_box)
108
+ @content_hover.show
109
+ end
110
+ false
111
+ }
112
+ self.signal_connect('leave_notify_event') { |wgt, ev|
113
+ @hovered = false
114
+ if @pressed
115
+ @content_pressed.reparent(@hide_box)
116
+ @content_pressed.hide
117
+ @content_hover.reparent(@hide_box)
118
+ @content_hover.hide
119
+ elsif @content_hover
120
+ @content_hover.reparent(@hide_box)
121
+ @content_hover.hide
122
+ end
123
+ @content.reparent(@show_box)
124
+ @content.show
125
+ false
126
+ }
127
+ end
128
+ end
129
+
130
+ end
@@ -0,0 +1,87 @@
1
+ require 'gtk2'
2
+ require 'pav/pav_find'
3
+ require 'pav/string/ext'
4
+
5
+ module PGtk
6
+
7
+ pgtk_symbs = [[:"pgtk-handle", 'Handle', 'alt_handle.xpm'],
8
+ [:"pgtk-handle-hover", 'Handle', 'alt_handle_hover.xpm'],
9
+ [:"pgtk-handle-pressed", 'Handle', 'alt_handle_pressed.xpm'],
10
+ [:"pgtk-previous", 'Previous', 'prev.xpm'],
11
+ [:"pgtk-previous-hover", 'Previous', 'prev_hover.xpm'],
12
+ [:"pgtk-previous-pressed", 'Previous', 'prev_pressed.xpm'],
13
+ [:"pgtk-next", 'Next', 'next.xpm'],
14
+ [:"pgtk-next-hover", 'Next', 'next_hover.xpm'],
15
+ [:"pgtk-next-pressed", 'Next', 'next_pressed.xpm'],
16
+ [:"pgtk-vertical-previous", 'Vertical previous', 'vprev.xpm'],
17
+ [:"pgtk-vertical-next", 'Vertical next', 'vnext.xpm']]
18
+ pgtk_symbs.each { |s| Gtk::Stock.add(s[0], s[1]) }
19
+ ifactory = Gtk::IconFactory.new
20
+ ifactory.add_default
21
+ pb_handle = pb_vhandle = nil
22
+ found_cnt = 0
23
+ PavFind.pfind($:) { |path|
24
+ pgtk_symbs.each { |s|
25
+ if path.ends_with("pav/icons/" + s[2]) && !s[3]
26
+ s[3] = Gdk::Pixbuf.new(path)
27
+ break if (found_cnt += 1) >= pgtk_symbs.length
28
+ end
29
+ }
30
+ break if found_cnt >= pgtk_symbs.length
31
+ }
32
+ pgtk_symbs.each { |s| ifactory.add(s[0].to_s, Gtk::IconSet.new(s[3])) }
33
+
34
+ @icon_cache = {}
35
+
36
+ def self.find_icon_file(fpath)
37
+ PavFind.pfind($:) { |path|
38
+ return path if path.ends_with(fpath)
39
+ }
40
+ end
41
+
42
+ def self.stock_image_of_size(stock_id, w, h)
43
+ if (tmp = @icon_cache[[stock_id, w, h]])
44
+ tmp.kind_of?(Gdk::Pixbuf) ? Gtk::Image.new(tmp) :
45
+ Gtk::Image.new(stock_id, tmp)
46
+ end
47
+ icon_set = Gtk::IconFactory.lookup_default(stock_id.to_s) ||
48
+ Gtk::IcontFactory.lookup_default("gtk-missing-image")
49
+ max_size = nil
50
+ max_sz = [0,0]
51
+ found_size = nil
52
+ icon_set.sizes.each { |size|
53
+ if (sz=Gtk::IconSize.lookup(size)) == [w, h]
54
+ found_size = size
55
+ end
56
+ if sz[0]*sz[1] > max_sz[0]*max_sz[1]
57
+ max_size = size
58
+ max_sz = Gtk::IconSize.lookup(max_size)
59
+ end
60
+ }
61
+ if found_size
62
+ @icon_cache[[stock_id, w, h]] = found_size
63
+ Gtk::Image.new(stock_id, found_size)
64
+ else
65
+ wd = Gtk::Window.new
66
+ pb=wd.render_icon(stock_id,max_size,stock_id.to_s+":#{w}x#{h}").
67
+ scale(w, h, Gdk::Pixbuf::INTERP_BILINEAR)
68
+ wd.destroy
69
+ @icon_cache[[stock_id, w, h]] = pb
70
+ Gtk::Image.new(pb)
71
+ end
72
+ end
73
+
74
+ def self.stock_icon_btn_of_size(window, stock_id, w, h)
75
+ res = Gtk::Button.new << self.stock_image_of_size(stock_id, w-10, h-10)
76
+ res.set_size_request(w, h)
77
+ res
78
+ end
79
+
80
+ def self.stock_icon_tool_btn_of_size(window, stock_id, w, h)
81
+ res = Gtk::ToolButton.new("")
82
+ res.icon_widget = self.stock_image_of_size(stock_id, w-10, h-10)
83
+ res.set_size_request(w, h)
84
+ res
85
+ end
86
+
87
+ end