ctioga2 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +18 -0
- data/lib/ctioga2/commands/arguments.rb +17 -2
- data/lib/ctioga2/commands/commands.rb +13 -5
- data/lib/ctioga2/commands/context.rb +53 -0
- data/lib/ctioga2/commands/doc/doc.rb +1 -1
- data/lib/ctioga2/commands/doc/documentation-commands.rb +1 -1
- data/lib/ctioga2/commands/doc/help.rb +1 -1
- data/lib/ctioga2/commands/doc/html.rb +1 -1
- data/lib/ctioga2/commands/doc/introspection.rb +16 -1
- data/lib/ctioga2/commands/doc/man.rb +1 -1
- data/lib/ctioga2/commands/doc/markup.rb +1 -1
- data/lib/ctioga2/commands/doc/wordwrap.rb +1 -1
- data/lib/ctioga2/commands/general-commands.rb +1 -1
- data/lib/ctioga2/commands/general-types.rb +1 -1
- data/lib/ctioga2/commands/groups.rb +1 -1
- data/lib/ctioga2/commands/interpreter.rb +22 -1
- data/lib/ctioga2/commands/parsers/command-line.rb +8 -1
- data/lib/ctioga2/commands/parsers/file.rb +2 -1
- data/lib/ctioga2/commands/strings.rb +1 -1
- data/lib/ctioga2/commands/type.rb +1 -1
- data/lib/ctioga2/commands/variables.rb +1 -1
- data/lib/ctioga2/data/backends/backend.rb +1 -1
- data/lib/ctioga2/data/backends/backends/gnuplot.rb +1 -1
- data/lib/ctioga2/data/backends/backends/math.rb +1 -1
- data/lib/ctioga2/data/backends/backends/text.rb +12 -2
- data/lib/ctioga2/data/backends/description.rb +1 -1
- data/lib/ctioga2/data/backends/factory.rb +1 -1
- data/lib/ctioga2/data/backends/parameter.rb +1 -1
- data/lib/ctioga2/data/datacolumn.rb +1 -1
- data/lib/ctioga2/data/dataset.rb +1 -1
- data/lib/ctioga2/data/filters.rb +1 -1
- data/lib/ctioga2/data/indexed-dtable.rb +1 -1
- data/lib/ctioga2/data/point.rb +1 -1
- data/lib/ctioga2/data/stack.rb +6 -6
- data/lib/ctioga2/graphics/coordinates.rb +1 -1
- data/lib/ctioga2/graphics/elements.rb +1 -1
- data/lib/ctioga2/graphics/elements/containers.rb +1 -1
- data/lib/ctioga2/graphics/elements/contour.rb +1 -1
- data/lib/ctioga2/graphics/elements/curve2d.rb +1 -1
- data/lib/ctioga2/graphics/elements/element.rb +1 -1
- data/lib/ctioga2/graphics/elements/gradient-region.rb +1 -1
- data/lib/ctioga2/graphics/elements/parametric2d.rb +1 -1
- data/lib/ctioga2/graphics/elements/primitive.rb +115 -69
- data/lib/ctioga2/graphics/elements/region.rb +1 -1
- data/lib/ctioga2/graphics/elements/subplot.rb +9 -3
- data/lib/ctioga2/graphics/elements/tangent.rb +1 -1
- data/lib/ctioga2/graphics/elements/xyz-map.rb +1 -1
- data/lib/ctioga2/graphics/generator.rb +1 -1
- data/lib/ctioga2/graphics/legends.rb +5 -7
- data/lib/ctioga2/graphics/legends/area.rb +8 -8
- data/lib/ctioga2/graphics/legends/items.rb +2 -2
- data/lib/ctioga2/graphics/legends/provider.rb +1 -1
- data/lib/ctioga2/graphics/legends/storage.rb +1 -1
- data/lib/ctioga2/graphics/root.rb +1 -1
- data/lib/ctioga2/graphics/styles.rb +5 -0
- data/lib/ctioga2/graphics/styles/arrows.rb +53 -0
- data/lib/ctioga2/graphics/styles/axes.rb +29 -23
- data/lib/ctioga2/graphics/styles/background.rb +12 -10
- data/lib/ctioga2/graphics/styles/base.rb +99 -5
- data/lib/ctioga2/graphics/styles/box.rb +67 -0
- data/lib/ctioga2/graphics/styles/carrays.rb +1 -1
- data/lib/ctioga2/graphics/styles/colormap.rb +1 -1
- data/lib/ctioga2/graphics/styles/curve.rb +7 -1
- data/lib/ctioga2/graphics/styles/drawable.rb +24 -11
- data/lib/ctioga2/graphics/styles/errorbar.rb +1 -1
- data/lib/ctioga2/graphics/styles/factory.rb +1 -1
- data/lib/ctioga2/graphics/styles/gradients.rb +3 -3
- data/lib/ctioga2/graphics/styles/legend.rb +20 -5
- data/lib/ctioga2/graphics/styles/location.rb +3 -3
- data/lib/ctioga2/graphics/styles/map-axes.rb +6 -7
- data/lib/ctioga2/graphics/styles/plot.rb +51 -26
- data/lib/ctioga2/graphics/styles/sets.rb +1 -1
- data/lib/ctioga2/graphics/styles/sheet.rb +348 -0
- data/lib/ctioga2/graphics/styles/texts.rb +45 -64
- data/lib/ctioga2/graphics/subplot-commands.rb +1 -1
- data/lib/ctioga2/graphics/types.rb +1 -3
- data/lib/ctioga2/graphics/types/bijection.rb +1 -1
- data/lib/ctioga2/graphics/types/boundaries.rb +1 -1
- data/lib/ctioga2/graphics/types/boxes.rb +1 -1
- data/lib/ctioga2/graphics/types/dimensions.rb +2 -2
- data/lib/ctioga2/graphics/types/grid.rb +1 -1
- data/lib/ctioga2/graphics/types/location.rb +2 -2
- data/lib/ctioga2/graphics/types/point.rb +1 -1
- data/lib/ctioga2/log.rb +10 -6
- data/lib/ctioga2/metabuilder/type.rb +1 -1
- data/lib/ctioga2/metabuilder/types/coordinates.rb +1 -1
- data/lib/ctioga2/metabuilder/types/data.rb +1 -1
- data/lib/ctioga2/metabuilder/types/dates.rb +1 -1
- data/lib/ctioga2/metabuilder/types/lists.rb +1 -1
- data/lib/ctioga2/metabuilder/types/numbers.rb +1 -1
- data/lib/ctioga2/metabuilder/types/strings.rb +1 -1
- data/lib/ctioga2/metabuilder/types/styles.rb +30 -3
- data/lib/ctioga2/plotmaker.rb +1 -1
- data/lib/ctioga2/postprocess.rb +1 -1
- data/lib/ctioga2/utils.rb +78 -3
- metadata +6 -5
- data/lib/ctioga2/git-fools-svn.rb +0 -7
- data/lib/ctioga2/graphics/elements/redirecting-container.rb~ +0 -123
- data/lib/ctioga2/metabuilder/types/generic.rb~ +0 -225
@@ -25,7 +25,7 @@ require 'stringio'
|
|
25
25
|
|
26
26
|
module CTioga2
|
27
27
|
|
28
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
28
|
+
Version::register_svn_info('$Revision: 372 $', '$Date: 2012-12-28 18:13:15 +0100 (Fri, 28 Dec 2012) $')
|
29
29
|
|
30
30
|
|
31
31
|
module Data
|
@@ -56,7 +56,17 @@ module CTioga2
|
|
56
56
|
|
57
57
|
describe 'text', 'Text format', <<EOD
|
58
58
|
This backend reads text files in a format close to the one understood
|
59
|
-
by gnuplot and the like.
|
59
|
+
by gnuplot and the like. More specifically, it reads text files organized
|
60
|
+
in columns.
|
61
|
+
|
62
|
+
The column separator is specified by the @separator@ option or using
|
63
|
+
the {command: text-separator} command; it is a {type: regexp}
|
64
|
+
|
65
|
+
By default, the {command: text} backend only loads the column 1 as X
|
66
|
+
and 2 as Y, but that can be changed either by specifiying a default
|
67
|
+
column spec using either the @default_column_spec@ option or by adding
|
68
|
+
a specification directly after the file name.
|
69
|
+
|
60
70
|
EOD
|
61
71
|
|
62
72
|
# Inherit the baseline handling, can be useful !
|
@@ -17,7 +17,7 @@ require 'ctioga2/utils'
|
|
17
17
|
# This module contains all the classes used by ctioga
|
18
18
|
module CTioga2
|
19
19
|
|
20
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
20
|
+
Version::register_svn_info('$Revision: 229 $', '$Date: 2011-01-17 17:34:57 +0100 (Mon, 17 Jan 2011) $')
|
21
21
|
|
22
22
|
module Data
|
23
23
|
|
data/lib/ctioga2/data/dataset.rb
CHANGED
@@ -18,7 +18,7 @@ require 'ctioga2/data/indexed-dtable'
|
|
18
18
|
|
19
19
|
module CTioga2
|
20
20
|
|
21
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
21
|
+
Version::register_svn_info('$Revision: 304 $', '$Date: 2012-01-03 15:06:33 +0100 (Tue, 03 Jan 2012) $')
|
22
22
|
|
23
23
|
|
24
24
|
# \todo now, port the backend infrastructure...
|
data/lib/ctioga2/data/filters.rb
CHANGED
@@ -19,7 +19,7 @@ require 'ctioga2/data/backends/factory'
|
|
19
19
|
# This module contains all the classes used by ctioga
|
20
20
|
module CTioga2
|
21
21
|
|
22
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
22
|
+
Version::register_svn_info('$Revision: 194 $', '$Date: 2010-11-22 10:26:54 +0100 (Mon, 22 Nov 2010) $')
|
23
23
|
|
24
24
|
|
25
25
|
module Data
|
data/lib/ctioga2/data/point.rb
CHANGED
data/lib/ctioga2/data/stack.rb
CHANGED
@@ -25,7 +25,7 @@ require 'ctioga2/data/filters'
|
|
25
25
|
# This module contains all the classes used by ctioga
|
26
26
|
module CTioga2
|
27
27
|
|
28
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
28
|
+
Version::register_svn_info('$Revision: 367 $', '$Date: 2012-12-28 16:14:52 +0100 (Fri, 28 Dec 2012) $')
|
29
29
|
|
30
30
|
|
31
31
|
module Data
|
@@ -173,10 +173,10 @@ module CTioga2
|
|
173
173
|
datasets = [ specified_dataset(opts) ]
|
174
174
|
else
|
175
175
|
nb = opts['number'] || 2
|
176
|
-
if stack.
|
176
|
+
if @stack.size < nb
|
177
177
|
raise "Not enough datasets on the stack"
|
178
178
|
end
|
179
|
-
datasets = stack
|
179
|
+
datasets = @stack[(- nb).. -2]
|
180
180
|
datasets.reverse!
|
181
181
|
end
|
182
182
|
end
|
@@ -355,7 +355,7 @@ stack. The name option can be used to give a name to the new dataset.
|
|
355
355
|
EOH
|
356
356
|
|
357
357
|
ApplyLastCommand =
|
358
|
-
Cmd.new("apply-formula",
|
358
|
+
Cmd.new("apply-formula", nil, "--apply-formula",
|
359
359
|
[CmdArg.new('text')],
|
360
360
|
{
|
361
361
|
'which' => CmdArg.new('stored-dataset'),
|
@@ -383,8 +383,8 @@ EOH
|
|
383
383
|
<<EOH, DataStackGroup)
|
384
384
|
Displays the current contents of the dataset stack.
|
385
385
|
|
386
|
-
Mostly used for debugging when operations like {
|
387
|
-
or {
|
386
|
+
Mostly used for debugging when operations like {command: merge-datasets}
|
387
|
+
or {command: join-datasets} don't work as expected.
|
388
388
|
EOH
|
389
389
|
|
390
390
|
|
@@ -17,7 +17,7 @@ require 'ctioga2/graphics/elements/primitive'
|
|
17
17
|
# This module contains all the classes used by ctioga
|
18
18
|
module CTioga2
|
19
19
|
|
20
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
20
|
+
Version::register_svn_info('$Revision: 299 $', '$Date: 2011-03-15 11:22:20 +0100 (Tue, 15 Mar 2011) $')
|
21
21
|
|
22
22
|
module Graphics
|
23
23
|
|
@@ -18,7 +18,7 @@ require 'ctioga2/log'
|
|
18
18
|
# This module contains all the classes used by ctioga
|
19
19
|
module CTioga2
|
20
20
|
|
21
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
21
|
+
Version::register_svn_info('$Revision: 151 $', '$Date: 2010-06-19 23:45:20 +0200 (Sat, 19 Jun 2010) $')
|
22
22
|
|
23
23
|
# This module contains all graphical elements of CTioga2
|
24
24
|
module Graphics
|
@@ -16,18 +16,24 @@ require 'ctioga2/utils'
|
|
16
16
|
require 'ctioga2/log'
|
17
17
|
|
18
18
|
require 'ctioga2/graphics/types'
|
19
|
+
require 'ctioga2/graphics/styles'
|
19
20
|
require 'shellwords'
|
20
21
|
|
21
22
|
# This module contains all the classes used by ctioga
|
22
23
|
module CTioga2
|
23
24
|
|
24
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
25
|
+
Version::register_svn_info('$Revision: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
|
25
26
|
|
26
27
|
module Graphics
|
27
28
|
|
28
29
|
module Elements
|
29
30
|
|
30
31
|
# A TiogaElement that represents a graphics primitive.
|
32
|
+
#
|
33
|
+
# @todo Most of the objects here should rely on getting a
|
34
|
+
# BasicStyle object from the options hash and use it to
|
35
|
+
# draw. There is no need to make cumbersome and hard to extend
|
36
|
+
# hashes.
|
31
37
|
class TiogaPrimitiveCall < TiogaElement
|
32
38
|
|
33
39
|
# Some kind of reimplementation of Command for graphics
|
@@ -87,7 +93,8 @@ module CTioga2
|
|
87
93
|
|
88
94
|
# Creates a new primitive with the given parameters, and makes
|
89
95
|
# it immediately available as a command.
|
90
|
-
def self.primitive(name, long_name, comp, opts = {},
|
96
|
+
def self.primitive(name, long_name, comp, opts = {},
|
97
|
+
desc = nil, &code)
|
91
98
|
primitive = TiogaPrimitive.new(name, comp, opts, &code)
|
92
99
|
@known_primitives[name] = primitive
|
93
100
|
|
@@ -98,7 +105,11 @@ module CTioga2
|
|
98
105
|
|
99
106
|
cmd_opts = {}
|
100
107
|
for k,v in opts
|
101
|
-
cmd_opts[k] =
|
108
|
+
cmd_opts[k] = if v.respond_to?(:type)
|
109
|
+
v
|
110
|
+
else
|
111
|
+
CmdArg.new(v)
|
112
|
+
end
|
102
113
|
end
|
103
114
|
|
104
115
|
cmd = Cmd.new("draw-#{name}",nil,"--draw-#{name}",
|
@@ -111,12 +122,53 @@ module CTioga2
|
|
111
122
|
plotmaker.root_object.current_plot.
|
112
123
|
add_element(call)
|
113
124
|
end
|
125
|
+
if ! desc
|
126
|
+
desc = "Directly draws #{long_name} on the current plot"
|
127
|
+
end
|
114
128
|
cmd.describe("Draws #{long_name}",
|
115
|
-
|
129
|
+
desc,
|
130
|
+
PrimitiveGroup)
|
116
131
|
|
117
132
|
PrimitiveCommands[name] = cmd
|
118
133
|
end
|
119
134
|
|
135
|
+
# This creates a primitive base on a style object, given a
|
136
|
+
# _style_class_, the base _style_name_ for the underlying
|
137
|
+
# styling system, options to remove and options to add.
|
138
|
+
#
|
139
|
+
# The underlying code receives:
|
140
|
+
# * the FigureMaker object
|
141
|
+
# * the compulsory arguments
|
142
|
+
# * the style
|
143
|
+
# * the raw options
|
144
|
+
def self.styled_primitive(name, long_name, comp, style_class,
|
145
|
+
style_name, without = [],
|
146
|
+
additional_options = {},
|
147
|
+
set_style_command = nil, # This
|
148
|
+
# could be
|
149
|
+
# removed
|
150
|
+
&code)
|
151
|
+
options = style_class.options_hash.without(without)
|
152
|
+
options.merge!(additional_options)
|
153
|
+
options['base-style'] = 'text' # the base style name
|
154
|
+
|
155
|
+
set_style_command ||= style_name
|
156
|
+
desc = <<"EOD"
|
157
|
+
Draws #{long_name} on the current plot, using the given style.
|
158
|
+
For more information on the available options, see the
|
159
|
+
{command: define-#{set_style_command}-style} command.
|
160
|
+
EOD
|
161
|
+
|
162
|
+
self.primitive(name, long_name, comp, options, desc) do |*all|
|
163
|
+
opts = all.pop
|
164
|
+
st_name = opts['base-style'] || "base"
|
165
|
+
style = Styles::StyleSheet.style_for(style_class,st_name)
|
166
|
+
style.set_from_hash(opts)
|
167
|
+
all << style << opts
|
168
|
+
code.call(*all)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
120
172
|
|
121
173
|
# Returns a pair primitive/primitive command for the named
|
122
174
|
# primitive, or [ _nil_, _nil_ ]
|
@@ -126,59 +178,42 @@ module CTioga2
|
|
126
178
|
|
127
179
|
# Now, a list of primitives, along with their code.
|
128
180
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
'font' => 'latex-font',
|
137
|
-
}
|
138
|
-
) do |t, point, string, options|
|
181
|
+
styled_primitive("text", "text",
|
182
|
+
[ 'point', 'text' ],
|
183
|
+
Styles::FullTextStyle,
|
184
|
+
'text',
|
185
|
+
['text'],
|
186
|
+
{'font' => 'latex-font'}
|
187
|
+
) do |t, point, string, style, options|
|
139
188
|
# @todo add a way to specify fonts ???
|
140
189
|
options ||= {}
|
141
190
|
if options['font']
|
142
191
|
string = options['font'].fontify(string)
|
143
|
-
options.delete('font')
|
144
192
|
end
|
145
|
-
|
146
|
-
options['at'] = point.to_figure_xy(t)
|
147
|
-
t.show_text(options)
|
193
|
+
style.draw_text(t, string, *(point.to_figure_xy(t)))
|
148
194
|
end
|
149
195
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
'angle' => 'float',
|
159
|
-
'justification' => 'justification',
|
160
|
-
'alignment' => 'alignment',
|
161
|
-
}
|
162
|
-
|
163
|
-
primitive("marker", "marker", [ 'point', 'marker' ],
|
164
|
-
MarkerOptions) do |t, point, marker, options|
|
165
|
-
## \todo add a way to specify fonts ???
|
166
|
-
options ||= {}
|
167
|
-
options['marker'] = marker
|
168
|
-
options['at'] = point.to_figure_xy(t)
|
169
|
-
t.show_marker(options)
|
196
|
+
styled_primitive("marker", "marker",
|
197
|
+
[ 'point', 'marker' ],
|
198
|
+
Styles::MarkerStringStyle,
|
199
|
+
'marker',
|
200
|
+
['font'] # font doesn't make any sense with a
|
201
|
+
# marker spec
|
202
|
+
) do |t, point, marker, style, options|
|
203
|
+
style.draw_marker(t, marker, *point.to_figure_xy(t))
|
170
204
|
end
|
171
205
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
t.
|
206
|
+
styled_primitive("string-marker", "marker",
|
207
|
+
[ 'point', 'text' ],
|
208
|
+
Styles::MarkerStringStyle,
|
209
|
+
'marker-string', [],
|
210
|
+
{},
|
211
|
+
'marker'
|
212
|
+
) do |t, point, string, style, options|
|
213
|
+
style.draw_string_marker(t, string, *point.to_figure_xy(t))
|
180
214
|
end
|
181
215
|
|
216
|
+
|
182
217
|
# options for arrows (and therefore tangents)
|
183
218
|
ArrowOptions = {
|
184
219
|
'color' => 'color',
|
@@ -192,32 +227,43 @@ module CTioga2
|
|
192
227
|
'line_style' => 'line-style',
|
193
228
|
}
|
194
229
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
options['tail'] = tail.to_figure_xy(t)
|
202
|
-
t.show_arrow(options)
|
230
|
+
styled_primitive("arrow", "arrow",
|
231
|
+
[ 'point', 'point' ],
|
232
|
+
Styles::ArrowStyle,
|
233
|
+
'arrow') do |t, tail, head, style, options|
|
234
|
+
style.draw_arrow(t, *tail.to_figure_xy(t),
|
235
|
+
*head.to_figure_xy(t))
|
203
236
|
end
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
options ||= {}
|
213
|
-
for a in ['head', 'tail']
|
214
|
-
options["#{a}_marker"] = "None"
|
215
|
-
end
|
216
|
-
options['head'] = head.to_figure_xy(t)
|
217
|
-
options['tail'] = tail.to_figure_xy(t)
|
218
|
-
t.show_arrow(options)
|
237
|
+
|
238
|
+
styled_primitive("line", "line",
|
239
|
+
[ 'point', 'point' ],
|
240
|
+
Styles::StrokeStyle,
|
241
|
+
'line'
|
242
|
+
) do |t, tail, head, style, options|
|
243
|
+
style.draw_line(t, *(tail.to_figure_xy(t)),
|
244
|
+
*(head.to_figure_xy(t)))
|
219
245
|
end
|
220
246
|
|
247
|
+
# Here, we need to add deprecated options for backward
|
248
|
+
# compatibility
|
249
|
+
|
250
|
+
for cmd in ['draw-line', 'draw-arrow']
|
251
|
+
Commands::make_alias_for_option cmd, 'width', 'line_width', true
|
252
|
+
Commands::make_alias_for_option cmd, 'style', 'line_style', true
|
253
|
+
end
|
254
|
+
|
255
|
+
styled_primitive("box", "box",
|
256
|
+
[ 'point', 'point' ],
|
257
|
+
Styles::BoxStyle,
|
258
|
+
'box') do |t, tl, br, style, options|
|
259
|
+
x1,y1 = tl.to_figure_xy(t)
|
260
|
+
x2,y2 = br.to_figure_xy(t)
|
261
|
+
style.draw_box(t, x1, y1, x2, y2)
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
Commands::make_alias_for_option 'draw-box', 'fill_color', 'fill-color'
|
266
|
+
Commands::make_alias_for_option 'draw-box', 'fill_transparency', 'fill-transparency'
|
221
267
|
|
222
268
|
protected
|
223
269
|
|