ruby-gr 0.0.21 → 0.0.22

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: 20591722440c58b4cea29effed6bd13debcdc2c0383b40163d5b2fbc3f517f3e
4
- data.tar.gz: 635fa83b40177e1c80936ca7fd949e2f2880c50710565db24e6e049f168d18ea
3
+ metadata.gz: d61176c3d03c6d635adbdc0cec5dd701b2303862405fa63a60815fc03b724054
4
+ data.tar.gz: 405d76e691b88c53d471b2e552f1af310e0a4d4b377c02ecbeac1827e62f5921
5
5
  SHA512:
6
- metadata.gz: b30985a6bc12803fd2aabc590ffaccf4a4b931a5d00bb1c8c443fec90fd60f799560edbe3454532650871a578222c3aafb6d949204fb74b4efc22b3ddc5b197e
7
- data.tar.gz: 61e34d2541e1821f739d5c12be8524b9fbc7e0332223c2c89cda40b0f38fc2eaa3ad695e5dca2fd5c955ee1bc04f07d0c235a7ce6a59f11b093ea7707f68e31f
6
+ metadata.gz: 4d23ae259c265dd3e8ed030a31a7f04ca4e358859e807885cda9f53c2c4b0be5839ccb2464bd4a6c2c9cf5d68fd99665d3f32dd74254ddd2eadfe4fe7123e9e3
7
+ data.tar.gz: 20b3a2dfec804617038a5884e272197d92f6f10069e568b149736d63775054d4d0c29e6f346397338401db44da1a4f3d9d5ba3c3f65a461c38df97ed8d10dc34
data/README.md CHANGED
@@ -28,16 +28,22 @@
28
28
 
29
29
  GR.rb supports Ruby 2.5+.
30
30
 
