ctioga2 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Changelog +16 -0
  2. data/lib/ctioga2/commands/arguments.rb +5 -2
  3. data/lib/ctioga2/commands/commands.rb +45 -13
  4. data/lib/ctioga2/commands/context.rb +9 -1
  5. data/lib/ctioga2/commands/doc/help.rb +2 -2
  6. data/lib/ctioga2/commands/doc/html.rb +8 -8
  7. data/lib/ctioga2/commands/doc/introspection.rb +7 -5
  8. data/lib/ctioga2/commands/parsers/file.rb +123 -120
  9. data/lib/ctioga2/commands/parsers/old-file.rb +191 -0
  10. data/lib/ctioga2/commands/strings.rb +2 -2
  11. data/lib/ctioga2/data/datacolumn.rb +5 -2
  12. data/lib/ctioga2/data/dataset.rb +3 -13
  13. data/lib/ctioga2/data/indexed-dtable.rb +43 -11
  14. data/lib/ctioga2/data/stack.rb +65 -8
  15. data/lib/ctioga2/graphics/elements.rb +2 -1
  16. data/lib/ctioga2/graphics/elements/containers.rb +22 -3
  17. data/lib/ctioga2/graphics/elements/primitive.rb +5 -5
  18. data/lib/ctioga2/graphics/elements/xyz-contour.rb +123 -0
  19. data/lib/ctioga2/graphics/generator.rb +31 -5
  20. data/lib/ctioga2/graphics/legends.rb +44 -3
  21. data/lib/ctioga2/graphics/legends/area.rb +28 -9
  22. data/lib/ctioga2/graphics/legends/items.rb +34 -23
  23. data/lib/ctioga2/graphics/legends/multicols.rb +132 -0
  24. data/lib/ctioga2/graphics/styles.rb +3 -1
  25. data/lib/ctioga2/graphics/styles/axes.rb +10 -4
  26. data/lib/ctioga2/graphics/styles/base.rb +65 -11
  27. data/lib/ctioga2/graphics/styles/colormap.rb +2 -1
  28. data/lib/ctioga2/graphics/styles/contour.rb +141 -0
  29. data/lib/ctioga2/graphics/styles/curve.rb +49 -67
  30. data/lib/ctioga2/graphics/styles/drawable.rb +17 -8
  31. data/lib/ctioga2/graphics/styles/factory.rb +79 -38
  32. data/lib/ctioga2/graphics/styles/legend.rb +49 -6
  33. data/lib/ctioga2/graphics/styles/plot.rb +10 -9
  34. data/lib/ctioga2/graphics/styles/sheet.rb +11 -11
  35. data/lib/ctioga2/graphics/styles/texts.rb +38 -9
  36. data/lib/ctioga2/graphics/types.rb +20 -1
  37. data/lib/ctioga2/graphics/types/dimensions.rb +7 -1
  38. data/lib/ctioga2/metabuilder/types/lists.rb +4 -4
  39. data/lib/ctioga2/metabuilder/types/numbers.rb +3 -3
  40. data/lib/ctioga2/metabuilder/types/styles.rb +2 -2
  41. data/lib/ctioga2/plotmaker.rb +12 -1
  42. data/lib/ctioga2/utils.rb +27 -3
  43. metadata +8 -4
