ctioga2 0.6.1 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,15 @@
1
+ ctioga2 (0.7)
2
+
3
+ * It is now possible to index marker size index on Z values for
4
+ parametric plots
5
+ * --csv shortcut to read CSV files
6
+ * Round boxes (for the draw-box command and for the legends too)
7
+ * Make -X smarter about which viewer to use
8
+ * Unclipped plot elements + full control of depth
9
+ * Small bug fixes
10
+
11
+ -- Vincent <vincent.fourmond@9online.fr> Thu 3 Oct 22:53:25 CEST 2013
12
+
1
13
  ctioga2 (0.6.1)
2
14
 
3
15
  * Fix crash when a curve has no points within the plot boundaries
@@ -17,7 +17,7 @@ require 'ctioga2/commands/groups'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision: 430 $', '$Date: 2013-08-23 14:23:52 +0200 (Fri, 23 Aug 2013) $')
20
+ Version::register_svn_info('$Revision: 518 $', '$Date: 2013-09-19 21:43:58 +0200 (Thu, 19 Sep 2013) $')
21
21
 
22
22
  module Commands
23
23
 
@@ -143,6 +143,7 @@ module CTioga2
143
143
  @short_description = short
144
144
  @long_description = long || short
145
145
  if(group)
146
+ group = Interpreter::group(group) if group.is_a? String
146
147
  @group = group
147
148
  group.commands << self
148
149
  end
@@ -18,7 +18,7 @@ require 'ctioga2/commands/doc/wordwrap'
18
18
 
19
19
  module CTioga2
20
20
 
21
- Version::register_svn_info('$Revision: 409 $', '$Date: 2013-08-22 21:23:51 +0200 (Thu, 22 Aug 2013) $')
21
+ Version::register_svn_info('$Revision: 532 $', '$Date: 2013-09-29 12:13:33 +0200 (Sun, 29 Sep 2013) $')
22
22
 
23
23
  module Commands
24
24
 
@@ -99,14 +99,24 @@ module CTioga2
99
99
  @color = false
100
100
  end
101
101
 
102
+ should_close = false
103
+ output = $stdout
104
+
102
105
  if @to_tty and @to_pager
103
106
  # We pass -R as default value...
104
107
  ENV['LESS'] = 'R'
105
- output = IO::popen("pager", "w")
106
- pager = true
107
- else
108
- output = $stdout
109
- pager = false
108
+ pager = 'pager'
109
+ for w in [ENV['PAGER'], 'less', 'pager' ]
110
+ if Utils::which(w)
111
+ pager = w
112
+ break
113
+ end
114
+ end
115
+ begin
116
+ output = IO::popen(pager, "w")
117
+ should_close = true
118
+ rescue
119
+ end
110
120
  end
111
121
 
112
122
  for group in groups
@@ -123,7 +133,7 @@ module CTioga2
123
133
  output.puts format_one_entry(cmd)
124
134
  end
125
135
  end
126
- output.close
136
+ output.close if should_close
127
137
  end
128
138
 
129
139
  protected
@@ -15,7 +15,7 @@ require 'ctioga2/utils'
15
15
 
16
16
  module CTioga2
17
17
 
18
- Version::register_svn_info('$Revision: 484 $', '$Date: 2013-09-02 22:44:42 +0200 (Mon, 02 Sep 2013) $')
18
+ Version::register_svn_info('$Revision: 517 $', '$Date: 2013-09-19 18:28:15 +0200 (Thu, 19 Sep 2013) $')
19
19
 
20
20
  module Commands
21
21
 
@@ -50,6 +50,13 @@ EOD
50
50
  A floating-point number.
51
51
  EOD
52
52
 
53
+ FloatOrFalseType = CmdType.new('float-or-false', {
54
+ :type => :float,
55
+ :shortcuts => {'none' => false }},
56
+ <<EOD)
57
+ A floating-point number, or @none@.
58
+ EOD
59
+
53
60
 
