ctioga2 0.3 → 0.4

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 (99) hide show
  1. data/Changelog +18 -0
  2. data/lib/ctioga2/commands/arguments.rb +17 -2
  3. data/lib/ctioga2/commands/commands.rb +13 -5
  4. data/lib/ctioga2/commands/context.rb +53 -0
  5. data/lib/ctioga2/commands/doc/doc.rb +1 -1
  6. data/lib/ctioga2/commands/doc/documentation-commands.rb +1 -1
  7. data/lib/ctioga2/commands/doc/help.rb +1 -1
  8. data/lib/ctioga2/commands/doc/html.rb +1 -1
  9. data/lib/ctioga2/commands/doc/introspection.rb +16 -1
  10. data/lib/ctioga2/commands/doc/man.rb +1 -1
  11. data/lib/ctioga2/commands/doc/markup.rb +1 -1
  12. data/lib/ctioga2/commands/doc/wordwrap.rb +1 -1
  13. data/lib/ctioga2/commands/general-commands.rb +1 -1
  14. data/lib/ctioga2/commands/general-types.rb +1 -1
  15. data/lib/ctioga2/commands/groups.rb +1 -1
  16. data/lib/ctioga2/commands/interpreter.rb +22 -1
  17. data/lib/ctioga2/commands/parsers/command-line.rb +8 -1
  18. data/lib/ctioga2/commands/parsers/file.rb +2 -1
  19. data/lib/ctioga2/commands/strings.rb +1 -1
  20. data/lib/ctioga2/commands/type.rb +1 -1
  21. data/lib/ctioga2/commands/variables.rb +1 -1
  22. data/lib/ctioga2/data/backends/backend.rb +1 -1
  23. data/lib/ctioga2/data/backends/backends/gnuplot.rb +1 -1
  24. data/lib/ctioga2/data/backends/backends/math.rb +1 -1
  25. data/lib/ctioga2/data/backends/backends/text.rb +12 -2
  26. data/lib/ctioga2/data/backends/description.rb +1 -1
  27. data/lib/ctioga2/data/backends/factory.rb +1 -1
  28. data/lib/ctioga2/data/backends/parameter.rb +1 -1
  29. data/lib/ctioga2/data/datacolumn.rb +1 -1
  30. data/lib/ctioga2/data/dataset.rb +1 -1
  31. data/lib/ctioga2/data/filters.rb +1 -1
  32. data/lib/ctioga2/data/indexed-dtable.rb +1 -1
  33. data/lib/ctioga2/data/point.rb +1 -1
  34. data/lib/ctioga2/data/stack.rb +6 -6
  35. data/lib/ctioga2/graphics/coordinates.rb +1 -1
  36. data/lib/ctioga2/graphics/elements.rb +1 -1
  37. data/lib/ctioga2/graphics/elements/containers.rb +1 -1
  38. data/lib/ctioga2/graphics/elements/contour.rb +1 -1
  39. data/lib/ctioga2/graphics/elements/curve2d.rb +1 -1
  40. data/lib/ctioga2/graphics/elements/element.rb +1 -1
  41. data/lib/ctioga2/graphics/elements/gradient-region.rb +1 -1
  42. data/lib/ctioga2/graphics/elements/parametric2d.rb +1 -1
  43. data/lib/ctioga2/graphics/elements/primitive.rb +115 -69
  44. data/lib/ctioga2/graphics/elements/region.rb +1 -1
  45. data/lib/ctioga2/graphics/elements/subplot.rb +9 -3
  46. data/lib/ctioga2/graphics/elements/tangent.rb +1 -1
  47. data/lib/ctioga2/graphics/elements/xyz-map.rb +1 -1
  48. data/lib/ctioga2/graphics/generator.rb +1 -1
  49. data/lib/ctioga2/graphics/legends.rb +5 -7
  50. data/lib/ctioga2/graphics/legends/area.rb +8 -8
  51. data/lib/ctioga2/graphics/legends/items.rb +2 -2
  52. data/lib/ctioga2/graphics/legends/provider.rb +1 -1
  53. data/lib/ctioga2/graphics/legends/storage.rb +1 -1
  54. data/lib/ctioga2/graphics/root.rb +1 -1
  55. data/lib/ctioga2/graphics/styles.rb +5 -0
  56. data/lib/ctioga2/graphics/styles/arrows.rb +53 -0
  57. data/lib/ctioga2/graphics/styles/axes.rb +29 -23
  58. data/lib/ctioga2/graphics/styles/background.rb +12 -10
  59. data/lib/ctioga2/graphics/styles/base.rb +99 -5
  60. data/lib/ctioga2/graphics/styles/box.rb +67 -0
  61. data/lib/ctioga2/graphics/styles/carrays.rb +1 -1
  62. data/lib/ctioga2/graphics/styles/colormap.rb +1 -1
  63. data/lib/ctioga2/graphics/styles/curve.rb +7 -1
  64. data/lib/ctioga2/graphics/styles/drawable.rb +24 -11
  65. data/lib/ctioga2/graphics/styles/errorbar.rb +1 -1
  66. data/lib/ctioga2/graphics/styles/factory.rb +1 -1
  67. data/lib/ctioga2/graphics/styles/gradients.rb +3 -3
  68. data/lib/ctioga2/graphics/styles/legend.rb +20 -5
  69. data/lib/ctioga2/graphics/styles/location.rb +3 -3
  70. data/lib/ctioga2/graphics/styles/map-axes.rb +6 -7
  71. data/lib/ctioga2/graphics/styles/plot.rb +51 -26
  72. data/lib/ctioga2/graphics/styles/sets.rb +1 -1
  73. data/lib/ctioga2/graphics/styles/sheet.rb +348 -0
  74. data/lib/ctioga2/graphics/styles/texts.rb +45 -64
  75. data/lib/ctioga2/graphics/subplot-commands.rb +1 -1
  76. data/lib/ctioga2/graphics/types.rb +1 -3
  77. data/lib/ctioga2/graphics/types/bijection.rb +1 -1
  78. data/lib/ctioga2/graphics/types/boundaries.rb +1 -1
  79. data/lib/ctioga2/graphics/types/boxes.rb +1 -1
  80. data/lib/ctioga2/graphics/types/dimensions.rb +2 -2
  81. data/lib/ctioga2/graphics/types/grid.rb +1 -1
  82. data/lib/ctioga2/graphics/types/location.rb +2 -2
  83. data/lib/ctioga2/graphics/types/point.rb +1 -1
  84. data/lib/ctioga2/log.rb +10 -6
  85. data/lib/ctioga2/metabuilder/type.rb +1 -1
  86. data/lib/ctioga2/metabuilder/types/coordinates.rb +1 -1
  87. data/lib/ctioga2/metabuilder/types/data.rb +1 -1
  88. data/lib/ctioga2/metabuilder/types/dates.rb +1 -1
  89. data/lib/ctioga2/metabuilder/types/lists.rb +1 -1
  90. data/lib/ctioga2/metabuilder/types/numbers.rb +1 -1
  91. data/lib/ctioga2/metabuilder/types/strings.rb +1 -1
  92. data/lib/ctioga2/metabuilder/types/styles.rb +30 -3
  93. data/lib/ctioga2/plotmaker.rb +1 -1
  94. data/lib/ctioga2/postprocess.rb +1 -1
  95. data/lib/ctioga2/utils.rb +78 -3
  96. metadata +6 -5
  97. data/lib/ctioga2/git-fools-svn.rb +0 -7
  98. data/lib/ctioga2/graphics/elements/redirecting-container.rb~ +0 -123
  99. data/lib/ctioga2/metabuilder/types/generic.rb~ +0 -225
