ruby-gr 0.0.21 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/lib/gr/ffi.rb CHANGED
@@ -15,7 +15,7 @@ module GR
15
15
  raise LoadError, 'Could not find GR Framework'
16
16
  end
17
17
 
18
- extend GRCommons::Extern
18
+ extend GRCommons::TryExtern
19
19
 
20
20
  # https://github.com/sciapp/gr/blob/master/lib/gr/gr.h
21
21
  # keep same order
@@ -41,6 +41,8 @@ module GR
41
41
  'int, int, int, int, int, int, int *)'
42
42
  try_extern 'void gr_polarcellarray(double, double, double, double, double, double, ' \
43
43
  'int, int, int, int, int, int, int *)'
44
+ try_extern 'void gr_nonuniformpolarcellarray(double, double, double *, double *, ' \
45
+ 'int, int, int, int, int, int, int *);'
44
46
  try_extern 'void gr_gdp(int, double *, double *, int, int, int *)'
45
47
  try_extern 'void gr_spline(int, double *, double *, int, int)'
46
48
  try_extern 'void gr_gridit(int, double *, double *, double *, int, int, ' \
@@ -174,7 +176,7 @@ module GR
174
176
  try_extern 'void gr_shadepoints(int, double *, double *, int, int, int)'
175
177
  try_extern 'void gr_shadelines(int, double *, double *, int, int, int)'
176
178
  try_extern 'void gr_panzoom(double, double, double, double, double *, double *, double *, double *)'
177
- # try_extern 'int gr_findboundary(int, double *, double *, double, double (*)(double, double), int, int *)'
179
+ try_extern 'int gr_findboundary(int, double *, double *, double, double (*)(double, double), int, int *)'
178
180
  try_extern 'void gr_setresamplemethod(unsigned int flag)'
179
181
  try_extern 'void gr_inqresamplemethod(unsigned int *flag)'
180
182
  try_extern 'void gr_path(int, double *, double *, const char *)'
@@ -182,6 +184,8 @@ module GR
182
184
  try_extern 'void gr_inqborderwidth(double *)'
183
185
  try_extern 'void gr_setbordercolorind(int)'
184
186
  try_extern 'void gr_inqbordercolorind(int *)'
187
+ try_extern 'void gr_selectclipxform(int)'
188
+ try_extern 'void gr_inqclipxform(int *);'
185
189
  try_extern 'void gr_setprojectiontype(int)'
186
190
  try_extern 'void gr_inqprojectiontype(int *)'
187
191
  try_extern 'void gr_setperspectiveprojection(double, double, double)'
@@ -202,5 +206,7 @@ module GR
202
206
  try_extern 'void gr_inqtext3d(double, double, double, char *, int axis, double *, double *)'
203
207
  try_extern 'void gr_settextencoding(int)'
204
208
  try_extern 'void gr_inqtextencoding(int *)'
209
+ try_extern 'void gr_loadfont(char *, int *)'
210
+ # gr_setcallback(char *(*)(const char *));
205
211
  end
206
212
  end
data/lib/gr/plot.rb CHANGED
@@ -33,17 +33,53 @@ module GR
33
33
  # Plot kinds conform to GR.jl
34
34
  PLOT_KIND = %i[line step scatter stem hist contour contourf hexbin heatmap
35
35
  nonuniformheatmap wireframe surface plot3 scatter3 imshow
36
- isosurface polar polarhist polarheatmap trisurf tricont shade
37
- volume].freeze # the name might be changed in the future.
36
+ isosurface polar polarhist polarheatmap nonuniformpolarheatmap
37
+ trisurf tricont shade volume].freeze
38
38
 
39
39
  # Keyword options conform to GR.jl.
40
40
  KW_ARGS = %i[accelerate algorithm alpha ax backgroundcolor barwidth baseline
41
- clabels clear clim color colormap crange figsize grid horizontal
42
- isovalue kind label labels levels location nbins ratio rotation
43
- scale size spec subplot tilt title update xaxis xflip xform
44
- xlabel xlim xlog xrange xticks yaxis yflip ylabel ylim ylog
45
- zflip yrange yticks viewport vp where window zaxis zlabel zlim
46
- zlog zrange zticks].freeze
41
+ clabels clear clim color colormap crange figsize font grid
42
+ horizontal isovalue kind label labels levels location nbins
43
+ ratio rotation scale size spec subplot tilt title update xaxis
44
+ xflip xform xlabel xlim xlog xrange xticks yaxis yflip ylabel
45
+ ylim ylog zflip yrange yticks viewport vp where window zaxis
46
+ zlabel zlim zlog zrange zticks].freeze
47
+
48
+ FONTS = {
49
+ times_roman: 101,
50
+ times_italic: 102,
51
+ times_bold: 103,
52
+ times_bolditalic: 104,
53
+ helvetica_regular: 105,
54
+ helvetica_oblique: 106,
55
+ helvetica_bold: 107,
56
+ helvetica_boldoblique: 108,
57
+ courier_regular: 109,
58
+ courier_oblique: 110,
59
+ courier_bold: 111,
60
+ courier_boldoblique: 112,
61
+ symbol: 113,
62
+ bookman_light: 114,
63
+ bookman_lightitalic: 115,
64
+ bookman_demi: 116,
65
+ bookman_demiitalic: 117,
66
+ newcenturyschlbk_roman: 118,
67
+ newcenturyschlbk_italic: 119,
68
+ newcenturyschlbk_bold: 120,
69
+ newcenturyschlbk_bolditalic: 121,
70
+ avantgarde_book: 122,
71
+ avantgarde_bookoblique: 123,
72
+ avantgarde_demi: 124,
73
+ avantgarde_demioblique: 125,
74
+ palatino_roman: 126,
75
+ palatino_italic: 127,
76
+ palatino_bold: 128,
77
+ palatino_bolditalic: 129,
78
+ zapfchancery_mediumitalic: 130,
79
+ zapfdingbats: 131,
80
+ cmuserif_math: 232, # original: cmuserif-math
81
+ dejavusans: 233
82
+ }.freeze
47
83
 
48
84
  @last_plot = nil
49
85
  class << self
@@ -122,7 +158,7 @@ module GR
122
158
  vp3 + 0.925 * (vp4 - vp3)]
123
159
 
124
160
  if %i[contour contourf hexbin heatmap nonuniformheatmap polarheatmap
125
- surface trisurf volume].include?(kind)
161
+ nonuniformpolarheatmap surface trisurf volume].include?(kind)
126
162
  viewport[1] -= 0.1
127
163
  end
128
164
 
@@ -156,7 +192,7 @@ module GR
156
192
  GR.restorestate
157
193
  end
158
194
 
