ruby-gr 0.58.1.0 → 0.61.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f620965108eafb5f65fc8b1c946db5abea180708db175b88246a2ecd97a66b53
4
- data.tar.gz: 8ff0c1b787c4b3e70a29ace39eb2fb39abaf60d71afc05b4b382edfcb6f570fa
3
+ metadata.gz: bacbabae072c86f3b7b227a82043d4ff8e0aaad4df9da3234582270491790d4c
4
+ data.tar.gz: 033e92c26281e32cc5b4a9d42d79c56953fac00b1da5a9479b472ce94f77c995
5
5
  SHA512:
6
- metadata.gz: cb816d775831c8e05f43e0ded3d15a22328ff0b7e5810c484782393b4fe06ee5aa03fbf431b3cbbe6c8bac2763b07ef377e42dd5d9024da1aec819251b264951
7
- data.tar.gz: 9e12f1fa434d64b1f202a3198afa30be70ee1b4961493cde92d308134b146703ff21e2e1915cd01ed286f476f7e6900425aaa5ebdc8f1b33fd550a3d3567a14f
6
+ metadata.gz: f181ff21a1254fd0791ec2e8862586be634b2ecdb4e5bec76298e22b5bf7dd59e727159cfc9c9b2fde6fc739b99cb889f25041b3592dad93ca2c1b183cb8153e
7
+ data.tar.gz: b4441cc2dbc8f2e7067d80c13407feff556f8fcb5cdb993b936df797ccfd8edd67c9db98a17fff9bf62c7a2f546877e065ba38f6bd0752e2d743473c5cbbeebd
data/README.md CHANGED
@@ -188,31 +188,20 @@ macOS : Please the section "How to open apps from un-notarized or unidentified
188
188
 
189
189
  ```sh
190
190
  brew install libgr
191
- export GKS_WSTYPE=411 # gksqt (recommended)
192
191
  ```
193
192
 
194
- #### Linux - APT
195
-
196
- [packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev`, `libgr3-dev` and `libgrm-dev`
197
-
198
- Debian GNU/Linux and Ubuntu
193
+ Set the workstation type to gksqt.
199
194
 
200
195
  ```sh
201
- sudo apt install -y -V ca-certificates lsb-release wget
202
- wget https://packages.red-data-tools.org/$(lsb_release --id --short | tr 'A-Z' 'a-z'\
203
- )/red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
204
- sudo apt install -y -V ./red-data-tools-apt-source-latest-$(lsb_release --codename --short).deb
205
- sudo apt update
206
- sudo apt install libgrm-dev
196
+ export GKS_WSTYPE=411 # gksqt (recommended)
207
197
  ```
208
198
 
209
- #### Linux - Yum
199
+ #### Linux - openSUSE Build service
210
200
 
211
- CentOS
201
+ 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).
212
202
 
213
203
  ```sh