54
61
  FloatList = CmdType.new('float-list',
55
62
  {
@@ -21,7 +21,7 @@ require 'ctioga2/commands/doc/doc'
21
21
 
22
22
  module CTioga2
23
23
 
24
- Version::register_svn_info('$Revision: 508 $', '$Date: 2013-09-09 22:13:14 +0200 (Mon, 09 Sep 2013) $')
24
+ Version::register_svn_info('$Revision: 512 $', '$Date: 2013-09-11 13:20:24 +0200 (Wed, 11 Sep 2013) $')
25
25
 
26
26
  # This module contains the real core of ctioga2: a set of classes
27
27
  # that implement the concept of commands. Each command translates
@@ -208,7 +208,8 @@ module CTioga2
208
208
  # specified.
209
209
  def run_command_file(file)
210
210
  if ! @plotmaker_target.figure_name
211
- @plotmaker_target.figure_name = file.gsub(/\.[^.]+$/,'')
211
+ @plotmaker_target.figure_name = file.gsub(/\.[^.]+$/,'').
212
+ gsub(/%/, '%%')
212
213
  end
213
214
 
214
215
  dir = File::dirname(file)
@@ -25,7 +25,7 @@ require 'stringio'
25
25
 
26
26
  module CTioga2
27
27
 
28
- Version::register_svn_info('$Revision: 493 $', '$Date: 2013-09-03 22:11:38 +0200 (Tue, 03 Sep 2013) $')
28
+ Version::register_svn_info('$Revision: 524 $', '$Date: 2013-09-22 16:18:39 +0200 (Sun, 22 Sep 2013) $')
29
29
 
30
30
 
31
31
  module Data
@@ -150,7 +150,12 @@ EOD
150
150
  end
151
151
  return ret
152
152
  else
153
- return super
153
+ m = Dir::glob(spec)
154
+ if m.size > 0
155
+ return m
156
+ else
157
+ return super
158
+ end
154
159
  end
155
160
  end
156
161
 
@@ -380,7 +385,11 @@ EOD
380
385
  @current_data,
381
386
  @included_modules)
382
387
  else
383
- return @current_data[column.to_i].dup
388
+ if @current_data[column.to_i]
389
+ return @current_data[column.to_i].dup
390
+ else
391
+ raise "Cannot find column number #{column.to_i} -- maybe you got the column separator wrong ?"
392
+ end
384
393
  end
385
394
  end
386
395
 
@@ -425,6 +434,7 @@ EOD
425
434
  # end
426
435
 
427
436
  end
437
+
428
438
 
429
439
  end
430
440
 
@@ -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: 390 $', '$Date: 2013-03-13 11:36:47 +0100 (Wed, 13 Mar 2013) $')
28
+ Version::register_svn_info('$Revision: 518 $', '$Date: 2013-09-19 21:43:58 +0200 (Thu, 19 Sep 2013) $')
29
29
 
30
30
 
31
31
  module Data
@@ -72,6 +72,20 @@ module CTioga2
72
72
 
73
73
  # Defaults to the 'text' backend
74
74
  @backend_factory = Data::Backends::BackendFactory.new('text')
75
+
76
+ # Probably a bit out of place...
77
+ csv =
78
+ Cmd.new('csv', nil, '--csv', []) do |plotmaker|
79
+ plotmaker.interpreter.
80
+ run_commands("text /separator=/[,;]/")
81
+ end
82
+
83
+ csv.describe("reads CSV files",
84
+ <<"EOH", "backend-text")
85
+ Now parse the following data files as CSV.
86
+
87
+ # text /separator=/[,;]/
88
+ EOH
75
89
  end
76
90
 
77
91
  # Performs expansion on the given _set_ with the current
@@ -547,7 +561,8 @@ EOH
547
561
  Adds the given commands to the dataset hook. See {command: dataset-hook}
548
562
  for more information about the dataset hook.
549
563
  EOH
550
-
564
+
565
+
551
566
  end
552
567
 
553
568
  end
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
 
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision: 378 $', '$Date: 2013-03-04 22:42:54 +0100 (Mon, 04 Mar 2013) $')
20
+ Version::register_svn_info('$Revision: 529 $', '$Date: 2013-09-25 18:23:27 +0200 (Wed, 25 Sep 2013) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -53,6 +53,7 @@ module CTioga2
53
53
 
54
54
  # Creates an empty new Container with the given _parent_.
55
55
  def initialize(parent = nil, root = nil)
56
+ super()
56
57
  @parent = parent
57
58
 
58
59
  # elements to be given to tioga
@@ -19,7 +19,7 @@ require 'Dobjects/Function'
19
19
 
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision: 505 $', '$Date: 2013-09-05 22:18:57 +0200 (Thu, 05 Sep 2013) $')
22
+ Version::register_svn_info('$Revision: 535 $', '$Date: 2013-10-02 20:31:21 +0200 (Wed, 02 Oct 2013) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -33,7 +33,7 @@ module CTioga2
33
33
  #
34
34
  # * transparency
35
35
  # * drawing order
36
- class Curve2D < TiogaElement
36
+ class Curve2D < PlotBasedElement
37
37
 
38
38
  include Log
39
39
  include Dobjects
@@ -45,18 +45,11 @@ module CTioga2
45
45
  # Elements of the path, when there are more than one:
46
46
  attr_accessor :path_elements
47
47
 
48
- # The Data::Dataset object that should get plotted.
49
- attr_accessor :dataset
50
48
 
51
- # A Styles::CurveStyle object saying how the curve should be
52
- # drawn.
53
- attr_accessor :curve_style
54
-
55
- undef :location=, :location
56
-
57
49
  # Creates a new Curve2D object with the given _dataset_ and
58
50
  # _style_.
59
51
  def initialize(dataset, style = nil)
52
+ super()
60
53
  @dataset = dataset
61
54
  if @dataset.size > 2
62
55
  warn { "Columns Y2 and further were ignored for set #{dataset.name}" }
@@ -78,12 +71,6 @@ module CTioga2
78
71
 
79
72
  end
80
73
 
81
- # Returns the LocationStyle object of the curve. Returns the
82
- # one from #curve_style.
83
- def location
84
- return @curve_style.location
85
- end
86
-
87
74
  # Returns the Types::Boundaries of this curve.
88
75
  def get_boundaries
89
76
  return Types::Boundaries.bounds(@function.x, @function.y)
@@ -101,7 +88,11 @@ module CTioga2
101
88
  case @curve_style.path_style
102
89
  when /^splines/
103
90
  for f in func.split_monotonic
104
- new_f = f.bound_values(*bnds.extrema)
91
+ new_f = if @curve_style.clipped
92
+ f.bound_values(*bnds.extrema)
93
+ else
94
+ f.dup
95
+ end
105
96
  t.append_interpolant_to_path(new_f.make_interpolant)
106
97
  end
107
98
  when /^impulses/
@@ -114,8 +105,11 @@ module CTioga2
114
105
 
115
106
  # Hmmmm. This may get the wrong thing if you happen to
116
107
  # draw something completely outside.
117
- f = func.bound_values(*bnds.extrema)
118
-
108
+ if @curve_style.clipped
109
+ f = func.bound_values(*bnds.extrema)
110
+ else
111
+ f = func
112
+ end
119
113
  # If for some reason, there is no point left, we plot
120
114
  # the original function.
121
115
  if f.size < 2
@@ -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: 151 $', '$Date: 2010-06-19 23:45:20 +0200 (Sat, 19 Jun 2010) $')
21
+ Version::register_svn_info('$Revision: 535 $', '$Date: 2013-10-02 20:31:21 +0200 (Wed, 02 Oct 2013) $')
22
22
 
23
23
  # This module contains all graphical elements of CTioga2
24
24
  module Graphics
@@ -38,6 +38,22 @@ module CTioga2
38
38
  # LocationStyle object
39
39
  attr_writer :location
40
40
 
41
+ attr_accessor :clipped
42
+
43
+
44
+ # Depth
45
+ attr_writer :depth
46
+
47
+ def initialize()
48
+ @clipped = true
49
+
50
+ @depth = 50 # Hey, like xfig
51
+ end
52
+
53
+ def depth
54
+ @depth || 50
55
+ end
56
+
41
57
  # Makes sure there is a location when one asks for it.
42
58
  def location
43
59
  @location ||= Styles::LocationStyle.new
@@ -77,24 +93,43 @@ module CTioga2
77
93
  raise "Should be reimplemented by children"
78
94
  end
79
95
  end
80
-
81
96
 
82
- # # A unique method call to a FigureMaker object.
83
- # class TiogaFuncall < TiogaElement
84
97
 
85
- # # _symbol_ is the symbol to be called, and the remainder will
86
- # # be used as arguments for the call.
87
- # def initialize(symbol, *args)
88
- # @symbol = symbol
89
- # @args = args
90
- # end
98
+ # The base class for all dataset-based elements
99
+ class PlotBasedElement < TiogaElement
100
+
101
+ # The Data::Dataset object that should get plotted.
102
+ attr_accessor :dataset
103
+
104
+ # A Styles::CurveStyle object saying how the curve should be
105
+ # drawn.
106
+ attr_accessor :curve_style
107
+
108
+ undef :location=, :location
109
+
110
+ # Returns the LocationStyle object of the curve. Returns the
111
+ # one from #curve_style.
112
+ def location
113
+ return @curve_style.location
114
+ end
115
+
116
+ undef :clipped, :clipped=
117
+
118
+ def clipped
119
+ return @curve_style.clipped
120
+ end
121
+
122
+ undef :depth, :depth=
123
+
124
+ def depth
125
+ return @curve_style.depth
126
+ end
127
+
128
+ def initialize()
129
+ super()
130
+ end
131
+ end
91
132
 
92
- # protected
93
-
94
- # def real_do(f)
95
- # f.send(@symbol, *@args)
96
- # end
97
- # end
98
133
  end
99
134
  end
100
135
  end
@@ -19,7 +19,7 @@ require 'Dobjects/Function'
19
19
 
20
20
  module CTioga2
21
21
 
22
- Version::register_svn_info('$Revision: 300 $', '$Date: 2011-06-07 21:17:49 +0200 (Tue, 07 Jun 2011) $')
22
+ Version::register_svn_info('$Revision: 535 $', '$Date: 2013-10-02 20:31:21 +0200 (Wed, 02 Oct 2013) $')
23
23
 
24
24
  module Graphics
25
25
 
@@ -40,35 +40,28 @@ module CTioga2
40
40
  # factory, I think. Color maps can be used for colors, but for
41
41
  # the rest, things will have to be implemented as parameters to
42
42
  # the curve generator, or even separated commands.
43
- class Parametric2D < TiogaElement
43
+ class Parametric2D < PlotBasedElement
44
44
 
45
45
  include Log
46
46
  include Dobjects
47
47
 
48
- # The Data::Dataset object that should get plotted.
49
- attr_accessor :dataset
50
-
51
- # A Styles::CurveStyle object saying how the curve should be
52
- # drawn.
53
- #
54
- # Some of the elements will be overridden.
55
- attr_accessor :curve_style
56
-
57
48
  # For convenience only: xy functions
58
49
  attr_accessor :function
59
50
 
60
51
  # A hash Z value -> corresponding XY functions.
61
52
  attr_accessor :planes
62
53
 
54
+ # A ParametricPlotStyle object handling the correspondance
55
+ # between Z axis and stylistic aspects
56
+ attr_accessor :parametric_style
63
57
 
64
-
65
- undef :location=, :location
66
-
67
58
  # Creates a new Curve2D object with the given _dataset_ and
68
59
  # _style_.
69
- def initialize(dataset, style = nil)
60
+ def initialize(dataset, style = nil, parametric_plot_style = nil)
70
61
  @dataset = dataset
71
62
  @curve_style = style
63
+
64
+ @parametric_style = parametric_plot_style
72
65
  prepare_data
73
66
  end
74
67
 
@@ -84,22 +77,26 @@ module CTioga2
84
77
  @planes[zs[0]].x << x
85
78
  @planes[zs[0]].y << y
86
79
  end
80
+
81
+
82
+ @zmin = []
83
+ @zmax = []
84
+
85
+ ## @todo This should rather use Z axes in the end ?
86
+ (@dataset.ys.size - 1).times do |i|
87
+ @zmin << @dataset.ys[i+1].values.min
88
+ @zmax << @dataset.ys[i+1].values.max
89
+ end
87
90
  end
88
91
 
89
92
  protected :prepare_data
90
93
 
91
- # Returns the LocationStyle object of the curve. Returns the
92
- # one from #curve_style.
93
- def location
94
- return @curve_style.location
95
- end
96
-
97
94
  # Returns the Types::Boundaries of this curve.
98
95
  def get_boundaries
99
96
  return Types::Boundaries.bounds(@function.x, @function.y)
100
97
  end
101
98
 
102
- # Draws the markers, if applicable.
99
+ # Draws the path lines, if applicable.
103
100
  def draw_path(t)
104
101
  min = @dataset.z.values.min
105
102
  max = @dataset.z.values.max
@@ -125,19 +122,16 @@ module CTioga2
125
122
 
126
123
  # Draws the markers, if applicable.
127
124
  def draw_markers(t)
128
- min = @dataset.z.values.min
129
- max = @dataset.z.values.max
125
+ @parametric_style.prepare
130
126
  if @curve_style.has_marker?
131
127
  # We use a default color map for the markers
132
128
  @curve_style.marker_color_map ||=
133
129
  Styles::ColorMap.from_text("Red--Green")
134
- cmap = @curve_style.marker_color_map
135
- for zs in @planes.keys.sort ## \todo have the sort
136
- ## direction configurable.
137
- f = @planes[zs]
138
- color = cmap.z_color(zs, min, max)
139
- @curve_style.marker.draw_markers_at(t, f.x, f.y,
140
- { 'color' => color})
130
+
131
+ @dataset.each_values do |i,x,y,*z|
132
+ ms = @parametric_style.marker_style(@curve_style,
133
+ z, @zmin, @zmax)
134
+ ms.draw_markers_at(t, x, y)
141
135
  end
142
136
  end
143
137
  end