159
- if %i[polar polarhist polarheatmap].include? kind
195
+ if %i[polar polarhist polarheatmap nonuniformpolarheatmap].include? kind
160
196
  xmin, xmax, ymin, ymax = viewport
161
197
  xcenter = 0.5 * (xmin + xmax)
162
198
  ycenter = 0.5 * (ymin + ymax)
@@ -167,7 +203,7 @@ module GR
167
203
 
168
204
  def set_window(kind)
169
205
  scale = 0
170
- unless %i[polar polarhist polarheatmap].include?(kind)
206
+ unless %i[polar polarhist polarheatmap nonuniformpolarheatmap].include?(kind)
171
207
  scale |= GR::OPTION_X_LOG if kvs[:xlog]
172
208
  scale |= GR::OPTION_Y_LOG if kvs[:ylog]
173
209
  scale |= GR::OPTION_Z_LOG if kvs[:zlog]
@@ -186,7 +222,7 @@ module GR
186
222
  end
187
223
 
188
224
  major_count = if %i[wireframe surface plot3 scatter3 polar polarhist
189
- polarheatmap trisurf volume].include?(kind)
225
+ polarheatmap nonuniformpolarheatmap trisurf volume].include?(kind)
190
226
  2
191
227
  else
192
228
  5
@@ -202,10 +238,10 @@ module GR
202
238
  xmax += 0.5
203
239
  end
204
240
  xtick, majorx = if (scale & GR::OPTION_X_LOG) == 0
205
- unless %i[heatmap polarheatmap].include?(kind)
206
- unless kvs.has_key?(:xlim)
207
- xmin, xmax = GR.adjustlimits(xmin, xmax) unless kvs[:panzoom]
208
- end
241
+ if !%i[heatmap polarheatmap].include?(kind) &&
242
+ !kvs.has_key?(:xlim) &&
243
+ !kvs[:panzoom]
244
+ xmin, xmax = GR.adjustlimits(xmin, xmax)
209
245
  end
210
246
  if kvs.has_key?(:xticks)
211
247
  kvs[:xticks]
@@ -231,10 +267,10 @@ module GR
231
267
  end
232
268
  end
233
269
  ytick, majory = if (scale & GR::OPTION_Y_LOG) == 0
234
- unless %i[heatmap polarheatmap].include?(kind)
235
- unless kvs.has_key?(:ylim)
236
- ymin, ymax = GR.adjustlimits(ymin, ymax) unless kvs[:panzoom]
237
- end
270
+ if !%i[heatmap polarheatmap].include?(kind) &&
271
+ !kvs.has_key?(:ylim) &&
272
+ !kvs[:panzoom]
273
+ ymin, ymax = GR.adjustlimits(ymin, ymax)
238
274
  end
239
275
  if kvs.has_key?(:yticks)
240
276
  kvs[:yticks]
@@ -264,7 +300,7 @@ module GR
264
300
  end
265
301
 
266
302
  kvs[:window] = xmin, xmax, ymin, ymax
267
- if %i[polar polarhist polarheatmap].include?(kind)
303
+ if %i[polar polarhist polarheatmap nonuniformpolarheatmap].include?(kind)
268
304
  GR.setwindow(-1, 1, -1, 1)
269
305
  else
270
306
  GR.setwindow(xmin, xmax, ymin, ymax)
@@ -345,29 +381,29 @@ module GR
345
381
  GR.axes(xtick, ytick, xorg[1], yorg[1], -majorx, -majory, -ticksize)
346
382
  end
347
383
 
348
- if kvs[:title]
384
+ if kvs.has_key?(:title)
349
385
  GR.savestate
350
386
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
351
- text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
387
+ text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
352
388
  GR.restorestate
353
389
  end
354
390
  if %i[wireframe surface plot3 scatter3 trisurf volume].include?(kind)
355
- xlabel = kvs[:xlabel] || ''
356
- ylabel = kvs[:ylabel] || ''
357
- zlabel = kvs[:zlabel] || ''
391
+ xlabel = (kvs[:xlabel] || '').to_s
392
+ ylabel = (kvs[:ylabel] || '').to_s
393
+ zlabel = (kvs[:zlabel] || '').to_s
358
394
  GR.titles3d(xlabel, ylabel, zlabel)
359
395
  else
360
396
  if kvs.has_key?(:xlabel)
361
397
  GR.savestate
362
398
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_BOTTOM)
363
- text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel])
399
+ text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel].to_s)
364
400
  GR.restorestate
365
401
  end
366
402
  if kvs.has_key?(:ylabel)
367
403
  GR.savestate
368
404
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
369
405
  GR.setcharup(-1, 0)
370
- text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel])
406
+ text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel].to_s)
371
407
  GR.restorestate
372
408
  end
373
409
  end
@@ -475,7 +511,7 @@ module GR
475
511
  if kvs.has_key?(:title)
476
512
  GR.savestate
477
513
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
478
- text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
514
+ text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
479
515
  GR.restorestate
480
516
  end
481
517
  GR.selntran(1)
@@ -577,16 +613,34 @@ module GR
577
613
  # Not yet.
578
614
  end
579
615
 
580
- # The following fonts are the default in GR.jl
581
- # Japanese, Chinese, Korean, etc. cannot be displayed.
582
- # GR.settextfontprec(232, 3) # CM Serif Roman
616
+ if kvs.has_key?(:font)
617
+ name = kvs[:font]
618
+ # 'Cmuserif-Math' => :cmuserif_math
619
+ sym_name = name.to_s.gsub('-', '_').downcase.to_sym
620
+ if FONTS.include?(sym_name)
621
+ font = FONTS[sym_name]
622
+ GR.settextfontprec(font, font > 200 ? 3 : 0)
623
+ else
624
+ font = GR.loadfont(name)
625
+ if font >= 0
626
+ GR.settextfontprec(font, 3)
627
+ else
628
+ warn "Unknown font name: #{name}"
629
+ end
630
+ end
631
+ else
632
+ # The following fonts are the default in GR.jl
633
+ # Japanese, Chinese, Korean, etc. cannot be displayed.
634
+
635
+ # GR.settextfontprec(232, 3) # CM Serif Roman
636
+ end
583
637
 
584
638
  set_viewport(kind, kvs[:subplot])
585
639
  unless kvs[:ax]
586
640
  set_window(kind)
587
641
  if %i[polar polarhist].include?(kind)
588
642
  draw_polar_axes
589
- elsif !%i[imshow isosurface polarheatmap].include?(kind)
643
+ elsif !%i[imshow isosurface polarheatmap nonuniformpolarheatmap].include?(kind)
590
644
  draw_axes(kind)
591
645
  end
592
646
  end
@@ -707,7 +761,7 @@ module GR
707
761
  GR.fillarc(-ρ[i], ρ[i], -ρ[i], ρ[i], θ[i - 1], θ[i])