@@ -25,7 +25,7 @@ require 'stringio'
25
25
 
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision$', '$Date$')
28
+ Version::register_svn_info('$Revision: 151 $', '$Date: 2010-06-19 23:45:20 +0200 (Sat, 19 Jun 2010) $')
29
29
 
30
30
 
31
31
  module Data
@@ -21,7 +21,7 @@ require 'Dobjects/Function'
21
21
 
22
22
  module CTioga2
23
23
 
24
- Version::register_svn_info('$Revision$', '$Date$')
24
+ Version::register_svn_info('$Revision: 155 $', '$Date: 2010-06-21 21:41:32 +0200 (Mon, 21 Jun 2010) $')
25
25
 
26
26
  module Data
27
27
 
@@ -25,7 +25,7 @@ require 'stringio'
25
25
 
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision$', '$Date$')
28
+ Version::register_svn_info('$Revision: 372 $', '$Date: 2012-12-28 18:13:15 +0100 (Fri, 28 Dec 2012) $')
29
29
 
30
30
 
31
31
  module Data
@@ -56,7 +56,17 @@ module CTioga2
56
56
 
57
57
  describe 'text', 'Text format', <<EOD
58
58
  This backend reads text files in a format close to the one understood
59
- by gnuplot and the like.
59
+ by gnuplot and the like. More specifically, it reads text files organized
60
+ in columns.
61
+
62
+ The column separator is specified by the @separator@ option or using
63
+ the {command: text-separator} command; it is a {type: regexp}
64
+
65
+ By default, the {command: text} backend only loads the column 1 as X
66
+ and 2 as Y, but that can be changed either by specifiying a default
67
+ column spec using either the @default_column_spec@ option or by adding
68
+ a specification directly after the file name.
69
+
60
70
  EOD
