ctioga2 0.13.1 → 0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +26 -0
- data/bin/ct2-make-movie +4 -1
- data/bin/ctioga2 +1 -1
- data/lib/ctioga2/commands/commands.rb +2 -0
- data/lib/ctioga2/commands/doc/doc.rb +1 -1
- data/lib/ctioga2/commands/doc/documentation-commands.rb +38 -0
- data/lib/ctioga2/commands/doc/html.rb +84 -0
- data/lib/ctioga2/commands/general-commands.rb +20 -1
- data/lib/ctioga2/commands/general-functions.rb +26 -0
- data/lib/ctioga2/commands/general-types.rb +1 -0
- data/lib/ctioga2/commands/instruction.rb +61 -0
- data/lib/ctioga2/commands/interpreter.rb +12 -2
- data/lib/ctioga2/data/datacolumn.rb +38 -0
- data/lib/ctioga2/data/dataset.rb +6 -5
- data/lib/ctioga2/data/filters.rb +12 -5
- data/lib/ctioga2/data/stack.rb +105 -22
- data/lib/ctioga2/graphics/elements.rb +1 -1
- data/lib/ctioga2/graphics/elements/curve2d.rb +1 -1
- data/lib/ctioga2/graphics/elements/element.rb +29 -10
- data/lib/ctioga2/graphics/elements/primitive.rb +26 -2
- data/lib/ctioga2/graphics/elements/subplot.rb +7 -1
- data/lib/ctioga2/graphics/generator.rb +1 -2
- data/lib/ctioga2/graphics/legends/area.rb +3 -0
- data/lib/ctioga2/graphics/root.rb +18 -2
- data/lib/ctioga2/graphics/styles/curve.rb +6 -0
- data/lib/ctioga2/graphics/styles/drawable.rb +4 -0
- data/lib/ctioga2/graphics/styles/factory.rb +4 -5
- data/lib/ctioga2/graphics/styles/plot-types.rb +22 -7
- data/lib/ctioga2/graphics/subplot-commands.rb +2 -4
- data/lib/ctioga2/graphics/types.rb +17 -0
- data/lib/ctioga2/graphics/types/boundaries.rb +10 -0
- data/lib/ctioga2/graphics/types/boxes.rb +18 -0
- data/lib/ctioga2/graphics/types/dimensions.rb +4 -0
- data/lib/ctioga2/graphics/types/grid.rb +98 -4
- data/lib/ctioga2/graphics/types/point.rb +9 -0
- data/lib/ctioga2/metabuilder/types/lists.rb +1 -1
- data/lib/ctioga2/metabuilder/types/styles.rb +5 -3
- data/lib/ctioga2/plotmaker.rb +28 -5
- data/lib/ctioga2/postprocess.rb +28 -0
- data/lib/ctioga2/ruby.rb +7 -0
- data/lib/ctioga2/utils.rb +45 -0
- data/lib/ctioga2/version.rb +2 -2
- metadata +4 -3
@@ -75,7 +75,7 @@ module CTioga2
|
|
75
75
|
if (elems.size % 2) == 0
|
76
76
|
elems << "White" # Implicit mix with white
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
temp = parse_one_color(elems.shift).dup
|
80
80
|
|
81
81
|
while elems.size > 0
|
@@ -121,7 +121,7 @@ module CTioga2
|
|
121
121
|
|
122
122
|
# A marker Type for Tioga. Input as
|
123
123
|
#
|
124
|
-
# a,b(,c)?
|
124
|
+
# a,(,b(,c)?)?
|
125
125
|
#
|
126
126
|
class MarkerType < Type
|
127
127
|
|
@@ -133,8 +133,10 @@ module CTioga2
|
|
133
133
|
return [specs[0].to_i, specs[1].to_i]
|
134
134
|
elsif specs.size == 3
|
135
135
|
return [specs[0].to_i, specs[1].to_i, specs[2].to_f]
|
136
|
+
elsif specs.size == 1 # Defaults to symbols !
|
137
|
+
return [14, specs[0].to_i]
|
136
138
|
else
|
137
|
-
raise IncorrectInput, "You need
|
139
|
+
raise IncorrectInput, "You need between one and three values to make a marker"
|
138
140
|
end
|
139
141
|
end
|
140
142
|
end
|
data/lib/ctioga2/plotmaker.rb
CHANGED
@@ -99,6 +99,9 @@
|
|
99
99
|
# \todo make --xrange automatically select the range for the --math
|
100
100
|
# backend unless another range was explicitly specified.
|
101
101
|
|
102
|
+
# Maybe, maybe, maybe... We need tioga ?
|
103
|
+
require 'Tioga/FigureMaker'
|
104
|
+
|
102
105
|
require 'ctioga2/utils'
|
103
106
|
require 'ctioga2/log'
|
104
107
|
|
@@ -109,8 +112,9 @@ require 'shellwords'
|
|
109
112
|
# Path name mangling
|
110
113
|
require 'pathname'
|
111
114
|
|
112
|
-
#
|
113
|
-
require '
|
115
|
+
# And yaml...
|
116
|
+
require 'yaml'
|
117
|
+
|
114
118
|
|
115
119
|
# Interaction with Ruby code
|
116
120
|
require 'ctioga2/ruby'
|
@@ -279,6 +283,9 @@ module CTioga2
|
|
279
283
|
end
|
280
284
|
|
281
285
|
# ctioga's entry point.
|
286
|
+
#
|
287
|
+
# Returns true if there was no errors and false if there was one
|
288
|
+
# or more.
|
282
289
|
def run(command_line)
|
283
290
|
|
284
291
|
# The main catch-all around the plot:
|
@@ -311,6 +318,7 @@ module CTioga2
|
|
311
318
|
STDIN.gets
|
312
319
|
end
|
313
320
|
end
|
321
|
+
return errs == 0
|
314
322
|
end
|
315
323
|
|
316
324
|
# Flushes the current root object and starts a new one:
|
@@ -490,8 +498,9 @@ module CTioga2
|
|
490
498
|
# of ctioga2 used to produce the PDF, and the command-line if
|
491
499
|
# applicable.
|
492
500
|
t.tex_preamble +=
|
493
|
-
"\n\\pdfinfo {\n#{title}/Creator(#{Utils::pdftex_quote_string("ctioga2 #{Version::version}")})\n}\n"
|
501
|
+
"\n\\pdfinfo {\n#{title}/Creator(#{Utils::pdftex_quote_string("ctioga2 #{Version::version}")})\n}\n"
|
494
502
|
|
503
|
+
#" #emacs ruby-mode is a dummy
|
495
504
|
return t
|
496
505
|
end
|
497
506
|
|
@@ -530,6 +539,8 @@ EOH
|
|
530
539
|
PlotLastOptions =
|
531
540
|
Graphics::Styles::CurveStyleFactory::PlotCommandOptions.dup
|
532
541
|
|
542
|
+
PlotLastOptions.merge!(Graphics::Elements::TiogaElement::StyleBaseOptions)
|
543
|
+
|
533
544
|
PlotLastOptions['which'] = CmdArg.new('stored-dataset')
|
534
545
|
|
535
546
|
PlotLastCommand =
|
@@ -642,8 +653,7 @@ EOH
|
|
642
653
|
|
643
654
|
ResolutionCommand =
|
644
655
|
Cmd.new("resolution", false,"--resolution",
|
645
|
-
[ CmdArg.new('float') ],
|
646
|
-
) do |plotmaker, size, options|
|
656
|
+
[ CmdArg.new('float') ]) do |plotmaker, size, options|
|
647
657
|
plotmaker.pdf_resolution = size
|
648
658
|
end
|
649
659
|
|
@@ -784,6 +794,19 @@ EOH
|
|
784
794
|
<<EOH, OutputSetupGroup)
|
785
795
|
When this feature is on, all produced PDF files are converted to SVG
|
786
796
|
using the neat pdf2svg program.
|
797
|
+
EOH
|
798
|
+
|
799
|
+
CleanupPDFCommand =
|
800
|
+
Cmd.new("cleanup-pdf",nil,"--cleanup-pdf",
|
801
|
+
[CmdArg.new('boolean') ]) do |plotmaker,val|
|
802
|
+
plotmaker.postprocess.cleanup_pdf = val
|
803
|
+
end
|
804
|
+
|
805
|
+
CleanupPDFCommand.describe('Cleanup produced PDF using gs',
|
806
|
+
<<EOH, OutputSetupGroup)
|
807
|
+
If this is on, then @ctioga2@ uses ghostscript to cleanup the PDF file
|
808
|
+
produced. It is on by default is @ctioga2@ is able to find the @gs@
|
809
|
+
executable.
|
787
810
|
EOH
|
788
811
|
|
789
812
|
EPSCommand =
|
data/lib/ctioga2/postprocess.rb
CHANGED
@@ -43,6 +43,13 @@ module CTioga2
|
|
43
43
|
# Are we converting to EPS using pdftops ?
|
44
44
|
attr_accessor :eps
|
45
45
|
|
46
|
+
# Are we cleaning up the PDF produced using gs (in particular, to
|
47
|
+
# include missing markers and such, that are known to cause
|
48
|
+
# problems from time to time).
|
49
|
+
#
|
50
|
+
# @todo Path to gs...
|
51
|
+
attr_accessor :cleanup_pdf
|
52
|
+
|
46
53
|
|
47
54
|
# @todo Maybe all the PNG stuff should be it is own class ?
|
48
55
|
|
@@ -72,6 +79,9 @@ module CTioga2
|
|
72
79
|
@png_pdftoppm = false
|
73
80
|
|
74
81
|
@processed_files = []
|
82
|
+
|
83
|
+
gs = Utils::which('gs')
|
84
|
+
@cleanup_pdf = (gs ? true : false)
|
75
85
|
end
|
76
86
|
|
77
87
|
|
@@ -106,6 +116,24 @@ module CTioga2
|
|
106
116
|
# only happen last happen.
|
107
117
|
def process_file(file, last = false)
|
108
118
|
@processed_files << file
|
119
|
+
|
120
|
+
|
121
|
+
if @cleanup_pdf
|
122
|
+
nw_src = file.sub(/(\.pdf)?$/,'.raw.pdf')
|
123
|
+
begin
|
124
|
+
File::rename(file, nw_src)
|
125
|
+
info { "Running gs to clean up the target PDF file: '#{file}'" }
|
126
|
+
if ! system('gs', "-sOutputFile=#{file}", "-q", "-sDEVICE=pdfwrite",
|
127
|
+
"-dCompatibilityLevel=1.4", "-dNOPAUSE", "-dAutoRotatePages=/None", "-dBATCH", nw_src)
|
128
|
+
error { "Failed to run gs to cleanup '#{nw_src}', you can disable that using --no-cleanup-pdf" }
|
129
|
+
else
|
130
|
+
File::unlink(nw_src)
|
131
|
+
end
|
132
|
+
rescue SystemCallError => e
|
133
|
+
error { "Could not rename '#{file}' to '#{nw_src}': #{e.message}, try using --no-cleanup-pdf, or resolve the problem otherwise" }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
109
137
|
# Converts to SVG if applicable
|
110
138
|
if @svg
|
111
139
|
target = file.sub(/(\.pdf)?$/,'.svg')
|
data/lib/ctioga2/ruby.rb
CHANGED
@@ -44,6 +44,13 @@ module CTioga2
|
|
44
44
|
def self.compute_formula(col, vals, mods = [])
|
45
45
|
return Dobjects::Dvector.compute_formula(col, vals, [@module] + mods)
|
46
46
|
end
|
47
|
+
|
48
|
+
# Returns a Dobjects::MathEvaluator object to evaluate
|
49
|
+
def self.make_evaluator(formula, vars, mods = [])
|
50
|
+
return Dobjects::MathEvaluator.new(formula, vars.join(","),
|
51
|
+
[@module] + mods)
|
52
|
+
end
|
53
|
+
|
47
54
|
end
|
48
55
|
end
|
49
56
|
|
data/lib/ctioga2/utils.rb
CHANGED
@@ -64,6 +64,14 @@ module CTioga2
|
|
64
64
|
return (flt.is_a?(Numeric) and flt.to_f.finite?)
|
65
65
|
end
|
66
66
|
|
67
|
+
def self.nan_number?(flt)
|
68
|
+
return (flt.respond_to?(:nan?) and flt.nan?)
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.infinite_number?(flt)
|
72
|
+
return (flt.respond_to?(:infinite?) and flt.infinite?)
|
73
|
+
end
|
74
|
+
|
67
75
|
# Converts a number to a float while trying to stay as lenient as
|
68
76
|
# possible
|
69
77
|
def self.txt_to_float(txt)
|
@@ -199,6 +207,34 @@ module CTioga2
|
|
199
207
|
return sets_by_prefix
|
200
208
|
end
|
201
209
|
|
210
|
+
@@color_name_by_value = nil
|
211
|
+
|
212
|
+
def self.color_name_by_value_hsh
|
213
|
+
if ! @@color_name_by_value
|
214
|
+
@@color_name_by_value = {}
|
215
|
+
colors = Tioga::ColorConstants::constants
|
216
|
+
for c in colors
|
217
|
+
color = Tioga::ColorConstants::const_get(c)
|
218
|
+
@@color_name_by_value[Utils::color_to_html(color)] = c.to_s
|
219
|
+
end
|
220
|
+
end
|
221
|
+
return @@color_name_by_value
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the Tioga name for the given color. Can be nil if the
|
225
|
+
# color does not match a Tioga named color.
|
226
|
+
def self.color_name_by_value(color)
|
227
|
+
return color_name_by_value_hsh()[Utils::color_to_html(color)]
|
228
|
+
end
|
229
|
+
|
230
|
+
# Transforms a Tioga color into a HTML color string "xxxxxx"
|
231
|
+
# (without the leeading #)
|
232
|
+
def self.color_to_html(color)
|
233
|
+
return color.map do |i|
|
234
|
+
"%02x" % (i*255.to_i)
|
235
|
+
end.join('')
|
236
|
+
end
|
237
|
+
|
202
238
|
# An instrumentized version of Dir::chdir
|
203
239
|
def self.chdir(dir, &blk)
|
204
240
|
@current_dirs ||= []
|
@@ -653,6 +689,15 @@ module CTioga2
|
|
653
689
|
|
654
690
|
end
|
655
691
|
|
692
|
+
|
693
|
+
# Patching YAML generation for recent Ruby
|
694
|
+
|
695
|
+
class Dobjects::Dvector
|
696
|
+
def encode_with(coder)
|
697
|
+
coder.seq = self.to_a
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
656
701
|
######################################################################
|
657
702
|
# Now come a few functions that add to ruby's standard classes or
|
658
703
|
# modules
|
data/lib/ctioga2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ctioga2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.14'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Fourmond <vincent.fourmond@9online.fr>
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tioga
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/ctioga2/commands/general-functions.rb
|
57
57
|
- lib/ctioga2/commands/general-types.rb
|
58
58
|
- lib/ctioga2/commands/groups.rb
|
59
|
+
- lib/ctioga2/commands/instruction.rb
|
59
60
|
- lib/ctioga2/commands/interpreter.rb
|
60
61
|
- lib/ctioga2/commands/parsers/command-line.rb
|
61
62
|
- lib/ctioga2/commands/parsers/file.rb
|
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
182
|
version: '0'
|
182
183
|
requirements: []
|
183
184
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.4.5.1
|
185
186
|
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: ctioga2 - the polymorphic plotting program
|