708
762
  end
709
763
 
710
- when :polarheatmap
764
+ when :polarheatmap, :nonuniformpolarheatmap
711
765
  w, h = z.shape
712
766
  cmap = colormap
713
767
  cmin, cmax = kvs[:zrange]
@@ -716,7 +770,15 @@ module GR
716
770
  data.reverse(axis: 1) if kvs[:yflip]
717
771
  colors = data * 255 + 1000
718
772
  colors = colors.transpose # Julia is column major
719
- GR.polarcellarray(0, 0, 0, 360, 0, 1, w, h, colors)
773
+ case kind
774
+ when :polarheatmap
775
+ GR.polarcellarray(0, 0, 0, 360, 0, 1, w, h, colors)
776
+ when :nonuniformpolarheatmap
777
+ ymax = y.max.to_f
778
+ ρ = y.map{|i| i / ymax}
779
+ θ = x.map { |i| i * 180 / Math::PI }
780
+ GR.nonuniformpolarcellarray(θ, ρ, w, h, colors)
781
+ end
720
782
  draw_polar_axes
721
783
  kvs[:zrange] = [cmin, cmax]
722
784
  colorbar
@@ -748,9 +810,10 @@ module GR
748
810
  else
749
811
  h = levels
750
812
  end
751
- if kind == :contour
813
+ case kind
814
+ when :contour
752
815
  GR._contour_(x, y, h, z, clabels ? 1 : 1000)
753
- elsif kind == :contourf
816
+ when :contourf
754
817
  GR._contourf_(x, y, h, z, clabels ? 1 : 0)
755
818
  end
756
819
  colorbar(0, h.length)
@@ -972,7 +1035,7 @@ module GR
972
1035
 
973
1036
  def to_svg
974
1037
  ## Need IRuby improvemend.
975
- GR.show(false) if ENV['GKSwstype'] == 'svg'
1038
+ GR.show(false) if ENV['GKS_WSTYPE'] == 'svg'
976
1039
  end
977
1040
 
978
1041
  private
@@ -1054,6 +1117,7 @@ module GR
1054
1117
  end
1055
1118
 
1056
1119
  def inqtext(x, y, s)
1120
+ s = s.to_s
1057
1121
  if s.length >= 2 && s[0] == '$' && s[-1] == '$'
1058
1122
  GR.inqmathtex(x, y, s[1..-2])
1059
1123
  elsif s.include?('\\') || s.include?('_') || s.include?('^')
@@ -1064,6 +1128,7 @@ module GR
1064
1128
  end
1065
1129
 
1066
1130
  def text(x, y, s)
1131
+ s = s.to_s
1067
1132
  if s.length >= 2 && s[0] == '$' && s[-1] == '$'
1068
1133
  GR.mathtex(x, y, s[1..-2])
1069
1134
  elsif s.include?('\\') || s.include?('_') || s.include?('^')
@@ -1163,20 +1228,12 @@ module GR
1163
1228
  [w, h]
1164
1229
  end
1165
1230
 
1166
- # NOTE: duplicated definition (GRCommonUtils)
1167
1231
  def equal_length(*args)
1168
- lengths = args.map(&:length)
1169
- unless lengths.all? { |l| l == lengths[0] }
1170
- raise ArgumentError,
1171
- 'Sequences must have same length.'
1172
- end
1173
-
1174
- lengths[0]
1232
+ GRCommons::GRCommonUtils.equal_length(*args)
1175
1233
  end
1176
1234
 
1177
- # NOTE: duplicated definition (GRCommonUtils)
1178
1235
  def narray?(data)
1179
- defined?(Numo::NArray) && data.is_a?(Numo::NArray)
1236
+ GRCommons::GRCommonUtils.narray?(data)
1180
1237
  end
1181
1238
  end
1182
1239
 
@@ -1240,6 +1297,20 @@ module GR
1240
1297
  end
1241
1298
  end
1242
1299
 
1300
+ # (Plot) Draw a nonuniformpolarheatmap.
1301
+ def nonuniformpolarheatmap(*args)
1302
+ # FIXME
1303
+ args, kv = format_xyzc(*args)
1304
+ _x, _y, z = args
1305
+ ysize, xsize = z.shape
1306
+ z = z.reshape(xsize, ysize)
1307
+ create_plot(:nonuniformpolarheatmap, kv) do |plt|
1308
+ plt.kvs[:xlim] ||= [0.5, xsize + 0.5]
1309
+ plt.kvs[:ylim] ||= [0.5, ysize + 0.5]
1310
+ plt.args = [[(1..xsize).to_a, (1..ysize).to_a, z, nil, '']]
1311
+ end
1312
+ end
1313
+
1243
1314
  alias _contour_ contour
1244
1315
  # (Plot) Draw a contour plot.
1245
1316
  def contour(*args)
data/lib/gr3.rb CHANGED
@@ -40,39 +40,51 @@
40
40
  #
41
41
  # Fiddley is Ruby-FFI compatible API layer for Fiddle.
42
42
  #
43
- # Why not GR::GR3?
44
- # * kojix2 did not want to force gr3 to be loaded when gr is loaded.
45
- # * kojix2 did not want to write `GR3 = GR::GR3` or something.
46
- # * This is a opinion of kojix2 and may be changed by future maintainers.
43
+ # @note
44
+ # Why not GR::GR3?
45
+ # * kojix2 did not want to force gr3 to be loaded when gr is loaded.
46
+ # * kojix2 did not want to write `GR3 = GR::GR3` or something.
47
+ # * This is a opinion of kojix2 and may be changed by future maintainers.
47
48
  #
48
- # GR3 uses Numo::Narrray.
49
- # * It is difficult to write GR3 modules with only Ruby arrays.
50
- # * Numo::Narray has better performance and is easier to read.
51
- # * Numo::Narray does not work with JRuby.
52
- # * https://github.com/ruby-numo/numo-narray/issues/147
49
+ # @note
50
+ # GR3 uses Numo::Narrray.
51
+ # * It is difficult to write GR3 modules with only Ruby arrays.
52
+ # * Numo::Narray has better performance and is easier to read.
53
+ # * Numo::Narray does not work with JRuby.
54
+ # * https://github.com/ruby-numo/numo-narray/issues/147
53
55
  #
54
56
  # This is a procedural interface to the GR3 in GR plotting library,
55
57
  # https://github.com/sciapp/gr
56
58
  module GR3
57
59
  class Error < StandardError; end
58
60
 
61
+ class NotFoundError < Error; end
62
+
59
63
  class << self
60
64
  attr_accessor :ffi_lib
61
65
  end
62
66
 
63
67
  require_relative 'gr_commons/gr_commons'
