ctioga2 0.0 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +25 -1
- data/lib/ctioga2/commands/commands.rb +13 -2
- data/lib/ctioga2/commands/doc/doc.rb +13 -17
- data/lib/ctioga2/commands/doc/documentation-commands.rb +14 -1
- data/lib/ctioga2/commands/doc/help.rb +136 -25
- data/lib/ctioga2/commands/doc/html.rb +56 -4
- data/lib/ctioga2/commands/doc/introspection.rb +45 -9
- data/lib/ctioga2/commands/doc/man.rb +7 -5
- data/lib/ctioga2/commands/doc/markup.rb +39 -12
- data/lib/ctioga2/commands/doc/wordwrap.rb +70 -0
- data/lib/ctioga2/commands/general-commands.rb +7 -4
- data/lib/ctioga2/commands/general-types.rb +27 -12
- data/lib/ctioga2/commands/interpreter.rb +2 -2
- data/lib/ctioga2/commands/parsers/command-line.rb +9 -5
- data/lib/ctioga2/commands/parsers/file.rb +5 -3
- data/lib/ctioga2/commands/type.rb +10 -3
- data/lib/ctioga2/commands/variables.rb +2 -2
- data/lib/ctioga2/data/backends/backend.rb +17 -15
- data/lib/ctioga2/data/backends/backends.rb +2 -2
- data/lib/ctioga2/data/backends/backends/gnuplot.rb +20 -5
- data/lib/ctioga2/data/backends/backends/math.rb +2 -2
- data/lib/ctioga2/data/backends/backends/text.rb +112 -17
- data/lib/ctioga2/data/backends/description.rb +10 -11
- data/lib/ctioga2/data/datacolumn.rb +73 -14
- data/lib/ctioga2/data/dataset.rb +305 -9
- data/lib/ctioga2/data/filters.rb +49 -1
- data/lib/ctioga2/data/indexed-dtable.rb +137 -0
- data/lib/ctioga2/data/point.rb +98 -7
- data/lib/ctioga2/data/stack.rb +98 -21
- data/lib/ctioga2/graphics/coordinates.rb +19 -2
- data/lib/ctioga2/graphics/elements.rb +12 -2
- data/lib/ctioga2/graphics/elements/containers.rb +14 -2
- data/lib/ctioga2/graphics/elements/contour.rb +67 -0
- data/lib/ctioga2/graphics/elements/curve2d.rb +103 -42
- data/lib/ctioga2/graphics/elements/element.rb +12 -2
- data/lib/ctioga2/graphics/elements/gradient-region.rb +94 -0
- data/lib/ctioga2/graphics/elements/parametric2d.rb +172 -0
- data/lib/ctioga2/graphics/elements/primitive.rb +37 -21
- data/lib/ctioga2/graphics/elements/region.rb +143 -0
- data/lib/ctioga2/graphics/elements/subplot.rb +92 -32
- data/lib/ctioga2/graphics/elements/tangent.rb +99 -0
- data/lib/ctioga2/graphics/elements/xyz-map.rb +126 -0
- data/lib/ctioga2/graphics/generator.rb +91 -6
- data/lib/ctioga2/graphics/legends.rb +26 -21
- data/lib/ctioga2/graphics/legends/area.rb +8 -8
- data/lib/ctioga2/graphics/legends/items.rb +5 -5
- data/lib/ctioga2/graphics/legends/storage.rb +4 -2
- data/lib/ctioga2/graphics/root.rb +24 -2
- data/lib/ctioga2/graphics/styles.rb +8 -0
- data/lib/ctioga2/graphics/styles/axes.rb +49 -23
- data/lib/ctioga2/graphics/styles/base.rb +2 -2
- data/lib/ctioga2/graphics/styles/carrays.rb +9 -2
- data/lib/ctioga2/graphics/styles/colormap.rb +272 -0
- data/lib/ctioga2/graphics/styles/curve.rb +64 -4
- data/lib/ctioga2/graphics/styles/drawable.rb +68 -9
- data/lib/ctioga2/graphics/styles/errorbar.rb +73 -0
- data/lib/ctioga2/graphics/styles/factory.rb +133 -17
- data/lib/ctioga2/graphics/styles/gradients.rb +60 -0
- data/lib/ctioga2/graphics/styles/location.rb +64 -0
- data/lib/ctioga2/graphics/styles/map-axes.rb +164 -0
- data/lib/ctioga2/graphics/styles/plot.rb +165 -62
- data/lib/ctioga2/graphics/styles/sets.rb +14 -1
- data/lib/ctioga2/graphics/styles/texts.rb +44 -34
- data/lib/ctioga2/graphics/subplot-commands.rb +94 -6
- data/lib/ctioga2/graphics/types.rb +113 -35
- data/lib/ctioga2/graphics/types/bijection.rb +3 -3
- data/lib/ctioga2/graphics/types/boundaries.rb +120 -1
- data/lib/ctioga2/graphics/types/dimensions.rb +8 -1
- data/lib/ctioga2/graphics/types/grid.rb +196 -0
- data/lib/ctioga2/graphics/types/location.rb +228 -0
- data/lib/ctioga2/graphics/types/point.rb +2 -2
- data/lib/ctioga2/log.rb +18 -18
- data/lib/ctioga2/metabuilder/type.rb +15 -3
- data/lib/ctioga2/metabuilder/types.rb +2 -2
- data/lib/ctioga2/metabuilder/types/coordinates.rb +13 -1
- data/lib/ctioga2/metabuilder/types/data.rb +50 -0
- data/lib/ctioga2/metabuilder/types/generic.rb +60 -0
- data/lib/ctioga2/metabuilder/types/lists.rb +53 -16
- data/lib/ctioga2/metabuilder/types/styles.rb +26 -45
- data/lib/ctioga2/plotmaker.rb +91 -20
- data/lib/ctioga2/postprocess.rb +8 -8
- data/lib/ctioga2/utils.rb +23 -4
- metadata +107 -75
- data/lib/ctioga2/data/merge.rb +0 -43
@@ -0,0 +1,73 @@
|
|
1
|
+
# drawable.rb: style objects pertaining to drawable objects.
|
2
|
+
# copyright (c) 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
|
+
require 'ctioga2/utils'
|
15
|
+
require 'ctioga2/log'
|
16
|
+
|
17
|
+
|
18
|
+
# This module contains all the classes used by ctioga
|
19
|
+
module CTioga2
|
20
|
+
|
21
|
+
Version::register_svn_info('$Revision: 123 $', '$Date: 2010-01-10 02:45:47 +0100 (Sun, 10 Jan 2010) $')
|
22
|
+
|
23
|
+
module Graphics
|
24
|
+
|
25
|
+
# All the styles
|
26
|
+
module Styles
|
27
|
+
|
28
|
+
# This class represents the stylistic information necessary to
|
29
|
+
# draw an error bar. It derives from StrokeStyle, as it is
|
30
|
+
# essentially a stroke.
|
31
|
+
class ErrorBarStyle < StrokeStyle
|
32
|
+
|
33
|
+
# The error bar style. For now, not much here.
|
34
|
+
attr_accessor :style
|
35
|
+
|
36
|
+
# Shows an error bar with the appropriate stylistic
|
37
|
+
# information. _x_ and _y_ are the coordinates of the data
|
38
|
+
# point. The corresponding _min_ and _max_ are the minimum and
|
39
|
+
# maximum values for the error bars. If either is _nil_, no
|
40
|
+
# error bar on that direction is drawn.
|
41
|
+
#
|
42
|
+
# \todo maybe make provisions (one day) for complex error bars
|
43
|
+
# showing min/max and stddev as well ?
|
44
|
+
def show_error_bar(t, x, xmin, xmax, y, ymin, ymax)
|
45
|
+
d = { 'x' => x,
|
46
|
+
'y' => y,
|
47
|
+
'color' => @color || Tioga::ColorConstants::Black,
|
48
|
+
'line_width' => @width || 1.0,
|
49
|
+
}
|
50
|
+
has = false
|
51
|
+
if (xmin && xmax && (xmax - xmin != 0))
|
52
|
+
d['dx_plus'] = xmax - x
|
53
|
+
d['dx_minus'] = x - xmin
|
54
|
+
has = true
|
55
|
+
end
|
56
|
+
|
57
|
+
if (ymin && ymax && (ymax - ymin != 0))
|
58
|
+
d['dy_plus'] = ymax - y
|
59
|
+
d['dy_minus'] = y - ymin
|
60
|
+
has = true
|
61
|
+
end
|
62
|
+
# We won't draw something when there isn't anything to draw
|
63
|
+
# !
|
64
|
+
if(has)
|
65
|
+
t.show_error_bars(d)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -17,7 +17,7 @@ require 'ctioga2/log'
|
|
17
17
|
# This module contains all the classes used by ctioga
|
18
18
|
module CTioga2
|
19
19
|
|
20
|
-
Version::register_svn_info('$Revision:
|
20
|
+
Version::register_svn_info('$Revision: 217 $', '$Date: 2010-12-31 16:18:20 +0100 (Fri, 31 Dec 2010) $')
|
21
21
|
|
22
22
|
module Graphics
|
23
23
|
|
@@ -52,18 +52,23 @@ module CTioga2
|
|
52
52
|
# The MetaBuilder::Type object that can convert a String to
|
53
53
|
# an Array suitable for use with CircularArray.
|
54
54
|
attr_accessor :sets_type
|
55
|
+
|
56
|
+
# If this attribute is on, then CurveStyleFactory will not
|
57
|
+
# generate commands for this parameter, only the option.
|
58
|
+
attr_accessor :disable_commands
|
55
59
|
|
56
60
|
|
57
61
|
# Creates a new CurveStyleFactoryParameter object.
|
58
62
|
def initialize(name, type, sets, description,
|
59
|
-
short_option = nil)
|
63
|
+
short_option = nil, disable_cmds = false)
|
60
64
|
@name = name
|
61
65
|
@type = Commands::CommandType.get_type(type)
|
62
66
|
@sets = sets
|
63
67
|
@description = description
|
64
68
|
@short_option = short_option
|
65
|
-
|
66
|
-
|
69
|
+
@disable_commands = disable_cmds
|
70
|
+
|
71
|
+
## \todo it is not very satisfying to mix CommandTypes and
|
67
72
|
# MetaBuilder::Type on the same level.
|
68
73
|
if @sets
|
69
74
|
@sets_type =
|
@@ -95,11 +100,16 @@ module CTioga2
|
|
95
100
|
# Sets some parameter to _false_.
|
96
101
|
DisableRE = /no(ne)?|off/i
|
97
102
|
|
103
|
+
# If that matches, we use the value as a link to other values.
|
104
|
+
LinkRE = /(?:=|->)(\S+)/
|
98
105
|
|
99
106
|
|
100
107
|
# Creates a new parameter for the style factory.
|
108
|
+
#
|
109
|
+
# \todo add a way to add some more text to the description;
|
110
|
+
# possibly a self.describe_parameter function ?
|
101
111
|
def self.define_parameter(target, name, type, sets, description,
|
102
|
-
short_option = nil)
|
112
|
+
short_option = nil, disable_cmds = false)
|
103
113
|
# We define two new types:
|
104
114
|
# - first, the color-or-auto type:
|
105
115
|
base_type = Commands::CommandType.get_type(type)
|
@@ -112,9 +122,12 @@ module CTioga2
|
|
112
122
|
mb_type.re_shortcuts[AutoRE] = 'auto'
|
113
123
|
mb_type.re_shortcuts[DisableRE] = false
|
114
124
|
|
125
|
+
# Add passthrough for expressions such as =color...
|
126
|
+
mb_type.passthrough = LinkRE
|
127
|
+
|
115
128
|
# Now, register a type for the type or automatic.
|
116
129
|
CmdType.new("#{base_type.name}-or-auto", mb_type,
|
117
|
-
"Same thing as type
|
130
|
+
"Same thing as {type:#{base_type.name}}, or @auto@ to let the style factory handle automatically.")
|
118
131
|
|
119
132
|
end
|
120
133
|
|
@@ -125,11 +138,12 @@ module CTioga2
|
|
125
138
|
:subtype => base_type.type,
|
126
139
|
:shortcuts => sets
|
127
140
|
} ,
|
128
|
-
"Sets of #{base_type.name}")
|
141
|
+
"Sets of {type: #{base_type.name}}")
|
129
142
|
end
|
130
143
|
param =
|
131
144
|
CurveStyleFactoryParameter.new(name, type, sets,
|
132
|
-
description, short_option
|
145
|
+
description, short_option,
|
146
|
+
disable_cmds)
|
133
147
|
@parameters ||= {}
|
134
148
|
@parameters[target] = param
|
135
149
|
|
@@ -151,8 +165,8 @@ module CTioga2
|
|
151
165
|
# The CmdGroup for stylistic information about
|
152
166
|
# curves.
|
153
167
|
CurveStyleGroup =
|
154
|
-
CmdGroup.new('curve-style', "
|
155
|
-
"Set stylistic details
|
168
|
+
CmdGroup.new('curve-style', "Curves styles",
|
169
|
+
"Set stylistic details of curves or other object drawn from data", 1)
|
156
170
|
|
157
171
|
|
158
172
|
# Creates two commands for each parameter of the object:
|
@@ -160,6 +174,7 @@ module CTioga2
|
|
160
174
|
# * a command to choose the sets.
|
161
175
|
def self.create_commands
|
162
176
|
parameters.each do |target, param|
|
177
|
+
next if param.disable_commands
|
163
178
|
override_cmd =
|
164
179
|
Cmd.new("#{param.name}",
|
165
180
|
param.short_option,
|
@@ -168,12 +183,13 @@ module CTioga2
|
|
168
183
|
CmdArg.new("#{param.type.name}-or-auto")
|
169
184
|
], {},
|
170
185
|
"Sets the #{param.description} for subsequent curves",
|
171
|
-
"Sets the #{param.description} for subsequent curves, until cancelled with
|
186
|
+
"Sets the #{param.description} for subsequent curves, until cancelled with @auto@ as argument.", CurveStyleGroup) do |plotmaker, value|
|
172
187
|
plotmaker.curve_generator.style_factory.
|
173
188
|
set_parameter_override(target, value)
|
174
189
|
end
|
175
190
|
|
176
191
|
if param.sets
|
192
|
+
next if param.disable_commands
|
177
193
|
set_cmd =
|
178
194
|
Cmd.new("#{param.name}-set",
|
179
195
|
nil,
|
@@ -182,10 +198,12 @@ module CTioga2
|
|
182
198
|
CmdArg.new("#{param.type.name}-set")
|
183
199
|
], {},
|
184
200
|
"Chooses a set for the #{param.description} of subsequent curves",
|
185
|
-
"Chooses a set for the #{param.description} of subsequent curves",
|
201
|
+
"Chooses a set for the #{param.description} of subsequent curves. Also sets {command: #{param.name}} to @auto@, so that the set takes effect immediately",
|
186
202
|
CurveStyleGroup) do |plotmaker, value|
|
187
203
|
plotmaker.curve_generator.style_factory.
|
188
204
|
set_parameter_set(target, value)
|
205
|
+
plotmaker.curve_generator.style_factory.
|
206
|
+
set_parameter_override(target, 'auto')
|
189
207
|
end
|
190
208
|
end
|
191
209
|
end
|
@@ -244,8 +262,7 @@ module CTioga2
|
|
244
262
|
end
|
245
263
|
base.merge!(@override_parameters)
|
246
264
|
base.merge!(hash_name_to_target(one_time))
|
247
|
-
|
248
|
-
return CurveStyle.from_hash(base)
|
265
|
+
return CurveStyle.from_hash(resolve_links(base))
|
249
266
|
end
|
250
267
|
|
251
268
|
|
@@ -265,8 +282,18 @@ module CTioga2
|
|
265
282
|
if value =~ AutoRE
|
266
283
|
@override_parameters.delete(target)
|
267
284
|
return
|
268
|
-
|
269
|
-
|
285
|
+
elsif value =~ LinkRE
|
286
|
+
t = $1
|
287
|
+
convert = self.class.name_to_target
|
288
|
+
if convert.key?(t)
|
289
|
+
value = "=#{convert[t]}".to_sym
|
290
|
+
else
|
291
|
+
warn { "No known key: #{t}, treating as auto" }
|
292
|
+
@override_parameters.delete(target)
|
293
|
+
return
|
294
|
+
end
|
295
|
+
|
296
|
+
elsif value =~ DisableRE
|
270
297
|
value = false
|
271
298
|
else
|
272
299
|
value = param.type.string_to_type(value)
|
@@ -287,6 +314,8 @@ module CTioga2
|
|
287
314
|
end
|
288
315
|
|
289
316
|
# Now, the parameters:
|
317
|
+
|
318
|
+
# Lines:
|
290
319
|
define_parameter 'line_color', 'color', 'color',
|
291
320
|
Sets::ColorSets, "color", "-c"
|
292
321
|
|
@@ -296,6 +325,7 @@ module CTioga2
|
|
296
325
|
define_parameter 'line_style', 'line-style', 'line-style',
|
297
326
|
Sets::LineStyleSets, "line style", nil
|
298
327
|
|
328
|
+
# Markers
|
299
329
|
define_parameter 'marker_marker', 'marker', 'marker',
|
300
330
|
Sets::MarkerSets, "marker", '-m'
|
301
331
|
|
@@ -305,6 +335,53 @@ module CTioga2
|
|
305
335
|
define_parameter 'marker_scale', 'marker-scale', 'float',
|
306
336
|
Sets::LineWidthSets, "marker scale", nil
|
307
337
|
|
338
|
+
# Error bars:
|
339
|
+
define_parameter 'error_bar_color', 'error-bar-color', 'color',
|
340
|
+
Sets::ColorSets, "error bar color", nil
|
341
|
+
|
342
|
+
# Location:
|
343
|
+
define_parameter 'location_xaxis', 'xaxis', 'axis',
|
344
|
+
nil, "X axis", nil, true
|
345
|
+
|
346
|
+
define_parameter 'location_yaxis', 'yaxis', 'axis',
|
347
|
+
nil, "Y axis", nil, true
|
348
|
+
|
349
|
+
# Now, fill style
|
350
|
+
define_parameter 'fill_y0', 'fill', 'fill-until',
|
351
|
+
{}, "Fill until", nil
|
352
|
+
|
353
|
+
define_parameter 'fill_color', 'fill-color', 'color',
|
354
|
+
Sets::ColorSets, "fill color", nil
|
355
|
+
|
356
|
+
define_parameter 'fill_transparency', 'fill-transparency', 'float',
|
357
|
+
{}, "Fill transparency", nil
|
358
|
+
|
359
|
+
# Region handling
|
360
|
+
define_parameter 'region_position', 'region-side', 'region-side',
|
361
|
+
{"default" => [:above, :below]}, "region side", nil
|
362
|
+
|
363
|
+
|
364
|
+
define_parameter 'style', 'style', 'text',
|
365
|
+
{}, "Path style", nil
|
366
|
+
|
367
|
+
# Only for xyz-maps or xy-parametric
|
368
|
+
define_parameter 'color_map', 'color-map', 'colormap',
|
369
|
+
nil, "Color map", nil
|
370
|
+
|
371
|
+
|
372
|
+
define_parameter 'zaxis', 'zaxis', 'text',
|
373
|
+
nil, "Name for the Z axis", nil
|
374
|
+
|
375
|
+
## @todo For xy-parametric, there should be a way to specify
|
376
|
+
## to which z value the maps apply (ie lines = y2, marker =
|
377
|
+
## y3...). Although for readability, it is probably better
|
378
|
+
## to avoid that...
|
379
|
+
define_parameter 'marker_color_map', 'marker-color-map', 'colormap',
|
380
|
+
nil, "Marker color map", nil
|
381
|
+
|
382
|
+
define_parameter 'split_on_nan', 'split-on-nan', 'boolean',
|
383
|
+
nil, "Split on NaN", nil
|
384
|
+
|
308
385
|
|
309
386
|
# And finally, we register all necessary commands...
|
310
387
|
create_commands
|
@@ -339,11 +416,50 @@ module CTioga2
|
|
339
416
|
if convert.key? k
|
340
417
|
retval[convert[k]] = v
|
341
418
|
else
|
342
|
-
warn "Unkown key for hash_name_to_target: #{k}"
|
419
|
+
warn { "Unkown key for hash_name_to_target: #{k}" }
|
343
420
|
end
|
344
421
|
end
|
345
422
|
return retval
|
346
423
|
end
|
424
|
+
|
425
|
+
# Resolve potential links in the form of :=stuff within the
|
426
|
+
# given hash, and returns a new version of the hash.
|
427
|
+
#
|
428
|
+
# \warning the _h_ parameter is completely destroyed in the
|
429
|
+
# process
|
430
|
+
def resolve_links(h)
|
431
|
+
tv = {}
|
432
|
+
|
433
|
+
# First, copy plain values
|
434
|
+
for k,v in h
|
435
|
+
if v.is_a?(Symbol) && v.to_s =~ /^(=|->)/
|
436
|
+
# We keep for later
|
437
|
+
else
|
438
|
+
tv[k] = v
|
439
|
+
h.delete(k)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
# Now, we will iterate over the remaining things; we will
|
444
|
+
# stop with an error if the number of remaining keys does
|
445
|
+
# not decrease after one step
|
446
|
+
while h.size > 0
|
447
|
+
pre_size = h.size
|
448
|
+
for k,v in h
|
449
|
+
v.to_s =~ /^(?:=|->)(\S+)/
|
450
|
+
target = $1
|
451
|
+
if tv.key? target
|
452
|
+
tv[k] = tv[target]
|
453
|
+
h.delete(k)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
if h.size >= pre_size
|
457
|
+
raise "Error: infinite recursion loop while gathering styles"
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
return tv
|
462
|
+
end
|
347
463
|
end
|
348
464
|
end
|
349
465
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# gradients.rb: objects dealing with (color) gradients
|
2
|
+
# copyright (c) 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
|
+
require 'ctioga2/utils'
|
15
|
+
require 'ctioga2/log'
|
16
|
+
|
17
|
+
require 'ctioga2/graphics/coordinates'
|
18
|
+
|
19
|
+
# This module contains all the classes used by ctioga
|
20
|
+
module CTioga2
|
21
|
+
|
22
|
+
Version::register_svn_info('$Revision: 168 $', '$Date: 2010-10-22 13:03:33 +0200 (Fri, 22 Oct 2010) $')
|
23
|
+
|
24
|
+
module Graphics
|
25
|
+
|
26
|
+
module Styles
|
27
|
+
|
28
|
+
|
29
|
+
# A color gradient with two points
|
30
|
+
#
|
31
|
+
# \todo There could be many more
|
32
|
+
#
|
33
|
+
# @todo This will have to be replaced by a real color map based
|
34
|
+
# on what
|
35
|
+
class TwoPointGradient < BasicStyle
|
36
|
+
|
37
|
+
include Log
|
38
|
+
|
39
|
+
# The starting color (for x = 0)
|
40
|
+
attr_accessor :start
|
41
|
+
|
42
|
+
# The ending color (for x = 1)
|
43
|
+
attr_accessor :end
|
44
|
+
|
45
|
+
def initialize(s,e)
|
46
|
+
warn { "This class shouldn't be used anymore at #{caller.inspect}" }
|
47
|
+
@start = s
|
48
|
+
@end = e
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns the color for the given value of _x_ (between 0 and 1)
|
52
|
+
def color(x)
|
53
|
+
return Utils::mix_objects(@end,@start, x)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# drawable.rb: style objects pertaining to drawable objects.
|
2
|
+
# copyright (c) 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
|
+
require 'ctioga2/utils'
|
15
|
+
require 'ctioga2/log'
|
16
|
+
|
17
|
+
# This module contains all the classes used by ctioga
|
18
|
+
module CTioga2
|
19
|
+
|
20
|
+
Version::register_svn_info('$Revision: 133 $', '$Date: 2010-01-18 21:37:36 +0100 (Mon, 18 Jan 2010) $')
|
21
|
+
|
22
|
+
module Graphics
|
23
|
+
|
24
|
+
# All the styles
|
25
|
+
module Styles
|
26
|
+
|
27
|
+
# This class represents various aspects of the location of a
|
28
|
+
# object within a plot, such as:
|
29
|
+
#
|
30
|
+
# * X and Y axes
|
31
|
+
# * foreground/normal/background position
|
32
|
+
# * whether it should be clipped or not.
|
33
|
+
#
|
34
|
+
# \todo currently only X and Y axes are implemented.
|
35
|
+
class LocationStyle < BasicStyle
|
36
|
+
|
37
|
+
# The name of the X axis, something to be fed to
|
38
|
+
# PlotStyle#get_axis_key
|
39
|
+
attr_accessor :xaxis
|
40
|
+
|
41
|
+
# The name of the Y axis
|
42
|
+
attr_accessor :yaxis
|
43
|
+
|
44
|
+
# Given a PlotStyle object, returns the axes keys as would
|
45
|
+
# PlotStyle#get_axis_key
|
46
|
+
def get_axis_keys(plot_style)
|
47
|
+
return [
|
48
|
+
plot_style.get_axis_key(@xaxis || 'x'),
|
49
|
+
plot_style.get_axis_key(@yaxis || 'y')
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Finalizes the location of the object, that is (for now)
|
54
|
+
# resolves references to default axes.
|
55
|
+
def finalize!(plot_style)
|
56
|
+
@xaxis, @yaxis = *get_axis_keys(plot_style)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|