@@ -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: 359 $', '$Date: 2012-12-26 10:45:35 +0100 (Wed, 26 Dec 2012) $')
20
+ Version::register_svn_info('$Revision: 387 $', '$Date: 2013-03-12 09:33:37 +0100 (Tue, 12 Mar 2013) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -27,16 +27,19 @@ module CTioga2
27
27
  class LegendStorageStyle < BasicStyle
28
28
 
29
29
  # The distance between two lines, a Types::Dimension object.
30
- typed_attribute :dy, 'dimension'
30
+ deprecated_attribute :dy, 'dimension', "use vpadding instead"
31
+
32
+ # The minimum distance between successive vertical elements
33
+ typed_attribute :vpadding, 'dimension'
31
34
 
32
35
  # The width of the legend pictogram, a Types::Dimension object.
33
- attr_accessor :picto_width
36
+ typed_attribute :picto_width, 'dimension'
34
37
 
35
38
  # The height of the legend pictogram, a Types::Dimension object.
36
- attr_accessor :picto_height
39
+ typed_attribute :picto_height, 'dimension'
37
40
 
38
41
  # The distance between the legend pictogram and the text
39
- attr_accessor :picto_to_text
42
+ typed_attribute :picto_to_text, 'dimension'
40
43
 
41
44
  # The overall scale of the legend
42
45
  typed_attribute :scale, 'float'
@@ -56,7 +59,10 @@ module CTioga2
56
59
  typed_attribute :frame_padding, 'dimension'
57
60
 
58
61
  def initialize
59
- @dy = Types::Dimension.new(:dy, 1.6, :y)
62
+
63
+ # @dy = Types::Dimension.new(:dy, 1.6, :y)
64
+
65
+ @vpadding = Types::Dimension.new(:dy, 0.3, :y)
60
66
 
61
67
  @picto_width = Types::Dimension.new(:dy, 1.6, :x)
62
68
  @picto_height = Types::Dimension.new(:dy, 0.6, :y)
@@ -71,6 +77,43 @@ module CTioga2
71
77
 
72
78
  @frame_padding = Types::Dimension.from_text("1mm", :x)
73
79
  end
80
+
81
+ def dy_to_figure(t)
82
+
83
+ # Defaults to one line height + the padding
84
+
85
+ if @dy
86
+ return @dy.to_figure(t, :y)
87
+ end
88
+
89
+ line = Types::Dimension.new(:dy, 1, :y)
90
+ return line.to_figure(t, :y) + @vpadding.to_figure(t, :y)
91
+ end
92
+
93
+ def vpadding_to_figure(t)
94
+ if @dy
95
+ line = Types::Dimension.new(:dy, 1, :y)
96
+ return (@dy.to_figure(t, :y) - line.to_figure(t, :y))
97
+ end
98
+ return @vpadding.to_figure(t, :y)
99
+ end
100
+
101
+ end
102
+
103
+ class MultiColumnLegendStyle < BasicStyle
104
+
105
+ # Padding !
106
+ typed_attribute :dx, 'dimension'
107
+
108
+ # Number of columns
109
+ typed_attribute :columns, 'integer'
110
+
111
+ def initialize()
112
+
113
+ @dx = Types::Dimension.new(:dy, 0.2, :x)
114
+
115
+ @columns = 2
116
+ end
74
117
  end
75
118
  end
76
119
  end
@@ -19,7 +19,7 @@ require 'ctioga2/graphics/coordinates'
19
19
  # This module contains all the classes used by ctioga
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
22
+ Version::register_svn_info('$Revision: 432 $', '$Date: 2013-08-23 19:06:36 +0200 (Fri, 23 Aug 2013) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -471,7 +471,7 @@ EOH
471
471
  X2Command =
472
472
  Cmd.new('x2', nil, '--x2', []) do |plotmaker|
473
473
  plotmaker.interpreter.
474
- run_commands("xaxis(top)\naxis-style(top,decoration=full)")
474
+ run_commands("xaxis top\naxis-style top /decoration=full")
475
475
  end
476
476
 
477
477
  X2Command.describe("Switches to top axis for subsequent curves",
@@ -479,14 +479,14 @@ EOH
479
479
  Switches to using the top axis for X axis for the subsequent curves,
480
480
  and turns on full decoration for the right axis. Shortcut for:
481
481
 
482
- # xaxis(top)
483
- # axis-style(top,decoration=full)
482
+ # xaxis top
483
+ # axis-style top /decoration=full
484
484
  EOH
485
485
 
486
486
  Y2Command =
487
487
  Cmd.new('y2', nil, '--y2', []) do |plotmaker|
488
488
  plotmaker.interpreter.
489
- run_commands("yaxis(right)\naxis-style(right,decoration=full)")
489
+ run_commands("yaxis right\naxis-style right /decoration=full")
490
490
  end
491
491
 
492
492
  Y2Command.describe("Switches to right axis for subsequent curves",
@@ -494,8 +494,8 @@ EOH
494
494
  Switches to using the right axis for Y axis for the subsequent curves,
495
495
  and turns on full decoration for the right axis. Shortcut for:
496
496
 
497
- # yaxis(right)
498
- # axis-style(right,decoration=full)
497
+ # yaxis right
498
+ # axis-style right /decoration=full
499
499
  EOH
500
500
 
501
501
  NewZAxisCommand =
@@ -529,14 +529,15 @@ EOH
529
529
  LabelStyleCommand.describe("Sets the style of the given label",
530
530
  <<"EOH", AxisGroup)
531
531
  Sets the style of the given label (see the type {type: label} for more
532
- information).
532
+ information). See {command: define-text-style} for detailed information
533
+ about the meaning of the options.
533
534
 
534
535
  The option text permits to also set the text of the label (does not
535
536
  work for ticks).
536
537
 
537
538
  For tick labels, setting the color option also sets the color for the
538
539
  lines of the corresponding axis. If you don't want that, you can
539
- override the color using the /stroke_color option of
540
+ override the color using the @stroke-color@ option of
540
541
  {command: axis-style}. This will only work with Tioga version 1.11 or
541
542
  greater.
542
543
  EOH
@@ -243,12 +243,12 @@ the @/base-style@ option to the {command: draw-arrow} command.
243
243
  Meaning of the style parameters:
244
244
 
245
245
  * @color@, @style@ and @width@: same as in {command: define-line-style}
246
- * @head_marker@, @tail_marker@: a {type: marker} to be used for the head
246
+ * @head-marker@, @tail-marker@: a {type: marker} to be used for the head
247
247
  or for the tail
248
- * @head_scale@, @tail_scale@: scale of the head or tail markers
249
- * @head_angle@, @tail_angle@: rotate the head or the tail by that many
248
+ * @head-scale@, @tail-scale@: scale of the head or tail markers
249
+ * @head-angle@, @tail-angle@: rotate the head or the tail by that many
250
250
  degrees
251
- * @head_color@, @tail_color@: the {type: color} of the head or tail
251
+ * @head-color@, @tail-color@: the {type: color} of the head or tail
252
252
  EOD
253
253
 
254
254
  StyleSheetCommands['box'].long_description = <<EOD
@@ -259,8 +259,8 @@ the @/base-style@ option to the {command: draw-box} command.
259
259
  Meaning of the style parameters:
260
260
 
261
261
  * @color@, @style@ and @width@: same as in {command: define-line-style}
262
- * @fill_color@: fill color for the box
263
- * @fill_transparency@: the transparency for the fill, from 0 to 1
262
+ * @fill-color@: fill color for the box
263
+ * @fill-transparency@: the transparency for the fill, from 0 to 1
264
264
  EOD
265
265
 
266
266
  StyleSheetCommands['text'].long_description = <<EOD
@@ -304,12 +304,12 @@ Meaning of the style parameters:
304
304
 
305
305
  * @alignment@, @justification@, @angle@, @color@ and @scale@:
306
306
  as in {command: define-text-style}
307
- * @fill_color@ and @stroke_color@: markers are both stroked and filled,
307
+ * @fill-color@ and @stroke_color@: markers are both stroked and filled,
308
308
  you can control all colors in one go using @color@ or specifying each
309
- with @fill_color@ and @stroke_color@
309
+ with @fill-color@ and @stroke_color@
310
310
  * @font@: is a PDF font number (from 1 to 14), only used for marker
311
311
  strings
312
- * @horizontal_scale@, @vertical_scale@: scales the marker only
312
+ * @horizontal-scale@, @vertical-scale@: scales the marker only
313
313
  horizontally or vertically
314
314
  EOD
315
315
 
@@ -334,12 +334,12 @@ Sets the style for a whole axis. All axis styles descend from the
334
334
 
335
335
  Axis styles have lots of parameters:
336
336
 
337
- * @axis_label_@ and @tick_label_@ parameters are title style parameters
337
+ * @axis-label-@ and @tick-label-@ parameters are title style parameters
338
338
  whose meaning is given in {command: define-title-style}, that affect
339
339
  ticks and axis labels
340
340
  * @decoration@: a {type: axis-decoration} that specify which ticks and
341
341
  tick labels to draw
342
- * @background_lines_@ parameters define the style of background lines,
342
+ * @background-lines-@ parameters define the style of background lines,
343
343
  as in {command: define-line-style}
344
344
  EOD
345
345
 
@@ -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: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
20
+ Version::register_svn_info('$Revision: 433 $', '$Date: 2013-08-26 22:03:14 +0200 (Mon, 26 Aug 2013) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -36,11 +36,12 @@ module CTioga2
36
36
 
37
37
  # The 'shift' of the text. Only meaningful for axes and tick
38
38
  # labels, where the position of the text is specified using a
39
- # side rather than a precise position. In frame coordinates ?
40
- typed_attribute :shift, 'float'
39
+ # side rather than a precise position.
40
+ typed_attribute :shift, 'dimension'
41
41
 
42
- # The scale of the text
43
- typed_attribute :scale, 'float'
42
+ # The scale of the text. In text height by default, but you
43
+ # can specify a real size too
44
+ typed_attribute :scale, 'dimension'
44
45
 
45
46
  # The vertical alignment
46
47
  typed_attribute :alignment, 'alignment'
@@ -53,17 +54,45 @@ module CTioga2
53
54
  # (see FigureMaker#show_text).
54
55
  def draw_text(t, text, x_or_loc, y = nil, measure = nil)
55
56
  t.context do
56
- dict = prepare_show_text_dict(text, x_or_loc, y, measure)
57
+ dict = prepare_show_text_dict(t, text, x_or_loc, y, measure)
57
58
  t.show_text(dict)
58
59
  end
59
60
  end
60
61
 
62
+ def shift_dy(t)
63
+ if @shift
64
+ return @shift.to_dy(t)
65
+ end
66
+ return nil
67
+ end
68
+
69
+ def scale_dy(t)
70
+ if @scale
71
+ return @scale.to_dy(t)
72
+ end
73
+ return nil
74
+ end
75
+
76
+ def hash_for_tioga(t)
77
+ dict = self.to_hash
78
+ if dict.key? 'shift'
79
+ dim = dict['shift']
80
+ dict['shift'] = dim.to_dy(t)
81
+ end
82
+ if dict.key? 'scale'
83
+ dim = dict['scale']
84
+ dict['scale'] = dim.to_dy(t)
85
+ end
86
+ return dict
87
+ end
88
+
61
89
  protected
62
90
 
63
91
  # Prepares the dictionnary for use with show_text
64
- def prepare_show_text_dict(text, x_or_loc, y = nil, measure = nil)
65
- dict = self.to_hash
92
+ def prepare_show_text_dict(t, text, x_or_loc, y = nil, measure = nil)
93
+ dict = self.hash_for_tioga(t)
66
94
  dict['text'] = text
95
+
67
96
  if y
68
97
  dict['at'] = [x_or_loc, y]
69
98
  else
@@ -148,7 +177,7 @@ module CTioga2
148
177
  protected
149
178
 
150
179
  def prepare_label_dict(t, default = nil, measure = nil)
151
- dict = prepare_show_text_dict(@text, @loc, nil, measure)
180
+ dict = prepare_show_text_dict(t, @text, @loc, nil, measure)
152
181
  if default
153
182
  for attribute in %w(scale angle shift)
154
183
  if ! dict.key?(attribute)
@@ -25,7 +25,7 @@ require 'ctioga2/graphics/types/grid'
25
25
  # This module contains all the classes used by ctioga
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision: 344 $', '$Date: 2012-12-23 22:45:22 +0100 (Sun, 23 Dec 2012) $')
28
+ Version::register_svn_info('$Revision: 376 $', '$Date: 2013-01-23 22:52:47 +0100 (Wed, 23 Jan 2013) $')
29
29
 
30
30
  module Graphics
31
31
 
@@ -216,6 +216,25 @@ tick labels. Possible values:
216
216
  * @full@: major ticks and labels + minor ticks
217
217
  EOD
218
218
 
219
+ TicksSideRE = {
220
+ /i(nside)?/i => {'ticks_inside' => true,
221
+ 'ticks_outside' => false},
222
+ /o(utside)?/i => {'ticks_outside' => true,
223
+ 'ticks_inside' => false},
224
+ /b(oth)?/i => {'ticks_outside' => true,
225
+ 'ticks_inside' => true}
226
+ }
227
+
228
+ TicksSideType =
229
+ CmdType.new('ticks-side', {:type => :re_list,
230
+ :list => TicksSideRE}, <<EOD)
231
+ On what side of an axis line are the ticks positioned:
232
+ * @inside@: on the inside
233
+ * @outside@: on the outside
234
+ * @both@: on both the inside and the outside
235
+ EOD
236
+
237
+
219
238
  # Dimensions
220
239
 
221
240
  DimensionType =
@@ -16,7 +16,7 @@ require 'ctioga2/log'
16
16
 
17
17
  module CTioga2
18
18
 
19
- Version::register_svn_info('$Revision: 328 $', '$Date: 2012-11-28 15:11:49 +0100 (Wed, 28 Nov 2012) $')
19
+ Version::register_svn_info('$Revision: 433 $', '$Date: 2013-08-26 22:03:14 +0200 (Mon, 26 Aug 2013) $')
20
20
 
21
21
  module Graphics
22
22
 
@@ -77,6 +77,12 @@ module CTioga2
77
77
  end
78
78
  end
79
79
 
80
+ # Return the value of the dimension in units of text height
81
+ def to_dy(t)
82
+ fig = to_figure(t, :y)
83
+ return fig/t.default_text_height_dy
84
+ end
85
+
80
86
  # Converts the Dimension to the *frame* coordinates of the
81
87
  # *current* frame in _t_.
82
88
  def to_frame(t, orientation = nil)
@@ -20,7 +20,7 @@ require 'ctioga2/utils'
20
20
 
21
21
  module CTioga2
22
22
 
23
- Version::register_svn_info('$Revision: 222 $', '$Date: 2011-01-11 00:52:31 +0100 (Tue, 11 Jan 2011) $')
23
+ Version::register_svn_info('$Revision: 401 $', '$Date: 2013-08-19 17:29:59 +0200 (Mon, 19 Aug 2013) $')
24
24
 
25
25
 
26
26
  module MetaBuilder
@@ -97,7 +97,7 @@ module CTioga2
97
97
  if @hash.has_key?(str.to_sym)
98
98
  return str.to_sym
99
99
  else
100
- raise IncorrectInput, "Invalid input: #{str} should be one of " +
100
+ raise IncorrectInput, "Invalid input: '#{str}' should be one of " +
101
101
  @hash.keys.map {|s| s.to_s}.join(',')
102
102
  end
103
103
  end
@@ -130,7 +130,7 @@ module CTioga2
130
130
  return v
131
131
  end
132
132
  end
133
- raise IncorrectInput, "Invalid input: #{str} should match " +
133
+ raise IncorrectInput, "Invalid input: '#{str}' should match " +
134
134
  @re_hash.keys.map {|s| s.to_s}.join(',')
135
135
  end
136
136
 
@@ -200,7 +200,7 @@ module CTioga2
200
200
  fact = if nb > 1
201
201
  1.0/(nb - 1) # The famous off-by one...
202
202
  else
203
- warn { "Incorrect gradient number: #{nb}" }
203
+ warn { "Incorrect gradient number: '#{nb}'" }
204
204
  1.0
205
205
  end
206
206
  array = []
@@ -20,7 +20,7 @@ require 'ctioga2/utils'
20
20
 
21
21
  module CTioga2
22
22
 
23
- Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
23
+ Version::register_svn_info('$Revision: 401 $', '$Date: 2013-08-19 17:29:59 +0200 (Mon, 19 Aug 2013) $')
24
24
 
25
25
  module MetaBuilder
26
26
 
@@ -58,7 +58,7 @@ module CTioga2
58
58
  type_name :float_range, 'range'
59
59
 
60
60
  def string_to_type_internal(str)
61
- raise IncorrectInput, "#{str} is not a valid range" unless
61
+ raise IncorrectInput, "'#{str}' is not a valid range" unless
62
62
  str =~ RANGE_RE
63
63
  s,e = Float($1), Float($2)
64
64
  return Range.new(s,e)
@@ -79,7 +79,7 @@ module CTioga2
79
79
  type_name :partial_float_range, 'range'
80
80
 
81
81
  def string_to_type_internal(str)
82
- raise IncorrectInput, "#{str} is not a valid range" unless
82
+ raise IncorrectInput, "'#{str}' is not a valid range" unless
83
83
  str =~ RANGE_RE
84
84
  s,e = ($1 ? Float($1) : nil), ($2 ? Float($2) : nil)
85
85
  return [s, e]
@@ -20,7 +20,7 @@ require 'ctioga2/utils'
20
20
 
21
21
  module CTioga2
22
22
 
23
- Version::register_svn_info('$Revision: 351 $', '$Date: 2012-12-25 22:48:10 +0100 (Tue, 25 Dec 2012) $')
23
+ Version::register_svn_info('$Revision: 401 $', '$Date: 2013-08-19 17:29:59 +0200 (Mon, 19 Aug 2013) $')
24
24
 
25
25
  module MetaBuilder
26
26
  module Types
@@ -159,7 +159,7 @@ module CTioga2
159
159
  return v
160
160
  end
161
161
  end
162
- raise IncorrectInput, "Not an axis type: #{str}"
162
+ raise IncorrectInput, "Not an axis type: '#{str}'"
163
163
  end
164
164
  end
165
165
 
@@ -155,7 +155,7 @@ require 'ctioga2/postprocess'
155
155
  # displays of rate constants vs potentials)
156
156
  module CTioga2
157
157
 
158
- Version::register_svn_info('$Revision: 314 $', '$Date: 2012-08-10 11:59:35 +0200 (Fri, 10 Aug 2012) $')
158
+ Version::register_svn_info('$Revision: 431 $', '$Date: 2013-08-23 17:58:47 +0200 (Fri, 23 Aug 2013) $')
159
159
 
160
160
  # This class is the core of ctioga. It parses the command-line arguments,
161
161
  # reads all necessary files and plots graphs. Most of its functionality
@@ -354,6 +354,17 @@ module CTioga2
354
354
  end
355
355
  t.make_preview_pdf(t.figure_index(figname))
356
356
 
357
+ # We look for latex errors
358
+ if t.respond_to? :pdflatex_errors
359
+ errs = t.pdflatex_errors
360
+ if errs.size > 0
361
+ error { "pdflatex returned with #{errs.size} error lines"}
362
+ for l in errs
363
+ warn { "pdflatex error: #{l.chomp}" }
364
+ end
365
+ end
366
+ end
367
+
357
368
  file = t.save_dir ? File::join(t.save_dir, figname + ".pdf") :
358
369
  figname + ".pdf"
359
370