64
- extend GRCommons::SearchSharedLibrary
65
68
 
66
69
  # Platforms | path
67
70
  # Windows | bin/libGR3.dll
68
- # MacOSX | lib/libGR3.so (NOT .dylib)
71
+ # MacOSX | lib/libGR3.dylib (v0.53.0 .so)
69
72
  # Ubuntu | lib/libGR3.so
70
- self.ffi_lib = case RbConfig::CONFIG['host_os']
71
- when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
72
- search_shared_library('libGR3.dll')
73
- else
74
- search_shared_library('libGR3.so')
75
- end
73
+ platform = RbConfig::CONFIG['host_os']
74
+ lib_names, pkg_name = \
75
+ case platform
76
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
77
+ [['libGR3.dll'], 'gr3']
78
+ when /darwin|mac os/
79
+ [['libGR3.dylib', 'libGR3.so'], 'gr3']
80
+ else
81
+ [['libGR3.so'], 'gr3']
82
+ end
83
+ lib_path = GRCommons::GRLib.search(lib_names, pkg_name)
84
+
85
+ raise NotFoundError, "#{lib_names} not found" if lib_path.nil?
86
+
87
+ self.ffi_lib = lib_path
76
88
 
77
89
  require_relative 'gr3/version'
78
90
  require_relative 'gr3/ffi'
@@ -117,70 +129,82 @@ module GR3
117
129
  end
118
130
  extend CheckError
119
131
 
120
- # Now you can see a lot of methods just calling super here.
121
- # They are written to help the yard generate the documentation.
122
132
  class << self
123
133
  # This method initializes the gr3 context.
134
+ #
124
135
  # @return [Integer]
125
- def gr3_init(*)
126
- super
127
- end
136
+ #
137
+ # @!method gr3_init
128
138
 
129
- def free(*)
130
- super
131
- end
139
+ # @!method free
132
140
 
133
141
  # This function terminates the gr3 context.
134
- def terminate(*)
135
- super
136
- end
142
+ #
143
+ # After calling this function, gr3 is in the same state as when it was first
144
+ # loaded, except for context-independent variables, i.e. the logging callback.
145
+ #
146
+ # @!method terminate
137
147
 
138
- # @!method geterror
148
+ # @note This method is defined in the CheckError module.
149
+ #
139
150
  # This function returns information on the most recent GR3 error.
151
+ #
140
152
  # @return [Integer]
141
- # @note This method is defined in the CheckError module.
153
+ #
154
+ # @!method geterror
142
155
 
143
156
  # This function allows the user to find out how his commands are rendered.
157
+ #
144
158
  # If gr3 is initialized, a string in the format:
145
- # `"gr3 - " + window toolkit + " - " + framebuffer extension + " - " + OpenGL version + " - " + OpenGL renderer string`.
146
- # For example `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
147
- # might be returned on a Linux system (using GLX) with an available GL_ARB_framebuffer_object implementation.
159
+ # `"gr3 - " + window toolkit + " - " + framebuffer extension + " - "
160
+ # + OpenGL version + " - " + OpenGL renderer string`.
161
+ # For example
162
+ # `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
163
+ # might be returned on a Linux system (using GLX) with an available
164
+ # GL_ARB_framebuffer_object implementation.
148
165
  # If gr3 is not initialized `"Not initialized"` is returned.
166
+ #
149
167
  # @return [String]
168
+ #
150
169
  def getrenderpathstring(*)
151
170
  super.to_s
152
171
  end
153
172
 
154
173
  # This function returns a string representation of a given error code.
174
+ #
155
175
  # @return [String]
176
+ #
156
177
  def geterrorstring(*)
157
178
  super.to_s
158
179
  end
159
180
 
160
181
  # This function clears the draw list.
182
+ #
161
183
  # @return [Integer]
162
- def clear(*)
163
- super
164
- end
184
+ #
185
+ # @!method clear
165
186
 
166
- # Use the currently bound framebuffer as the framebuffer used for drawing to OpenGL (using gr3.drawimage).
167
- # This function is only needed when you do not want to render to 0, the default framebuffer.
168
- def usecurrentframebuffer(*)
169
- super
170
- end
187
+ # Use the currently bound framebuffer as the framebuffer used for drawing to
188
+ # OpenGL (using gr3.drawimage).
189
+ # This function is only needed when you do not want to render to 0, the
190
+ # default framebuffer.
191
+ #
192
+ # @!method usecurrentframebuffer
171
193
 
172
194
  # Set the framebuffer used for drawing to OpenGL (using gr3.drawimage).
173
- # This function is only needed when you do not want to render to 0, the default framebuffer.
174
- def useframebuffer(*)
175
- super
176
- end
195
+ #
196
+ # This function is only needed when you do not want to render to 0, the
197
+ # default framebuffer.
198
+ #
199
+ # @!method useframebuffer
177
200
 
178
201
  # Set rendering quality
202
+ #
179
203
  # @param quality [] The quality to set
204
+ #
180
205
  # @return [Integer]
181
- def setquality(*)
182
- super
183
- end
206
+ #
207
+ # @!method setquality
184
208
 
185
209
  # @return [Integer]
186
210
  def getimage(width, height, use_alpha = true)
@@ -191,31 +215,31 @@ module GR3
191
215
  end
192
216
 
193
217
  # @return [Integer]
194
- def export(*)
195
- super
196
- end
218
+ # @!method export
197
219
 
198
220
  # @return [Integer]
199
- def drawimage(*)
200
- super
201
- end
221
+ # @!method drawimage
202
222
 
203
- # createmesh_nocopy
223
+ # This function creates a mesh from vertex position, normal and color data.
224
+ #
204
225
  # @return [Integer]
205
- def createmesh_nocopy(_n, vertices, normals, colors)
226
+ def createmesh_nocopy(n, vertices, normals, colors)
206
227
  inquiry_int do |mesh|
207
- super(mesh, vertices, normals, colors)
228
+ super(mesh, n, vertices, normals, colors)
208
229
  end
209
230
  end
210
231
 
211
232
  # This function creates a int from vertex position, normal and color data.
212
233
  # Returns a mesh.
213
- # @param n [Integer] the number of vertices in the mesh
234
+ #
235
+ # @param n [Integer] the number of vertices in the mesh
214
236
  # @param vertices [Array, NArray] the vertex positions
215
- # @param normals [Array, NArray] the vertex normals
216
- # @param colors [Array, NArray] the vertex colors,
217
- # they should be white (1,1,1) if you want to change the color for each drawn mesh
237
+ # @param normals [Array, NArray] the vertex normals
238
+ # @param colors [Array, NArray] the vertex colors, they should be
239
+ # white (1,1,1) if you want to change the color for each drawn mesh
240
+ #
218
241
  # @return [Integer]