31
- First, [install GR](#gr-installation). Next, set environment variable `GRDIR`.
31
+ First, [install GR](#gr-installation). Then install `ruby-gr` gem.
32
32
 
33
33
  ```sh
34
- export GRDIR="/your/path/to/gr"
34
+ gem install ruby-gr
35
35
  ```
36
36
 
37
+ Note: If you are using Rubyinstaller(Windows), pacman will automatically install [mingw-w64-gr](https://packages.msys2.org/base/mingw-w64-gr).
38
+
39
+ Set environment variable `GRDIR`.
40
+
37
41
  ```sh
38
- gem install ruby-gr
42
+ export GRDIR="/your/path/to/gr"
39
43
  ```
40
44
 
45
+ Note: 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.
46
+
41
47
  ## Quick Start
42
48
 
43
49
  <p align="center">
@@ -161,10 +167,11 @@ export GRDIR="your/path/to/gr"
161
167
 
162
168
  * macOS Catalina and macOS Mojave: See the "How to open an app that hasn’t been notarized or is from an unidentified developer" section of [Safely open apps on your Mac](https://support.apple.com/en-us/HT202491) in the Apple documentation.
163
169
 
164
- ### Using your package manager
170
+ ### Using package managers
165
171
 
166
172
  * The third party GR packages for Mac, Linux and Windows are available (for advanced users).
167
173
  * If you find any problem, please report the issue [here](https://github.com/red-data-tools/GR.rb/issues).
174
+ * Note: These packages may not have some features, for example, video output.
168
175
 
169
176
  #### Mac - Homebrew
170
177
 
@@ -172,17 +179,11 @@ export GRDIR="your/path/to/gr"
172
179
  brew install libgr
173
180
  ```
174
181
 
175
- Set environment variable `GRDIR`.
176
-
177
- ```sh
178
- export GRDIR=$(brew --prefix libgr)
179
- ```
180
-
181
182
  #### Linux - APT Yum
182
183
 
183
- [packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev` and `libgr3-dev`.
184
+ [packages.red-data-tools.org](https://github.com/red-data-tools/packages.red-data-tools.org) provides `libgr-dev`, `libgr3-dev` and `libgrm-dev`
184
185
 
185
- #### Windows - MSYS2
186
+ ### Windows - MSYS2
186
187
 
187
188
  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.
188
189
 
@@ -192,13 +193,14 @@ GR.rb will be the default backend for [Charty](https://github.com/red-data-tools
192
193
 
193
194
  ## Contributing
194
195
 
195
- * Report bugs
196
- * Fix bugs and submit pull requests
196
+ * [Report bugs](https://github.com/red-data-tools/GR.rb/issues)
197
+ * Fix bugs and [submit pull requests](https://github.com/red-data-tools/GR.rb/pulls)
197
198
  * Write, clarify, or fix documentation
198
199
  * Suggest or add new features
199
- * Create visualization library based on GR.rb
200
+ * Update GR packages ( Homebrew, MinGW, red-data-tools )
201
+ * Create visualization tools based on GR.rb
200
202
 
201
203
  ## Acknowledgements
202
204
 
203
- We would like to thank Josef Heinen, the creator of [GR.jl](https://github.com/jheinen/GR.jl), Florian Rhiem, the creator of [python-gr](https://github.com/sciapp/python-gr), and [GR](https://github.com/sciapp/gr) developers.
205
+ 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.
204
206
 
data/lib/gr.rb CHANGED
@@ -61,9 +61,9 @@ module GR
61
61
  # Ubuntu | lib/libGR.so
62
62
  self.ffi_lib = case RbConfig::CONFIG['host_os']
63
63
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
64
- search_shared_library('libgr.dll')
64
+ search_shared_library('libgr.dll', 'gr')
65
65
  else
66
- search_shared_library('libGR.so')
66
+ search_shared_library('libGR.so', 'gr')
67
67
  end
68
68
 
69
69
  require_relative 'gr/version'
@@ -96,7 +96,12 @@ module GR
96
96
  super
97
97
  end
98
98
 
99
- # inqdspsize
99
+ # Get the current display size.
100
+ # Depending on the current workstation type, the current display might be
101
+ # the primary screen (e.g. when using gksqt or GKSTerm) or a purely virtual
102
+ # display (e.g. when using Cairo). When a high DPI screen is used as the
103
+ # current display, width and height will be in logical pixels.
104
+ # @return [Array] meter_width, meter_height, width, height
100
105
  def inqdspsize
101
106
  inquiry %i[double double int int] do |*pts|
102
107
  super(*pts)
@@ -108,9 +113,7 @@ module GR
108
113
  # @param connection [String] A connection identifier.
109
114
  # @param workstation_type [Integer] The desired workstation type.
110
115
  # * 5 : Workstation Independent Segment Storage
111
- # * 7, 8 : Computer Graphics Metafile (CGM binary, clear text)
112
116
  # * 41 : Windows GDI
113
- # * 51 : Mac Quickdraw
114
117
  # * 61 - 64 : PostScript (b/w, color)
115
118
  # * 101, 102 : Portable Document Format (plain, compressed)
116
119
  # * 210 - 213 : X Windows
@@ -131,7 +134,6 @@ module GR
131
134
  # * 410 : Socket driver
132
135
  # * 415 : 0MQ driver
133
136
  # * 420 : OpenGL
134
- # * 430 : HTML5 Canvas
135
137
  def openws(*)
136
138
  super
137
139
  end
@@ -154,6 +156,7 @@ module GR
154
156
  super
155
157
  end
156
158
 
159
+ # Configure the specified workstation.
157
160
  def configurews(*)
158
161
  super
159
162
  end
@@ -295,6 +298,7 @@ module GR
295
298
  super(n, x, y, m, method)
296
299
  end
297
300
 
301
+ # Interpolate data from arbitrary points at points on a rectangular grid.
298
302
  def gridit(xd, yd, zd, nx, ny)
299
303
  nd = equal_length(xd, yd, zd)
300
304
  inquiry [{ double: nx }, { double: ny }, { double: nx * ny }] do |px, py, pz|
@@ -356,7 +360,6 @@ module GR
356
360
  super
357
361
  end
358
362
 
359
- # inqlinecolorind
360
363
  def inqlinecolorind
361
364
  inquiry_int { |pt| super(pt) }
362
365
  end
@@ -516,7 +519,9 @@ module GR
516
519
  # The appearance of a font depends on the text precision value specified.
517
520
  # STRING, CHARACTER or STROKE precision allows for a greater or lesser
518
521
  # realization of the text primitives, for efficiency. STRING is the default
519
- # precision for GR and produces the highest quality output.
522
+ # precision for GR and produces the highest quality output using either
523
+ # native font rendering or FreeType. OUTLINE uses the GR path rendering
524
+ # functions to draw individual glyphs and produces the highest quality output.
520
525
  def settextfontprec(*)
521
526
  super
522
527
  end
@@ -627,6 +632,8 @@ module GR
627
632
  # * Fill the interior of the polygon using the style index as a pattern index
628
633
  # * 3 : HATCH
629
634
  # * Fill the interior of the polygon using the style index as a cross-hatched style
635
+ # * 4 : SOLID_WITH_BORDER
636
+ # * Fill the interior of the polygon using the fill color index and draw the bounding polyline
630
637
  # `setfillintstyle` defines the interior style for subsequent fill area output
631
638
  # primitives. The default interior style is HOLLOW.
632
639
  def setfillintstyle(*)
@@ -650,6 +657,7 @@ module GR
650
657
  end
651
658
 
652
659
  # Returns the current fill area color index.
660
+ # This function gets the color index for PATTERN and HATCH fills.
653
661
  def inqfillstyle
654
662
  inquiry_int { |pt| super(pt) }
655
663
  end
@@ -663,6 +671,7 @@ module GR
663
671
  end
664
672
 
665
673
  # Returns the current fill area color index.
674
+ # This function gets the color of fill area output primitives.
666
675
  def inqfillcolorind
667
676
  inquiry_int { |pt| super(pt) }
668
677
  end
@@ -937,12 +946,40 @@ module GR
937
946
  # coordinate unit. Major tick marks are twice as long as minor tick marks.
938
947
  # A negative value reverses the tick marks on the axes from inward facing
939
948
  # to outward facing (or vice versa).
949
+ # Tick marks are positioned along each axis so that major tick marks fall on
950
+ # the axes origin (whether visible or not). Major tick marks are labeled
951
+ # with the corresponding data values. Axes are drawn according to the scale
952
+ # of the window. Axes and tick marks are drawn using solid lines; line color
953
+ # and width can be modified using the gr_setlinetype and gr_setlinewidth
954
+ # functions. Axes are drawn according to the linear or logarithmic
955
+ # transformation established by the gr_setscale function.
940
956
  def axes(*)
941
957
  super
942
958
  end
943
959
 
944
960
  alias axes2d axes
945
961
 
962
+ # Create axes in the current workspace and supply a custom function for
963
+ # changing the behaviour of the tick labels.
964
+ # @param x_tick [Numeric] The interval between minor tick marks on the X axis.
965
+ # @param y_tick [Numeric] The interval between minor tick marks on the Y axis.
966
+ # @param x_org [Numeric] The world coordinate of the origin (point of intersection) of the X axis.
967
+ # @param y_org [Numeric] The world coordinate of the origin (point of intersection) of the Y axis.
968
+ # @param major_x [Integer] Unitless integer value specifying the number of minor tick intervals between major tick marks on the X axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.
969
+ # @param major_y [Integer] Unitless integer value specifying the number of minor tick intervals between major tick marks on the Y axis. Values of 0 or 1 imply no minor ticks. Negative values specify no labels will be drawn for the associated axis.
970
+ # @param tick_size [Numeric] The length of minor tick marks specified in a normalized device coordinate unit. Major tick marks are twice as long as minor tick marks. A negative value reverses the tick marks on the axes from inward facing to outward facing (or vice versa).
971
+ # @param fpx [Pointer] Function pointer to a function that returns a label for a given tick on the X axis. The callback function should have the following arguments [Numeric]
972
+ # @param fpy [Pointer] Exactly same as the fpx above, but for the the Y axis.
973
+ # Similar to gr_axes() but allows more fine-grained control over tick labels
974
+ # and text positioning by supplying callback functions. Within the callback
975
+ # function you can use normal GR text primitives for performing any
976
+ # manipulations on the label text.
977
+ # See gr_axes() for more details on drawing axes.
978
+ # * fpx/fpy
979
+ # * param x [Numeric] NDC of the label in X direction.
980
+ # * param y [Numeric] NDC of the label in Y direction.
981
+ # * param svalue [String] Internal string representation of the text drawn by GR at (x,y).
982
+ # * param value [Numeric] Floating point representation of the label drawn at (x,y).
946
983
  def axeslbl(*)
947
984
  super
948
985
  end
data/lib/gr3.rb CHANGED
@@ -69,9 +69,9 @@ module GR3
69
69
  # Ubuntu | lib/libGR3.so
70
70
  self.ffi_lib = case RbConfig::CONFIG['host_os']
71
71
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
72
- search_shared_library('libGR3.dll')
72
+ search_shared_library('libGR3.dll', 'gr3')
73
73
  else
74
- search_shared_library('libGR3.so')
74
+ search_shared_library('libGR3.so', 'gr3')
75
75
  end
76
76
 
77
77
  require_relative 'gr3/version'
@@ -1,6 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pkg-config'
4
+
1
5
  module GRCommons
6
+ # This module helps GR, GR and GRM to search the shared library.
7
+ #
8
+ # The order of priority:
9
+ # 1. RubyInstaller ( for Windows only )
10
+ # 2. Environment variable GRDIR
11
+ # 3. pkg-config : https://github.com/ruby-gnome/pkg-config
12
+ # The following packages (should) support pkg-config.
13
+ # - Linux
14
+ # - Red Data Tools https://github.com/red-data-tools/packages.red-data-tools.org
15
+ # - libgr-dev
16
+ # - libgr3-dev
17
+ # - libgrm-dev
18
+ # - Mac
19
+ # - Homebrew https://github.com/Homebrew/homebrew-core
20
+ # - libgr
21
+ # - Windows
22
+ # - MinGW https://github.com/msys2/MINGW-packages
23
+ # - mingw-w64-gr
2
24
  module SearchSharedLibrary
3
- def search_shared_library(gr_lib_name)
25
+ # Search the shared library.
26
+ # @note This method does not detect the Operating System.
27
+ #
28
+ # @param gr_lib_name [String] The actual file name of the shared library.
29
+ # @param pkg_name [String] The package name to be used when searching with pkg-configg
30
+ def search_shared_library(gr_lib_name, pkg_name)
31
+ # Windows + RubyInstaller
4
32
  if Object.const_defined?(:RubyInstaller)
5
33
  ENV['GRDIR'] ||= [
6
34
  RubyInstaller::Runtime.msys2_installation.msys_path,
@@ -9,23 +37,37 @@ module GRCommons
9
37
  recursive_search(gr_lib_name, ENV['GRDIR']).tap do |path|
10
38
  RubyInstaller::Runtime.add_dll_directory(File.dirname(path))
11
39
  end
12
- else
13
- unless ENV['GRDIR']
14
- warn 'Please set environment variable GRDIR'
15
- exit 1
40
+ # ENV['GRDIR'] (Linux, Mac, Windows)
41
+ elsif ENV['GRDIR']
42
+ begin
43
+ recursive_search(gr_lib_name, ENV['GRDIR'])
44
+ rescue StandardError => e
45
+ warn "\nWhile searching for #{gr_lib_name} in the directory specified " \
46
+ "in the GRDIR environment variable, ENV['GRDIR']=#{ENV['GRDIR']}, " \
47
+ "the following error occurred : #{e.message}"
48
+ pkg_config_search(gr_lib_name, pkg_name)
16
49
  end
17
- recursive_search(gr_lib_name, ENV['GRDIR'])
50
+ else
51
+ pkg_config_search(gr_lib_name, pkg_name)
18
52
  end
19
53
  end
20
54
 
21
55
  def recursive_search(name, base_dir)
22
56
  Dir.chdir(base_dir) do
23
- if path = Dir["**/#{name}"].first
57
+ if path = Dir["**/#{name}"].first # FIXME
24
58
  File.expand_path(path)
25
59
  else
26
- raise StandardError '#{name} not found in #{base_dir}'
60
+ raise StandardError "#{name} not found in #{base_dir}"
27
61
  end
28
62
  end
29
63
  end
64
+
65
+ def pkg_config_search(gr_lib_name, pkg_name)
66
+ PKGConfig.variable(pkg_name, 'sopath')
67
+ rescue NotFoundError => e
68
+ warn "Cannot find #{gr_lib_name}."
69
+ warn 'Please set environment variable GRDIR.'
70
+ raise e
71
+ end
30
72
  end
31
73
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GRCommons
4
- VERSION = '0.0.21'
4
+ VERSION = '0.0.22'
5
5
  end
data/lib/grm.rb CHANGED
@@ -30,9 +30,9 @@ module GRM
30
30
  # Ubuntu | lib/libGRM.so
31
31
  self.ffi_lib = case RbConfig::CONFIG['host_os']
32
32
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
33
- search_shared_library('libGRM.dll')
33
+ search_shared_library('libGRM.dll', 'grm')
34
34
  else
35
- search_shared_library('libGRM.so')
35
+ search_shared_library('libGRM.so', 'grm')
36
36
  end
37
37
 
38
38
  require_relative 'grm/version'
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.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: histogram
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pkg-config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement