ruby-gr 0.0.26 → 0.64.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -73
- data/lib/gr/ffi.rb +11 -0
- data/lib/gr.rb +148 -32
- data/lib/gr3/ffi.rb +11 -0
- data/lib/gr3.rb +5 -1
- data/lib/gr_commons/fiddley.rb +1 -1
- data/lib/gr_commons/gr_lib.rb +43 -22
- data/lib/gr_commons/gr_logger.rb +23 -11
- data/lib/gr_commons/version.rb +1 -1
- data/lib/grm/ffi.rb +0 -3
- data/lib/grm.rb +5 -1
- metadata +8 -79
- data/lib/gr/plot.rb +0 -1530
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e87b16084dadf1b42355615e60e8b3537179eea0d2bab51a9b482abb060036
|
4
|
+
data.tar.gz: a645e707451e939abe3d6706bcda2bc49544149c21fe0fb93785ae3162794958
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf43899a660104ac091218d43be18d74f94488f04f44056a8cb09c89ce793aefaa05070dde4bf129b4601f10071b4617bccbcf573818c6d531ed61c8c354c705
|
7
|
+
data.tar.gz: 868a4a08896bce2ac780eeea5d1ebab82d56262dbc9407fb8eb1ad11bc13a71d18a6b291ac57abc3a78d021eb47b788da4d942df057a7071e191d5afaf588a71
|
data/README.md
CHANGED
@@ -27,23 +27,22 @@
|
|
27
27
|
|
28
28
|
GR.rb supports Ruby 2.5+.
|
29
29
|
|
30
|
-
First, [install GR](#gr-installation). Then install `
|
30
|
+
First, [install GR](#gr-installation). Then install `gr-plot` gem.
|
31
31
|
|
32
32
|
```sh
|
33
|
-
gem install
|
33
|
+
gem install gr-plot
|
34
34
|
```
|
35
|
-
Note: If you are using [RubyInstaller](https://rubyinstaller.org/) (Windows), pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr).
|
36
35
|
|
37
|
-
|
36
|
+
[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.
|
38
37
|
|
39
38
|
```sh
|
40
39
|
export GRDIR="/your/path/to/gr"
|
41
40
|
```
|
42
41
|
|
43
|
-
If you use package managers to install GR, [pkg-config](https://github.com/ruby-gnome/pkg-config) may automatically detect the shared library location without specifying the `GRDIR` environment variable.
|
44
|
-
|
45
42
|
## Quick Start
|
46
43
|
|
44
|
+
:point_right: [Wiki -plotting functions](https://github.com/red-data-tools/GR.rb/wiki/Plotting-functions)
|
45
|
+
|
47
46
|
<p align="center">
|
48
47
|
<img src="https://user-images.githubusercontent.com/5798442/69689128-74cb1480-110b-11ea-9097-29e878a19e8f.png">
|
49
48
|
</p>
|
@@ -54,41 +53,15 @@ require 'gr/plot'
|
|
54
53
|
x = [0, 0.2, 0.4, 0.6, 0.8, 1.0]
|
55
54
|
y = [0.3, 0.5, 0.4, 0.2, 0.6, 0.7]
|
56
55
|
|
56
|
+
# show the figure
|
57
57
|
GR.plot(x, y)
|
58
|
-
```
|
59
|
-
|
60
|
-
<p align="center">
|
61
|
-
<img src="https://user-images.githubusercontent.com/5798442/84570709-242ab880-adca-11ea-9099-3a6b3418bf19.png">
|
62
|
-
</p>
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
require 'gr/plot'
|
66
58
|
|
67
|
-
|
68
|
-
y1 = Numo::NMath.sin(x)
|
69
|
-
y2 = Numo::NMath.cos(x)
|
70
|
-
|
71
|
-
GR.plot(
|
72
|
-
[x, y1, 'bo'], [x, y2, 'g*'],
|
73
|
-
title: "Multiple plot example",
|
74
|
-
xlabel: "x",
|
75
|
-
ylabel: "y",
|
76
|
-
ylim: [-1.2, 1.2],
|
77
|
-
labels: ["sin(x)", "cos(x)"],
|
78
|
-
location: 11
|
79
|
-
)
|
80
|
-
```
|
81
|
-
|
82
|
-
Save the figure in PNG format.
|
83
|
-
|
84
|
-
```ruby
|
59
|
+
# Save the figure in PNG format.
|
85
60
|
GR.savefig("figure.png")
|
86
61
|
```
|
87
62
|
|
88
63
|
## API Overview
|
89
64
|
|
90
|
-
There are two different approaches when plotting with GR.rb. One is to call Matlab-like APIs. The other is to call GR/GR3 native functions.
|
91
|
-
|
92
65
|
#### GR::Plot - A simple, matlab-style API.
|
93
66
|
|
94
67
|
```ruby
|
@@ -96,8 +69,7 @@ require 'gr/plot'
|
|
96
69
|
GR.plot(x, y)
|
97
70
|
```
|
98
71
|
|
99
|
-
|
100
|
-
Some GR module methods are overwritten.
|
72
|
+
List of available functions.
|
101
73
|
|
102
74
|
[`plot`](../../wiki/Plotting-functions#plot)
|
103
75
|
[`step`](../../wiki/Plotting-functions#step)
|
@@ -123,7 +95,8 @@ Some GR module methods are overwritten.
|
|
123
95
|
[`imshow`](../../wiki/Plotting-functions#imshow)
|
124
96
|
[`isosurface`](../../wiki/Plotting-functions#isosurface)
|
125
97
|
|
126
|
-
|
98
|
+
See [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki) for details.
|
99
|
+
Some GR module methods are overwritten. Code has been moved to [gr-plot](https://github.com/red-data-tools/gr-plot).
|
127
100
|
|
128
101
|
#### GR - A module for calling native GR functions.
|
129
102
|
|
@@ -148,73 +121,57 @@ require 'gr3'
|
|
148
121
|
GR3.cameralookat(-3, 2, -2, 0, 0, 0, 0, 0, -1)
|
149
122
|
```
|
150
123
|
|
124
|
+
### Using GR.rb non-interactively
|
125
|
+
|
126
|
+
Both APIs will by default start a Qt based window to show the result of the last call.
|
127
|
+
This behavior is caused by GR itself as it will [implicitly generate output to a file or application](https://gr-framework.org/workstations.html#no-output).
|
128
|
+
If you want to use GR.rb non-interactively, eg., as part of a static site build, you can do this by setting the environment variable `GKS_WSTYPE`to `100`.
|
129
|
+
|
130
|
+
```sh
|
131
|
+
export GKS_WSTYPE=100
|
132
|
+
```
|
133
|
+
|
151
134
|
## Documentation
|
152
135
|
|
153
136
|
- [GR.rb Wiki](https://github.com/red-data-tools/GR.rb/wiki)
|
154
|
-
- [GR
|
155
|
-
- [GR
|
156
|
-
|
157
|
-
Although GR.rb adds methods dynamically, we try our best to provide a complete yard document. If you want to see more up-to-date information, we recommend using the official GR reference.
|
137
|
+
- [GR.rb API Documentation](https://rubydoc.info/gems/ruby-gr) - Yard documents.
|
138
|
+
- [GR Framework](https://gr-framework.org/) - The official GR reference.
|
158
139
|
|
159
140
|
## GR Installation
|
160
141
|
|
161
142
|
### Installing an official release (recommended)
|
162
143
|
|
163
|
-
Download the [latest release](https://github.com/sciapp/gr/releases).
|
164
|
-
|
165
|
-
Set environment variable GRDIR.
|
144
|
+
Download the [latest release](https://github.com/sciapp/gr/releases) and place it where you want. Then set environment variable `GRDIR`.
|
166
145
|
|
167
146
|
```sh
|
168
147
|
export GRDIR="your/path/to/gr"
|
169
148
|
```
|
170
149
|
|
171
|
-
|
150
|
+
macOS : See ["How to open apps from un-notarized or unidentified developers"](https://support.apple.com/en-us/HT202491) in the Apple documentation.
|
172
151
|
|
173
152
|
### Using package managers
|
174
153
|
|
175
|
-
|
176
|
-
* If you find any problem, please report the issue [here](https://github.com/red-data-tools/GR.rb/issues).
|
177
|
-
* Note: These packages may not have some features such as video output.
|
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).
|
178
155
|
|
179
156
|
#### Mac - Homebrew
|
180
157
|
|
181
158
|
```sh
|
182
159
|
brew install libgr
|
183
|
-
#
|
160
|
+
export GKS_WSTYPE=411 # Set the workstation type to gksqt (recommended)
|
184
161
|
```
|
185
162
|
|
163
|
+
#### Linux - openSUSE Build service
|
186
164
|
|
187
|
-
|
188
|
-
|
189
|
-
[packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev`, `libgr3-dev` and `libgrm-dev`
|
190
|
-
|
191
|
-
Debian GNU/Linux and Ubuntu
|
165
|
+
GR releases are also available from the [openSUSE Build service](https://software.opensuse.org//download.html?project=science%3Agr-framework&package=gr) for CentOS, Debian, Fedora openSUSE and Ubuntu. Obtain a packaged release [here](https://software.opensuse.org//download.html?project=science%3Agr-framework&package=gr).
|
192
166
|
|
193
167
|
```sh
|
194
|
-
|
195
|
-
wget https://packages.red-data-tools.org/$(lsb_release --id --short | tr 'A-Z' 'a-z')/red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
|
196
|
-
sudo apt install -y -V ./red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
|
197
|
-
sudo apt update
|
198
|
-
sudo apt install libgrm-dev
|
168
|
+
export GRDIR="/usr/gr" # Check the location with `dpkg -L gr`
|
199
169
|
```
|
200
170
|
|
201
|
-
####
|
202
|
-
|
203
|
-
CentOS
|
204
|
-
|
205
|
-
```sh
|
206
|
-
(. /etc/os-release && sudo dnf install -y https://packages.red-data-tools.org/centos/${VERSION_ID}/red-data-tools-release-latest.noarch.rpm)
|
207
|
-
sudo dnf install -y gr-devel
|
208
|
-
```
|
209
|
-
|
210
|
-
### Windows - MSYS2
|
171
|
+
#### Windows - MSYS2
|
211
172
|
|
212
173
|
If you are using Rubyinstaller, pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr) when the gem is installed.
|
213
174
|
|
214
|
-
## Backend for Charty
|
215
|
-
|
216
|
-
GR.rb will be the default backend for [Charty](https://github.com/red-data-tools/charty).
|
217
|
-
|
218
175
|
## Contributing
|
219
176
|
|
220
177
|
GR.rb is a library under development, so even small improvements like fixing typos are welcome!
|
@@ -227,6 +184,17 @@ Please feel free to send us your PR.
|
|
227
184
|
* Update GR packages ( Homebrew, MinGW, red-data-tools )
|
228
185
|
* Create visualization tools based on GR.rb
|
229
186
|
|
187
|
+
If you are not familiar with Ruby gem development, please see
|
188
|
+
[I'm new to Ruby](https://github.com/red-data-tools/GR.rb/wiki/I%27m-new-to-Ruby)
|
189
|
+
|
190
|
+
```
|
191
|
+
Do you need commit rights to my repository?
|
192
|
+
Do you want to get admin rights and take over the project?
|
193
|
+
If so, please feel free to contact us.
|
194
|
+
```
|
195
|
+
|
196
|
+
I've seen a lot of OSS abandoned because no one has commit rights to the original repository anymore; the right to request commit rights for GR.rb is always open.
|
197
|
+
|
230
198
|
## Acknowledgements
|
231
199
|
|
232
200
|
We would like to thank Josef Heinen, the creator of [GR](https://github.com/sciapp/gr) and [GR.jl](https://github.com/jheinen/GR.jl), Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr), and all [GR](https://github.com/sciapp/gr) developers.
|
data/lib/gr/ffi.rb
CHANGED
@@ -33,7 +33,9 @@ module GR
|
|
33
33
|
try_extern 'void gr_polyline(int, double *, double *)'
|
34
34
|
try_extern 'void gr_polymarker(int, double *, double *)'
|
35
35
|
try_extern 'void gr_text(double, double, char *)'
|
36
|
+
try_extern 'void gr_textx(double, double, char *, int)'
|
36
37
|
try_extern 'void gr_inqtext(double, double, char *, double *, double *)'
|
38
|
+
try_extern 'gr_inqtextx(double, double, char *, int, double *, double *)'
|
37
39
|
try_extern 'void gr_fillarea(int, double *, double *)'
|
38
40
|
try_extern 'void gr_cellarray(double, double, double, double, ' \
|
39
41
|
'int, int, int, int, int, int, int *)'
|
@@ -117,6 +119,7 @@ module GR
|
|
117
119
|
try_extern 'void gr_setcolormap(int)'
|
118
120
|
try_extern 'void gr_inqcolormap(int *)'
|
119
121
|
try_extern 'void gr_setcolormapfromrgb(int n, double *r, double *g, double *b, double *x)'
|
122
|
+
try_extern 'void gr_inqcolormapinds(int *, int *)'
|
120
123
|
try_extern 'void gr_colorbar(void)'
|
121
124
|
try_extern 'void gr_inqcolor(int, int *)'
|
122
125
|
try_extern 'int gr_inqcolorfromrgb(double, double, double)'
|
@@ -208,5 +211,13 @@ module GR
|
|
208
211
|
try_extern 'void gr_inqtextencoding(int *)'
|
209
212
|
try_extern 'void gr_loadfont(char *, int *)'
|
210
213
|
# gr_setcallback(char *(*)(const char *));
|
214
|
+
try_extern 'void gr_setthreadnumber(int)'
|
215
|
+
try_extern 'void gr_setpicturesizeforvolume(int, int)'
|
216
|
+
try_extern 'void gr_setvolumebordercalculation(int)'
|
217
|
+
try_extern 'void gr_setapproximativecalculation(int)'
|
218
|
+
try_extern 'void gr_inqvolumeflags(int *, int *, int *, int *, int *)'
|
219
|
+
try_extern 'void gr_cpubasedvolume(int, int, int, double *, int, double *, double *, double *, double *)'
|
220
|
+
try_extern 'void gr_inqvpsize(int *, int *, double *)'
|
221
|
+
try_extern 'void gr_polygonmesh3d(int, const double *, const double *, const double *, int, const int *, const int *)'
|
211
222
|
end
|
212
223
|
end
|
data/lib/gr.rb
CHANGED
@@ -58,7 +58,7 @@ module GR
|
|
58
58
|
|
59
59
|
# Platforms | path
|
60
60
|
# Windows | bin/libgr.dll
|
61
|
-
# MacOSX | lib/libGR.
|
61
|
+
# MacOSX | lib/libGR.dylib ( <= v0.53.0 .so)
|
62
62
|
# Ubuntu | lib/libGR.so
|
63
63
|
platform = RbConfig::CONFIG['host_os']
|
64
64
|
lib_names, pkg_name = \
|
@@ -66,10 +66,14 @@ module GR
|
|
66
66
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
67
67
|
[['libGR.dll'], 'gr']
|
68
68
|
when /darwin|mac os/
|
69
|
+
ENV['GKSwstype'] ||= 'gksqt'
|
69
70
|
[['libGR.dylib', 'libGR.so'], 'gr']
|
70
71
|
else
|
71
72
|
[['libGR.so'], 'gr']
|
72
73
|
end
|
74
|
+
|
75
|
+
# On Windows + RubyInstaller,
|
76
|
+
# the environment variable GKS_FONTPATH will be set.
|
73
77
|
lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
|
74
78
|
|
75
79
|
raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
|
@@ -178,7 +182,7 @@ module GR
|
|
178
182
|
# @param x [Array, NArray] A list containing the X coordinates
|
179
183
|
# @param y [Array, NArray] A list containing the Y coordinates
|
180
184
|
# @param linewidth [Array, NArray, Numeric] A list containing the line widths
|
181
|
-
# @param line_z [Array, NArray]
|
185
|
+
# @param line_z [Array, NArray, Numeric] A list to be converted to colors
|
182
186
|
#
|
183
187
|
# The values for x and y are in world coordinates.
|
184
188
|
# The attributes that control the appearance of a polyline are linetype,
|
@@ -190,13 +194,24 @@ module GR
|
|
190
194
|
if linewidth.nil? && line_z.nil?
|
191
195
|
super(n, x, y)
|
192
196
|
else
|
193
|
-
linewidth
|
194
|
-
linewidth
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
197
|
+
linewidth ||= GR.inqlinewidth
|
198
|
+
linewidth = if linewidth.is_a?(Numeric)
|
199
|
+
Array.new(n, linewidth * 100)
|
200
|
+
else
|
201
|
+
raise ArgumentError if n != linewidth.length
|
202
|
+
|
203
|
+
linewidth.map { |i| (100 * i).round }
|
204
|
+
end
|
205
|
+
line_z ||= GR.inqcolor(989) # FIXME
|
206
|
+
color = if line_z.is_a?(Numeric)
|
207
|
+
Array.new(n, line_z)
|
208
|
+
else
|
209
|
+
raise ArgumentError if n != line_z.length
|
210
|
+
|
211
|
+
to_rgb_color(line_z)
|
212
|
+
end
|
213
|
+
z = linewidth.to_a.zip(color).flatten # to_a : NArray
|
214
|
+
gdp(x, y, GDP_DRAW_LINES, z)
|
200
215
|
end
|
201
216
|
end
|
202
217
|
|
@@ -205,7 +220,7 @@ module GR
|
|
205
220
|
# @param x [Array, NArray] A list containing the X coordinates
|
206
221
|
# @param y [Array, NArray] A list containing the Y coordinates
|
207
222
|
# @param markersize [Array, NArray, Numeric] A list containing the marker sizes
|
208
|
-
# @param marker_z [Array, NArray]
|
223
|
+
# @param marker_z [Array, NArray, Numeric] A list to be converted to colors
|
209
224
|
#
|
210
225
|
# The values for x and y are in world coordinates.
|
211
226
|
# The attributes that control the appearance of a polymarker are marker type,
|
@@ -217,13 +232,24 @@ module GR
|
|
217
232
|
if markersize.nil? && marker_z.nil?
|
218
233
|
super(n, x, y)
|
219
234
|
else
|
220
|
-
markersize
|
221
|
-
markersize
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
235
|
+
markersize ||= GR.inqmarkersize
|
236
|
+
markersize = if markersize.is_a?(Numeric)
|
237
|
+
Array.new(n, markersize * 100)
|
238
|
+
else
|
239
|
+
raise ArgumentError if n != markersize.length
|
240
|
+
|
241
|
+
markersize.map { |i| (100 * i).round }
|
242
|
+
end
|
243
|
+
marker_z ||= GR.inqcolor(989) # FIXME
|
244
|
+
color = if marker_z.is_a?(Numeric)
|
245
|
+
Array.new(n, marker_z)
|
246
|
+
else
|
247
|
+
raise ArgumentError if n != marker_z.length
|
248
|
+
|
249
|
+
to_rgb_color(marker_z)
|
250
|
+
end
|
251
|
+
z = markersize.to_a.zip(color).flatten # to_a : NArray
|
252
|
+
gdp(x, y, GDP_DRAW_MARKERS, z)
|
227
253
|
end
|
228
254
|
end
|
229
255
|
|
@@ -308,9 +334,9 @@ module GR
|
|
308
334
|
# raidus. The center point of the resulting disk is located at `xorg`, `yorg`
|
309
335
|
# and the radius of the disk is `rmax`.
|
310
336
|
#
|
311
|
-
# @param
|
337
|
+
# @param x_org [Numeric] X coordinate of the disk center in world
|
312
338
|
# coordinates
|
313
|
-
# @param
|
339
|
+
# @param y_org [Numeric] Y coordinate of the disk center in world
|
314
340
|
# coordinates
|
315
341
|
# @param phimin [Numeric] start angle of the disk sector in degrees
|
316
342
|
# @param phimax [Numeric] end angle of the disk sector in degrees
|
@@ -318,7 +344,7 @@ module GR
|
|
318
344
|
# coordinates
|
319
345
|
# @param rmax [Numeric] outer radius of the punctured disk in world
|
320
346
|
# coordinates
|
321
|
-
# @param
|
347
|
+
# @param dimphi [Integer] Phi (X) dimension of the color index array
|
322
348
|
# @param dimr [Integer] iR (Y) dimension of the color index array
|
323
349
|
# @param color [Array, NArray] Color index array
|
324
350
|
#
|
@@ -1355,7 +1381,7 @@ module GR
|
|
1355
1381
|
# @param x [Array, NArray] A list containing the X coordinates
|
1356
1382
|
# @param y [Array, NArray] A list containing the Y coordinates
|
1357
1383
|
# @param z [Array, NArray] A list containing the Z coordinates
|
1358
|
-
# @param
|
1384
|
+
# @param levels [Array, NArray] A list of contour levels
|
1359
1385
|
#
|
1360
1386
|
def tricontour(x, y, z, levels)
|
1361
1387
|
npoints = x.length # equal_length ?
|
@@ -1414,6 +1440,16 @@ module GR
|
|
1414
1440
|
super(n, r, g, b, positions)
|
1415
1441
|
end
|
1416
1442
|
|
1443
|
+
# Inquire the color index range of the current colormap.
|
1444
|
+
#
|
1445
|
+
# @return [Array] first_color_ind The color index of the first color,
|
1446
|
+
# last_color_ind The color index of the last color
|
1447
|
+
def inqcolormapinds
|
1448
|
+
inquiry %i[int int] do |first_color_ind, last_color_ind|
|
1449
|
+
super(first_color_ind, last_color_ind)
|
1450
|
+
end
|
1451
|
+
end
|
1452
|
+
|
1417
1453
|
# @!method colorbar
|
1418
1454
|
|
1419
1455
|
def inqcolor(color)
|
@@ -1601,14 +1637,14 @@ module GR
|
|
1601
1637
|
# curves.
|
1602
1638
|
#
|
1603
1639
|
# @param points [Array, NArray] (N, 2) array of (x, y) vertices
|
1604
|
-
# @
|
1640
|
+
# @param codes [Array, NArray] N-length array of path codes
|
1605
1641
|
# * STOP : end the entire path
|
1606
1642
|
# * MOVETO : move to the given vertex
|
1607
1643
|
# * LINETO : draw a line from the current position to the given vertex
|
1608
1644
|
# * CURVE3 : draw a quadratic Bézier curve
|
1609
1645
|
# * CURVE4 : draw a cubic Bézier curve
|
1610
1646
|
# * CLOSEPOLY : draw a line segment to the start point of the current path
|
1611
|
-
# @
|
1647
|
+
# @param fill [Integer]
|
1612
1648
|
# A flag indication whether resulting path is to be filled or not
|
1613
1649
|
#
|
1614
1650
|
def drawpath(points, codes, fill)
|
@@ -1668,7 +1704,7 @@ module GR
|
|
1668
1704
|
def readimage(path)
|
1669
1705
|
# Feel free to make a pull request if you catch a mistake
|
1670
1706
|
# or you have an idea to improve it.
|
1671
|
-
data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1707
|
+
data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T, Fiddle::RUBY_FREE)
|
1672
1708
|
w, h = inquiry [:int, :int] do |width, height|
|
1673
1709
|
# data is a pointer of a pointer
|
1674
1710
|
super(path, width, height, data.ref)
|
@@ -1806,7 +1842,7 @@ module GR
|
|
1806
1842
|
# Feel free to make a pull request if you catch a mistake
|
1807
1843
|
# or you have an idea to improve it.
|
1808
1844
|
npoints = equal_length(x, y)
|
1809
|
-
triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
|
1845
|
+
triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T, Fiddle::RUBY_FREE)
|
1810
1846
|
dim = 3
|
1811
1847
|
n_tri = inquiry_int do |ntri|
|
1812
1848
|
super(npoints, x, y, ntri, triangles.ref)
|
@@ -2113,9 +2149,9 @@ module GR
|
|
2113
2149
|
#
|
2114
2150
|
# @param flag [Integer] projection type
|
2115
2151
|
# The available options are:
|
2116
|
-
# * 0 :
|
2117
|
-
# * 1 :
|
2118
|
-
# * 2 :
|
2152
|
+
# * 0 : PROJECTION_DEFAULT - default
|
2153
|
+
# * 1 : PROJECTION_ORTHOGRAPHIC - orthographic
|
2154
|
+
# * 2 : PROJECTION_PERSPECTIVE - perspective
|
2119
2155
|
#
|
2120
2156
|
# @!method setprojectiontype
|
2121
2157
|
|
@@ -2279,6 +2315,76 @@ module GR
|
|
2279
2315
|
super(str, font)
|
2280
2316
|
end
|
2281
2317
|
end
|
2318
|
+
|
2319
|
+
# Set the number of threads which can run parallel.
|
2320
|
+
# The default value is the number of threads the cpu has.
|
2321
|
+
#
|
2322
|
+
# @param num [Integer] num number of threads
|
2323
|
+
#
|
2324
|
+
# @!method setthreadnumber
|
2325
|
+
|
2326
|
+
# Set the width and height of the resulting picture.
|
2327
|
+
# These values are only used for gr_volume and gr_cpubasedvolume.
|
2328
|
+
# The default values are 1000 for both.
|
2329
|
+
#
|
2330
|
+
# @param width [Integer] width of the resulting image
|
2331
|
+
# @param height [Integer] height of the resulting image
|
2332
|
+
#
|
2333
|
+
# @!method setpicturesizeforvolume
|
2334
|
+
|
2335
|
+
# Set the gr_volume border type with this flag.
|
2336
|
+
# This inflicts how the volume is calculated. When the flag is set to
|
2337
|
+
# GR_VOLUME_WITH_BORDER the border will be calculated the same as the points
|
2338
|
+
# inside the volume.
|
2339
|
+
#
|
2340
|
+
# @param flag [Integer] calculation of the gr_volume border
|
2341
|
+
# The available options are:
|
2342
|
+
# * 0 : VOLUME_WITHOUT_BORDER - default value
|
2343
|
+
# * 1 : VOLUME_WITH_BORDER - gr_volume with border
|
2344
|
+
#
|
2345
|
+
# @!method setvolumebordercalculation # @!method setthreadnumber
|
2346
|
+
|
2347
|
+
# Set if gr_cpubasedvolume is calculated approximative or exact.
|
2348
|
+
# To use the exact calculation set approximative_calculation to 0.
|
2349
|
+
# The default value is the approximative version, which can be set with the
|
2350
|
+
# number 1.
|
2351
|
+
#
|
2352
|
+
# @param approximative_calculation [Integer] exact or approximative calculation
|
2353
|
+
# of the volume
|
2354
|
+
#
|
2355
|
+
# @!method setapproximativecalculation
|
2356
|
+
|
2357
|
+
# Inquire the parameters which can be set for cpubasedvolume.
|
2358
|
+
# The size of the resulting image, the way the volumeborder is calculated and
|
2359
|
+
# the amount of threads which are used.
|
2360
|
+
#
|
2361
|
+
# @return [Array]
|
2362
|
+
# * border - flag which tells how the border is calculated
|
2363
|
+
# * max_threads - number of threads
|
2364
|
+
# * picture_width - width of the resulting image
|
2365
|
+
# * picture_height - height of the resulting image
|
2366
|
+
# * approximative_calculation - exact or approximative calculation of gr_cpubasedvolume
|
2367
|
+
#
|
2368
|
+
def inqvolumeflags
|
2369
|
+
inquiry([:int] * 5) do |*pts|
|
2370
|
+
super(*pts)
|
2371
|
+
end
|
2372
|
+
end
|
2373
|
+
|
2374
|
+
# FIXME! (#61)
|
2375
|
+
# @!method cpubasedvolume
|
2376
|
+
|
2377
|
+
def inqvpsize
|
2378
|
+
inquiry %i[int int double] do |*pts|
|
2379
|
+
super(*pts)
|
2380
|
+
end
|
2381
|
+
end
|
2382
|
+
|
2383
|
+
def polygonmesh3d(px, py, pz, connections, colors)
|
2384
|
+
n_points = equal_length(px, py, pz)
|
2385
|
+
n_connections = colors.length
|
2386
|
+
super(n_points, px, py, pz, n_connections, int(connections), int(colors))
|
2387
|
+
end
|
2282
2388
|
end
|
2283
2389
|
|
2284
2390
|
ASF_BUNDLED = 0
|
@@ -2487,8 +2593,8 @@ module GR
|
|
2487
2593
|
PATH_CURVE4 = 0x04
|
2488
2594
|
PATH_CLOSEPOLY = 0x4f
|
2489
2595
|
|
2490
|
-
GDP_DRAW_PATH
|
2491
|
-
GDP_DRAW_LINES
|
2596
|
+
GDP_DRAW_PATH = 1
|
2597
|
+
GDP_DRAW_LINES = 2
|
2492
2598
|
GDP_DRAW_MARKERS = 3
|
2493
2599
|
|
2494
2600
|
MPL_SUPPRESS_CLEAR = 1
|
@@ -2534,7 +2640,17 @@ module GR
|
|
2534
2640
|
(UPSAMPLE_VERTICAL_LANCZOS | UPSAMPLE_HORIZONTAL_LANCZOS |
|
2535
2641
|
DOWNSAMPLE_VERTICAL_LANCZOS | DOWNSAMPLE_HORIZONTAL_LANCZOS)
|
2536
2642
|
|
2537
|
-
PROJECTION_DEFAULT
|
2643
|
+
PROJECTION_DEFAULT = 0
|
2538
2644
|
PROJECTION_ORTHOGRAPHIC = 1
|
2539
|
-
PROJECTION_PERSPECTIVE
|
2645
|
+
PROJECTION_PERSPECTIVE = 2
|
2646
|
+
|
2647
|
+
VOLUME_WITHOUT_BORDER = 0
|
2648
|
+
VOLUME_WITH_BORDER = 1
|
2649
|
+
|
2650
|
+
VOLUME_EMISSION = 0
|
2651
|
+
VOLUME_ABSORPTION = 1
|
2652
|
+
VOLUME_MIP = 2
|
2653
|
+
|
2654
|
+
TEXT_USE_WC = (1 << 0)
|
2655
|
+
TEXT_ENABLE_INLINE_MATH = (1 << 1)
|
2540
2656
|
end
|
data/lib/gr3/ffi.rb
CHANGED
@@ -91,6 +91,8 @@ module GR3
|
|
91
91
|
'double offset_x, double offset_y, double offset_z)'
|
92
92
|
try_extern 'int gr3_createsurfacemesh(int *mesh, int nx, int ny, ' \
|
93
93
|
'float *px, float *py, float *pz, int option)'
|
94
|
+
try_extern 'int gr3_createsurface3dmesh(int *mesh, int ncols, int nrows, ' \
|
95
|
+
'float *px, float *py, float *pz);'
|
94
96
|
try_extern 'void gr3_drawmesh_grlike(int mesh, int n, ' \
|
95
97
|
'const float *positions, const float *directions, const float *ups, ' \
|
96
98
|
'const float *colors, const float *scales)'
|
@@ -140,5 +142,14 @@ module GR3
|
|
140
142
|
'int algorithm, double *dmin_ptr, double *dmax_ptr)'
|
141
143
|
try_extern 'void gr3_setorthographicprojection' \
|
142
144
|
'(float left, float right, float bottom, float top, float znear, float zfar)'
|
145
|
+
try_extern 'void gr3_setsurfaceoption(int option)'
|
146
|
+
try_extern 'int gr3_getsurfaceoption(void)'
|
147
|
+
try_extern 'int gr3_getlightsources(int max_num_lights, float *positions, float *colors)'
|
148
|
+
try_extern 'int gr3_setlightsources(int num_lights, float *positions, float *colors)'
|
149
|
+
try_extern 'void gr3_setlightparameters(float ambient, float diffuse, float specular, float specular_power)'
|
150
|
+
try_extern 'void gr3_getlightparameters(float *ambient, float *diffuse, float *specular, float *specular_power)'
|
151
|
+
try_extern 'void gr3_setdefaultlightparameters()'
|
152
|
+
try_extern 'void gr3_setclipping(float xmin, float xmax, float ymin, float ymax, float zmin, float zmax)'
|
153
|
+
try_extern 'void gr3_getclipping(float *xmin, float *xmax, float *ymin, float *ymax, float *zmin, float *zmax)'
|
143
154
|
end
|
144
155
|
end
|
data/lib/gr3.rb
CHANGED
@@ -68,7 +68,7 @@ module GR3
|
|
68
68
|
|
69
69
|
# Platforms | path
|
70
70
|
# Windows | bin/libGR3.dll
|
71
|
-
# MacOSX | lib/libGR3.dylib (v0.53.0 .so)
|
71
|
+
# MacOSX | lib/libGR3.dylib ( <= v0.53.0 .so)
|
72
72
|
# Ubuntu | lib/libGR3.so
|
73
73
|
platform = RbConfig::CONFIG['host_os']
|
74
74
|
lib_names, pkg_name = \
|
@@ -76,10 +76,14 @@ module GR3
|
|
76
76
|
when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
|
77
77
|
[['libGR3.dll'], 'gr3']
|
78
78
|
when /darwin|mac os/
|
79
|
+
ENV['GKSwstype'] ||= 'gksqt'
|
79
80
|
[['libGR3.dylib', 'libGR3.so'], 'gr3']
|
80
81
|
else
|
81
82
|
[['libGR3.so'], 'gr3']
|
82
83
|
end
|
84
|
+
|
85
|
+
# On Windows + RubyInstaller,
|
86
|
+
# the environment variable GKS_FONTPATH will be set.
|
83
87
|
lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
|
84
88
|
|
85
89
|
raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
|