242
+ #
219
243
  def createmesh(n, vertices, normals, colors)
220
244
  inquiry_int do |mesh|
221
245
  super(mesh, n, vertices, normals, colors)
@@ -223,6 +247,7 @@ module GR3
223
247
  end
224
248
 
225
249
  # This function creates a mesh from vertex position, normal and color data.
250
+ #
226
251
  # @return [Integer]
227
252
  def createindexedmesh_nocopy(num_vertices, vertices, normals, colors, num_indices, indices)
228
253
  inquiry_int do |mesh|
@@ -233,150 +258,159 @@ module GR3
233
258
  # This function creates an indexed mesh from vertex information (position,
234
259
  # normal and color) and triangle information (indices).
235
260
  # Returns a mesh.
236
- # @param num_vertices [Integer] the number of vertices in the mesh
237
- # @param vertices [Array, NArray] the vertex positions
238
- # @param normals [Array, NArray] the vertex normals
239
- # @param colors [Array, NArray] the vertex colors,
240
- # they should be white (1,1,1) if you want to change the color for each drawn mesh
241
- # @param num_indices [Integer] the number of indices in the mesh (three times the number of triangles)
242
- # @param indices [Array, NArray] the index array (vertex indices for each triangle)
261
+ #
262
+ # @param num_vertices [Integer] the number of vertices in the mesh
263
+ # @param vertices [Array, NArray] the vertex positions
264
+ # @param normals [Array, NArray] the vertex normals
265
+ # @param colors [Array, NArray] the vertex colors, they should be
266
+ # white (1,1,1) if you want to change
267
+ # the color for each drawn mesh
268
+ # @param num_indices [Integer] the number of indices in the mesh
269
+ # (three times the number of triangles)
270
+ # @param indices [Array, NArray] the index array (vertex indices for
271
+ # each triangle)
272
+ #
243
273
  # @return [Integer]
274
+ #
244
275
  def createindexedmesh(num_vertices, vertices, normals, colors, num_indices, indices)
245
276
  inquiry_int do |mesh|
246
277
  super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
247
278
  end
248
279
  end
249
280
 
250
- # This function adds a mesh to the draw list, so it will be drawn when the user calls getpixmap.
251
- # The given data stays owned by the user, a copy will be saved in the draw list and the mesh reference counter will be increased.
252
- # @param mesh [Integer] The mesh to be drawn
253
- # @param n [Integer] The number of meshes to be drawn
254
- # @param positions [Array, NArray] The positions where the meshes should be drawn
281
+ # This function adds a mesh to the draw list, so it will be drawn when the
282
+ # user calls getpixmap. The given data stays owned by the user, a copy will
283
+ # be saved in the draw list and the mesh reference counter will be increased.
284
+ #
285
+ # This function does not return an error code, because of its asynchronous
286
+ # nature. If gr3_getpixmap_() returns a GR3_ERROR_OPENGL_ERR, this might be
287
+ # caused by this function saving unuseable data into the draw list.
288
+ #
289
+ # @param mesh [Integer] The mesh to be drawn
290
+ # @param n [Integer] The number of meshes to be drawn
291
+ # @param positions [Array, NArray] The positions where the meshes should be drawn
255
292
  # @param directions [Array, NArray] The forward directions the meshes should be facing at
256
- # @param ups [Array, NArray] The up directions
257
- # @param colors [Array, NArray] The colors the meshes should be drawn in, it will be multiplied with each vertex color
258
- # @param scales [Array, NArray] The scaling factors
259
- def drawmesh(*)
260
- super
261
- end
262
-
263
- # This function marks a mesh for deletion and removes the user’s reference from the mesh’s referenc counter,
264
- # so a user must not use the mesh after calling this function.
293
+ # @param ups [Array, NArray] The up directions
294
+ # @param colors [Array, NArray] The colors the meshes should be drawn in,
295
+ # it will be multiplied with each vertex color
296
+ # @param scales [Array, NArray] The scaling factors
297
+ #
298
+ # @!method drawmesh
299
+
300
+ # This function marks a mesh for deletion and removes the user’s reference
301
+ # from the mesh’s referenc counter, so a user must not use the mesh after
302
+ # calling this function.
303
+ #
265
304
  # @param mesh [Integer] The mesh that should be marked for deletion
266
- def deletemesh(*)
267
- super
268
- end
305
+ #
306
+ # @!method deletemesh
269
307
 
270
308
  # This function sets the view matrix by getting the position of the camera,
271
309
  # the position of the center of focus and the direction which should point up.
310
+ # This function takes effect when the next image is created. Therefore if
311
+ # you want to take pictures of the same data from different perspectives,
312
+ # you can call and gr3_cameralookat(), gr3_getpixmap_(), gr3_cameralookat(),
313
+ # gr3_getpixmap_(), … without calling gr3_clear() and gr3_drawmesh() again.
314
+ #
272
315
  # @param camera_x [Array, NArray] The x-coordinate of the camera
273
316
  # @param camera_y [Array, NArray] The y-coordinate of the camera
274
317
  # @param camera_z [Array, NArray] The z-coordinate of the camera
275
318
  # @param center_x [Array, NArray] The x-coordinate of the center of focus
276
319
  # @param center_y [Array, NArray] The y-coordinate of the center of focus
277
320
  # @param center_z [Array, NArray] The z-coordinate of the center of focus
278
- # @param up_x [Array, NArray] The x-component of the up direction
279
- # @param up_y [Array, NArray] The y-component of the up direction
280
- # @param up_z [Array, NArray] The z-component of the up direction
281
- def cameralookat(*)
282
- super
283
- end
321
+ # @param up_x [Array, NArray] The x-component of the up direction
322
+ # @param up_y [Array, NArray] The y-component of the up direction
323
+ # @param up_z [Array, NArray] The z-component of the up direction
324
+ #
325
+ # @!method cameralookat
284
326
 
285
327
  # This function sets the projection parameters.
286
328
  # This function takes effect when the next image is created.
287
- # @param vertical_field_of_view [Numeric] This parameter is the vertical field of view in degrees.
288
- # It must be greater than 0 and less than 180.
329
+ #
330
+ # The ratio between zFar and zNear influences the precision of the depth
331
+ # buffer, the greater (zFar/zNear), the more likely are errors. So you should
332
+ # try to keep both values as close to each other as possible while making
333
+ # sure everything you want to be visible, is visible.
334
+ #
335
+ # @param vertical_field_of_view [Numeric]
336
+ # This parameter is the vertical field of view in degrees.
337
+ # It must be greater than 0 and less than 180.
289
338
  # @param zNear [Numeric] The distance to the near clipping plane.
290
- # @param zFar [Numeric] The distance to the far clipping plane.
339
+ # @param zFar [Numeric] The distance to the far clipping plane.
340
+ #
291
341
  # @return [Integer]
