ctioga 1.11.1

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.
Files changed (103) hide show
  1. data/COPYING +340 -0
  2. data/ctioga/bin/ctable +28 -0
  3. data/ctioga/bin/ctioga +37 -0
  4. data/ctioga/doc/ctable.1 +156 -0
  5. data/ctioga/doc/ctioga.1 +2363 -0
  6. data/ctioga/examples/README +46 -0
  7. data/ctioga/examples/ctioga.gnuplot +4 -0
  8. data/ctioga/examples/ctioga_within_tioga.rb +53 -0
  9. data/ctioga/examples/ctiogarc.rb +24 -0
  10. data/ctioga/examples/include_1.rb +15 -0
  11. data/ctioga/examples/noise.dat +100 -0
  12. data/ctioga/examples/noise.rb +13 -0
  13. data/ctioga/examples/trig.csv +100 -0
  14. data/ctioga/examples/trig.dat +100 -0
  15. data/ctioga/examples/trig.rb +14 -0
  16. data/ctioga/examples/trigh.dat +100 -0
  17. data/ctioga/examples/trigh.rb +10 -0
  18. data/ctioga/examples/tutorial +763 -0
  19. data/ctioga/examples/tutorial.sh +269 -0
  20. data/ctioga/tests/README +14 -0
  21. data/ctioga/tests/axes.sh +40 -0
  22. data/ctioga/tests/basic.sh +11 -0
  23. data/ctioga/tests/draw.sh +24 -0
  24. data/ctioga/tests/histograms.sh +14 -0
  25. data/ctioga/tests/insets.sh +41 -0
  26. data/ctioga/tests/layouts.sh +29 -0
  27. data/ctioga/tests/legends.sh +113 -0
  28. data/ctioga/tests/styles.sh +43 -0
  29. data/ctioga/tests/test_style.sh +8 -0
  30. data/ctioga/tests/tests.sh +24 -0
  31. data/ctioga/tests/text_backend.sh +83 -0
  32. data/ctioga/tests/tioga_defaults.rb +18 -0
  33. data/lib/CTioga/axes.rb +904 -0
  34. data/lib/CTioga/backends.rb +88 -0
  35. data/lib/CTioga/boundaries.rb +224 -0
  36. data/lib/CTioga/ctable.rb +134 -0
  37. data/lib/CTioga/curve_style.rb +246 -0
  38. data/lib/CTioga/debug.rb +199 -0
  39. data/lib/CTioga/dimension.rb +133 -0
  40. data/lib/CTioga/elements.rb +17 -0
  41. data/lib/CTioga/elements/base.rb +84 -0
  42. data/lib/CTioga/elements/containers.rb +578 -0
  43. data/lib/CTioga/elements/curves.rb +368 -0
  44. data/lib/CTioga/elements/tioga_primitives.rb +440 -0
  45. data/lib/CTioga/layout.rb +595 -0
  46. data/lib/CTioga/legends.rb +29 -0
  47. data/lib/CTioga/legends/cmdline.rb +187 -0
  48. data/lib/CTioga/legends/item.rb +164 -0
  49. data/lib/CTioga/legends/style.rb +257 -0
  50. data/lib/CTioga/log.rb +73 -0
  51. data/lib/CTioga/movingarrays.rb +131 -0
  52. data/lib/CTioga/partition.rb +271 -0
  53. data/lib/CTioga/plot_style.rb +230 -0
  54. data/lib/CTioga/plotmaker.rb +1677 -0
  55. data/lib/CTioga/shortcuts.rb +69 -0
  56. data/lib/CTioga/structures.rb +82 -0
  57. data/lib/CTioga/styles.rb +140 -0
  58. data/lib/CTioga/themes.rb +581 -0
  59. data/lib/CTioga/themes/classical.rb +82 -0
  60. data/lib/CTioga/themes/demo.rb +63 -0
  61. data/lib/CTioga/themes/fits.rb +91 -0
  62. data/lib/CTioga/themes/mono.rb +33 -0
  63. data/lib/CTioga/tioga.rb +32 -0
  64. data/lib/CTioga/utils.rb +173 -0
  65. data/lib/MetaBuilder/Parameters/dates.rb +38 -0
  66. data/lib/MetaBuilder/Parameters/lists.rb +132 -0
  67. data/lib/MetaBuilder/Parameters/numbers.rb +69 -0
  68. data/lib/MetaBuilder/Parameters/strings.rb +86 -0
  69. data/lib/MetaBuilder/Parameters/styles.rb +75 -0
  70. data/lib/MetaBuilder/Qt4/Parameters/dates.rb +51 -0
  71. data/lib/MetaBuilder/Qt4/Parameters/numbers.rb +65 -0
  72. data/lib/MetaBuilder/Qt4/Parameters/strings.rb +106 -0
  73. data/lib/MetaBuilder/Qt4/parameter.rb +172 -0
  74. data/lib/MetaBuilder/Qt4/parameters.rb +9 -0
  75. data/lib/MetaBuilder/descriptions.rb +603 -0
  76. data/lib/MetaBuilder/factory.rb +101 -0
  77. data/lib/MetaBuilder/group.rb +57 -0
  78. data/lib/MetaBuilder/metabuilder.rb +10 -0
  79. data/lib/MetaBuilder/parameter.rb +374 -0
  80. data/lib/MetaBuilder/parameters.rb +11 -0
  81. data/lib/MetaBuilder/qt4.rb +8 -0
  82. data/lib/SciYAG/Backends/backend.rb +379 -0
  83. data/lib/SciYAG/Backends/binner.rb +168 -0
  84. data/lib/SciYAG/Backends/cache.rb +102 -0
  85. data/lib/SciYAG/Backends/dataset.rb +158 -0
  86. data/lib/SciYAG/Backends/descriptions.rb +469 -0
  87. data/lib/SciYAG/Backends/filters.rb +25 -0
  88. data/lib/SciYAG/Backends/filters/average.rb +134 -0
  89. data/lib/SciYAG/Backends/filters/cumulate.rb +37 -0
  90. data/lib/SciYAG/Backends/filters/filter.rb +70 -0
  91. data/lib/SciYAG/Backends/filters/norm.rb +39 -0
  92. data/lib/SciYAG/Backends/filters/smooth.rb +63 -0
  93. data/lib/SciYAG/Backends/filters/sort.rb +43 -0
  94. data/lib/SciYAG/Backends/filters/strip.rb +34 -0
  95. data/lib/SciYAG/Backends/filters/trim.rb +64 -0
  96. data/lib/SciYAG/Backends/gnuplot.rb +131 -0
  97. data/lib/SciYAG/Backends/math.rb +108 -0
  98. data/lib/SciYAG/Backends/mdb.rb +462 -0
  99. data/lib/SciYAG/Backends/multitext.rb +96 -0
  100. data/lib/SciYAG/Backends/source.rb +64 -0
  101. data/lib/SciYAG/Backends/text.rb +339 -0
  102. data/lib/SciYAG/backends.rb +16 -0
  103. metadata +191 -0