61
71
 
62
72
  # Inherit the baseline handling, can be useful !
@@ -22,7 +22,7 @@ require 'ctioga2/commands/groups'
22
22
 
23
23
  module CTioga2
24
24
 
25
- Version::register_svn_info('$Revision$', '$Date$')
25
+ Version::register_svn_info('$Revision: 307 $', '$Date: 2012-01-05 14:50:43 +0100 (Thu, 05 Jan 2012) $')
26
26
 
27
27
 
28
28
  module Data
@@ -20,7 +20,7 @@ require 'ctioga2/data/backends/backend'
20
20
 
21
21
  module CTioga2
22
22
 
23
- Version::register_svn_info('$Revision$', '$Date$')
23
+ Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
24
24
 
25
25
  module Data
26
26
 
@@ -21,7 +21,7 @@ require 'ctioga2/metabuilder/type'
21
21
 
22
22
  module CTioga2
23
23
 
24
- Version::register_svn_info('$Revision$', '$Date$')
24
+ Version::register_svn_info('$Revision: 17 $', '$Date: 2009-04-28 22:22:22 +0200 (Tue, 28 Apr 2009) $')
25
25
 
26
26
  module Data
27
27
 
@@ -17,7 +17,7 @@ require 'ctioga2/utils'
17
17
  # This module contains all the classes used by ctioga
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 229 $', '$Date: 2011-01-17 17:34:57 +0100 (Mon, 17 Jan 2011) $')
21
21
 
22
22
  module Data
23
23
 
@@ -18,7 +18,7 @@ require 'ctioga2/data/indexed-dtable'
18
18
 
19
19
  module CTioga2
20
20
 
21
- Version::register_svn_info('$Revision$', '$Date$')
21
+ Version::register_svn_info('$Revision: 304 $', '$Date: 2012-01-03 15:06:33 +0100 (Tue, 03 Jan 2012) $')
22
22
 
23
23
 
24
24
  # \todo now, port the backend infrastructure...
@@ -19,7 +19,7 @@ require 'ctioga2/data/backends/factory'
19
19
  # This module contains all the classes used by ctioga
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision$', '$Date$')
22
+ Version::register_svn_info('$Revision: 194 $', '$Date: 2010-11-22 10:26:54 +0100 (Mon, 22 Nov 2010) $')
23
23
 
24
24
 
25
25
  module Data
@@ -15,7 +15,7 @@ require 'ctioga2/utils'
15
15
 
16
16
  module CTioga2
17
17
 
18
- Version::register_svn_info('$Revision$', '$Date$')
18
+ Version::register_svn_info('$Revision: 181 $', '$Date: 2010-10-27 15:18:35 +0200 (Wed, 27 Oct 2010) $')
19
19
 
20
20
 
21
21
  module Data
@@ -17,7 +17,7 @@ require 'ctioga2/data/dataset'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 112 $', '$Date: 2009-11-09 22:34:12 +0100 (Mon, 09 Nov 2009) $')
21
21
 
22
22
 
23
23
  module Data
@@ -25,7 +25,7 @@ require 'ctioga2/data/filters'
25
25
  # This module contains all the classes used by ctioga
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision$', '$Date$')
28
+ Version::register_svn_info('$Revision: 367 $', '$Date: 2012-12-28 16:14:52 +0100 (Fri, 28 Dec 2012) $')
29
29
 
30
30
 
31
31
  module Data
@@ -173,10 +173,10 @@ module CTioga2
173
173
  datasets = [ specified_dataset(opts) ]
174
174
  else
175
175
  nb = opts['number'] || 2
176
- if stack.stack.size < nb
176
+ if @stack.size < nb
177
177
  raise "Not enough datasets on the stack"
178
178
  end