214
- (. /etc/os-release && sudo dnf install -y https://packages.red-data-tools.org/centos/${VERSION_ID}/red-data-tools-release-latest.noarch.rpm)
215
- sudo dnf install -y gr-devel
204
+ export GRDIR="/usr/gr" # Check the location with `dpkg -L gr`
216
205
  ```
217
206
 
218
207
  #### Windows - MSYS2
@@ -244,7 +233,7 @@ bundle exec rake test
244
233
 
245
234
  ## Future plans
246
235
 
247
- * GR.rb will be the default backend for [Charty](https://github.com/red-data-tools/charty).
236
+ * Creating a backend for [Charty](https://github.com/red-data-tools/charty).
248
237
  * [Object-oriented interface](https://github.com/kojix2/GRUtils.rb) based on [GRUtils.jl](https://github.com/heliosdrm/GRUtils.jl).
249
238
 
250
239
  ## Acknowledgements
data/lib/gr/ffi.rb CHANGED
@@ -209,5 +209,13 @@ module GR
209
209
  try_extern 'void gr_inqtextencoding(int *)'
210
210
  try_extern 'void gr_loadfont(char *, int *)'
211
211
  # gr_setcallback(char *(*)(const char *));
212
+ try_extern 'void gr_setthreadnumber(int)'
213
+ try_extern 'void gr_setpicturesizeforvolume(int, int)'
214
+ try_extern 'void gr_setvolumebordercalculation(int)'
215
+ try_extern 'void gr_setapproximativecalculation(int)'
216
+ try_extern 'void gr_inqvolumeflags(int *, int *, int *, int *, int *)'
217
+ try_extern 'void gr_cpubasedvolume(int, int, int, double *, int, double *, double *, double *, double *)'
218
+ try_extern 'void gr_inqvpsize(int *, int *, double *)'
219
+ try_extern 'void gr_polygonmesh3d(int, const double *, const double *, const double *, int, const int *, const int *)'
212
220
  end
213
221
  end
data/lib/gr/plot.rb CHANGED
@@ -89,7 +89,8 @@ module GR
89
89
  attr_accessor :args, :kvs, :scheme
90
90
 
91
91
  def initialize(*raw_args)
92
- @kvs = raw_args.last.is_a?(Hash) ? raw_args.pop : {}
92
+ # Keywords are cloned to avoid disruptive changes
93
+ @kvs = raw_args.last.is_a?(Hash) ? raw_args.pop.clone : {}
93
94
  @args = plot_args(raw_args) # method name is the same as Julia/Python
94
95
 
95
96
  # Check keyword options.
@@ -324,7 +325,7 @@ module GR
324
325
  def draw_axes(kind, pass = 1)
325
326
  viewport = kvs[:viewport]
326
327
  vp = kvs[:vp]
327
- ratio = kvs[:ratio]
328
+ _ratio = kvs[:ratio]
328
329
  xtick, xorg, majorx = kvs[:xaxis]
329
330
  ytick, yorg, majory = kvs[:yaxis]
330
331
  drawgrid = kvs.has_key?(:grid) ? kvs[:grid] : true
@@ -1161,7 +1162,8 @@ module GR
1161
1162
  xmin = [x0, xmin].min
1162
1163
  xmax = [x1, xmax].max
1163
1164
  elsif kind == :volume
1164
- xmin, xmax = -1, 1
1165
+ xmin = -1
1166
+ xmax = 1
1165
1167
  else
1166
1168
  xmin = 0
1167
1169
  xmax = 1
@@ -1174,7 +1176,8 @@ module GR
1174
1176
  ymin = [y0, ymin].min
1175
1177
  ymax = [y1, ymax].max
1176
1178
  elsif kind == :volume
1177
- ymin, ymax = -1, 1
1179
+ ymin = -1
1180
+ ymax = 1
1178
1181
  else
1179
1182
  ymin = 0
1180
1183
  ymax = 1
@@ -1228,7 +1231,7 @@ module GR
1228
1231
  i = tick_size.find_index do |tsize|
1229
1232
  ((amax - amin) / scale / tsize) > 7 # maximum number of tick marks
1230
1233
  end
1231
- tick = tick_size[i - 1] * scale
1234
+ tick_size[i - 1] * scale
1232
1235
  end
1233
1236
 
1234
1237
  def legend_size
data/lib/gr.rb CHANGED
@@ -66,6 +66,7 @@ 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']
@@ -1703,7 +1704,7 @@ module GR
1703
1704
  def readimage(path)
1704
1705
  # Feel free to make a pull request if you catch a mistake
1705
1706
  # or you have an idea to improve it.
1706
- data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
1707
+ data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T, Fiddle::RUBY_FREE)
1707
1708
  w, h = inquiry [:int, :int] do |width, height|
1708
1709
  # data is a pointer of a pointer
1709
1710
  super(path, width, height, data.ref)
@@ -1841,7 +1842,7 @@ module GR
1841
1842
  # Feel free to make a pull request if you catch a mistake
1842
1843
  # or you have an idea to improve it.
1843
1844
  npoints = equal_length(x, y)
1844
- triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T)
1845
+ triangles = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INTPTR_T, Fiddle::RUBY_FREE)
1845
1846
  dim = 3
1846
1847
  n_tri = inquiry_int do |ntri|
1847
1848
  super(npoints, x, y, ntri, triangles.ref)
@@ -2148,9 +2149,9 @@ module GR
2148
2149
  #
2149
2150
  # @param flag [Integer] projection type
2150
2151
  # The available options are:
2151
- # * 0 : GR_PROJECTION_DEFAULT - default
2152
- # * 1 : GR_PROJECTION_ORTHOGRAPHIC - orthographic
2153
- # * 2 : GR_PROJECTION_PERSPECTIVE - perspective
2152
+ # * 0 : PROJECTION_DEFAULT - default
2153
+ # * 1 : PROJECTION_ORTHOGRAPHIC - orthographic
2154
+ # * 2 : PROJECTION_PERSPECTIVE - perspective
2154
2155
  #
2155
2156
  # @!method setprojectiontype
2156
2157
 
@@ -2314,6 +2315,76 @@ module GR
2314
2315
  super(str, font)
2315
2316
  end
2316
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
2317
2388
  end
2318
2389
 
2319
2390
  ASF_BUNDLED = 0
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,7 @@ 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)'
143
147
  end
144
148
  end
data/lib/gr3.rb CHANGED
@@ -76,6 +76,7 @@ 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']
@@ -188,7 +188,7 @@ module GRCommons
188
188
  @size = @ptr.size
189
189
  else
190
190
  @size = type2size(type) * num
191
- @ptr = Fiddle::Pointer.malloc(@size)
191
+ @ptr = Fiddle::Pointer.malloc(@size, Fiddle::RUBY_FREE)
192
192
  end
193
193
  end
194
194
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.58.1.0'
4
+ VERSION = '0.61.0.0'
5
5
  end
data/lib/grm.rb CHANGED
@@ -35,6 +35,7 @@ module GRM
35
35
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
36
36
  [['libGRM.dll'], 'grm']
37
37
  when /darwin|mac os/
38
+ ENV['GKSwstype'] ||= 'gksqt'
38
39
  [['libGRM.dylib', 'libGRM.so'], 'grm']
39
40
  else
40
41
  [['libGRM.so'], 'grm']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.58.1.0
4
+ version: 0.61.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: histogram
@@ -52,90 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 12.3.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 12.3.3
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: simplecov
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: test-unit
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
55
  description: GR framework - the graphics library for visualisation - for Ruby
140
56
  email: 2xijok@gmail.com
141
57
  executables: []
@@ -186,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
102
  - !ruby/object:Gem::Version
187
103
  version: '0'
188
104
  requirements: []
189
- rubygems_version: 3.2.22
105
+ rubygems_version: 3.2.26
190
106
  signing_key:
191
107
  specification_version: 4
192
108
  summary: GR for Ruby