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
@@ -1,123 +0,0 @@
|
|
1
|
-
# containers.rb: drawables that contains other drawables
|
2
|
-
# copyright (c) 2006, 2007, 2008, 2009 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,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details (in the COPYING file).
|
13
|
-
|
14
|
-
|
15
|
-
require 'ctioga2/utils'
|
16
|
-
require 'ctioga2/log'
|
17
|
-
|
18
|
-
module CTioga2
|
19
|
-
|
20
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
21
|
-
|
22
|
-
module Graphics
|
23
|
-
|
24
|
-
module Elements
|
25
|
-
|
26
|
-
# A Container is a drawable object that contains several others, its
|
27
|
-
# #elements.
|
28
|
-
class Container < TiogaElement
|
29
|
-
|
30
|
-
# All drawable Element contained in this object. It may
|
31
|
-
# contain other Container subobjects.
|
32
|
-
attr_accessor :elements
|
33
|
-
|
34
|
-
# The subframe position of this element with respect to its
|
35
|
-
# parent. It is a Types::Box object.
|
36
|
-
attr_accessor :subframe
|
37
|
-
|
38
|
-
# A reference to the RootObject
|
39
|
-
attr_accessor :root_object
|
40
|
-
|
41
|
-
# The Legends::LegendArea dedicated to the display of the
|
42
|
-
# legend of this object and its children, or _nil_ if the
|
43
|
-
# parent should handle the display.
|
44
|
-
attr_accessor :legend_area
|
45
|
-
|
46
|
-
# The Legends::LegendStorage that holds all the legends of the
|
47
|
-
# object
|
48
|
-
attr_accessor :legend_storage
|
49
|
-
|
50
|
-
# Creates an empty new Container with the given _parent_.
|
51
|
-
def initialize(parent = nil, root = nil)
|
52
|
-
@parent = parent
|
53
|
-
|
54
|
-
# elements to be given to tioga
|
55
|
-
@elements = []
|
56
|
-
|
57
|
-
# By default the frame takes up all the space.
|
58
|
-
@subframe = Types::MarginsBox.new(0, 0, 0, 0)
|
59
|
-
|
60
|
-
@root_object = root
|
61
|
-
|
62
|
-
@legend_storage = Legends::LegendStorage.new
|
63
|
-
|
64
|
-
# By default, don't display legends.
|
65
|
-
@legend_area = nil
|
66
|
-
end
|
67
|
-
|
68
|
-
# Returns the number of child elements
|
69
|
-
def size
|
70
|
-
return @elements.size
|
71
|
-
end
|
72
|
-
|
73
|
-
# Sometimes, the value of the subframe is _nil_ and determined
|
74
|
-
# during the plot. This function is guaranteed to return the
|
75
|
-
# correct value. It takes a reference to a FigureMaker object.
|
76
|
-
def actual_subframe(t)
|
77
|
-
return @subframe
|
78
|
-
end
|
79
|
-
|
80
|
-
# Adds an element
|
81
|
-
def add_element(element)
|
82
|
-
element.parent = self
|
83
|
-
@elements << element
|
84
|
-
|
85
|
-
# If the element has a curve_style, we add it as a
|
86
|
-
# CurveLegend
|
87
|
-
if element.respond_to?(:curve_style) and
|
88
|
-
element.curve_style.has_legend?
|
89
|
-
add_legend_item(Legends::CurveLegend.new(element.curve_style))
|
90
|
-
elsif element.is_a? Container
|
91
|
-
add_legend_item(element)
|
92
|
-
end
|
93
|
-
|
94
|
-
# We call LocationStyle#finalize! if possible
|
95
|
-
if(self.respond_to?(:style) and element.respond_to?(:location))
|
96
|
-
element.location.finalize!(self.style)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
# Adds a legend item to the #associated_legend_storage
|
102
|
-
def add_legend_item(item)
|
103
|
-
@legend_storage.add_item(item)
|
104
|
-
end
|
105
|
-
|
106
|
-
# \todo provide coordinate conversion facilities...
|
107
|
-
|
108
|
-
protected
|
109
|
-
|
110
|
-
# Creates the appropriate subfigure and draws all its elements
|
111
|
-
# within.
|
112
|
-
def real_do(t)
|
113
|
-
t.subfigure(@subframe.to_frame_margins(t)) do
|
114
|
-
for el in @elements
|
115
|
-
el.do(t)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
@@ -1,225 +0,0 @@
|
|
1
|
-
# lists.rb : Different Types to deal with types where
|
2
|
-
# you can choose among several possibilities
|
3
|
-
# Copyright (C) 2006, 2009 Vincent Fourmond
|
4
|
-
#
|
5
|
-
# This program is free software; you can redistribute it and/or modify
|
6
|
-
# it under the terms of the GNU General Public License as published by
|
7
|
-
# the Free Software Foundation; either version 2 of the License, or
|
8
|
-
# (at your option) any later version.
|
9
|
-
#
|
10
|
-
# This program is distributed in the hope that it will be useful,
|
11
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
# GNU General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU General Public License
|
16
|
-
# along with this program; if not, write to the Free Software
|
17
|
-
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
-
|
19
|
-
require 'ctioga2/utils'
|
20
|
-
|
21
|
-
module CTioga2
|
22
|
-
|
23
|
-
Version::register_svn_info('$Revision$', '$Date$')
|
24
|
-
|
25
|
-
|
26
|
-
module MetaBuilder
|
27
|
-
|
28
|
-
# The module Types should be used for all subclasses of
|
29
|
-
# Type, to keep the place clean and tidy.
|
30
|
-
module Types
|
31
|
-
|
32
|
-
# A regular expression matching true
|
33
|
-
TRUE_RE = /^\s*(true|yes|on)\s*$/i
|
34
|
-
|
35
|
-
# A regular expression matching false
|
36
|
-
FALSE_RE = /^\s*(false|no(ne)?|off)\s*$/i
|
37
|
-
|
38
|
-
|
39
|
-
# A boolean parameter
|
40
|
-
class BooleanParameter < Type
|
41
|
-
|
42
|
-
type_name :boolean
|
43
|
-
|
44
|
-
def type_name
|
45
|
-
return 'bool'
|
46
|
-
end
|
47
|
-
|
48
|
-
# Yes, this *really* is a boolean !
|
49
|
-
def boolean?
|
50
|
-
return true
|
51
|
-
end
|
52
|
-
|
53
|
-
def string_to_type_internal(str)
|
54
|
-
if str == true or str =~ TRUE_RE
|
55
|
-
return true
|
56
|
-
else
|
57
|
-
return false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def type_to_string_internal(val)
|
62
|
-
if val
|
63
|
-
return "true"
|
64
|
-
else
|
65
|
-
return "false"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# Booleans are a special case for option parser, as they
|
70
|
-
# are handled completely differently
|
71
|
-
def option_parser_long_option(name, biniou = nil)
|
72
|
-
return "--[no-]#{name}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
# A list of symbols. A hash :list must be provided that states
|
77
|
-
# the correspondance between the legal symbols that can be
|
78
|
-
# accepted by this parameter and their "english" name.
|
79
|
-
# This parameter can typically be used to prompt the user
|
80
|
-
# for different choices.
|
81
|
-
class ListParameter < Type
|
82
|
-
|
83
|
-
type_name :list
|
84
|
-
|
85
|
-
def initialize(type)
|
86
|
-
super
|
87
|
-
raise "type must have a :list key" unless type.has_key?(:list)
|
88
|
-
# We make a copy for our own purposes.
|
89
|
-
@hash = type[:list].dup
|
90
|
-
end
|
91
|
-
|
92
|
-
def type_name
|
93
|
-
return 'list'
|
94
|
-
end
|
95
|
-
|
96
|
-
def string_to_type_internal(str)
|
97
|
-
if @hash.has_key?(str.to_sym)
|
98
|
-
return str.to_sym
|
99
|
-
else
|
100
|
-
raise IncorrectInput, "Invalid input: #{str} should be one of " +
|
101
|
-
@hash.keys.map {|s| s.to_s}.join(',')
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def type_to_string_internal(val)
|
106
|
-
return val.to_s
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
# A choice between different symbols based on regular expressions.
|
112
|
-
class REListParameter < Type
|
113
|
-
|
114
|
-
type_name :re_list
|
115
|
-
|
116
|
-
def initialize(type)
|
117
|
-
super
|
118
|
-
raise "type must have a :list key" unless type.has_key?(:list)
|
119
|
-
# We make a copy for our own purposes.
|
120
|
-
@re_hash = type[:list].dup
|
121
|
-
end
|
122
|
-
|
123
|
-
def type_name
|
124
|
-
return 'relist'
|
125
|
-
end
|
126
|
-
|
127
|
-
def string_to_type_internal(str)
|
128
|
-
for k,v in @re_hash
|
129
|
-
if str =~ /^\s*#{k}\s*$/
|
130
|
-
return v
|
131
|
-
end
|
132
|
-
end
|
133
|
-
raise IncorrectInput, "Invalid input: #{str} should match " +
|
134
|
-
@re_hash.keys.map {|s| s.to_s}.join(',')
|
135
|
-
end
|
136
|
-
|
137
|
-
def type_to_string_internal(val)
|
138
|
-
return val.to_s
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
# An array of identical elements of type specified by :subtype. Defaults
|
143
|
-
# to String
|
144
|
-
class ArrayParameter < Type
|
145
|
-
type_name :array
|
146
|
-
|
147
|
-
def initialize(type)
|
148
|
-
super
|
149
|
-
# We make a copy for our own purposes.
|
150
|
-
subtype = type[:subtype] || {:type => :string}
|
151
|
-
@subtype = Type.get_type(subtype)
|
152
|
-
@separator = /\s*,\s*/
|
153
|
-
@separator_out = ','
|
154
|
-
end
|
155
|
-
|
156
|
-
def type_name
|
157
|
-
return 'array'
|
158
|
-
end
|
159
|
-
|
160
|
-
def string_to_type_internal(str)
|
161
|
-
ary = str.split(@separator)
|
162
|
-
return ary.map do |a|
|
163
|
-
@subtype.string_to_type(a)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def type_to_string_internal(val)
|
168
|
-
return val.map do |a|
|
169
|
-
@subtype.type_to_string(a)
|
170
|
-
end.join(@separator_out)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
# A Type used for sets for Graphics::Styles::CircularArray
|
175
|
-
# objects.
|
176
|
-
#
|
177
|
-
# \todo write a gradient stuff !!!
|
178
|
-
class SetParameter < ArrayParameter
|
179
|
-
type_name :set
|
180
|
-
|
181
|
-
def initialize(type)
|
182
|
-
super
|
183
|
-
@separator = /\s*\|\s*/
|
184
|
-
@separator_out = '|'
|
185
|
-
end
|
186
|
-
|
187
|
-
def type_name
|
188
|
-
return 'set'
|
189
|
-
end
|
190
|
-
|
191
|
-
def string_to_type_internal(str)
|
192
|
-
multiply = nil
|
193
|
-
if str =~ /(.*)\*\s*(\d+)\s*$/
|
194
|
-
multiply = $2.to_i
|
195
|
-
str = $1
|
196
|
-
end
|
197
|
-
if str =~ /^\s*gradient:(.+)--(.+),(\d+)\s*$/
|
198
|
-
s,e,nb = $1, $2, $3.to_i
|
199
|
-
s,e = @subtype.string_to_type(s),@subtype.string_to_type(e)
|
200
|
-
fact = if nb > 1
|
201
|
-
1.0/(nb - 1) # The famous off-by one...
|
202
|
-
else
|
203
|
-
warn { "Incorrect gradient number: #{nb}" }
|
204
|
-
1.0
|
205
|
-
end
|
206
|
-
array = []
|
207
|
-
nb.times do |i|
|
208
|
-
array << Utils::mix_objects(e,s, i * fact)
|
209
|
-
end
|
210
|
-
else
|
211
|
-
array = super
|
212
|
-
end
|
213
|
-
if multiply
|
214
|
-
# Seems that I've finally managed to understand what zip
|
215
|
-
# is useful for !
|
216
|
-
array = array.zip(*([array]*(multiply-1))).flatten(1)
|
217
|
-
end
|
218
|
-
return array
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|