ctioga2 0.9 → 0.10
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/Changelog +27 -0
- data/bin/ct2-make-movie +92 -45
- data/lib/ctioga2/commands/doc/html.rb +1 -1
- data/lib/ctioga2/commands/doc/introspection.rb +52 -0
- data/lib/ctioga2/commands/doc/markup.rb +4 -0
- data/lib/ctioga2/commands/general-commands.rb +19 -0
- data/lib/ctioga2/commands/general-functions.rb +8 -1
- data/lib/ctioga2/commands/general-types.rb +14 -3
- data/lib/ctioga2/commands/parsers/file.rb +20 -3
- data/lib/ctioga2/data/backends/backends/math.rb +1 -1
- data/lib/ctioga2/data/backends/backends/text.rb +3 -3
- data/lib/ctioga2/data/point.rb +1 -1
- data/lib/ctioga2/graphics/elements.rb +1 -0
- data/lib/ctioga2/graphics/elements/curve2d.rb +5 -0
- data/lib/ctioga2/graphics/elements/primitive.rb +16 -14
- data/lib/ctioga2/graphics/elements/style-lists.rb +353 -0
- data/lib/ctioga2/graphics/elements/subplot.rb +17 -2
- data/lib/ctioga2/graphics/elements/tangent.rb +16 -17
- data/lib/ctioga2/graphics/styles.rb +1 -0
- data/lib/ctioga2/graphics/styles/axes.rb +63 -0
- data/lib/ctioga2/graphics/styles/base.rb +13 -0
- data/lib/ctioga2/graphics/styles/colorbrewer.rb +316 -0
- data/lib/ctioga2/graphics/styles/colormap.rb +47 -7
- data/lib/ctioga2/graphics/styles/image.rb +83 -0
- data/lib/ctioga2/graphics/styles/plot.rb +43 -7
- data/lib/ctioga2/graphics/styles/sets.rb +47 -5
- data/lib/ctioga2/graphics/styles/sheet.rb +18 -3
- data/lib/ctioga2/graphics/styles/texts.rb +49 -8
- data/lib/ctioga2/graphics/subplot-commands.rb +13 -13
- data/lib/ctioga2/graphics/types.rb +42 -10
- data/lib/ctioga2/graphics/types/boundaries.rb +3 -2
- data/lib/ctioga2/graphics/types/boxes.rb +13 -0
- data/lib/ctioga2/graphics/types/dimensions.rb +4 -1
- data/lib/ctioga2/graphics/types/location.rb +13 -2
- data/lib/ctioga2/graphics/types/point.rb +86 -0
- data/lib/ctioga2/metabuilder/types/styles.rb +2 -2
- data/lib/ctioga2/plotmaker.rb +3 -0
- data/lib/ctioga2/ruby.rb +49 -0
- data/lib/ctioga2/utils.rb +34 -0
- data/lib/ctioga2/version.rb +2 -2
- metadata +8 -4
@@ -111,7 +111,7 @@ EOD
|
|
111
111
|
# Uses compute_formula to get data from
|
112
112
|
def get_data_column(column, variable, values)
|
113
113
|
column.gsub!(/\b#{variable}\b/, "(column[0])")
|
114
|
-
|
114
|
+
return Ruby.compute_formula(column, [values])
|
115
115
|
end
|
116
116
|
|
117
117
|
|
@@ -378,9 +378,9 @@ EOD
|
|
378
378
|
if compute_formulas
|
379
379
|
formula = Utils::parse_formula(column, parameters, header)
|
380
380
|
debug { "Using formula #{formula} for column spec: #{column}" }
|
381
|
-
return
|
382
|
-
|
383
|
-
|
381
|
+
return Ruby.compute_formula(formula,
|
382
|
+
@current_data,
|
383
|
+
@included_modules)
|
384
384
|
else
|
385
385
|
if @current_data[column.to_i]
|
386
386
|
return @current_data[column.to_i].dup
|
data/lib/ctioga2/data/point.rb
CHANGED
@@ -27,6 +27,7 @@ require 'ctioga2/graphics/elements/xyz-contour'
|
|
27
27
|
require 'ctioga2/graphics/elements/primitive'
|
28
28
|
|
29
29
|
require 'ctioga2/graphics/elements/tangent'
|
30
|
+
require 'ctioga2/graphics/elements/style-lists'
|
30
31
|
require 'ctioga2/graphics/elements/contour'
|
31
32
|
|
32
33
|
module CTioga2
|
@@ -114,7 +114,11 @@ module CTioga2
|
|
114
114
|
|
115
115
|
# Now, create the command
|
116
116
|
cmd_args = comp.map do |x|
|
117
|
-
|
117
|
+
if x.respond_to?(:type)
|
118
|
+
x
|
119
|
+
else
|
120
|
+
CmdArg.new(x)
|
121
|
+
end
|
118
122
|
end
|
119
123
|
|
120
124
|
cmd_opts = {}
|
@@ -230,19 +234,6 @@ EOD
|
|
230
234
|
end
|
231
235
|
|
232
236
|
|
233
|
-
# options for arrows (and therefore tangents)
|
234
|
-
ArrowOptions = {
|
235
|
-
'color' => 'color',
|
236
|
-
'head_scale' => 'float',
|
237
|
-
'head_marker' => 'marker',
|
238
|
-
'head_color' => 'color',
|
239
|
-
'tail_scale' => 'float',
|
240
|
-
'tail_marker' => 'marker',
|
241
|
-
'tail_color' => 'color',
|
242
|
-
'line_width' => 'float',
|
243
|
-
'line_style' => 'line-style',
|
244
|
-
}
|
245
|
-
|
246
237
|
styled_primitive("arrow", "arrow",
|
247
238
|
[ 'point', 'point' ],
|
248
239
|
Styles::ArrowStyle,
|
@@ -260,6 +251,17 @@ EOD
|
|
260
251
|
head.to_figure_xy(t) ))
|
261
252
|
end
|
262
253
|
|
254
|
+
|
255
|
+
styled_primitive("image", "image",
|
256
|
+
[ CmdArg.new('text', 'file'),
|
257
|
+
CmdArg.new('point', 'top-left'),
|
258
|
+
CmdArg.new('point', 'bottom-right')
|
259
|
+
],
|
260
|
+
Styles::ImageStyle,
|
261
|
+
'image') do |t, file, tl, br, style, options|
|
262
|
+
style.draw_image(t, file, tl, br)
|
263
|
+
end
|
264
|
+
|
263
265
|
# Here, we need to add deprecated options for backward
|
264
266
|
# compatibility
|
265
267
|
|
@@ -0,0 +1,353 @@
|
|
1
|
+
# style-lists.rb: drawing of lists of style elements (colors)
|
2
|
+
# copyright (c) 2014 by Vincent Fourmond
|
3
|
+
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
|
9
|
+
# This program is distributed in the hope that it will be useful, but
|
10
|
+
# 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 (in the COPYING file).
|
13
|
+
|
14
|
+
|
15
|
+
require 'ctioga2/graphics/elements/primitive'
|
16
|
+
|
17
|
+
# This module contains all the classes used by ctioga
|
18
|
+
module CTioga2
|
19
|
+
|
20
|
+
module Graphics
|
21
|
+
|
22
|
+
module Elements
|
23
|
+
|
24
|
+
module StyleLists
|
25
|
+
|
26
|
+
ListCommonOptions = {
|
27
|
+
'columns' => 'integer',
|
28
|
+
'padding' => 'dimension',
|
29
|
+
'scale' => 'float'
|
30
|
+
}
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
TiogaPrimitiveCall.
|
35
|
+
primitive("color-list",
|
36
|
+
"the list of all named colors",
|
37
|
+
[ 'point', 'dimension' ],
|
38
|
+
ListCommonOptions) do |t, point, width, options|
|
39
|
+
|
40
|
+
cols = options['columns'] || 3
|
41
|
+
|
42
|
+
ox, oy = point.to_figure_xy(t)
|
43
|
+
|
44
|
+
# There's going to be a lot of common code here
|
45
|
+
padding = options['padding'] ||
|
46
|
+
Types::Dimension.from_text("5bp", :x)
|
47
|
+
pad_dx = padding.to_figure(t, :x)
|
48
|
+
col_dx = width.to_figure(t, :x)/cols
|
49
|
+
col_w = col_dx - pad_dx * (cols - 1)/cols
|
50
|
+
|
51
|
+
|
52
|
+
# Colors by alphabetic name...
|
53
|
+
colors = Tioga::ColorConstants::constants.sort
|
54
|
+
l = 0
|
55
|
+
cc = 0
|
56
|
+
|
57
|
+
scale = options['scale'] || 0.8
|
58
|
+
|
59
|
+
txt_dy = -Types::Dimension::from_text("1.2dy", :y).to_figure(t, :y) * scale
|
60
|
+
box_dy = -Types::Dimension::from_text("1.1dy", :y).to_figure(t, :y)
|
61
|
+
|
62
|
+
tdy = txt_dy + box_dy
|
63
|
+
|
64
|
+
t.context do
|
65
|
+
for c in colors
|
66
|
+
color = Tioga::ColorConstants::const_get(c)
|
67
|
+
|
68
|
+
xb = ox + cc * col_dx
|
69
|
+
yt = oy + l * tdy
|
70
|
+
ym = yt + txt_dy
|
71
|
+
t.show_text({
|
72
|
+
'x' => xb + 0.5 * col_dx,
|
73
|
+
'y' => 0.8*ym +0.2*yt,
|
74
|
+
'text' => c.to_s,
|
75
|
+
'scale' => scale
|
76
|
+
})
|
77
|
+
|
78
|
+
t.fill_color = color
|
79
|
+
t.line_width = 0.7
|
80
|
+
t.append_rect_to_path(xb + 0.5 * pad_dx,
|
81
|
+
ym, col_w, box_dy)
|
82
|
+
t.fill_and_stroke
|
83
|
+
|
84
|
+
|
85
|
+
cc += 1
|
86
|
+
if cc >= cols
|
87
|
+
cc = 0
|
88
|
+
l += 1
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
TiogaPrimitiveCall.
|
95
|
+
primitive("marker-list",
|
96
|
+
"the list of all named markers",
|
97
|
+
[ 'point', 'dimension' ],
|
98
|
+
ListCommonOptions) do |t, point, width, options|
|
99
|
+
|
100
|
+
cols = options['columns'] || 3
|
101
|
+
|
102
|
+
ox, oy = point.to_figure_xy(t)
|
103
|
+
|
104
|
+
# There's going to be a lot of common code here
|
105
|
+
padding = options['padding'] ||
|
106
|
+
Types::Dimension.from_text("5bp", :x)
|
107
|
+
pad_dx = padding.to_figure(t, :x)
|
108
|
+
col_dx = width.to_figure(t, :x)/cols
|
109
|
+
col_w = col_dx - pad_dx * (cols - 1)/cols
|
110
|
+
|
111
|
+
|
112
|
+
# Colors by alphabetic name...
|
113
|
+
colors = Tioga::MarkerConstants::constants.sort
|
114
|
+
l = 0
|
115
|
+
cc = 0
|
116
|
+
|
117
|
+
scale = options['scale'] || 0.8
|
118
|
+
|
119
|
+
dy = -Types::Dimension::from_text("1.3dy", :y).to_figure(t, :y) * scale
|
120
|
+
|
121
|
+
m_dx = Types::Dimension::from_text("1.2dy", :x).to_figure(t, :x) * scale
|
122
|
+
|
123
|
+
for c in colors
|
124
|
+
mk = Tioga::MarkerConstants::const_get(c)
|
125
|
+
next unless mk.is_a? Array
|
126
|
+
|
127
|
+
xb = ox + cc * col_dx
|
128
|
+
yt = oy + (l+0.5) * dy
|
129
|
+
t.show_text({
|
130
|
+
'x' => xb + m_dx,
|
131
|
+
'y' => yt,
|
132
|
+
'text' => c.to_s,
|
133
|
+
'scale' => scale,
|
134
|
+
'justification' => Tioga::FigureConstants::LEFT_JUSTIFIED,
|
135
|
+
'alignment' => Tioga::FigureConstants::ALIGNED_AT_MIDHEIGHT
|
136
|
+
})
|
137
|
+
|
138
|
+
t.show_marker({
|
139
|
+
'x' => xb + m_dx*0.5,
|
140
|
+
'y' => yt,
|
141
|
+
'marker' => mk,
|
142
|
+
'scale' => scale * 1.1,
|
143
|
+
'alignment' => Tioga::FigureConstants::ALIGNED_AT_MIDHEIGHT
|
144
|
+
})
|
145
|
+
|
146
|
+
cc += 1
|
147
|
+
if cc >= cols
|
148
|
+
cc = 0
|
149
|
+
l += 1
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
TiogaPrimitiveCall.
|
156
|
+
primitive("line-style-list",
|
157
|
+
"the list of all named line styles",
|
158
|
+
[ 'point', 'dimension' ],
|
159
|
+
ListCommonOptions) do |t, point, width, options|
|
160
|
+
|
161
|
+
cols = options['columns'] || 3
|
162
|
+
|
163
|
+
ox, oy = point.to_figure_xy(t)
|
164
|
+
|
165
|
+
# There's going to be a lot of common code here
|
166
|
+
padding = options['padding'] ||
|
167
|
+
Types::Dimension.from_text("5bp", :x)
|
168
|
+
pad_dx = padding.to_figure(t, :x)
|
169
|
+
col_dx = width.to_figure(t, :x)/cols
|
170
|
+
col_w = col_dx - pad_dx * (cols - 1)/cols
|
171
|
+
|
172
|
+
|
173
|
+
# Colors by alphabetic name...
|
174
|
+
colors = Graphics::LineStyles::constants.sort
|
175
|
+
colors -= Tioga::FigureConstants::constants
|
176
|
+
l = 0
|
177
|
+
cc = 0
|
178
|
+
|
179
|
+
scale = options['scale'] || 0.8
|
180
|
+
|
181
|
+
txt_dy = -Types::Dimension::from_text("1.2dy", :y).to_figure(t, :y) * scale
|
182
|
+
box_dy = -Types::Dimension::from_text("1.1dy", :y).to_figure(t, :y)
|
183
|
+
|
184
|
+
tdy = txt_dy + box_dy
|
185
|
+
|
186
|
+
for c in colors
|
187
|
+
color = Graphics::LineStyles::const_get(c)
|
188
|
+
next unless color.is_a? Array
|
189
|
+
|
190
|
+
xb = ox + cc * col_dx
|
191
|
+
yt = oy + l * tdy
|
192
|
+
ym = yt + txt_dy
|
193
|
+
t.show_text({
|
194
|
+
'x' => xb + 0.5 * col_dx,
|
195
|
+
'y' => 0.8*ym +0.2*yt,
|
196
|
+
'text' => c.to_s.gsub(/_/, '\_'),
|
197
|
+
'scale' => scale
|
198
|
+
})
|
199
|
+
|
200
|
+
t.context do
|
201
|
+
t.line_type = color
|
202
|
+
t.move_to_point(xb + 1.5 * pad_dx,
|
203
|
+
ym+box_dy*0.5)
|
204
|
+
t.append_point_to_path(xb +col_dx- 1.5 * pad_dx,
|
205
|
+
ym+box_dy*0.5)
|
206
|
+
t.stroke
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
cc += 1
|
211
|
+
if cc >= cols
|
212
|
+
cc = 0
|
213
|
+
l += 1
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
SetOptions = {
|
220
|
+
'scale' => 'float',
|
221
|
+
'include' => 'regexp',
|
222
|
+
'exclude' => 'regexp'
|
223
|
+
}
|
224
|
+
|
225
|
+
# Now, a list of color sets
|
226
|
+
TiogaPrimitiveCall.
|
227
|
+
primitive("color-set-list",
|
228
|
+
"the list of all color sets",
|
229
|
+
[ 'point', 'dimension' ],
|
230
|
+
SetOptions) do |t, point, width, options|
|
231
|
+
|
232
|
+
ox, oy = point.to_figure_xy(t)
|
233
|
+
|
234
|
+
col_dx = width.to_figure(t, :x)
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
scale = options['scale'] || 0.8
|
239
|
+
txt_dy = -Types::Dimension::from_text("1.3dy", :y).to_figure(t, :y) * scale
|
240
|
+
box_dy = -Types::Dimension::from_text("1.1dy", :y).to_figure(t, :y)
|
241
|
+
|
242
|
+
tdy = txt_dy + box_dy
|
243
|
+
|
244
|
+
sets = Styles::CurveStyleFactory::parameters['line_color'].sets
|
245
|
+
|
246
|
+
set_names = sets.keys.sort
|
247
|
+
|
248
|
+
if options['include']
|
249
|
+
set_names = set_names.select do |x|
|
250
|
+
x =~ options['include']
|
251
|
+
end
|
252
|
+
elsif options['exclude']
|
253
|
+
set_names = set_names.select do |x|
|
254
|
+
x !~ options['exclude']
|
255
|
+
end
|
256
|
+
end
|
257
|
+
xl = ox
|
258
|
+
yt = oy
|
259
|
+
|
260
|
+
p_dx = Types::Dimension::from_text("2bp", :x).to_figure(t, :x)
|
261
|
+
|
262
|
+
for s in set_names
|
263
|
+
cs = sets[s]
|
264
|
+
ym = yt + txt_dy
|
265
|
+
nb = cs.size
|
266
|
+
t.show_text({
|
267
|
+
'x' => xl + 0.5 * col_dx,
|
268
|
+
'y' => 0.7*ym +0.3*yt,
|
269
|
+
'text' => "\\texttt{#{s}}: #{nb} colors",
|
270
|
+
'scale' => scale
|
271
|
+
})
|
272
|
+
|
273
|
+
dx = col_dx/nb
|
274
|
+
|
275
|
+
idx = 0
|
276
|
+
t.context do
|
277
|
+
for c in cs
|
278
|
+
t.fill_color = c
|
279
|
+
t.line_width = 0.7
|
280
|
+
t.append_rect_to_path(xl + 0.5 * p_dx + idx * dx,
|
281
|
+
ym, dx - p_dx, box_dy)
|
282
|
+
t.fill_and_stroke
|
283
|
+
idx += 1
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
yt += tdy
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
# Now, a list of color sets
|
292
|
+
TiogaPrimitiveCall.
|
293
|
+
primitive("marker-set-list",
|
294
|
+
"the list of all marker sets",
|
295
|
+
[ 'point', 'dimension' ], SetOptions
|
296
|
+
) do |t, point, width, options|
|
297
|
+
|
298
|
+
ox, oy = point.to_figure_xy(t)
|
299
|
+
col_dx = width.to_figure(t, :x)
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
scale = options['scale'] || 0.8
|
304
|
+
txt_dy = -Types::Dimension::from_text("1.3dy", :y).to_figure(t, :y) * scale
|
305
|
+
box_dy = -Types::Dimension::from_text("1.1dy", :y).to_figure(t, :y)
|
306
|
+
|
307
|
+
tdy = txt_dy + box_dy
|
308
|
+
|
309
|
+
sets = Styles::CurveStyleFactory::parameters['marker_marker'].sets
|
310
|
+
|
311
|
+
set_names = sets.keys.sort
|
312
|
+
|
313
|
+
xl = ox
|
314
|
+
yt = oy
|
315
|
+
|
316
|
+
p_dx = Types::Dimension::from_text("2bp", :x).to_figure(t, :x)
|
317
|
+
|
318
|
+
mdx = Types::Dimension::from_text("1.1dy", :x).to_figure(t, :x)
|
319
|
+
|
320
|
+
for s in set_names
|
321
|
+
cs = sets[s]
|
322
|
+
ym = yt + txt_dy
|
323
|
+
nb = cs.size
|
324
|
+
t.show_text({
|
325
|
+
'x' => xl + 0.5 * col_dx,
|
326
|
+
'y' => 0.7*ym +0.3*yt,
|
327
|
+
'text' => "\\texttt{#{s}}: #{nb} markers",
|
328
|
+
'scale' => scale
|
329
|
+
})
|
330
|
+
|
331
|
+
dx = col_dx/nb
|
332
|
+
|
333
|
+
idx = 0
|
334
|
+
for c in cs
|
335
|
+
t.show_marker({
|
336
|
+
'x' => xl + mdx * (idx + 0.5),
|
337
|
+
'y' => ym,
|
338
|
+
'marker' => c,
|
339
|
+
'scale' => scale * 1.1,
|
340
|
+
'alignment' => Tioga::FigureConstants::ALIGNED_AT_TOP
|
341
|
+
})
|
342
|
+
|
343
|
+
idx += 1
|
344
|
+
end
|
345
|
+
|
346
|
+
yt += tdy
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|
353
|
+
end
|