ruby-gr 0.73.17.0 → 0.73.19.1
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/README.md +10 -10
- data/lib/gr/ffi.rb +35 -1
- data/lib/gr.rb +116 -6
- data/lib/gr3.rb +64 -0
- data/lib/gr_commons/version.rb +1 -1
- data/lib/grm/ffi.rb +1 -0
- data/lib/grm.rb +54 -7
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 875e34444c38c15bd8d817784ded0a930e3126a3cc57ae90f8ae34e720ea7e06
|
|
4
|
+
data.tar.gz: d3e8357786782a3da6b2256f40865a82a3408506d605d27692b8f52e5f8d787f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d49ab20cb176d37d092600164fb29fbb6c762d445c8b18803aca52d557f23873ba6af60126a62ece955a22c4274d7430aeb2e0ba7a31d07af8e211d7077dfda
|
|
7
|
+
data.tar.gz: f8594bf5ea403ef7cd663ce44919e760f5d79d5d1122e2b29ac45195f9108226407c1953da225667b0f26ed788009fc6e26c983e38902b49cc196dd79860b464
|
data/README.md
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
[](examples/face.rb)
|
|
22
22
|
[](examples/shade_ex.rb)
|
|
23
23
|
|
|
24
|
-
:bar_chart:
|
|
24
|
+
:bar_chart: [GR framework](https://github.com/sciapp/gr) - powerful visualization library - for Ruby
|
|
25
25
|
|
|
26
26
|
## Installation
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ First, [install GR](#gr-installation). Then install [`gr-plot`](https://github.c
|
|
|
31
31
|
gem install gr-plot
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
[pkg-config](https://github.com/ruby-gnome/pkg-config) will detect the location of the shared library. Otherwise, you need to specify the environment variable.
|
|
34
|
+
[pkg-config](https://github.com/ruby-gnome/pkg-config) will detect the location of the shared library. Otherwise, you need to specify the environment variable.
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
37
|
export GRDIR="/your/path/to/gr"
|
|
@@ -69,7 +69,7 @@ require 'gr/plot'
|
|
|
69
69
|
GR.plot(x, y)
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
List of available functions.
|
|
72
|
+
List of available functions.
|
|
73
73
|
|
|
74
74
|
[`plot`](../../wiki/Plotting-functions#plot)
|
|
75
75
|
[`step`](../../wiki/Plotting-functions#step)
|
|
@@ -151,7 +151,7 @@ macOS : See ["How to open apps from un-notarized or unidentified developers"](ht
|
|
|
151
151
|
|
|
152
152
|
### Using package managers
|
|
153
153
|
|
|
154
|
-
The third party GR packages for Mac, Linux and Windows are available for advanced users. However, these packages are provided by OSS volunteers and may not be the latest version or support some features (such as video output). If you find any problem, please report the issue [here](https://github.com/red-data-tools/GR.rb/issues).
|
|
154
|
+
The third party GR packages for Mac, Linux and Windows are available for advanced users. However, these packages are provided by OSS volunteers and may not be the latest version or support some features (such as video output). If you find any problem, please report the issue [here](https://github.com/red-data-tools/GR.rb/issues).
|
|
155
155
|
|
|
156
156
|
#### Mac - Homebrew
|
|
157
157
|
|
|
@@ -183,12 +183,12 @@ If you are using Rubyinstaller, pacman will automatically install [mingw-w64-gr]
|
|
|
183
183
|
GR.rb is a library under development, so even small improvements like fixing typos are welcome!
|
|
184
184
|
Please feel free to send us your PR.
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
186
|
+
- [Report bugs](https://github.com/red-data-tools/GR.rb/issues)
|
|
187
|
+
- Fix bugs and [submit pull requests](https://github.com/red-data-tools/GR.rb/pulls)
|
|
188
|
+
- Write, clarify, or fix documentation
|
|
189
|
+
- Suggest or add new features
|
|
190
|
+
- Update GR packages ( Homebrew, MinGW, red-data-tools )
|
|
191
|
+
- Create visualization tools based on GR.rb
|
|
192
192
|
|
|
193
193
|
If you are not familiar with Ruby gem development, please see
|
|
194
194
|
[I'm new to Ruby](https://github.com/red-data-tools/GR.rb/wiki/I%27m-new-to-Ruby)
|
data/lib/gr/ffi.rb
CHANGED
|
@@ -65,6 +65,39 @@ module GR
|
|
|
65
65
|
'hexbin_2pass_priv_t *priv'
|
|
66
66
|
]
|
|
67
67
|
|
|
68
|
+
Tick = struct [
|
|
69
|
+
'double value',
|
|
70
|
+
'int is_major'
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
TickLabel = struct [
|
|
74
|
+
'double tick',
|
|
75
|
+
'char *label',
|
|
76
|
+
'double width'
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
Axis = struct [
|
|
80
|
+
'double min',
|
|
81
|
+
'double max',
|
|
82
|
+
'double tick',
|
|
83
|
+
'double org',
|
|
84
|
+
'double position',
|
|
85
|
+
'int major_count',
|
|
86
|
+
'int num_ticks',
|
|
87
|
+
'void *ticks',
|
|
88
|
+
'double tick_size',
|
|
89
|
+
'int num_tick_labels',
|
|
90
|
+
'void *tick_labels',
|
|
91
|
+
'double label_position',
|
|
92
|
+
'int draw_axis_line',
|
|
93
|
+
'int label_orientation'
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
FormatReference = struct [
|
|
97
|
+
'char *format',
|
|
98
|
+
'int length'
|
|
99
|
+
]
|
|
100
|
+
|
|
68
101
|
try_extern 'void gr_initgr(void)'
|
|
69
102
|
try_extern 'int gr_debug(void)'
|
|
70
103
|
try_extern 'void gr_opengks(void)'
|
|
@@ -243,6 +276,7 @@ module GR
|
|
|
243
276
|
try_extern 'void gr_trisurface(int, double *, double *, double *)'
|
|
244
277
|
try_extern 'void gr_gradient(int, int, double *, double *, double *, double *, double *)'
|
|
245
278
|
try_extern 'void gr_quiver(int, int, double *, double *, double *, double *, int)'
|
|
279
|
+
typealias 'interp2_method_t', 'int'
|
|
246
280
|
try_extern 'void gr_interp2(int nx, int ny, const double *x, const double *y, const double *z,' \
|
|
247
281
|
' int nxq, int nyq, const double *xq, const double *yq, double *zq,' \
|
|
248
282
|
' interp2_method_t method, double extrapval)'
|
|
@@ -261,6 +295,7 @@ module GR
|
|
|
261
295
|
try_extern 'void gr_inqbordercolorind(int *)'
|
|
262
296
|
try_extern 'void gr_selectclipxform(int)'
|
|
263
297
|
try_extern 'void gr_inqclipxform(int *)'
|
|
298
|
+
try_extern 'void gr_inqclip(int *, double *)'
|
|
264
299
|
try_extern 'void gr_setprojectiontype(int)'
|
|
265
300
|
try_extern 'void gr_inqprojectiontype(int *)'
|
|
266
301
|
try_extern 'void gr_setperspectiveprojection(double, double, double)'
|
|
@@ -298,7 +333,6 @@ module GR
|
|
|
298
333
|
# typedef double (*radius_f)(const data_point3d_t *, const void *);
|
|
299
334
|
typealias 'kernel_f', 'void*'
|
|
300
335
|
typealias 'radius_f', 'void*'
|
|
301
|
-
typealias 'interp2_method_t', 'int'
|
|
302
336
|
try_extern 'void gr_volume_nogrid(unsigned long, const data_point3d_t *, const void *, int, kernel_f, double *, double *, double, radius_f)'
|
|
303
337
|
try_extern 'void gr_volume_interp_tri_linear_init(double, double, double)'
|
|
304
338
|
try_extern 'void gr_volume_interp_gauss_init(double, double *)'
|
data/lib/gr.rb
CHANGED
|
@@ -1116,6 +1116,52 @@ module GR
|
|
|
1116
1116
|
|
|
1117
1117
|
alias axes2d axes
|
|
1118
1118
|
|
|
1119
|
+
def axis(option, min: Float::NAN, max: Float::NAN, tick: Float::NAN, org: Float::NAN, position: Float::NAN, major_count: 1,
|
|
1120
|
+
tick_size: Float::NAN, label_position: Float::NAN, draw_axis_line: 1, label_orientation: 0)
|
|
1121
|
+
ax = FFI::Axis.malloc
|
|
1122
|
+
ax[:min] = min
|
|
1123
|
+
ax[:max] = max
|
|
1124
|
+
ax[:tick] = tick
|
|
1125
|
+
ax[:org] = org
|
|
1126
|
+
ax[:position] = position
|
|
1127
|
+
ax[:major_count] = major_count
|
|
1128
|
+
ax[:tick_size] = tick_size
|
|
1129
|
+
ax[:label_position] = label_position
|
|
1130
|
+
ax[:draw_axis_line] = draw_axis_line
|
|
1131
|
+
ax[:label_orientation] = label_orientation
|
|
1132
|
+
ax[:ticks] = 0
|
|
1133
|
+
ax[:num_ticks] = 0
|
|
1134
|
+
ax[:tick_labels] = 0
|
|
1135
|
+
ax[:num_tick_labels] = 0
|
|
1136
|
+
super(option, ax)
|
|
1137
|
+
ax
|
|
1138
|
+
end
|
|
1139
|
+
|
|
1140
|
+
def drawaxis(option, min: Float::NAN, max: Float::NAN, tick: Float::NAN, org: Float::NAN, position: Float::NAN,
|
|
1141
|
+
major_count: 1, tick_size: Float::NAN, label_position: Float::NAN, draw_axis_line: 1, label_orientation: 0)
|
|
1142
|
+
ax = FFI::Axis.malloc
|
|
1143
|
+
ax[:min] = min
|
|
1144
|
+
ax[:max] = max
|
|
1145
|
+
ax[:tick] = tick
|
|
1146
|
+
ax[:org] = org
|
|
1147
|
+
ax[:position] = position
|
|
1148
|
+
ax[:major_count] = major_count
|
|
1149
|
+
ax[:tick_size] = tick_size
|
|
1150
|
+
ax[:label_position] = label_position
|
|
1151
|
+
ax[:draw_axis_line] = draw_axis_line
|
|
1152
|
+
ax[:label_orientation] = label_orientation
|
|
1153
|
+
ax[:ticks] = 0
|
|
1154
|
+
ax[:num_ticks] = 0
|
|
1155
|
+
ax[:tick_labels] = 0
|
|
1156
|
+
ax[:num_tick_labels] = 0
|
|
1157
|
+
super(option, ax)
|
|
1158
|
+
ax
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
def drawaxes(x_axis, y_axis, option = 1)
|
|
1162
|
+
super(x_axis, y_axis, option)
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1119
1165
|
# Create axes in the current workspace and supply a custom function for
|
|
1120
1166
|
# changing the behaviour of the tick labels.
|
|
1121
1167
|
#
|
|
@@ -1348,9 +1394,10 @@ module GR
|
|
|
1348
1394
|
# * 6 SHADED_MESH - Applies light source shading to the 3-D surface
|
|
1349
1395
|
#
|
|
1350
1396
|
def surface(x, y, z, option)
|
|
1351
|
-
# TODO: check: Arrays have incorrect length or dimension.
|
|
1352
1397
|
nx = x.length
|
|
1353
1398
|
ny = y.length
|
|
1399
|
+
raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny
|
|
1400
|
+
|
|
1354
1401
|
super(nx, ny, x, y, z, option)
|
|
1355
1402
|
end
|
|
1356
1403
|
|
|
@@ -1376,10 +1423,11 @@ module GR
|
|
|
1376
1423
|
# of 1000 to `major_h`.
|
|
1377
1424
|
#
|
|
1378
1425
|
def contour(x, y, h, z, major_h)
|
|
1379
|
-
# TODO: check: Arrays have incorrect length or dimension.
|
|
1380
1426
|
nx = x.length
|
|
1381
1427
|
ny = y.length
|
|
1382
1428
|
nh = h.length
|
|
1429
|
+
raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny
|
|
1430
|
+
|
|
1383
1431
|
super(nx, ny, nh, x, y, h, z, major_h)
|
|
1384
1432
|
end
|
|
1385
1433
|
|
|
@@ -1401,10 +1449,11 @@ module GR
|
|
|
1401
1449
|
# array containing the Z coordinates
|
|
1402
1450
|
#
|
|
1403
1451
|
def contourf(x, y, h, z, major_h)
|
|
1404
|
-
# TODO: check: Arrays have incorrect length or dimension.
|
|
1405
1452
|
nx = x.length
|
|
1406
1453
|
ny = y.length
|
|
1407
1454
|
nh = h.length
|
|
1455
|
+
raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny
|
|
1456
|
+
|
|
1408
1457
|
super(nx, ny, nh, x, y, h, z, major_h)
|
|
1409
1458
|
end
|
|
1410
1459
|
|
|
@@ -1416,7 +1465,7 @@ module GR
|
|
|
1416
1465
|
# @param levels [Array, NArray] A list of contour levels
|
|
1417
1466
|
#
|
|
1418
1467
|
def tricontour(x, y, z, levels)
|
|
1419
|
-
npoints = x
|
|
1468
|
+
npoints = equal_length(x, y, z)
|
|
1420
1469
|
nlevels = levels.length
|
|
1421
1470
|
super(npoints, x, y, z, nlevels, levels)
|
|
1422
1471
|
end
|
|
@@ -1919,9 +1968,10 @@ module GR
|
|
|
1919
1968
|
|
|
1920
1969
|
# @deprecated
|
|
1921
1970
|
def gradient(x, y, z)
|
|
1922
|
-
# TODO: check: Arrays have incorrect length or dimension.
|
|
1923
1971
|
nx = x.length
|
|
1924
1972
|
ny = y.length
|
|
1973
|
+
raise ArgumentError, "z must have length nx * ny (expected #{nx * ny}, got #{z.length})" if z.length != nx * ny
|
|
1974
|
+
|
|
1925
1975
|
inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv|
|
|
1926
1976
|
super(nx, ny, x, y, z, pu, pv)
|
|
1927
1977
|
end
|
|
@@ -1942,9 +1992,12 @@ module GR
|
|
|
1942
1992
|
# The values for `x` and `y` are in world coordinates.
|
|
1943
1993
|
#
|
|
1944
1994
|
def quiver(x, y, u, v, color)
|
|
1945
|
-
# TODO: check: Arrays have incorrect length or dimension.
|
|
1946
1995
|
nx = x.length
|
|
1947
1996
|
ny = y.length
|
|
1997
|
+
if u.length != nx * ny || v.length != nx * ny
|
|
1998
|
+
raise ArgumentError, "u and v must have length nx * ny (expected #{nx * ny}, got u: #{u.length}, v: #{v.length})"
|
|
1999
|
+
end
|
|
2000
|
+
|
|
1948
2001
|
super(nx, ny, x, y, u, v, (color ? 1 : 0))
|
|
1949
2002
|
end
|
|
1950
2003
|
|
|
@@ -2419,6 +2472,45 @@ module GR
|
|
|
2419
2472
|
n_connections = colors.length
|
|
2420
2473
|
super(n_points, px, py, pz, n_connections, int(connections), int(colors))
|
|
2421
2474
|
end
|
|
2475
|
+
|
|
2476
|
+
# @return [Integer]
|
|
2477
|
+
def startlistener
|
|
2478
|
+
inquiry_int do |ret|
|
|
2479
|
+
super(ret)
|
|
2480
|
+
end
|
|
2481
|
+
end
|
|
2482
|
+
|
|
2483
|
+
# @!method setmathfont
|
|
2484
|
+
|
|
2485
|
+
def inqmathfont
|
|
2486
|
+
inquiry_int { |pt| super(pt) }
|
|
2487
|
+
end
|
|
2488
|
+
|
|
2489
|
+
# @!method setclipregion
|
|
2490
|
+
|
|
2491
|
+
def inqclipregion
|
|
2492
|
+
inquiry_int { |pt| super(pt) }
|
|
2493
|
+
end
|
|
2494
|
+
|
|
2495
|
+
# @!method setclipsector
|
|
2496
|
+
|
|
2497
|
+
def inqclipsector
|
|
2498
|
+
inquiry %i[double double] do |*pts|
|
|
2499
|
+
super(*pts)
|
|
2500
|
+
end
|
|
2501
|
+
end
|
|
2502
|
+
|
|
2503
|
+
def getformat(origin, min, max, tick_width, major)
|
|
2504
|
+
ref = FFI::FormatReference.malloc
|
|
2505
|
+
super(ref, origin, min, max, tick_width, major)
|
|
2506
|
+
ref
|
|
2507
|
+
end
|
|
2508
|
+
|
|
2509
|
+
def ftoa(value, format_ref)
|
|
2510
|
+
string = Fiddle::Pointer.malloc(256)
|
|
2511
|
+
super(string, value, format_ref)
|
|
2512
|
+
string.to_s
|
|
2513
|
+
end
|
|
2422
2514
|
end
|
|
2423
2515
|
|
|
2424
2516
|
ASF_BUNDLED = 0
|
|
@@ -2506,12 +2598,29 @@ module GR
|
|
|
2506
2598
|
MARKERTYPE_HLINE = -31
|
|
2507
2599
|
MARKERTYPE_OMARK = -32
|
|
2508
2600
|
|
|
2601
|
+
AXES_SIMPLE_AXES = 1
|
|
2602
|
+
AXES_TWIN_AXES = 2
|
|
2603
|
+
AXES_WITH_GRID = 4
|
|
2604
|
+
|
|
2605
|
+
REGION_RECTANGLE = 0
|
|
2606
|
+
REGION_ELLIPSE = 1
|
|
2607
|
+
|
|
2509
2608
|
OPTION_X_LOG = 1
|
|
2510
2609
|
OPTION_Y_LOG = 2
|
|
2511
2610
|
OPTION_Z_LOG = 4
|
|
2512
2611
|
OPTION_FLIP_X = 8
|
|
2513
2612
|
OPTION_FLIP_Y = 16
|
|
2514
2613
|
OPTION_FLIP_Z = 32
|
|
2614
|
+
OPTION_X_LOG2 = 64
|
|
2615
|
+
OPTION_Y_LOG2 = 128
|
|
2616
|
+
OPTION_Z_LOG2 = 256
|
|
2617
|
+
OPTION_X_LN = 512
|
|
2618
|
+
OPTION_Y_LN = 1024
|
|
2619
|
+
OPTION_Z_LN = 2048
|
|
2620
|
+
|
|
2621
|
+
SPEC_LINE = 1
|
|
2622
|
+
SPEC_MARKER = 2
|
|
2623
|
+
SPEC_COLOR = 4
|
|
2515
2624
|
|
|
2516
2625
|
OPTION_LINES = 0
|
|
2517
2626
|
OPTION_MESH = 1
|
|
@@ -2520,6 +2629,7 @@ module GR
|
|
|
2520
2629
|
OPTION_COLORED_MESH = 4
|
|
2521
2630
|
OPTION_CELL_ARRAY = 5
|
|
2522
2631
|
OPTION_SHADED_MESH = 6
|
|
2632
|
+
OPTION_3D_MESH = 7
|
|
2523
2633
|
|
|
2524
2634
|
MODEL_RGB = 0
|
|
2525
2635
|
MODEL_HSV = 1
|
data/lib/gr3.rb
CHANGED
|
@@ -593,6 +593,70 @@ module GR3
|
|
|
593
593
|
drawspins(positions, spins, colors)
|
|
594
594
|
end
|
|
595
595
|
|
|
596
|
+
# @!method setalphamode
|
|
597
|
+
|
|
598
|
+
# @return [Integer]
|
|
599
|
+
def getalphamode
|
|
600
|
+
inquiry_int do |mode|
|
|
601
|
+
super(mode)
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
# @!method setlightsources
|
|
606
|
+
|
|
607
|
+
# @return [Integer]
|
|
608
|
+
def getlightsources(max_num_lights = 16)
|
|
609
|
+
positions = GRCommons::Fiddley::MemoryPointer.new(:float, max_num_lights * 3)
|
|
610
|
+
colors = GRCommons::Fiddley::MemoryPointer.new(:float, max_num_lights * 3)
|
|
611
|
+
num_lights = super(max_num_lights, positions, colors)
|
|
612
|
+
# TODO: Return arrays instead of pointers?
|
|
613
|
+
# For now, returning pointers as they might be large?
|
|
614
|
+
# But usually we want ruby objects.
|
|
615
|
+
# Let's convert them to arrays if num_lights > 0
|
|
616
|
+
pos_arr = positions.read_array_of_float(num_lights * 3).each_slice(3).to_a
|
|
617
|
+
col_arr = colors.read_array_of_float(num_lights * 3).each_slice(3).to_a
|
|
618
|
+
[num_lights, pos_arr, col_arr]
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
# @!method setlightparameters
|
|
622
|
+
|
|
623
|
+
# @return [Array<Float>]
|
|
624
|
+
def getlightparameters
|
|
625
|
+
inquiry %i[float float float float] do |ambient, diffuse, specular, specular_power|
|
|
626
|
+
super(ambient, diffuse, specular, specular_power)
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
# @!method setdefaultlightparameters
|
|
631
|
+
|
|
632
|
+
# @!method setclipping
|
|
633
|
+
|
|
634
|
+
# @return [Array<Float>]
|
|
635
|
+
def getclipping
|
|
636
|
+
inquiry %i[float float float float float float] do |xmin, xmax, ymin, ymax, zmin, zmax|
|
|
637
|
+
super(xmin, xmax, ymin, ymax, zmin, zmax)
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
# @!method setsurfaceoption
|
|
642
|
+
|
|
643
|
+
# @return [Integer]
|
|
644
|
+
def getsurfaceoption
|
|
645
|
+
super
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
# @param data [NArray] 3D narray array containing the voxel data
|
|
649
|
+
# @param isovalue [Float] isovalue at which the surface will be created
|
|
650
|
+
# @param color [Array, NArray] the color of the surface
|
|
651
|
+
# @param strides [Array, NArray] the strides in each direction
|
|
652
|
+
def isosurface(data, isovalue = 0.5, color = nil, strides = nil)
|
|
653
|
+
nx, ny, nz = data.shape
|
|
654
|
+
color ||= [1.0, 1.0, 1.0]
|
|
655
|
+
strides ||= [1, 1, 1]
|
|
656
|
+
strides = GRCommons::GRCommonUtils.int(strides)
|
|
657
|
+
super(nx, ny, nz, data, isovalue, color, strides)
|
|
658
|
+
end
|
|
659
|
+
|
|
596
660
|
# Creates meshes for slices through the given data, using the current GR
|
|
597
661
|
# colormap. Use the parameters x, y or z to specify what slices should be
|
|
598
662
|
# drawn and at which positions they should go through the data. If neither
|
data/lib/gr_commons/version.rb
CHANGED
data/lib/grm/ffi.rb
CHANGED
|
@@ -84,6 +84,7 @@ module GRM
|
|
|
84
84
|
try_extern 'int grm_process_tree(void)'
|
|
85
85
|
try_extern 'int grm_export(const char *file_path)'
|
|
86
86
|
try_extern 'int grm_switch(unsigned int id)'
|
|
87
|
+
try_extern 'int grm_get_error_code()'
|
|
87
88
|
try_extern 'int grm_load_graphics_tree(FILE *file)'
|
|
88
89
|
try_extern 'int grm_validate(void)'
|
|
89
90
|
# The following functions use C++ types that cannot be parsed by Fiddle
|
data/lib/grm.rb
CHANGED
|
@@ -82,6 +82,28 @@ module GRM
|
|
|
82
82
|
|
|
83
83
|
def push(key, value)
|
|
84
84
|
key = key.to_s if key.is_a?(Symbol)
|
|
85
|
+
|
|
86
|
+
# Support Numo::NArray transparently when available
|
|
87
|
+
if defined?(Numo::NArray) && value.is_a?(Numo::NArray)
|
|
88
|
+
shape = value.shape
|
|
89
|
+
case shape.length
|
|
90
|
+
when 1
|
|
91
|
+
# 1D NArray: delegate to existing Array handling
|
|
92
|
+
return push(key, value.to_a)
|
|
93
|
+
when 2
|
|
94
|
+
# 2D NArray: convert to nested Array and reuse 2D Array path
|
|
95
|
+
rows, cols = shape
|
|
96
|
+
nested = Array.new(rows) do |r|
|
|
97
|
+
Array.new(cols) do |c|
|
|
98
|
+
value[r, c]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
return push(key, nested)
|
|
102
|
+
else
|
|
103
|
+
raise ArgumentError, "Numo::NArray with dimension > 2 is not supported for key '#{key}'"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
85
107
|
case value
|
|
86
108
|
when String
|
|
87
109
|
GRM.args_push(@args, key, 's', :const_string, value)
|
|
@@ -93,6 +115,26 @@ module GRM
|
|
|
93
115
|
GRM.args_push(@args, key, 'a', :voidp, value.address)
|
|
94
116
|
value.to_gr.free = nil
|
|
95
117
|
when Array
|
|
118
|
+
raise ArgumentError, "Array value for key '#{key}' cannot be empty" if value.empty?
|
|
119
|
+
|
|
120
|
+
# Handle 2D Array (Matrix): flatten and add dimensions
|
|
121
|
+
if value[0].is_a?(Array)
|
|
122
|
+
rows = value.size
|
|
123
|
+
cols = value[0].size
|
|
124
|
+
# Validate that all rows have the same length
|
|
125
|
+
unless value.all? { |row| row.size == cols }
|
|
126
|
+
raise ArgumentError, "All rows in 2D array for key '#{key}' must have the same length"
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Flatten in row-major order
|
|
130
|
+
flattened = value.flatten
|
|
131
|
+
|
|
132
|
+
push(key, flattened)
|
|
133
|
+
# GRM expects dims in [width, height] order (columns, rows)
|
|
134
|
+
push("#{key}_dims", [cols, rows])
|
|
135
|
+
return
|
|
136
|
+
end
|
|
137
|
+
|
|
96
138
|
case value[0]
|
|
97
139
|
when String
|
|
98
140
|
addresses = value.collect { |v| Fiddle::Pointer[v].to_i }
|
|
@@ -148,23 +190,28 @@ module GRM
|
|
|
148
190
|
|
|
149
191
|
class << self
|
|
150
192
|
def merge(args = nil)
|
|
151
|
-
|
|
193
|
+
args = Args.try_convert(args) || args
|
|
194
|
+
super(args)
|
|
152
195
|
end
|
|
153
196
|
|
|
154
|
-
def merge_extended(args = nil, hold = 0,
|
|
155
|
-
|
|
197
|
+
def merge_extended(args = nil, hold = 0, identificator = nil)
|
|
198
|
+
args = Args.try_convert(args) || args
|
|
199
|
+
super(args, hold, identificator)
|
|
156
200
|
end
|
|
157
201
|
|
|
158
202
|
def merge_hold(args = nil)
|
|
159
|
-
|
|
203
|
+
args = Args.try_convert(args) || args
|
|
204
|
+
super(args)
|
|
160
205
|
end
|
|
161
206
|
|
|
162
|
-
def merge_named(args = nil,
|
|
163
|
-
|
|
207
|
+
def merge_named(args = nil, identificator = nil)
|
|
208
|
+
args = Args.try_convert(args) || args
|
|
209
|
+
super(args, identificator)
|
|
164
210
|
end
|
|
165
211
|
|
|
166
212
|
def plot(args = nil)
|
|
167
|
-
|
|
213
|
+
args = Args.try_convert(args) || args
|
|
214
|
+
super(args)
|
|
168
215
|
end
|
|
169
216
|
end
|
|
170
217
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-gr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.73.
|
|
4
|
+
version: 0.73.19.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kojix2
|
|
@@ -24,7 +24,7 @@ dependencies:
|
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: 1.1.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: numo-narray
|
|
27
|
+
name: numo-narray-alt
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
- !ruby/object:Gem::Version
|
|
100
100
|
version: '0'
|
|
101
101
|
requirements: []
|
|
102
|
-
rubygems_version: 3.7.
|
|
102
|
+
rubygems_version: 3.7.2
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: GR for Ruby
|
|
105
105
|
test_files: []
|