ctioga2 0.0
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/COPYING +339 -0
- data/Changelog +6 -0
- data/bin/ctioga2 +26 -0
- data/lib/ctioga2/commands/arguments.rb +58 -0
- data/lib/ctioga2/commands/commands.rb +258 -0
- data/lib/ctioga2/commands/doc/doc.rb +118 -0
- data/lib/ctioga2/commands/doc/documentation-commands.rb +119 -0
- data/lib/ctioga2/commands/doc/help.rb +95 -0
- data/lib/ctioga2/commands/doc/html.rb +230 -0
- data/lib/ctioga2/commands/doc/introspection.rb +211 -0
- data/lib/ctioga2/commands/doc/man.rb +279 -0
- data/lib/ctioga2/commands/doc/markup.rb +359 -0
- data/lib/ctioga2/commands/general-commands.rb +119 -0
- data/lib/ctioga2/commands/general-types.rb +118 -0
- data/lib/ctioga2/commands/groups.rb +73 -0
- data/lib/ctioga2/commands/interpreter.rb +257 -0
- data/lib/ctioga2/commands/parsers/command-line.rb +187 -0
- data/lib/ctioga2/commands/parsers/file.rb +186 -0
- data/lib/ctioga2/commands/strings.rb +303 -0
- data/lib/ctioga2/commands/type.rb +100 -0
- data/lib/ctioga2/commands/variables.rb +101 -0
- data/lib/ctioga2/data/backends/backend.rb +260 -0
- data/lib/ctioga2/data/backends/backends.rb +39 -0
- data/lib/ctioga2/data/backends/backends/gnuplot.rb +140 -0
- data/lib/ctioga2/data/backends/backends/math.rb +121 -0
- data/lib/ctioga2/data/backends/backends/text.rb +335 -0
- data/lib/ctioga2/data/backends/description.rb +405 -0
- data/lib/ctioga2/data/backends/factory.rb +73 -0
- data/lib/ctioga2/data/backends/parameter.rb +109 -0
- data/lib/ctioga2/data/datacolumn.rb +245 -0
- data/lib/ctioga2/data/dataset.rb +233 -0
- data/lib/ctioga2/data/filters.rb +131 -0
- data/lib/ctioga2/data/merge.rb +43 -0
- data/lib/ctioga2/data/point.rb +72 -0
- data/lib/ctioga2/data/stack.rb +294 -0
- data/lib/ctioga2/graphics/coordinates.rb +73 -0
- data/lib/ctioga2/graphics/elements.rb +111 -0
- data/lib/ctioga2/graphics/elements/containers.rb +111 -0
- data/lib/ctioga2/graphics/elements/curve2d.rb +155 -0
- data/lib/ctioga2/graphics/elements/element.rb +90 -0
- data/lib/ctioga2/graphics/elements/primitive.rb +256 -0
- data/lib/ctioga2/graphics/elements/subplot.rb +140 -0
- data/lib/ctioga2/graphics/generator.rb +68 -0
- data/lib/ctioga2/graphics/legends.rb +108 -0
- data/lib/ctioga2/graphics/legends/area.rb +199 -0
- data/lib/ctioga2/graphics/legends/items.rb +183 -0
- data/lib/ctioga2/graphics/legends/provider.rb +58 -0
- data/lib/ctioga2/graphics/legends/storage.rb +65 -0
- data/lib/ctioga2/graphics/root.rb +209 -0
- data/lib/ctioga2/graphics/styles.rb +30 -0
- data/lib/ctioga2/graphics/styles/axes.rb +247 -0
- data/lib/ctioga2/graphics/styles/background.rb +122 -0
- data/lib/ctioga2/graphics/styles/base.rb +115 -0
- data/lib/ctioga2/graphics/styles/carrays.rb +53 -0
- data/lib/ctioga2/graphics/styles/curve.rb +101 -0
- data/lib/ctioga2/graphics/styles/drawable.rb +87 -0
- data/lib/ctioga2/graphics/styles/factory.rb +351 -0
- data/lib/ctioga2/graphics/styles/legend.rb +63 -0
- data/lib/ctioga2/graphics/styles/plot.rb +410 -0
- data/lib/ctioga2/graphics/styles/sets.rb +64 -0
- data/lib/ctioga2/graphics/styles/texts.rb +277 -0
- data/lib/ctioga2/graphics/subplot-commands.rb +141 -0
- data/lib/ctioga2/graphics/types.rb +188 -0
- data/lib/ctioga2/graphics/types/bijection.rb +79 -0
- data/lib/ctioga2/graphics/types/boundaries.rb +170 -0
- data/lib/ctioga2/graphics/types/boxes.rb +157 -0
- data/lib/ctioga2/graphics/types/dimensions.rb +157 -0
- data/lib/ctioga2/graphics/types/point.rb +247 -0
- data/lib/ctioga2/log.rb +97 -0
- data/lib/ctioga2/metabuilder/type.rb +316 -0
- data/lib/ctioga2/metabuilder/types.rb +39 -0
- data/lib/ctioga2/metabuilder/types/coordinates.rb +124 -0
- data/lib/ctioga2/metabuilder/types/dates.rb +43 -0
- data/lib/ctioga2/metabuilder/types/lists.rb +188 -0
- data/lib/ctioga2/metabuilder/types/numbers.rb +97 -0
- data/lib/ctioga2/metabuilder/types/strings.rb +93 -0
- data/lib/ctioga2/metabuilder/types/styles.rb +178 -0
- data/lib/ctioga2/plotmaker.rb +677 -0
- data/lib/ctioga2/postprocess.rb +115 -0
- data/lib/ctioga2/utils.rb +120 -0
- data/setup.rb +1586 -0
- metadata +144 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# coordinates.rb: coordinate transformations
|
|
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
|
+
module CTioga2
|
|
19
|
+
|
|
20
|
+
Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
|
|
21
|
+
|
|
22
|
+
module Graphics
|
|
23
|
+
|
|
24
|
+
# Deals with transforming the coordinates of all datasets
|
|
25
|
+
#
|
|
26
|
+
# TODO:
|
|
27
|
+
# * offsets
|
|
28
|
+
# * scales
|
|
29
|
+
# * x/y log
|
|
30
|
+
# * non-linear transformations ?
|
|
31
|
+
# * the possibility to provide locations using this.
|
|
32
|
+
# * conversion of datasets.
|
|
33
|
+
class CoordinateTransforms
|
|
34
|
+
|
|
35
|
+
# A scaling factor for coordinates:
|
|
36
|
+
attr_accessor :x_scale, :y_scale
|
|
37
|
+
|
|
38
|
+
# An offset for coordinates
|
|
39
|
+
attr_accessor :x_offset, :y_offset
|
|
40
|
+
|
|
41
|
+
# Whether to use logarithmic coordinates
|
|
42
|
+
attr_accessor :x_log, :y_log
|
|
43
|
+
|
|
44
|
+
# Creates a CoordinateTransformations object.
|
|
45
|
+
def initialize
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Apply a transformation to a Data::Dataset holding 2D signals.
|
|
49
|
+
# Modifies the dataset in place.
|
|
50
|
+
def transform_2d!(dataset)
|
|
51
|
+
for w in [:x , :y]
|
|
52
|
+
if v = self.send("#{w}_scale")
|
|
53
|
+
dataset.send(w).apply do |x|
|
|
54
|
+
x.mul!(v)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
if v = self.send("#{w}_offset")
|
|
58
|
+
dataset.send(w).apply do |x|
|
|
59
|
+
x.add!(v)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
if v = self.send("#{w}_log")
|
|
63
|
+
dataset.send(w).apply do |x|
|
|
64
|
+
x.safe_log10!
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# elements.rb: all 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, 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/types'
|
|
16
|
+
require 'ctioga2/graphics/elements/element'
|
|
17
|
+
require 'ctioga2/graphics/elements/containers'
|
|
18
|
+
require 'ctioga2/graphics/elements/subplot'
|
|
19
|
+
require 'ctioga2/graphics/elements/curve2d'
|
|
20
|
+
require 'ctioga2/graphics/elements/primitive'
|
|
21
|
+
|
|
22
|
+
module CTioga2
|
|
23
|
+
|
|
24
|
+
Version::register_svn_info('$Revision: 55 $', '$Date: 2009-05-27 00:01:34 +0200 (Wed, 27 May 2009) $')
|
|
25
|
+
|
|
26
|
+
module Graphics
|
|
27
|
+
|
|
28
|
+
# Now, various commands pertaining to various drawables
|
|
29
|
+
|
|
30
|
+
PlotCoordinatesGroup = CmdGroup.new('coordinates',
|
|
31
|
+
"Plot coordinates",
|
|
32
|
+
"Plot coordinates", 2)
|
|
33
|
+
PlotMarginCommand =
|
|
34
|
+
Cmd.new("margin",nil,"--margin",
|
|
35
|
+
[ CmdArg.new('float') ]) do |plotmaker, margin|
|
|
36
|
+
plotmaker.root_object.current_plot.style.plot_margin = margin
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
PlotMarginCommand.describe("Leaves a margin around data points",
|
|
40
|
+
<<EOH, PlotCoordinatesGroup)
|
|
41
|
+
Leaves a margin around the data points. Expressed in relative size of the
|
|
42
|
+
whole plot.
|
|
43
|
+
EOH
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Various coordinate-related commands:
|
|
47
|
+
CoordinateRelatedCommands = []
|
|
48
|
+
[:x, :y].each do |x|
|
|
49
|
+
cmd =
|
|
50
|
+
Cmd.new("#{x}range",nil,"--#{x}range",
|
|
51
|
+
[ CmdArg.new('partial-float-range') ]) do |plotmaker, range|
|
|
52
|
+
plotmaker.root_object.current_plot.
|
|
53
|
+
user_boundaries.set_from_range(range, x)
|
|
54
|
+
end
|
|
55
|
+
cmd.describe("Sets the #{x.to_s.upcase} range",
|
|
56
|
+
<<EOH, PlotCoordinatesGroup)
|
|
57
|
+
Sets the range of the #{x.to_s.upcase} coordinates.
|
|
58
|
+
EOH
|
|
59
|
+
CoordinateRelatedCommands << cmd
|
|
60
|
+
|
|
61
|
+
cmd =
|
|
62
|
+
Cmd.new("#{x}offset",nil,"--#{x}offset",
|
|
63
|
+
[ CmdArg.new('float') ]) do |plotmaker, val|
|
|
64
|
+
plotmaker.root_object.current_plot.
|
|
65
|
+
style.transforms.send("#{x}_offset=", val)
|
|
66
|
+
end
|
|
67
|
+
cmd.describe("Offset #{x.to_s.upcase} data",
|
|
68
|
+
<<EOH, PlotCoordinatesGroup)
|
|
69
|
+
Adds the given offset to all #{x.to_s.upcase} coordinates.
|
|
70
|
+
EOH
|
|
71
|
+
CoordinateRelatedCommands << cmd
|
|
72
|
+
|
|
73
|
+
cmd =
|
|
74
|
+
Cmd.new("#{x}scale",nil,"--#{x}scale",
|
|
75
|
+
[ CmdArg.new('float') ]) do |plotmaker, val|
|
|
76
|
+
plotmaker.root_object.current_plot.
|
|
77
|
+
style.transforms.send("#{x}_scale=", val)
|
|
78
|
+
end
|
|
79
|
+
cmd.describe("Scale #{x.to_s.upcase} data",
|
|
80
|
+
<<EOH, PlotCoordinatesGroup)
|
|
81
|
+
Multiplies the #{x.to_s.upcase} coordinates by this factor.
|
|
82
|
+
EOH
|
|
83
|
+
CoordinateRelatedCommands << cmd
|
|
84
|
+
|
|
85
|
+
# Alias
|
|
86
|
+
cmd =
|
|
87
|
+
Cmd.new("#{x}fact",nil,"--#{x}fact",
|
|
88
|
+
[ CmdArg.new('float') ]) do |plotmaker, val|
|
|
89
|
+
plotmaker.root_object.current_plot.
|
|
90
|
+
style.transforms.send("#{x}_scale=", val)
|
|
91
|
+
end
|
|
92
|
+
cmd.describe("Alias for #{x}scale",
|
|
93
|
+
<<EOH, PlotCoordinatesGroup)
|
|
94
|
+
Alias for {command: #{x}scale}.
|
|
95
|
+
EOH
|
|
96
|
+
CoordinateRelatedCommands << cmd
|
|
97
|
+
|
|
98
|
+
cmd =
|
|
99
|
+
Cmd.new("#{x}log",nil,"--#{x}log",
|
|
100
|
+
[ CmdArg.new('boolean') ]) do |plotmaker, val|
|
|
101
|
+
plotmaker.root_object.current_plot.
|
|
102
|
+
style.send("set_log_scale", x, val)
|
|
103
|
+
end
|
|
104
|
+
cmd.describe("Use log scale for #{x.to_s.upcase}",
|
|
105
|
+
<<EOH, PlotCoordinatesGroup)
|
|
106
|
+
Uses a logarithmic scale for the #{x.to_s.upcase} axis.
|
|
107
|
+
EOH
|
|
108
|
+
CoordinateRelatedCommands << cmd
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
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: 38 $', '$Date: 2009-05-07 23:11:55 +0200 (Thu, 07 May 2009) $')
|
|
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
|
+
# Adds an element
|
|
74
|
+
def add_element(element)
|
|
75
|
+
element.parent = self
|
|
76
|
+
@elements << element
|
|
77
|
+
|
|
78
|
+
# If the element has a curve_style, we add it as a
|
|
79
|
+
# CurveLegend
|
|
80
|
+
if element.respond_to?(:curve_style) and
|
|
81
|
+
element.curve_style.has_legend?
|
|
82
|
+
add_legend_item(Legends::CurveLegend.new(element.curve_style))
|
|
83
|
+
elsif element.is_a? Container
|
|
84
|
+
add_legend_item(element)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Adds a legend item to the #associated_legend_storage
|
|
90
|
+
def add_legend_item(item)
|
|
91
|
+
@legend_storage.add_item(item)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# TODO: provide coordinate conversion facilities...
|
|
95
|
+
|
|
96
|
+
protected
|
|
97
|
+
|
|
98
|
+
# Creates the appropriate subfigure and draws all its elements
|
|
99
|
+
# within.
|
|
100
|
+
def real_do(t)
|
|
101
|
+
t.subfigure(@subframe.to_frame_margins(t)) do
|
|
102
|
+
for el in @elements
|
|
103
|
+
el.do(t)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# curve2d.rb: a 2D curve
|
|
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, 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: 55 $', '$Date: 2009-05-27 00:01:34 +0200 (Wed, 27 May 2009) $')
|
|
23
|
+
|
|
24
|
+
module Graphics
|
|
25
|
+
|
|
26
|
+
module Elements
|
|
27
|
+
|
|
28
|
+
# A Curve2D object represents a 2D curve, along with its style and so
|
|
29
|
+
# on.
|
|
30
|
+
class Curve2D < TiogaElement
|
|
31
|
+
|
|
32
|
+
include Log
|
|
33
|
+
include Dobjects
|
|
34
|
+
|
|
35
|
+
# A Dobjects::Function holding the "real" X and Y values, for
|
|
36
|
+
# the sake of manipulations.
|
|
37
|
+
attr_accessor :function
|
|
38
|
+
|
|
39
|
+
# The Data::Dataset object that should get plotted.
|
|
40
|
+
attr_accessor :dataset
|
|
41
|
+
|
|
42
|
+
# A Styles::CurveStyle object saying how the curve should be
|
|
43
|
+
# drawn.
|
|
44
|
+
attr_accessor :curve_style
|
|
45
|
+
|
|
46
|
+
# Creates a new Curve2D object with the given _dataset_ and
|
|
47
|
+
# _style_.
|
|
48
|
+
def initialize(dataset, style = nil)
|
|
49
|
+
@dataset = dataset
|
|
50
|
+
if @dataset.size > 2
|
|
51
|
+
warn "Columns Y2 and further were ignored for set #{dataset.name}"
|
|
52
|
+
end
|
|
53
|
+
# We build the function on a duplicate of the values ?
|
|
54
|
+
@function = Function.new(@dataset.x.values.dup,
|
|
55
|
+
@dataset.y.values.dup)
|
|
56
|
+
|
|
57
|
+
# We remove NaN, as they are not very liked by Tioga...
|
|
58
|
+
#
|
|
59
|
+
# TODO: maybe there should be a way to *split* on NaN rather
|
|
60
|
+
# than to ignore them ?
|
|
61
|
+
@function.strip_nan
|
|
62
|
+
|
|
63
|
+
@curve_style = style
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Returns the Types::Boundaries of this curve.
|
|
67
|
+
def get_boundaries
|
|
68
|
+
return Types::Boundaries.bounds(@function.x, @function.y)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Creates a path for the given curve. This should be defined
|
|
72
|
+
# with care, as it will be used for instance for region
|
|
73
|
+
# coloring and stroking. The function should only append to
|
|
74
|
+
# the current path, not attempt to create a new path or empty
|
|
75
|
+
# what was done before.
|
|
76
|
+
def make_path(t)
|
|
77
|
+
bnds = parent.real_boundaries
|
|
78
|
+
# if @style.interpolate
|
|
79
|
+
# for f in @function.split_monotonic
|
|
80
|
+
# new_f = f.bound_values(*bnds.to_a)
|
|
81
|
+
# t.append_interpolant_to_path(f.make_interpolant)
|
|
82
|
+
# end
|
|
83
|
+
# else
|
|
84
|
+
f = @function.bound_values(*bnds.extrema)
|
|
85
|
+
t.append_points_to_path(f.x, f.y)
|
|
86
|
+
# end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Strokes the path.
|
|
90
|
+
def draw_path(t)
|
|
91
|
+
if @curve_style.has_line?
|
|
92
|
+
t.context do
|
|
93
|
+
@curve_style.line.set_stroke_style(t)
|
|
94
|
+
make_path(t)
|
|
95
|
+
t.stroke
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Draws the markers, if applicable.
|
|
101
|
+
def draw_markers(t)
|
|
102
|
+
if @curve_style.has_marker?
|
|
103
|
+
xs = @function.x
|
|
104
|
+
ys = @function.y
|
|
105
|
+
@curve_style.marker.draw_markers_at(t, xs, ys)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# A function to close the path created by make_path.
|
|
110
|
+
# Overridden in the histogram code.
|
|
111
|
+
def close_path(t, y0)
|
|
112
|
+
t.append_point_to_path(@function.x.last, y0)
|
|
113
|
+
t.append_point_to_path(@function.x.first, y0)
|
|
114
|
+
t.close_path
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Draws the filled region according to the :fill_type element
|
|
118
|
+
# of the style pseudo-hash. It can be:
|
|
119
|
+
def draw_fill(t)
|
|
120
|
+
# y = y_value(@style.fill_type)
|
|
121
|
+
# return unless y
|
|
122
|
+
|
|
123
|
+
# t.fill_transparency = @style.fill_transparency || 0
|
|
124
|
+
# # Now is the tricky part. To do the actual fill, we first make a
|
|
125
|
+
# # path according to the make_path function.
|
|
126
|
+
# make_path(t)
|
|
127
|
+
|
|
128
|
+
# # Then we add two line segments that go from the end to the
|
|
129
|
+
# # beginning.
|
|
130
|
+
# close_path(t, y)
|
|
131
|
+
|
|
132
|
+
# # Now the path is ready. Just strike -- or, rather, fill !
|
|
133
|
+
# t.fill_color = @style.fill_color
|
|
134
|
+
# t.fill
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def real_do(t)
|
|
138
|
+
debug "Plotting curve #{inspect}"
|
|
139
|
+
t.context do
|
|
140
|
+
# TODO reinstate the choice of the order of drawing ???
|
|
141
|
+
draw_path(t)
|
|
142
|
+
draw_markers(t)
|
|
143
|
+
# # The fill is always first
|
|
144
|
+
# draw_fill(t)
|
|
145
|
+
|
|
146
|
+
# for op in CurveStyle::DrawingOrder[@style[:drawing_order]]
|
|
147
|
+
# self.send("draw_#{op}".to_sym, t)
|
|
148
|
+
# end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|