ctioga2 0.4 → 0.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.
- data/Changelog +16 -0
- data/lib/ctioga2/commands/arguments.rb +5 -2
- data/lib/ctioga2/commands/commands.rb +45 -13
- data/lib/ctioga2/commands/context.rb +9 -1
- data/lib/ctioga2/commands/doc/help.rb +2 -2
- data/lib/ctioga2/commands/doc/html.rb +8 -8
- data/lib/ctioga2/commands/doc/introspection.rb +7 -5
- data/lib/ctioga2/commands/parsers/file.rb +123 -120
- data/lib/ctioga2/commands/parsers/old-file.rb +191 -0
- data/lib/ctioga2/commands/strings.rb +2 -2
- data/lib/ctioga2/data/datacolumn.rb +5 -2
- data/lib/ctioga2/data/dataset.rb +3 -13
- data/lib/ctioga2/data/indexed-dtable.rb +43 -11
- data/lib/ctioga2/data/stack.rb +65 -8
- data/lib/ctioga2/graphics/elements.rb +2 -1
- data/lib/ctioga2/graphics/elements/containers.rb +22 -3
- data/lib/ctioga2/graphics/elements/primitive.rb +5 -5
- data/lib/ctioga2/graphics/elements/xyz-contour.rb +123 -0
- data/lib/ctioga2/graphics/generator.rb +31 -5
- data/lib/ctioga2/graphics/legends.rb +44 -3
- data/lib/ctioga2/graphics/legends/area.rb +28 -9
- data/lib/ctioga2/graphics/legends/items.rb +34 -23
- data/lib/ctioga2/graphics/legends/multicols.rb +132 -0
- data/lib/ctioga2/graphics/styles.rb +3 -1
- data/lib/ctioga2/graphics/styles/axes.rb +10 -4
- data/lib/ctioga2/graphics/styles/base.rb +65 -11
- data/lib/ctioga2/graphics/styles/colormap.rb +2 -1
- data/lib/ctioga2/graphics/styles/contour.rb +141 -0
- data/lib/ctioga2/graphics/styles/curve.rb +49 -67
- data/lib/ctioga2/graphics/styles/drawable.rb +17 -8
- data/lib/ctioga2/graphics/styles/factory.rb +79 -38
- data/lib/ctioga2/graphics/styles/legend.rb +49 -6
- data/lib/ctioga2/graphics/styles/plot.rb +10 -9
- data/lib/ctioga2/graphics/styles/sheet.rb +11 -11
- data/lib/ctioga2/graphics/styles/texts.rb +38 -9
- data/lib/ctioga2/graphics/types.rb +20 -1
- data/lib/ctioga2/graphics/types/dimensions.rb +7 -1
- data/lib/ctioga2/metabuilder/types/lists.rb +4 -4
- data/lib/ctioga2/metabuilder/types/numbers.rb +3 -3
- data/lib/ctioga2/metabuilder/types/styles.rb +2 -2
- data/lib/ctioga2/plotmaker.rb +12 -1
- data/lib/ctioga2/utils.rb +27 -3
- metadata +8 -4
@@ -22,6 +22,7 @@ require 'ctioga2/graphics/elements/gradient-region'
|
|
22
22
|
require 'ctioga2/graphics/elements/curve2d'
|
23
23
|
require 'ctioga2/graphics/elements/parametric2d'
|
24
24
|
require 'ctioga2/graphics/elements/xyz-map'
|
25
|
+
require 'ctioga2/graphics/elements/xyz-contour'
|
25
26
|
require 'ctioga2/graphics/elements/primitive'
|
26
27
|
|
27
28
|
require 'ctioga2/graphics/elements/tangent'
|
@@ -29,7 +30,7 @@ require 'ctioga2/graphics/elements/contour'
|
|
29
30
|
|
30
31
|
module CTioga2
|
31
32
|
|
32
|
-
Version::register_svn_info('$Revision:
|
33
|
+
Version::register_svn_info('$Revision: 405 $', '$Date: 2013-08-22 16:25:13 +0200 (Thu, 22 Aug 2013) $')
|
33
34
|
|
34
35
|
module Graphics
|
35
36
|
|
@@ -17,7 +17,7 @@ require 'ctioga2/log'
|
|
17
17
|
|
18
18
|
module CTioga2
|
19
19
|
|
20
|
-
Version::register_svn_info('$Revision:
|
20
|
+
Version::register_svn_info('$Revision: 378 $', '$Date: 2013-03-04 22:42:54 +0100 (Mon, 04 Mar 2013) $')
|
21
21
|
|
22
22
|
module Graphics
|
23
23
|
|
@@ -47,6 +47,10 @@ module CTioga2
|
|
47
47
|
# object
|
48
48
|
attr_accessor :legend_storage
|
49
49
|
|
50
|
+
# The current legend container to which legend items are added.
|
51
|
+
# Defaults to the #legend_storage, but it can be changed
|
52
|
+
attr_accessor :legend_item_target
|
53
|
+
|
50
54
|
# Creates an empty new Container with the given _parent_.
|
51
55
|
def initialize(parent = nil, root = nil)
|
52
56
|
@parent = parent
|
@@ -60,6 +64,8 @@ module CTioga2
|
|
60
64
|
@root_object = root
|
61
65
|
|
62
66
|
@legend_storage = Legends::LegendStorage.new
|
67
|
+
|
68
|
+
@legend_item_target = @legend_storage
|
63
69
|
|
64
70
|
# By default, don't display legends.
|
65
71
|
@legend_area = nil
|
@@ -98,9 +104,22 @@ module CTioga2
|
|
98
104
|
end
|
99
105
|
|
100
106
|
|
101
|
-
# Adds a legend item to the
|
107
|
+
# Adds a legend item to the current storage
|
102
108
|
def add_legend_item(item)
|
103
|
-
@
|
109
|
+
@legend_item_target.add_item(item)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Adds a legend item to the current storage and make that item
|
113
|
+
# the next target for legend items.
|
114
|
+
#
|
115
|
+
# If @a sub is nil, then switch back to the top
|
116
|
+
def enter_legend_subcontainer(sub)
|
117
|
+
if sub
|
118
|
+
add_legend_item(sub)
|
119
|
+
@legend_item_target = sub
|
120
|
+
else
|
121
|
+
@legend_item_target = @legend_storage
|
122
|
+
end
|
104
123
|
end
|
105
124
|
|
106
125
|
# \todo provide coordinate conversion facilities...
|
@@ -22,7 +22,7 @@ require 'shellwords'
|
|
22
22
|
# This module contains all the classes used by ctioga
|
23
23
|
module CTioga2
|
24
24
|
|
25
|
-
Version::register_svn_info('$Revision:
|
25
|
+
Version::register_svn_info('$Revision: 391 $', '$Date: 2013-03-14 11:04:36 +0100 (Thu, 14 Mar 2013) $')
|
26
26
|
|
27
27
|
module Graphics
|
28
28
|
|
@@ -231,8 +231,8 @@ EOD
|
|
231
231
|
[ 'point', 'point' ],
|
232
232
|
Styles::ArrowStyle,
|
233
233
|
'arrow') do |t, tail, head, style, options|
|
234
|
-
style.draw_arrow(t, *tail.to_figure_xy(t)
|
235
|
-
|
234
|
+
style.draw_arrow(t, *( tail.to_figure_xy(t) +
|
235
|
+
head.to_figure_xy(t) ))
|
236
236
|
end
|
237
237
|
|
238
238
|
styled_primitive("line", "line",
|
@@ -240,8 +240,8 @@ EOD
|
|
240
240
|
Styles::StrokeStyle,
|
241
241
|
'line'
|
242
242
|
) do |t, tail, head, style, options|
|
243
|
-
style.draw_line(t, *(tail.to_figure_xy(t)
|
244
|
-
|
243
|
+
style.draw_line(t, *( tail.to_figure_xy(t) +
|
244
|
+
head.to_figure_xy(t) ))
|
245
245
|
end
|
246
246
|
|
247
247
|
# Here, we need to add deprecated options for backward
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# xyz-contour.rb: contour plot of a xyz set of data
|
2
|
+
# copyright (c) 2013 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
|
+
require 'ctioga2/utils'
|
15
|
+
require 'ctioga2/log'
|
16
|
+
|
17
|
+
require 'Dobjects/Function'
|
18
|
+
|
19
|
+
|
20
|
+
module CTioga2
|
21
|
+
|
22
|
+
Version::register_svn_info('$Revision$', '$Date$')
|
23
|
+
|
24
|
+
module Graphics
|
25
|
+
|
26
|
+
module Elements
|
27
|
+
|
28
|
+
# This class displays a XYZ element using contour lines.
|
29
|
+
class XYZContour < TiogaElement
|
30
|
+
|
31
|
+
include Log
|
32
|
+
include Dobjects
|
33
|
+
|
34
|
+
# The Data::Dataset object that should get plotted.
|
35
|
+
attr_accessor :dataset
|
36
|
+
|
37
|
+
# A Styles::CurveStyle object saying how the curve should be
|
38
|
+
# drawn.
|
39
|
+
#
|
40
|
+
# Some of the elements will be overridden.
|
41
|
+
attr_accessor :curve_style
|
42
|
+
|
43
|
+
# The IndexedTable object representing the underlying data
|
44
|
+
attr_accessor :table
|
45
|
+
|
46
|
+
|
47
|
+
undef :location=, :location
|
48
|
+
|
49
|
+
# Creates a new XYZContour object with the given _dataset_ and
|
50
|
+
# _style_.
|
51
|
+
#
|
52
|
+
# Lots of code in common with XYZMap
|
53
|
+
def initialize(dataset, style = nil)
|
54
|
+
@dataset = dataset
|
55
|
+
@curve_style = style
|
56
|
+
prepare_data
|
57
|
+
end
|
58
|
+
|
59
|
+
# Prepares the internal storage of the data, from the @dataset
|
60
|
+
def prepare_data
|
61
|
+
@table = @dataset.indexed_table
|
62
|
+
end
|
63
|
+
|
64
|
+
protected :prepare_data
|
65
|
+
|
66
|
+
# Returns the LocationStyle object of the curve. Returns the
|
67
|
+
# one from #curve_style.
|
68
|
+
def location
|
69
|
+
return @curve_style.location
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns the Types::Boundaries of this curve.
|
73
|
+
def get_boundaries
|
74
|
+
return @table.xy_boundaries
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
## Actually draws the curve
|
79
|
+
def real_do(t)
|
80
|
+
debug { "Plotting curve #{inspect}" }
|
81
|
+
t.context do
|
82
|
+
# Of course, there are still quite a few things to do
|
83
|
+
# ;-)...
|
84
|
+
|
85
|
+
# Ideas: for leaving things out, I may have to use min_gt
|
86
|
+
# along with masking.
|
87
|
+
|
88
|
+
## @todo handle non-homogeneous XY maps.
|
89
|
+
|
90
|
+
@curve_style.color_map ||=
|
91
|
+
Styles::ColorMap.from_text("Red--Green")
|
92
|
+
|
93
|
+
if @curve_style.zaxis
|
94
|
+
begin
|
95
|
+
@parent.style.get_axis_style(@curve_style.zaxis).
|
96
|
+
set_color_map(@curve_style.color_map,
|
97
|
+
@table.table.min,
|
98
|
+
@table.table.max)
|
99
|
+
rescue
|
100
|
+
error { "Could not set Z info to non-existent axis #{@curve_style.zaxis}" }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Computation of equally spaced level lines
|
105
|
+
nb = 20
|
106
|
+
|
107
|
+
zmin = @table.table.min
|
108
|
+
zmax = @table.table.max
|
109
|
+
|
110
|
+
t.context do
|
111
|
+
@curve_style.line.set_stroke_style(t)
|
112
|
+
@curve_style.contour.plot_contours(t, table,
|
113
|
+
zmin, zmax,
|
114
|
+
@curve_style.color_map)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -18,7 +18,7 @@ require 'ctioga2/graphics/coordinates'
|
|
18
18
|
|
19
19
|
module CTioga2
|
20
20
|
|
21
|
-
Version::register_svn_info('$Revision:
|
21
|
+
Version::register_svn_info('$Revision: 412 $', '$Date: 2013-08-22 23:04:59 +0200 (Thu, 22 Aug 2013) $')
|
22
22
|
|
23
23
|
module Graphics
|
24
24
|
|
@@ -73,13 +73,17 @@ module CTioga2
|
|
73
73
|
CurveStyleFactory::PlotCommandOptions.key?(k)
|
74
74
|
}
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
curve = send(@current_curves, plot, dataset, options)
|
77
|
+
curve.curve_style.target = curve
|
78
|
+
return curve
|
78
79
|
end
|
79
80
|
|
80
81
|
private
|
81
82
|
|
82
83
|
## \name Available kinds of curves
|
84
|
+
##
|
85
|
+
## @todo All these are completely identical, there probably
|
86
|
+
## isn't need for separate code ?
|
83
87
|
#
|
84
88
|
# @{
|
85
89
|
#
|
@@ -98,11 +102,11 @@ module CTioga2
|
|
98
102
|
def xy_parametric(plot, dataset, options = {})
|
99
103
|
legend = @legend_provider.dataset_legend(dataset)
|
100
104
|
style = @style_factory.next(options)
|
101
|
-
style.legend = false
|
102
105
|
style.legend ||= legend # The legend specified as option to
|
103
106
|
# the --plot command has precedence
|
104
107
|
# over the one specified by --legend.
|
105
108
|
curve = Graphics::Elements::Parametric2D.new(dataset, style)
|
109
|
+
style
|
106
110
|
return curve
|
107
111
|
end
|
108
112
|
|
@@ -110,14 +114,26 @@ module CTioga2
|
|
110
114
|
def xyz_map(plot, dataset, options = {})
|
111
115
|
legend = @legend_provider.dataset_legend(dataset)
|
112
116
|
style = @style_factory.next(options)
|
113
|
-
style.legend = false
|
114
117
|
style.legend ||= legend # The legend specified as option to
|
115
118
|
# the --plot command has precedence
|
116
119
|
# over the one specified by --legend.
|
120
|
+
style.legend = false # No legend for XYZ maps
|
117
121
|
curve = Graphics::Elements::XYZMap.new(dataset, style)
|
118
122
|
return curve
|
119
123
|
end
|
120
124
|
|
125
|
+
# XYZ maps
|
126
|
+
def xyz_contour(plot, dataset, options = {})
|
127
|
+
legend = @legend_provider.dataset_legend(dataset)
|
128
|
+
style = @style_factory.next(options)
|
129
|
+
style.legend ||= legend # The legend specified as option to
|
130
|
+
# the --plot command has precedence
|
131
|
+
# over the one specified by --legend.
|
132
|
+
style.legend = false # No legend for XYZ maps
|
133
|
+
curve = Graphics::Elements::XYZContour.new(dataset, style)
|
134
|
+
return curve
|
135
|
+
end
|
136
|
+
|
121
137
|
|
122
138
|
## @}
|
123
139
|
|
@@ -141,6 +157,16 @@ module CTioga2
|
|
141
157
|
Switch to XY parametric plots, that is standard XY plots whose appearance
|
142
158
|
(such as color, marker color, and, potentially, marker kinds and more)
|
143
159
|
are governed by one (or more ?) Z values.
|
160
|
+
EOH
|
161
|
+
|
162
|
+
ContourPlotCommand =
|
163
|
+
Cmd.new("contour",nil,"--contour") do |plotmaker|
|
164
|
+
plotmaker.curve_generator.current_curves = :xyz_contour
|
165
|
+
end
|
166
|
+
|
167
|
+
ContourPlotCommand.describe('select contour plots',
|
168
|
+
<<EOH, PlotTypesGroup)
|
169
|
+
...
|
144
170
|
EOH
|
145
171
|
|
146
172
|
XYPlotCommand =
|
@@ -16,10 +16,11 @@ require 'ctioga2/graphics/legends/items'
|
|
16
16
|
require 'ctioga2/graphics/legends/area'
|
17
17
|
require 'ctioga2/graphics/legends/storage'
|
18
18
|
require 'ctioga2/graphics/legends/provider'
|
19
|
+
require 'ctioga2/graphics/legends/multicols'
|
19
20
|
|
20
21
|
module CTioga2
|
21
22
|
|
22
|
-
Version::register_svn_info('$Revision:
|
23
|
+
Version::register_svn_info('$Revision: 432 $', '$Date: 2013-08-23 19:06:36 +0200 (Fri, 23 Aug 2013) $')
|
23
24
|
|
24
25
|
module Graphics
|
25
26
|
|
@@ -52,6 +53,9 @@ EOH
|
|
52
53
|
LegendLineCommand.describe("Adds a pure text line to the legend",
|
53
54
|
<<EOH, LegendGroup)
|
54
55
|
Adds a line of text unrelated to any curve to the legend.
|
56
|
+
|
57
|
+
The options controlling the aspect of the legend are documented in the
|
58
|
+
{command: define-text-style} command.
|
55
59
|
EOH
|
56
60
|
|
57
61
|
|
@@ -82,9 +86,16 @@ EOH
|
|
82
86
|
<<EOH, LegendGroup)
|
83
87
|
Sets the various aspects of the style of the legends throught
|
84
88
|
its options:
|
85
|
-
* @dy@: the spacing between consecutive lines
|
89
|
+
* @dy@: the spacing between the baseline of consecutive lines;
|
90
|
+
it is deprecated now in favor of @vpadding@;
|
91
|
+
* @vpadding@: the space left between the bottom of a line and the top of
|
92
|
+
the next one;
|
86
93
|
* @scale@: the overall scale of the legends
|
87
|
-
* @
|
94
|
+
* @text-scale@: the scale of the text (and the markers) inside the legends
|
95
|
+
|
96
|
+
The @frame-@ options control the drawing of a frame around the legend;
|
97
|
+
they have the same meaning as corresponding ones of
|
98
|
+
{command: define-box-style} with the @frame-@ bit dropped.
|
88
99
|
EOH
|
89
100
|
|
90
101
|
LegendInsideCommand =
|
@@ -107,5 +118,35 @@ As a shortcut, {command: legend-inside} also takes all the options that
|
|
107
118
|
EOH
|
108
119
|
|
109
120
|
|
121
|
+
LegendMulticolOptions = Styles::MultiColumnLegendStyle.options_hash()
|
122
|
+
|
123
|
+
LegendMultiColCommand =
|
124
|
+
Cmd.new("legend-multicol", nil, "--legend-multicol",
|
125
|
+
[], LegendMulticolOptions) do |plotmaker, options|
|
126
|
+
multicol = Legends::MultiColumnLegend.new
|
127
|
+
multicol.style.set_from_hash(options)
|
128
|
+
plotmaker.root_object.current_plot.
|
129
|
+
enter_legend_subcontainer(multicol)
|
130
|
+
end
|
131
|
+
|
132
|
+
LegendMultiColCommand.describe("Lay out legends in several columns",
|
133
|
+
<<EOH, LegendGroup)
|
134
|
+
Following legends will be layed out in multiple columns, until a call
|
135
|
+
to {command: legend-multicol-end}.
|
136
|
+
EOH
|
137
|
+
|
138
|
+
LegendMultiColEndCommand =
|
139
|
+
Cmd.new("legend-multicol-end", nil, "--legend-multicol-end",
|
140
|
+
[], {}) do |plotmaker, options|
|
141
|
+
plotmaker.root_object.current_plot.
|
142
|
+
enter_legend_subcontainer(nil)
|
143
|
+
end
|
144
|
+
|
145
|
+
LegendMultiColEndCommand.describe("End of multicolumn legends",
|
146
|
+
<<EOH, LegendGroup)
|
147
|
+
Stop layout out legends in several columns
|
148
|
+
EOH
|
149
|
+
|
150
|
+
|
110
151
|
end
|
111
152
|
end
|
@@ -16,7 +16,7 @@ require 'ctioga2/log'
|
|
16
16
|
|
17
17
|
module CTioga2
|
18
18
|
|
19
|
-
Version::register_svn_info('$Revision:
|
19
|
+
Version::register_svn_info('$Revision: 386 $', '$Date: 2013-03-11 22:57:16 +0100 (Mon, 11 Mar 2013) $')
|
20
20
|
|
21
21
|
module Graphics
|
22
22
|
|
@@ -74,6 +74,8 @@ module CTioga2
|
|
74
74
|
def display_legend(t, container)
|
75
75
|
items = container.legend_storage.harvest_contents
|
76
76
|
t.context do
|
77
|
+
|
78
|
+
## @todo These two commands should join LegendStyle
|
77
79
|
t.rescale(@legend_style.scale)
|
78
80
|
t.rescale_text(@legend_style.text_scale)
|
79
81
|
|
@@ -82,8 +84,9 @@ module CTioga2
|
|
82
84
|
## \todo customize this !
|
83
85
|
x, y = initial_xy(t, container)
|
84
86
|
|
85
|
-
w,h = *size(t, container)
|
86
|
-
|
87
|
+
w,h = *size(t, container, false)
|
88
|
+
|
89
|
+
|
87
90
|
@legend_style.frame.
|
88
91
|
draw_box_around(t, x, y,
|
89
92
|
x + w, y - h, @legend_style.frame_padding)
|
@@ -91,8 +94,9 @@ module CTioga2
|
|
91
94
|
for item in items
|
92
95
|
## \todo transform the 0.0 for x into a negative
|
93
96
|
# user-specifiable stuff.
|
97
|
+
iw, ih = *item.size(t, @legend_style)
|
94
98
|
item.draw(t, @legend_style, x , y)
|
95
|
-
y -=
|
99
|
+
y -= ih
|
96
100
|
end
|
97
101
|
end
|
98
102
|
end
|
@@ -100,19 +104,34 @@ module CTioga2
|
|
100
104
|
# Returns the total size of the legend as a
|
101
105
|
# [ width, height ]
|
102
106
|
# array in figure coordinates.
|
103
|
-
|
107
|
+
#
|
108
|
+
# It assumes that the scales are not setup yet, unless
|
109
|
+
# _resize_ is set to false.
|
110
|
+
def size(t, container, resize = true)
|
104
111
|
items = container.legend_storage.harvest_contents
|
105
112
|
width, height = 0,0
|
113
|
+
|
114
|
+
# We apparently can't use context here, for a reason that fails me...
|
115
|
+
if resize
|
116
|
+
t.rescale(@legend_style.scale)
|
117
|
+
t.rescale_text(@legend_style.text_scale)
|
118
|
+
end
|
119
|
+
|
106
120
|
for item in items
|
107
121
|
w,h = item.size(t, @legend_style)
|
122
|
+
|
108
123
|
if w > width
|
109
124
|
width = w
|
110
125
|
end
|
111
|
-
|
112
|
-
|
113
|
-
height += @legend_style.dy.to_figure(t,:y) *
|
114
|
-
@legend_style.scale * @legend_style.text_scale
|
126
|
+
|
127
|
+
height += h
|
115
128
|
end
|
129
|
+
|
130
|
+
if resize
|
131
|
+
t.rescale(1/@legend_style.scale)
|
132
|
+
t.rescale_text(1/@legend_style.text_scale)
|
133
|
+
end
|
134
|
+
|
116
135
|
return [ width, height ]
|
117
136
|
end
|
118
137
|
|