179
- datasets = stack.stack[(- nb).. -2]
179
+ datasets = @stack[(- nb).. -2]
180
180
  datasets.reverse!
181
181
  end
182
182
  end
@@ -355,7 +355,7 @@ stack. The name option can be used to give a name to the new dataset.
355
355
  EOH
356
356
 
357
357
  ApplyLastCommand =
358
- Cmd.new("apply-formula", '', "--apply-formula",
358
+ Cmd.new("apply-formula", nil, "--apply-formula",
359
359
  [CmdArg.new('text')],
360
360
  {
361
361
  'which' => CmdArg.new('stored-dataset'),
@@ -383,8 +383,8 @@ EOH
383
383
  <<EOH, DataStackGroup)
384
384
  Displays the current contents of the dataset stack.
385
385
 
386
- Mostly used for debugging when operations like {cmd: merge-datasets}
387
- or {cmd: join-datasets} don't work as expected.
386
+ Mostly used for debugging when operations like {command: merge-datasets}
387
+ or {command: join-datasets} don't work as expected.
388
388
  EOH
389
389
 
390
390
 
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 177 $', '$Date: 2010-10-25 13:22:39 +0200 (Mon, 25 Oct 2010) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -29,7 +29,7 @@ require 'ctioga2/graphics/elements/contour'
29
29
 
30
30
  module CTioga2
31
31
 
32
- Version::register_svn_info('$Revision$', '$Date$')
32
+ Version::register_svn_info('$Revision: 288 $', '$Date: 2011-02-22 21:12:58 +0100 (Tue, 22 Feb 2011) $')
33
33
 
34
34
  module Graphics
35
35
 
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 155 $', '$Date: 2010-06-21 21:41:32 +0200 (Mon, 21 Jun 2010) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -17,7 +17,7 @@ require 'ctioga2/graphics/elements/primitive'
17
17
  # This module contains all the classes used by ctioga
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 299 $', '$Date: 2011-03-15 11:22:20 +0100 (Tue, 15 Mar 2011) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -19,7 +19,7 @@ require 'Dobjects/Function'
19
19
 
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision$', '$Date$')
22
+ Version::register_svn_info('$Revision: 184 $', '$Date: 2010-11-07 00:44:40 +0100 (Sun, 07 Nov 2010) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -18,7 +18,7 @@ require 'ctioga2/log'
18
18
  # This module contains all the classes used by ctioga
19
19
  module CTioga2
20
20
 
21
- Version::register_svn_info('$Revision$', '$Date$')
21
+ Version::register_svn_info('$Revision: 151 $', '$Date: 2010-06-19 23:45:20 +0200 (Sat, 19 Jun 2010) $')
22
22
 
23
23
  # This module contains all graphical elements of CTioga2
24
24
  module Graphics
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 288 $', '$Date: 2011-02-22 21:12:58 +0100 (Tue, 22 Feb 2011) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -19,7 +19,7 @@ require 'Dobjects/Function'
19
19
 
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision$', '$Date$')
22
+ Version::register_svn_info('$Revision: 300 $', '$Date: 2011-06-07 21:17:49 +0200 (Tue, 07 Jun 2011) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -16,18 +16,24 @@ require 'ctioga2/utils'
16
16
  require 'ctioga2/log'
17
17
 
18
18
  require 'ctioga2/graphics/types'
19
+ require 'ctioga2/graphics/styles'
19
20
  require 'shellwords'
20
21
 
21
22
  # This module contains all the classes used by ctioga
22
23
  module CTioga2
23
24
 
24
- Version::register_svn_info('$Revision$', '$Date$')
25
+ Version::register_svn_info('$Revision: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
25
26
 
26
27
  module Graphics
27
28
 
28
29
  module Elements
29
30
 
30
31
  # A TiogaElement that represents a graphics primitive.
32
+ #
33
+ # @todo Most of the objects here should rely on getting a
34
+ # BasicStyle object from the options hash and use it to
35
+ # draw. There is no need to make cumbersome and hard to extend
36
+ # hashes.
31
37
  class TiogaPrimitiveCall < TiogaElement
32
38
 
33
39
  # Some kind of reimplementation of Command for graphics
@@ -87,7 +93,8 @@ module CTioga2
87
93
 
88
94
  # Creates a new primitive with the given parameters, and makes
89
95
  # it immediately available as a command.
90
- def self.primitive(name, long_name, comp, opts = {}, &code)
96
+ def self.primitive(name, long_name, comp, opts = {},
97
+ desc = nil, &code)
91
98
  primitive = TiogaPrimitive.new(name, comp, opts, &code)
92
99
  @known_primitives[name] = primitive
93
100
 
@@ -98,7 +105,11 @@ module CTioga2
98
105
 
99
106
  cmd_opts = {}
100
107
  for k,v in opts
101
- cmd_opts[k] = CmdArg.new(v)
108
+ cmd_opts[k] = if v.respond_to?(:type)
109
+ v
110
+ else
111
+ CmdArg.new(v)
112
+ end
102
113
  end
103
114
 
104
115
  cmd = Cmd.new("draw-#{name}",nil,"--draw-#{name}",
@@ -111,12 +122,53 @@ module CTioga2
111
122
  plotmaker.root_object.current_plot.
112
123
  add_element(call)
113
124
  end
125
+ if ! desc
126
+ desc = "Directly draws #{long_name} on the current plot"
127
+ end
114
128
  cmd.describe("Draws #{long_name}",
115
- "Directly draws #{long_name} on the current plot", PrimitiveGroup)
129
+ desc,
130
+ PrimitiveGroup)
116
131
 
117
132
  PrimitiveCommands[name] = cmd
118
133
  end
119
134
 
135
+ # This creates a primitive base on a style object, given a
136
+ # _style_class_, the base _style_name_ for the underlying
137
+ # styling system, options to remove and options to add.
138
+ #
139
+ # The underlying code receives:
140
+ # * the FigureMaker object
141
+ # * the compulsory arguments
142
+ # * the style
143
+ # * the raw options
144
+ def self.styled_primitive(name, long_name, comp, style_class,
145
+ style_name, without = [],
146
+ additional_options = {},
147
+ set_style_command = nil, # This
148
+ # could be
149
+ # removed
150
+ &code)
151
+ options = style_class.options_hash.without(without)
152
+ options.merge!(additional_options)
153
+ options['base-style'] = 'text' # the base style name
154
+
155
+ set_style_command ||= style_name
156
+ desc = <<"EOD"
157
+ Draws #{long_name} on the current plot, using the given style.
158
+ For more information on the available options, see the
159
+ {command: define-#{set_style_command}-style} command.
160
+ EOD
161
+
162
+ self.primitive(name, long_name, comp, options, desc) do |*all|
163
+ opts = all.pop
164
+ st_name = opts['base-style'] || "base"
165
+ style = Styles::StyleSheet.style_for(style_class,st_name)
166
+ style.set_from_hash(opts)
167
+ all << style << opts
168
+ code.call(*all)
169
+ end
170
+ end
171
+
120
172
 
121
173
  # Returns a pair primitive/primitive command for the named
122
174
  # primitive, or [ _nil_, _nil_ ]
@@ -126,59 +178,42 @@ module CTioga2
126
178
 
127
179
  # Now, a list of primitives, along with their code.
128
180
 
129
- primitive("text", "text", [ 'point', 'text' ],
130
- {
131
- 'color' => 'color',
132
- 'scale' => 'float',
133
- 'angle' => 'float',
134
- 'justification' => 'justification',
135
- 'alignment' => 'alignment',
136
- 'font' => 'latex-font',
137
- }
138
- ) do |t, point, string, options|
181
+ styled_primitive("text", "text",
182
+ [ 'point', 'text' ],
183
+ Styles::FullTextStyle,
184
+ 'text',
185
+ ['text'],
186
+ {'font' => 'latex-font'}
187
+ ) do |t, point, string, style, options|
139
188
  # @todo add a way to specify fonts ???
140
189
  options ||= {}
141
190
  if options['font']
142
191
  string = options['font'].fontify(string)
143
- options.delete('font')
144
192
  end
145
- options['text'] = string
146
- options['at'] = point.to_figure_xy(t)
147
- t.show_text(options)
193
+ style.draw_text(t, string, *(point.to_figure_xy(t)))
148
194
  end
149
195
 
150
- # @todo add rendering mode !!
151
- MarkerOptions = {
152
- 'color' => 'color',
153
- 'stroke_color' => 'color',
154
- 'fill_color' => 'color',
155
- 'scale' => 'float',
156
- 'horizontal_scale' => 'float',
157
- 'vertical_scale' => 'float',
158
- 'angle' => 'float',
159
- 'justification' => 'justification',
160
- 'alignment' => 'alignment',
161
- }
162
-
163
- primitive("marker", "marker", [ 'point', 'marker' ],
164
- MarkerOptions) do |t, point, marker, options|
165
- ## \todo add a way to specify fonts ???
166
- options ||= {}
167
- options['marker'] = marker
168
- options['at'] = point.to_figure_xy(t)
169
- t.show_marker(options)
196
+ styled_primitive("marker", "marker",
197
+ [ 'point', 'marker' ],
198
+ Styles::MarkerStringStyle,
199
+ 'marker',
200
+ ['font'] # font doesn't make any sense with a
201
+ # marker spec
202
+ ) do |t, point, marker, style, options|
203
+ style.draw_marker(t, marker, *point.to_figure_xy(t))
170
204
  end
171
205
 
172
- primitive("string-marker", "marker", [ 'point', 'text' ],
173
- {'font' => 'pdf-font' }.update(MarkerOptions)
174
- ) do |t, point, string, options|
175
- ## \todo add a way to specify fonts ???
176
- options ||= {}
177
- options['text'] = string
178
- options['at'] = point.to_figure_xy(t)
179
- t.show_marker(options)
206
+ styled_primitive("string-marker", "marker",
207
+ [ 'point', 'text' ],
208
+ Styles::MarkerStringStyle,
209
+ 'marker-string', [],
210
+ {},
211
+ 'marker'
212
+ ) do |t, point, string, style, options|
213
+ style.draw_string_marker(t, string, *point.to_figure_xy(t))
180
214
  end
181
215
 
216
+
182
217
  # options for arrows (and therefore tangents)
183
218
  ArrowOptions = {
184
219
  'color' => 'color',
@@ -192,32 +227,43 @@ module CTioga2
192
227
  'line_style' => 'line-style',
193
228
  }
194
229
 
195
- primitive("arrow", "arrow", [ 'point', 'point' ],
196
- ArrowOptions) do |t, tail,head, options|
197
- ## \todo a scale or marker_scale option that sets the scale
198
- ## of both head and tail
199
- options ||= {}
200
- options['head'] = head.to_figure_xy(t)
201
- options['tail'] = tail.to_figure_xy(t)
202
- t.show_arrow(options)
230
+ styled_primitive("arrow", "arrow",
231
+ [ 'point', 'point' ],
232
+ Styles::ArrowStyle,
233
+ 'arrow') do |t, tail, head, style, options|
234
+ style.draw_arrow(t, *tail.to_figure_xy(t),
235
+ *head.to_figure_xy(t))
203
236
  end
204
-
205
- primitive("line", "line", [ 'point', 'point' ],
206
- {
207
- 'color' => 'color',
208
- 'line_width' => 'float',
209
- 'line_style' => 'line-style',
210
- }
211
- ) do |t, tail,head, options|
212
- options ||= {}
213
- for a in ['head', 'tail']
214
- options["#{a}_marker"] = "None"
215
- end
216
- options['head'] = head.to_figure_xy(t)
217
- options['tail'] = tail.to_figure_xy(t)
218
- t.show_arrow(options)
237
+
238
+ styled_primitive("line", "line",
239
+ [ 'point', 'point' ],
240
+ Styles::StrokeStyle,
241
+ 'line'
242
+ ) do |t, tail, head, style, options|
243
+ style.draw_line(t, *(tail.to_figure_xy(t)),
244
+ *(head.to_figure_xy(t)))
219
245
  end
220
246
 
247
+ # Here, we need to add deprecated options for backward
248
+ # compatibility
249
+
250
+ for cmd in ['draw-line', 'draw-arrow']
251
+ Commands::make_alias_for_option cmd, 'width', 'line_width', true
252
+ Commands::make_alias_for_option cmd, 'style', 'line_style', true
253
+ end
254
+
255
+ styled_primitive("box", "box",
256
+ [ 'point', 'point' ],
257
+ Styles::BoxStyle,
258
+ 'box') do |t, tl, br, style, options|
259
+ x1,y1 = tl.to_figure_xy(t)
260
+ x2,y2 = br.to_figure_xy(t)
261
+ style.draw_box(t, x1, y1, x2, y2)
262
+ end
263
+
264
+
265
+ Commands::make_alias_for_option 'draw-box', 'fill_color', 'fill-color'
266
+ Commands::make_alias_for_option 'draw-box', 'fill_transparency', 'fill-transparency'
221
267
 
222
268
  protected
223
269