292
- def setcameraprojectionparameters(*)
293
- super
294
- end
342
+ #
343
+ # @!method setcameraprojectionparameters
295
344
 
296
345
  # Get the projection parameters.
346
+ #
347
+ # @param vfov [Array, NArray] Vertical field of view in degrees
348
+ # @param znear [Array, NArray] The distance to the near clipping plane.
349
+ # @param zfar [Array, NArray] The distance to the far clipping plane.
350
+ #
297
351
  # @return [Integer]
298
- def getcameraprojectionparameters(*)
299
- super
300
- end
352
+ #
353
+ # @!method getcameraprojectionparameters
301
354
 
302
- # This function sets the direction of light.
303
- # If it is called with (0, 0, 0), the light is always pointing into the same direction as the camera.
355
+ # This function sets the direction of light. If it is called with (0, 0, 0),
356
+ # the light is always pointing into the same direction as the camera.
357
+ #
304
358
  # @param x [Numeric] The x-component of the light's direction
305
359
  # @param y [Numeric] The y-component of the light's direction
306
360
  # @param z [Numeric] The z-component of the light's direction
307
- def setlightdirection(*)
308
- super
309
- end
361
+ #
362
+ # @!method setlightdirection
310
363
 
311
364
  # This function sets the background color.
312
- def setbackgroundcolor(*)
313
- super
314
- end
365
+ # @!method setbackgroundcolor
315
366
 
316
367
  # @return [Integer]
317
- def createheightmapmesh(*)
318
- super
319
- end
368
+ # @!method createheightmapmesh
320
369
 
321
- def drawheightmap(*)
322
- super
323
- end
370
+ # @!method drawheightmap
324
371
 
325
372
  # This function allows drawing a cylinder without requiring a mesh.
326
- def drawconemesh(*)
327
- super
328
- end
373
+ # @!method drawconemesh
329
374
 
330
375
  # This function allows drawing a cylinder without requiring a mesh.
331
- def drawcylindermesh(*)
332
- super
333
- end
376
+ # @!method drawcylindermesh
334
377
 
335
378
  # This function allows drawing a sphere without requiring a mesh.
336
- def drawspheremesh(*)
337
- super
338
- end
379
+ # @!method drawspheremesh
339
380
 
340
- def drawcubemesh(*)
341
- super
342
- end
381
+ # @!method drawcubemesh
343
382
 
344
- def setobjectid(*)
345
- super
346
- end
383
+ # @!method setobjectid
347
384
 
348
385
  # @return [Integer]
349
- def selectid(*)
350
- super
351
- end
386
+ # @!method selectid
352
387
 
353
- def getviewmatrix(*)
354
- super
355
- end
388
+ # @param m [Array, NArray] the 4x4 column major view matrix
389
+ # @!method getviewmatrix
356
390
 
357
- def setviewmatrix(*)
358
- super
359
- end
391
+ # @param m [Array, NArray] the 4x4 column major view matrix
392
+ # @!method setviewmatrix
360
393
 
361
- # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
362
394
  # @return [Integer]
363
- def getprojectiontype(*)
364
- super
365
- end
395
+ # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
396
+ # @!method getprojectiontype
366
397
 
367
- # @param type [Integer] the new projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
368
- def setprojectiontype(*)
369
- super
370
- end
398
+ # @param type [Integer]
399
+ # the new projection type: GR3_PROJECTION_PERSPECTIVE,
400
+ # GR3_PROJECTION_PARALLEL or GR3_PROJECTION_ORTHOGRAPHIC
401
+ # @!method setprojectiontype
371
402
 
372
403
  # This function creates an isosurface from voxel data using the
373
404
  # marching cubes algorithm.
374
405
  # Returns a mesh.
375
- # @param grid [NArray] 3D narray array containing the voxel data
376
- # @param step [Array] voxel sizes in each direction
377
- # @param offset [Array] coordinate origin in each direction
378
- # @param isolevel [Integer] isovalue at which the surface will be created
406
+ #
407
+ # @param grid [NArray] 3D narray array containing the voxel data
408
+ # @param step [Array, NArray] voxel sizes in each direction
409
+ # @param offset [Array, NArray] coordinate origin in each direction
410
+ # @param isolevel [Integer] isovalue at which the surface will be created
411
+ #
379
412
  # @return [Integer]
413
+ #
380
414
  def createisosurfacemesh(grid, step, offset, isolevel)
381
415
  args = _preprocess_createslicemesh(grid, step, offset)
382
416
  grid = args.shift
@@ -388,10 +422,11 @@ module GR3
388
422
  # Create a mesh of a surface plot similar to gr_surface.
389
423
  # Uses the current colormap. To apply changes of the colormap
390
424
  # a new mesh has to be created.
391
- # @param nx [Integer] number of points in x-direction
392
- # @param ny [Integer] number of points in y-direction
393
- # @param x [Array, NArray] an array containing the x-coordinates
394
- # @param y [Array, NArray] an array containing the y-coordinates
425
+ #
426
+ # @param nx [Integer] number of points in x-direction
427
+ # @param ny [Integer] number of points in y-direction
428
+ # @param x [Array, NArray] an array containing the x-coordinates
429
+ # @param y [Array, NArray] an array containing the y-coordinates
395
430
  # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
396
431
  # @param option [Integer] option for the surface mesh; the GR3_SURFACE constants can be combined with bitwise or. See the table below.
397
432
  # * 0 : GR3_SURFACE_DEFAULT
@@ -406,6 +441,7 @@ module GR3
406
441
  # * color the surface according to the current gr colormap
407
442
  # * 16 : GR3_SURFACE_GRZSHADED
408
443
  # * like GR3_SURFACE_GRCOLOR, but use the z-value directly as color index
444
+ #
409
445
  # @return [Integer]
410
446
  def createsurfacemesh(nx, ny, x, y, z, option = 0)
411
447
  inquiry_int do |mesh|
@@ -419,29 +455,32 @@ module GR3
419
455
  # the viewmatrix and the light direction. If necessary, the user has to
420
456
  # save them before the call to this function and restore them after
421
457
  # the call to gr3_drawimage.
422
- # @param mesh [Integer] the mesh to be drawn
423
- # @param n [Integer] the number of meshes to be drawn
424
- # @param positions [Array, NArray] the positions where the meshes should be drawn
458
+ #
459
+ # @param mesh [Integer] the mesh to be drawn
460
+ # @param n [Integer] the number of meshes to be drawn
461
+ # @param positions [Array, NArray] the positions where the meshes should be drawn
425
462
  # @param directions [Array, NArray] the forward directions the meshes should be facing at
