statsailr 0.7.3 → 0.7.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.
- checksums.yaml +4 -4
- data/lib/statsailr/sts_build_exec.rb +52 -20
- data/lib/statsailr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f27292effff5ace93fcbae7cecd0a62615450ff496ba1c2bdc03b3824894a56
|
4
|
+
data.tar.gz: 7a13e3905398a04bde7f3dd0719576bcfc92a6b95b62e2a34071eca9db0086c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 356f45dd828c22c84071879e6d0a9a16ec215adf5f3894d37b6a292a6189dde7e211a12aea4697e5695a21cc8d6848c57ae5156d263b035c5b2eed667abb7300
|
7
|
+
data.tar.gz: 1f94bb8192f0af9d20ee9a79600a8db9278d17c4a323da274e8aad6e6ad3318368d070422fd30c631da75ac845773810708999d92a066ebcff0e2dce9bb8be59
|
@@ -26,34 +26,54 @@ def self.initial_setting_for_r(device_info)
|
|
26
26
|
RBridge.exec_function_no_return(attach_widget_func)
|
27
27
|
@new_device_info = { "file_output" => false, "dev_off_required" => false }
|
28
28
|
|
29
|
-
when "cairoraster" # (e.g.) ["CairoRaster", {"width" => 800, "height" => 600, "
|
29
|
+
when "cairoraster" # (e.g.) ["CairoRaster", {"width" => 800, "height" => 600 }, {"file_output_opt" => {"dir_path"=> dir_to_save , "prefix"=> "plot", "type" => "png"} }]
|
30
30
|
puts "Use Cairo function in Cairo library"
|
31
31
|
if ! device_info[1].is_a?(Hash)
|
32
32
|
raise "The second element of device info needs to be Hash"
|
33
33
|
end
|
34
|
-
cairo_info = device_info[1]
|
35
|
-
|
34
|
+
cairo_info = device_info[1].dup
|
35
|
+
file_output_opt = device_info[2]["file_output_opt"]
|
36
|
+
if ! ["png", "jpeg"].include? file_output_opt["type"]
|
36
37
|
raise "only png or jpeg is supported for type"
|
37
38
|
else
|
38
|
-
case
|
39
|
+
case file_output_opt["type"]
|
39
40
|
when "png"
|
40
41
|
# load png library
|
41
42
|
lib_func = RBridge.create_library_function("png")
|
42
43
|
RBridge.exec_function_no_return(lib_func)
|
43
44
|
when "jpeg"
|
44
45
|
# use default jpeg device
|
46
|
+
lib_func = RBridge.create_library_function("jpeg")
|
47
|
+
RBridge.exec_function_no_return(lib_func)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
lib_func = RBridge.create_library_function("Cairo")
|
48
51
|
RBridge.exec_function_no_return(lib_func)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
|
53
|
+
@new_device_info = { "file_output" => true, "dev_off_required" => true ,"file_output_opt" => file_output_opt,
|
54
|
+
"dev_control" => {
|
55
|
+
"new" => lambda {
|
56
|
+
RBridge.exec_function_no_return(
|
57
|
+
RBridge.create_function_call("Cairo",
|
58
|
+
{ "width" => RBridge.create_intvec([ cairo_info["width"] ]),
|
59
|
+
"height" => RBridge.create_intvec([ cairo_info["height"] ]),
|
60
|
+
"type" => RBridge.create_strvec([ "raster" ]) }))
|
61
|
+
},
|
62
|
+
"off" => lambda {
|
63
|
+
RBridge.exec_function_no_return(
|
64
|
+
RBridge.create_function_call("dev.off", {}))
|
65
|
+
},
|
66
|
+
"get_size" => lambda {
|
67
|
+
{:width => cairo_info["width"], :height => cairo_info["height"]}
|
68
|
+
},
|
69
|
+
"set_size" => lambda {|width, height|
|
70
|
+
cairo_info["width"] = width
|
71
|
+
cairo_info["height"] = height
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
@new_device_info["dev_control"]["new"].call()
|
76
|
+
|
57
77
|
else
|
58
78
|
puts "Unknown device type: #{device_type}"
|
59
79
|
end
|
@@ -253,17 +273,29 @@ blocks.each(){|blk|
|
|
253
273
|
else
|
254
274
|
if @new_device_info["file_output"] == true
|
255
275
|
# The plot needs to be saved on disk.
|
256
|
-
|
276
|
+
file_output_opt = @new_device_info["file_output_opt"]
|
257
277
|
temp_path = ""
|
258
|
-
temp_file = Tempfile.new( [
|
278
|
+
temp_file = Tempfile.new( [file_output_opt["prefix"] , "." + file_output_opt["type"] ] , file_output_opt["dir_path"] )
|
259
279
|
temp_path = temp_file.path
|
260
280
|
temp_file.close(true)
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
281
|
+
|
282
|
+
if ["png", "jpeg" ].include? file_output_opt["type"]
|
283
|
+
# writePNG( image=Cairo.capture( device=dev.cur() ), target="./plot.png" )
|
284
|
+
r_func_curr_dev = RBridge::create_function_call("dev.cur", {})
|
285
|
+
r_func_cairo_capture = RBridge::create_function_call("Cairo.capture",{"device" => r_func_curr_dev})
|
286
|
+
r_str_file_path = RBridge::create_strvec([temp_path])
|
287
|
+
if file_output_opt["type"] == "png"
|
288
|
+
r_func_write_png = RBridge::create_function_call("writePNG", {"image" => r_func_cairo_capture, "target" => r_str_file_path })
|
289
|
+
RBridge::exec_function_no_return( r_func_write_png )
|
290
|
+
elsif file_output_opt["type"] == "jpeg"
|
291
|
+
r_func_write_jpeg = RBridge::create_function_call("writeJPEG", {"image" => r_func_cairo_capture, "target" => r_str_file_path })
|
292
|
+
RBridge::exec_function_no_return( r_func_write_jpeg )
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
@new_device_info["dev_control"]["off"].call()
|
297
|
+
@new_device_info["dev_control"]["new"].call()
|
298
|
+
|
267
299
|
if(File.exist? temp_path)
|
268
300
|
output_mngr.add_new_message(:plot_file).set_content( temp_path )
|
269
301
|
end
|
data/lib/statsailr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsailr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshihiro Umehara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: r_bridge
|