@@ -0,0 +1,82 @@
1
+ # theme/classical.rb, copyright (c) 2007 by Vincent Fourmond:
2
+ # The "classical" theme
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 'Tioga/tioga'
16
+ require 'CTioga/themes'
17
+ require 'CTioga/movingarrays'
18
+
19
+
20
+ module CTioga
21
+
22
+ module Themes
23
+
24
+ class ClassicalTheme < BaseTheme
25
+
26
+ include Tioga::FigureConstants
27
+
28
+ # Mainly for listing purposes:
29
+ attr_reader :sets
30
+
31
+ def initialize(color_set = 'standard',
32
+ marker_set = 'standard',
33
+ # By default, the marker color will match
34
+ # the line color, even if the latter is set
35
+ # manually.
36
+ marker_color_set = :"=>color",
37
+ linestyle_set = Line_Type_Solid)
38
+ @sets = {
39
+ :colors => MovingArray.new(Styles::COLORS, color_set),
40
+ :markers => MovingArray.new(Styles::MARKERS, marker_set),
41
+ :markers_colors => MovingArray.new(Styles::COLORS,
42
+ marker_color_set),
43
+ :linestyle => MovingArray.new(Styles::LINES, linestyle_set)
44
+ }
45
+ end
46
+
47
+
48
+ def next_curve_style(name)
49
+ style = CurveStyle.new(@sets[:colors].value,
50
+ @sets[:markers].value,
51
+ @sets[:markers_colors].value,
52
+ @sets[:linestyle].value,
53
+ name,
54
+ 1.0,
55
+ false, # Does not interpolate by default
56
+ 0.5)
57
+ return style
58
+ end
59
+
60
+ def choose_set(type, set)
61
+ @sets[type].choose_current_set(set)
62
+ end
63
+
64
+ end
65
+
66
+ # Some pastel colors... Just a demonstration of what you can
67
+ # actually do.
68
+ class PastelTheme < ClassicalTheme
69
+
70
+ def initialize
71
+ super('pastel1')
72
+ end
73
+
74
+ def cmdline_extra_args
75
+ return ["--background", "FloralWhite"]
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,63 @@
1
+ # theme/demo.rb, copyright (c) 2007 by Vincent Fourmond:
2
+ # The "demo" theme, a theme that demonstrates some
3
+ # possibilities of the theme stuff.
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 (in the COPYING file).
14
+
15
+
16
+ # This file is intended as a small display of the possibilities
17
+ # of the theme thing. Please have a look at this code and also
18
+ # make sure you understand how the classical (default) theme is
19
+ # working, and then play around with this file.
20
+ #
21
+ # bod_hook and cmdline_extra_args can both do similar things,
22
+ # although not completely equivalent. Moreover, I find it is
23
+ # always good to have several ways to do things.
24
+
25
+ require 'CTioga/themes/classical'
26
+
27
+ module CTioga
28
+
29
+ module Themes
30
+
31
+ class DemoTheme < ClassicalTheme
32
+
33
+ def initialize
34
+ super # We don't want to use more for now
35
+ end
36
+
37
+ # To understand the following code, I can only encourage
38
+ # you to have a look at Tioga's rdoc documentation, which
39
+ # can be generated on your tioga source tree or
40
+ # browsed online at
41
+ #
42
+ # http://tioga.rubyforge.org/doc/
43
+ #
44
+ # The _t_ argument is a Tioga::FigureMaker object that
45
+ # is in charge of actually drawing the plots.
46
+ def bod_hook(t)
47
+ t.tex_fontfamily = 'sfdefault' # Sans serif fonts
48
+ t.tex_xaxis_numeric_label = '$x = #1$'
49
+ t.tex_yaxis_numeric_label = '$y = #1$'
50
+ end
51
+
52
+ # This function pushes back some arguments to the command
53
+ # line. No further processing happens, so you need to
54
+ # make sure that you did correct splitting:
55
+ # ['--marker auto'] is wrong: use ['--marker', 'auto'] instead.
56
+ def cmdline_extra_args
57
+ return ["--background", "Cornsilk"]
58
+ end
59
+ end
60
+
61
+ end
62
+
63
+ end
@@ -0,0 +1,91 @@
1
+ # theme/fits.rb, copyright (c) 2007 by Vincent Fourmond:
2
+ # The "fits" theme
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 'Tioga/tioga'
16
+ require 'CTioga/themes'
17
+ require 'CTioga/movingarrays'
18
+
19
+
20
+ module CTioga
21
+
22
+ module Themes
23
+
24
+ # A theme where marker-only curves (data) alternate with
25
+ # lines-only curves (fits)
26
+ class FitsTheme < BaseTheme
27
+
28
+ include Tioga::FigureConstants
29
+
30
+ # Mainly for listing purposes:
31
+ attr_reader :sets
32
+
33
+ def initialize(color_set = 'standard',
34
+ marker_set = 'standard',
35
+ # By default, the marker color will match
36
+ # the line color, even if the latter is set
37
+ # manually.
38
+ marker_color_set = :"=>color",
39
+ linestyle_set = Line_Type_Solid)
40
+ @sets = {
41
+ :colors => MovingArray.new(Styles::COLORS, color_set),
42
+ :markers => MovingArray.new(Styles::MARKERS, marker_set),
43
+ :markers_colors => MovingArray.new(Styles::COLORS,
44
+ marker_color_set),
45
+ :linestyle => MovingArray.new(Styles::LINES, linestyle_set)
46
+ }
47
+
48
+ @data = true
49
+ end
50
+
51
+
52
+ def next_curve_style(name)
53
+ if @data
54
+ @last_color = @sets[:colors].value
55
+ style = CurveStyle.new(@last_color,
56
+ @sets[:markers].value,
57
+ @last_color,
58
+ false,
59
+ name,
60
+ 1.0,
61
+ false, # Does not interpolate by default
62
+ 0.5)
63
+ @data = false
64
+ else
65
+ style = CurveStyle.new(@last_color,
66
+ false,
67
+ @last_color,
68
+ @sets[:linestyle].value,
69
+ name,
70
+ 1.0,
71
+ true, # Data is interpolated by default
72
+ 0.5)
73
+ @data = true
74
+ end
75
+ return style
76
+ end
77
+
78
+ def choose_set(type, set)
79
+ @sets[type].choose_current_set(set)
80
+ end
81
+
82
+ def cmdline_extra_args
83
+ return ["--marker", "auto"]
84
+ end
85
+
86
+
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,33 @@
1
+ # theme/mono.rb, copyright (c) 2007 by Vincent Fourmond:
2
+ # The "mono" theme
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 'CTioga/themes/classical'
16
+
17
+ module CTioga
18
+
19
+ module Themes
20
+
21
+ class MonoTheme < ClassicalTheme
22
+
23
+ def initialize
24
+ super(Tioga::FigureConstants::Black, 'standard',
25
+ Tioga::FigureConstants::Black, 'standard')
26
+ end
27
+
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,32 @@
1
+ # tioga.rb, copyright (c) 2006 by Vincent Fourmond:
2
+ # The interface between Tioga and CTioga (to use CTioga from within
3
+ # Tioga code)
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 (in the COPYING file).
14
+
15
+ require 'Tioga/FigureMaker'
16
+ require 'CTioga/plotmaker'
17
+ require 'shellwords'
18
+
19
+ CTioga::Version::register_svn_info('$Revision: 653 $', '$Date: 2007-11-15 21:58:42 +0100 (Thu, 15 Nov 2007) $')
20
+
21
+ class FigureMaker
22
+
23
+
24
+ def def_figure_ctioga(name, cmdline)
25
+ CTioga.define_tioga_figure(self, 'CTioga', *Shellwords.shellwords(cmdline))
26
+ end
27
+
28
+ def show_plot_ctioga(cmdline)
29
+ CTioga.show_tioga_plot(self, *Shellwords.shellwords(cmdline))
30
+ end
31
+
32
+ end # FigureMaker
@@ -0,0 +1,173 @@
1
+ # utils.rb, copyright (c) 2006 by Vincent Fourmond:
2
+ # Some small utility functions
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 'Tioga/FigureMaker'
15
+
16
+ module CTioga
17
+
18
+ # A module for small convenience functions.
19
+ module Utils
20
+
21
+ # A function that interprets a string according to a hash, and
22
+ # returns either what was found in the hash, or the result of the
23
+ # given block if that was not found -- or just the original string
24
+ # itself when no block was given and no corresponding hash element
25
+ # was found. Correspondance is done with the === operator.
26
+ #
27
+ # Actually, the first argument doesn't need to be a string.
28
+ def self.interpret_arg(arg, hash)
29
+ for key, val in hash
30
+ if key === arg
31
+ return val
32
+ end
33
+ end
34
+ if block_given?
35
+ return yield(arg)
36
+ else
37
+ return arg
38
+ end
39
+ end
40
+
41
+ # Returns a frame specification from a classical array
42
+ def self.framespec_str(a)
43
+ return "top : #{a[2]} bottom: #{a[3]} " +
44
+ "left : #{a[0]} right: #{a[1]}"
45
+ end
46
+
47
+ def self.frames_str(t)
48
+ return framespec_str([t.frame_left, t.frame_right,
49
+ t.frame_top, t.frame_bottom])
50
+ end
51
+
52
+ # A function that takes care of converting the given parameter
53
+ # to a float, while ensuring that it was decently taken care of.
54
+ # Returns false if that happens not to be a float.
55
+ def safe_float(a)
56
+ return begin
57
+ Float(a)
58
+ rescue
59
+ warn "Expected a float, but got '#{a}' instead"
60
+ false
61
+ end
62
+ end
63
+
64
+ # A function that 'applies' a margin specification (like for
65
+ # show_plot_with_legend) to a frame spec (left,right,top,bottom).
66
+ #
67
+ # The margin spec has to contain all plot_*_margin things.
68
+ def self.apply_margin_to_frame(frame, margin)
69
+ width = frame[1] - frame[0]
70
+ height = frame[2] - frame[3]
71
+ dest =
72
+ [
73
+ frame[0] + width * (margin['plot_left_margin'] ||
74
+ margin['left']),
75
+ frame[1] - width * (margin['plot_right_margin']||
76
+ margin['right']),
77
+ frame[2] - height * (margin['plot_top_margin'] ||
78
+ margin['top']),
79
+ frame[3] + height * (margin['plot_bottom_margin'] ||
80
+ margin['bottom'])
81
+ ]
82
+ return dest
83
+ end
84
+
85
+ def self.margin_hash(a)
86
+ if Hash === a
87
+ return a
88
+ else
89
+ return {
90
+ 'left' => a[0],
91
+ 'right' => a[1],
92
+ 'top' => a[2],
93
+ 'bottom' => a[3]
94
+ }
95
+ end
96
+ end
97
+
98
+
99
+ # Converts a location into the index of the corresponding
100
+ # coordinates...
101
+ Locations = {
102
+ Tioga::FigureConstants::LEFT => 0,
103
+ Tioga::FigureConstants::RIGHT => 1,
104
+ Tioga::FigureConstants::TOP => 2,
105
+ Tioga::FigureConstants::BOTTOM => 3,
106
+ }
107
+
108
+ def self.location_index(d)
109
+ return Locations[d]
110
+ end
111
+
112
+
113
+ FrameNames = {
114
+ :left => 0,
115
+ :right => 1,
116
+ :bottom => 2,
117
+ :top => 3
118
+ }
119
+
120
+
121
+ # Returns true if the spec is left, right, top or bottom
122
+ def self.side?(spec)
123
+ return FrameNames.key?(spec.to_sym)
124
+ end
125
+
126
+ # Returns the position corresponding to the side:
127
+ def self.side(spec)
128
+ return FrameNames[spec.to_sym]
129
+ end
130
+
131
+ end
132
+
133
+ # A small module to deal with versions and dates
134
+ module Version
135
+
136
+ # The position of the URL, used for getting the version
137
+ SVN_URL = '$HeadURL: svn+ssh://rubyforge.org/var/svn/sciyag/trunk/SciYAG/ctioga/lib/utils.rb $'
138
+
139
+ CTIOGA_VERSION = if SVN_URL =~ /releases\/ctioga-([^\/]+)/
140
+ $1
141
+ else
142
+ "SVN version"
143
+ end
144
+
145
+ # The current version of the program.
146
+ def self.version
147
+ if CTIOGA_VERSION =~ /SVN/
148
+ return "SVN, revision #{SVN_INFO['revision']}, #{SVN_INFO['date']}"
149
+ else
150
+ return CTIOGA_VERSION
151
+ end
152
+ end
153
+
154
+ SVN_INFO = {
155
+ 'revision' => 0,
156
+ 'date' => "old"
157
+ }
158
+
159
+ def self.register_svn_info(rev_str, date_str)
160
+ if rev_str =~ /(\d+)/
161
+ rev = $1
162
+ str = 'Date'
163
+ date = date_str.gsub(/\$#{str}: (.*)\$/) { $1 }
164
+ if SVN_INFO['revision'] < rev.to_i
165
+ SVN_INFO['revision'] = rev.to_i
166
+ SVN_INFO['date'] = date
167
+ end
168
+ end
169
+ end
170
+
171
+ register_svn_info('$Revision: 780 $', '$Date: 2008-03-09 14:25:14 +0100 (Sun, 09 Mar 2008) $')
172
+ end
173
+ end