426
- # @param ups [Array, NArray] the up directions
427
- # @param colors [Array, NArray] the colors the meshes should be drawn in, it will be multiplied with each vertex color
428
- # @param scales [Array, NArray] the scaling factors
429
- def drawmesh_grlike(*)
430
- super
431
- end
463
+ # @param ups [Array, NArray] the up directions
464
+ # @param colors [Array, NArray] the colors the meshes should be drawn in,
465
+ # it will be multiplied with each vertex color
466
+ # @param scales [Array, NArray] the scaling factors
467
+ #
468
+ # @!method drawmesh_grlike
432
469
 
433
470
  # Convenience function for drawing a surfacemesh.
471
+ #
434
472
  # @param mesh [Integer] the mesh to be drawn
435
- def drawsurface(*)
436
- super
437
- end
473
+ #
474
+ # @!method drawsurface
438
475
 
439
476
  # Create a surface plot with gr3 and draw it with gks as cellarray.
440
- # @param x [Array, NArray] an array containing the x-coordinates
441
- # @param y [Array, NArray] an array containing the y-coordinates
442
- # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
443
- # @param option [Integer] see the option parameter of gr_surface.
444
- # OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
477
+ #
478
+ # @param x [Array, NArray] an array containing the x-coordinates
479
+ # @param y [Array, NArray] an array containing the y-coordinates
480
+ # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
481
+ # @param option [Integer] see the option parameter of gr_surface.
482
+ # OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
483
+ #
445
484
  def surface(x, y, z, option)
446
485
  nx = x.length
447
486
  ny = y.length
@@ -449,17 +488,20 @@ module GR3
449
488
  super(nx, ny, x, y, z, option)
450
489
  end
451
490
 
452
- # drawtubemesh
453
491
  # Draw a tube following a path given by a list of points. The colors and
454
492
  # radii arrays specify the color and radius at each point.
455
- # @param n [Integer] the number of points given
493
+ #
494
+ # @param n [Integer] the number of points given
456
495
  # @param points [Array, NArray] the points the tube should go through
457
496
  # @param colors [Array, NArray] the color at each point
458
- # @param radii [Array, NArray] the desired tube radius at each point
459
- # @param num_steps [Integer] the number of steps between each point, allowing for a more smooth tube
460
- # @param num_segments [Integer] the number of segments each ring of the tube consists of,
461
- # e.g. 3 would yield a triangular tube
497
+ # @param radii [Array, NArray] the desired tube radius at each point
498
+ # @param num_steps [Integer] the number of steps between each point,
499
+ # allowing for a more smooth tube
500
+ # @param num_segments [Integer] the number of segments each ring of the tube
501
+ # consists of, e.g. 3 would yield a triangular tube
502
+ #
462
503
  # @return [Integer]
504
+ #
463
505
  def drawtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
464
506
  super(n, points, colors, radii, num_steps, num_segments)
465
507
  end
@@ -467,12 +509,17 @@ module GR3
467
509
  # Create a mesh object in the shape of a tube following a path given by a
468
510
  # list of points. The colors and radii arrays specify the color and radius at
469
511
  # each point.
470
- # @param n [Integer] the number of points given
471
- # @param points [Array, NArray] the points the tube should go through
472
- # @param colors [Array, NArray] the color at each point
473
- # @param radii [Array, NArray] the desired tube radius at each point
474
- # @param num_steps [Integer] the number of steps between each point, allowing for a more smooth tube
475
- # @param num_segments [Integer] the number of segments each ring of the tube consists of, e.g. 3 would yield a triangular tube
512
+ #
513
+ # @param n [Integer] the number of points given
514
+ # @param points [Array, NArray] the points the tube should go through
515
+ # @param colors [Array, NArray] the color at each point
516
+ # @param radii [Array, NArray] the desired tube radius at each point
517
+ # @param num_steps [Integer] the number of steps between each point,
518
+ # allowing for a more smooth tube
519
+ # @param num_segments [Integer] the number of segments each ring of the
520
+ # tube consists of, e.g. 3 would yield a
521
+ # triangular tube
522
+ #
476
523
  # @return [Integer]
477
524
  def createtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
478
525
  inquiry_uint do |mesh| # mesh should be Int?
@@ -547,12 +594,14 @@ module GR3
547
594
  # drawn and at which positions they should go through the data. If neither
548
595
  # x nor y nor z are set, 0.5 will be used for all three.
549
596
  # Returns meshes for the yz-slice, the xz-slice and the xy-slice.
550
- # @param grid [NArray] 3D narray array containing the voxel data
551
- # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
552
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
553
- # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
554
- # @param step [Array] voxel sizes in each direction
555
- # @param offset [Array] coordinate origin in each direction
597
+ #
598
+ # @param grid [NArray] 3D narray array containing the voxel data
599
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
600
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
601
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
602
+ # @param step [Array, NArray] voxel sizes in each direction
603
+ # @param offset [Array, NArray] coordinate origin in each direction
604
+ #
556
605
  def createslicemeshes(grid, x = nil, y = nil, z = nil, step = nil, offset = nil)
557
606
  if [x, y, z].all?(&:nil?)
558
607
  x = 0.5
@@ -569,10 +618,11 @@ module GR3
569
618
  # using the current GR colormap. Use the x parameter to set the position of
570
619
  # the yz-slice.
571
620
  # Returns a mesh for the yz-slice.
572
- # @param grid [NArray] 3D narray array containing the voxel data
573
- # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
574
- # @param step [Array] voxel sizes in each direction
575
- # @param offset [Array] coordinate origin in each direction
621
+ #
622
+ # @param grid [NArray] 3D narray array containing the voxel data
623
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
624
+ # @param step [Array, NArray] voxel sizes in each direction
625
+ # @param offset [Array, NArray] coordinate origin in each direction
576
626
  def createxslicemesh(grid, x = 0.5, step = nil, offset = nil)
577
627
  args = _preprocess_createslicemesh(grid, step, offset)
578
628
  grid = args.shift
@@ -586,10 +636,12 @@ module GR3
586
636
  # using the current GR colormap. Use the y parameter to set the position of
587
637
  # the xz-slice.
588
638
  # Returns a mesh for the xz-slice.
589
- # @param grid [NArray] 3D narray array containing the voxel data
590
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
591
- # @param step [Array] voxel sizes in each direction
592
- # @param offset [Array] coordinate origin in each direction
639
+ #
640
+ # @param grid [NArray] 3D narray array containing the voxel data
641
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
642
+ # @param step [Array, NArray] voxel sizes in each direction
643
+ # @param offset [Array, NArray] coordinate origin in each direction
644
+ #
593
645
  def createyslicemesh(grid, y = 0.5, step = nil, offset = nil)
594
646
  args = _preprocess_createslicemesh(grid, step, offset)
595
647
  grid = args.shift
@@ -603,10 +655,12 @@ module GR3
603
655
  # using the current GR colormap. Use the z parameter to set the position of
604
656
  # the xy-slice.
605
657
  # Returns a mesh for the xy-slice.
606
- # @param grid [NArray] 3D narray array containing the voxel data
607
- # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
608
- # @param step [Array] voxel sizes in each direction
609
- # @param offset [Array] coordinate origin in each direction
658
+ #
659
+ # @param grid [NArray] 3D narray array containing the voxel data
660
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
661
+ # @param step [Array, NArray] voxel sizes in each direction
662
+ # @param offset [Array, NArray] coordinate origin in each direction
663
+ #
610
664
  def createzslicemesh(grid, z = 0.5, step = nil, offset = nil)
611
665
  args = _preprocess_createslicemesh(grid, step, offset)
612
666
  grid = args.shift
@@ -617,15 +671,18 @@ module GR3
617
671
  end
618
672
 
619
673
  # Draw a yz-slice through the given data, using the current GR colormap.
620
- # @param grid [NArray] 3D narray array containing the voxel data
621
- # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
622
- # @param step [Array] voxel sizes in each direction
623
- # @param offset [Array] coordinate origin in each direction
624
- # @param position [Array] the positions where the meshes should be drawn
625
- # @param direction [Array] the forward directions the meshes should be facing at
626
- # @param up [Array] the up directions
627
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
628
- # @param scale [Array] the scaling factors
674
+ #
675
+ # @param grid [NArray] 3D narray array containing the voxel data
676
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
677
+ # @param step [Array, NArray] voxel sizes in each direction
678
+ # @param offset [Array, NArray] coordinate origin in each direction
679
+ # @param position [Array, NArray] the positions where the meshes should be drawn
680
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
681
+ # @param up [Array, NArray] the up directions
682
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
683
+ # it will be multiplied with each vertex color
684
+ # @param scale [Array, NArray] the scaling factors
685
+ #
629
686
  def drawxslicemesh(grid, x = 0.5, step = nil, offset = nil,
630
687
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
631
688
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -635,15 +692,18 @@ module GR3
635
692
  end
636
693
 
637
694
  # Draw a xz-slice through the given data, using the current GR colormap.
638
- # @param grid [NArray] 3D narray array containing the voxel data
639
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
640
- # @param step [Array] voxel sizes in each direction
641
- # @param offset [Array] coordinate origin in each direction
642
- # @param position [Array] the positions where the meshes should be drawn
643
- # @param direction [Array] the forward directions the meshes should be facing at
644
- # @param up [Array] the up directions
645
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
646
- # @param scale [Array] the scaling factors
695
+ #
696
+ # @param grid [NArray] 3D narray array containing the voxel data
697
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
698
+ # @param step [Array, NArray] voxel sizes in each direction
699
+ # @param offset [Array, NArray] coordinate origin in each direction
700
+ # @param position [Array, NArray] the positions where the meshes should be drawn
701
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
702
+ # @param up [Array, NArray] the up directions
703
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
704
+ # it will be multiplied with each vertex color
705
+ # @param scale [Array, NArray] the scaling factors
706
+ #
647
707
  def drawyslicemesh(grid, y = 0.5, step = nil, offset = nil,
648
708
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
649
709
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -653,15 +713,18 @@ module GR3
653
713
  end
654
714
 
655
715
  # Draw a xy-slice through the given data, using the current GR colormap.
656
- # @param grid [NArray] 3D narray array containing the voxel data
657
- # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
658
- # @param step [Array] voxel sizes in each direction
659
- # @param offset [Array] coordinate origin in each direction
660
- # @param position [Array] the positions where the meshes should be drawn
661
- # @param direction [Array] the forward directions the meshes should be facing at
662
- # @param up [Array] the up directions
663
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
664
- # @param scale [Array] the scaling factors
716
+ #
717
+ # @param grid [NArray] 3D narray array containing the voxel data
718
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
719
+ # @param step [Array, NArray] voxel sizes in each direction
720
+ # @param offset [Array, NArray] coordinate origin in each direction
721
+ # @param position [Array, NArray] the positions where the meshes should be drawn
722
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
723
+ # @param up [Array, NArray] the up directions
724
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
725
+ # it will be multiplied with each vertex color
726
+ # @param scale [Array, NArray] the scaling factors
727
+ #
665
728
  def drawzslicemesh(grid, z = 0.5, step = nil, offset = nil,
666
729
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
667
730
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -674,17 +737,20 @@ module GR3
674
737
  # Use the parameters x, y or z to specify what slices should be drawn and at
675
738
  # which positions they should go through the data. If neither x nor y nor
676
739
  # z are set, 0.5 will be used for all three.
740
+ #
677
741
  # @param grid [NArray] 3D narray array containing the voxel data
678
- # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
679
- # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
680
- # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
681
- # @param step [Array] voxel sizes in each direction
682
- # @param offset [Array] coordinate origin in each direction
683
- # @param position [Array] the positions where the meshes should be drawn
684
- # @param direction [Array] the forward directions the meshes should be facing at
685
- # @param up [Array] the up directions
686
- # @param color [Array] the colors the meshes should be drawn in, it will be multiplied with each vertex color
687
- # @param scale [Array] the scaling factors
742
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
743
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
744
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
745
+ # @param step [Array, NArray] voxel sizes in each direction
746
+ # @param offset [Array, NArray] coordinate origin in each direction
747
+ # @param position [Array, NArray] the positions where the meshes should be drawn
748
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
749
+ # @param up [Array, NArray] the up directions
750
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
751
+ # it will be multiplied with each vertex color
752
+ # @param scale [Array, NArray] the scaling factors
753
+ #
688
754
  def drawslicemeshes(grid, x = nil, y = nil, z = nil, step = nil,
689
755
  offset = nil, position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
690
756
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -757,6 +823,7 @@ module GR3
757
823
  IA_END_OF_LIST = 0
758
824
  IA_FRAMEBUFFER_WIDTH = 1
759
825
  IA_FRAMEBUFFER_HEIGHT = 2
826
+ IA_NUM_THREADS = 3
760
827
 
761
828
  # Error
762
829
  ERROR_NONE = 0
@@ -787,6 +854,11 @@ module GR3
787
854
  DRAWABLE_OPENGL = 1
788
855
  DRAWABLE_GKS = 2
789
856
 
857
+ # Projection
858
+ PROJECTION_PERSPECTIVE = 0
859
+ PROJECTION_PARALLEL = 1
860
+ PROJECTION_ORTHOGRAPHIC = 2
861
+
790
862
  # SurfaceOption
791
863
  SURFACE_DEFAULT = 0
792
864
  SURFACE_NORMALS = 1