ruby-gr 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
@@ -174,7 +174,7 @@ module GR
174
174
  try_extern 'void gr_shadepoints(int, double *, double *, int, int, int)'
175
175
  try_extern 'void gr_shadelines(int, double *, double *, int, int, int)'
176
176
  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 *)'
177
+ try_extern 'int gr_findboundary(int, double *, double *, double, double (*)(double, double), int, int *)'
178
178
  try_extern 'void gr_setresamplemethod(unsigned int flag)'
179
179
  try_extern 'void gr_inqresamplemethod(unsigned int *flag)'
180
180
  try_extern 'void gr_path(int, double *, double *, const char *)'
@@ -202,5 +202,6 @@ module GR
202
202
  try_extern 'void gr_inqtext3d(double, double, double, char *, int axis, double *, double *)'
203
203
  try_extern 'void gr_settextencoding(int)'
204
204
  try_extern 'void gr_inqtextencoding(int *)'
205
+ # gr_setcallback(char *(*)(const char *));
205
206
  end
206
207
  end
@@ -38,12 +38,49 @@ module GR
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
+ pingfangsc: 234
83
+ }.freeze
47
84
 
48
85
  @last_plot = nil
49
86
  class << self
@@ -345,29 +382,29 @@ module GR
345
382
  GR.axes(xtick, ytick, xorg[1], yorg[1], -majorx, -majory, -ticksize)
346
383
  end
347
384
 
348
- if kvs[:title]
385
+ if kvs.has_key?(:title)
349
386
  GR.savestate
350
387
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
351
- text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
388
+ text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
352
389
  GR.restorestate
353
390
  end
354
391
  if %i[wireframe surface plot3 scatter3 trisurf volume].include?(kind)
355
- xlabel = kvs[:xlabel] || ''
356
- ylabel = kvs[:ylabel] || ''
357
- zlabel = kvs[:zlabel] || ''
392
+ xlabel = (kvs[:xlabel] || '').to_s
393
+ ylabel = (kvs[:ylabel] || '').to_s
394
+ zlabel = (kvs[:zlabel] || '').to_s
358
395
  GR.titles3d(xlabel, ylabel, zlabel)
359
396
  else
360
397
  if kvs.has_key?(:xlabel)
361
398
  GR.savestate
362
399
  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])
400
+ text(0.5 * (viewport[0] + viewport[1]), vp[2] + 0.5 * charheight, kvs[:xlabel].to_s)
364
401
  GR.restorestate
365
402
  end
366
403
  if kvs.has_key?(:ylabel)
367
404
  GR.savestate
368
405
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
369
406
  GR.setcharup(-1, 0)
370
- text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel])
407
+ text(vp[0] + 0.5 * charheight, 0.5 * (viewport[2] + viewport[3]), kvs[:ylabel].to_s)
371
408
  GR.restorestate
372
409
  end
373
410
  end
@@ -475,7 +512,7 @@ module GR
475
512
  if kvs.has_key?(:title)
476
513
  GR.savestate
477
514
  GR.settextalign(GR::TEXT_HALIGN_CENTER, GR::TEXT_VALIGN_TOP)
478
- text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title])
515
+ text(0.5 * (viewport[0] + viewport[1]), vp[3], kvs[:title].to_s)
479
516
  GR.restorestate
480
517
  end
481
518
  GR.selntran(1)
@@ -577,9 +614,22 @@ module GR
577
614
  # Not yet.
578
615
  end
579
616
 
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
617
+ if kvs.has_key?(:font)
618
+ name = kvs[:font]
619
+ # 'Cmuserif-Math' => :cmuserif_math
620
+ sym_name = name.to_s.gsub('-','_').downcase.to_sym
621
+ if FONTS.include?(sym_name)
622
+ font = FONTS[sym_name]
623
+ GR.settextfontprec(font, font > 200 ? 3 : 0)
624
+ else
625
+ warn "Unknown font name: #{name}" # should raise error?
626
+ end
627
+ else
628
+ # The following fonts are the default in GR.jl
629
+ # Japanese, Chinese, Korean, etc. cannot be displayed.
630
+
631
+ # GR.settextfontprec(232, 3) # CM Serif Roman
632
+ end
583
633
 
584
634
  set_viewport(kind, kvs[:subplot])
585
635
  unless kvs[:ax]
@@ -748,9 +798,10 @@ module GR
748
798
  else
749
799
  h = levels
750
800
  end
751
- if kind == :contour
801
+ case kind
802
+ when :contour
752
803
  GR._contour_(x, y, h, z, clabels ? 1 : 1000)
753
- elsif kind == :contourf
804
+ when :contourf
754
805
  GR._contourf_(x, y, h, z, clabels ? 1 : 0)
755
806
  end
756
807
  colorbar(0, h.length)
@@ -1054,6 +1105,7 @@ module GR
1054
1105
  end
1055
1106
 
1056
1107
  def inqtext(x, y, s)
1108
+ s = s.to_s
1057
1109
  if s.length >= 2 && s[0] == '$' && s[-1] == '$'
1058
1110
  GR.inqmathtex(x, y, s[1..-2])
1059
1111
  elsif s.include?('\\') || s.include?('_') || s.include?('^')
@@ -1064,6 +1116,7 @@ module GR
1064
1116
  end
1065
1117
 
1066
1118
  def text(x, y, s)
1119
+ s = s.to_s
1067
1120
  if s.length >= 2 && s[0] == '$' && s[-1] == '$'
1068
1121
  GR.mathtex(x, y, s[1..-2])
1069
1122
  elsif s.include?('\\') || s.include?('_') || s.include?('^')
@@ -1163,20 +1216,12 @@ module GR
1163
1216
  [w, h]
1164
1217
  end
1165
1218
 
1166
- # NOTE: duplicated definition (GRCommonUtils)
1167
1219
  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]
1220
+ GRCommons::GRCommonUtils.equal_length(*args)
1175
1221
  end
1176
1222
 
1177
- # NOTE: duplicated definition (GRCommonUtils)
1178
1223
  def narray?(data)
1179
- defined?(Numo::NArray) && data.is_a?(Numo::NArray)
1224
+ GRCommons::GRCommonUtils.narray?(data)
1180
1225
  end
1181
1226
  end
1182
1227
 
data/lib/gr3.rb CHANGED
@@ -40,16 +40,18 @@
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
@@ -117,70 +119,82 @@ module GR3
117
119
  end
118
120
  extend CheckError
119
121
 
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
122
  class << self
123
123
  # This method initializes the gr3 context.
124
+ #
124
125
  # @return [Integer]
125
- def gr3_init(*)
126
- super
127
- end
126
+ #
127
+ # @!method gr3_init
128
128
 
129
- def free(*)
130
- super
131
- end
129
+ # @!method free
132
130
 
133
131
  # This function terminates the gr3 context.
134
- def terminate(*)
135
- super
136
- end
132
+ #
133
+ # After calling this function, gr3 is in the same state as when it was first
134
+ # loaded, except for context-independent variables, i.e. the logging callback.
135
+ #
136
+ # @!method terminate
137
137
 
138
- # @!method geterror
138
+ # @note This method is defined in the CheckError module.
139
+ #
139
140
  # This function returns information on the most recent GR3 error.
141
+ #
140
142
  # @return [Integer]
141
- # @note This method is defined in the CheckError module.
143
+ #
144
+ # @!method geterror
142
145
 
143
146
  # This function allows the user to find out how his commands are rendered.
147
+ #
144
148
  # 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.
149
+ # `"gr3 - " + window toolkit + " - " + framebuffer extension + " - "
150
+ # + OpenGL version + " - " + OpenGL renderer string`.
151
+ # For example
152
+ # `"gr3 - GLX - GL_ARB_framebuffer_object - 2.1 Mesa 7.10.2 - Software Rasterizer"`
153
+ # might be returned on a Linux system (using GLX) with an available
154
+ # GL_ARB_framebuffer_object implementation.
148
155
  # If gr3 is not initialized `"Not initialized"` is returned.
156
+ #
149
157
  # @return [String]
158
+ #
150
159
  def getrenderpathstring(*)
151
160
  super.to_s
152
161
  end
153
162
 
154
163
  # This function returns a string representation of a given error code.
164
+ #
155
165
  # @return [String]
166
+ #
156
167
  def geterrorstring(*)
157
168
  super.to_s
158
169
  end
159
170
 
160
171
  # This function clears the draw list.
172
+ #
161
173
  # @return [Integer]
162
- def clear(*)
163
- super
164
- end
174
+ #
175
+ # @!method clear
165
176
 
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
177
+ # Use the currently bound framebuffer as the framebuffer used for drawing to
178
+ # OpenGL (using gr3.drawimage).
179
+ # This function is only needed when you do not want to render to 0, the
180
+ # default framebuffer.
181
+ #
182
+ # @!method usecurrentframebuffer
171
183
 
172
184
  # 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
185
+ #
186
+ # This function is only needed when you do not want to render to 0, the
187
+ # default framebuffer.
188
+ #
189
+ # @!method useframebuffer
177
190
 
178
191
  # Set rendering quality
192
+ #
179
193
  # @param quality [] The quality to set
194
+ #
180
195
  # @return [Integer]
181
- def setquality(*)
182
- super
183
- end
196
+ #
197
+ # @!method setquality
184
198
 
185
199
  # @return [Integer]
186
200
  def getimage(width, height, use_alpha = true)
@@ -191,31 +205,31 @@ module GR3
191
205
  end
192
206
 
193
207
  # @return [Integer]
194
- def export(*)
195
- super
196
- end
208
+ # @!method export
197
209
 
198
210
  # @return [Integer]
199
- def drawimage(*)
200
- super
201
- end
211
+ # @!method drawimage
202
212
 
203
- # createmesh_nocopy
213
+ # This function creates a mesh from vertex position, normal and color data.
214
+ #
204
215
  # @return [Integer]
205
- def createmesh_nocopy(_n, vertices, normals, colors)
216
+ def createmesh_nocopy(n, vertices, normals, colors)
206
217
  inquiry_int do |mesh|
207
- super(mesh, vertices, normals, colors)
218
+ super(mesh, n, vertices, normals, colors)
208
219
  end
209
220
  end
210
221
 
211
222
  # This function creates a int from vertex position, normal and color data.
212
223
  # Returns a mesh.
213
- # @param n [Integer] the number of vertices in the mesh
224
+ #
225
+ # @param n [Integer] the number of vertices in the mesh
214
226
  # @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
227
+ # @param normals [Array, NArray] the vertex normals
228
+ # @param colors [Array, NArray] the vertex colors, they should be
229
+ # white (1,1,1) if you want to change the color for each drawn mesh
230
+ #
218
231
  # @return [Integer]
232
+ #
219
233
  def createmesh(n, vertices, normals, colors)
220
234
  inquiry_int do |mesh|
221
235
  super(mesh, n, vertices, normals, colors)
@@ -223,6 +237,7 @@ module GR3
223
237
  end
224
238
 
225
239
  # This function creates a mesh from vertex position, normal and color data.
240
+ #
226
241
  # @return [Integer]
227
242
  def createindexedmesh_nocopy(num_vertices, vertices, normals, colors, num_indices, indices)
228
243
  inquiry_int do |mesh|
@@ -233,150 +248,159 @@ module GR3
233
248
  # This function creates an indexed mesh from vertex information (position,
234
249
  # normal and color) and triangle information (indices).
235
250
  # 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)
251
+ #
252
+ # @param num_vertices [Integer] the number of vertices in the mesh
253
+ # @param vertices [Array, NArray] the vertex positions
254
+ # @param normals [Array, NArray] the vertex normals
255
+ # @param colors [Array, NArray] the vertex colors, they should be
256
+ # white (1,1,1) if you want to change
257
+ # the color for each drawn mesh
258
+ # @param num_indices [Integer] the number of indices in the mesh
259
+ # (three times the number of triangles)
260
+ # @param indices [Array, NArray] the index array (vertex indices for
261
+ # each triangle)
262
+ #
243
263
  # @return [Integer]
264
+ #
244
265
  def createindexedmesh(num_vertices, vertices, normals, colors, num_indices, indices)
245
266
  inquiry_int do |mesh|
246
267
  super(mesh, num_vertices, vertices, normals, colors, num_indices, indices)
247
268
  end
248
269
  end
249
270
 
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
271
+ # This function adds a mesh to the draw list, so it will be drawn when the
272
+ # user calls getpixmap. The given data stays owned by the user, a copy will
273
+ # be saved in the draw list and the mesh reference counter will be increased.
274
+ #
275
+ # This function does not return an error code, because of its asynchronous
276
+ # nature. If gr3_getpixmap_() returns a GR3_ERROR_OPENGL_ERR, this might be
277
+ # caused by this function saving unuseable data into the draw list.
278
+ #
279
+ # @param mesh [Integer] The mesh to be drawn
280
+ # @param n [Integer] The number of meshes to be drawn
281
+ # @param positions [Array, NArray] The positions where the meshes should be drawn
255
282
  # @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.
283
+ # @param ups [Array, NArray] The up directions
284
+ # @param colors [Array, NArray] The colors the meshes should be drawn in,
285
+ # it will be multiplied with each vertex color
286
+ # @param scales [Array, NArray] The scaling factors
287
+ #
288
+ # @!method drawmesh
289
+
290
+ # This function marks a mesh for deletion and removes the user’s reference
291
+ # from the mesh’s referenc counter, so a user must not use the mesh after
292
+ # calling this function.
293
+ #
265
294
  # @param mesh [Integer] The mesh that should be marked for deletion
266
- def deletemesh(*)
267
- super
268
- end
295
+ #
296
+ # @!method deletemesh
269
297
 
270
298
  # This function sets the view matrix by getting the position of the camera,
271
299
  # the position of the center of focus and the direction which should point up.
300
+ # This function takes effect when the next image is created. Therefore if
301
+ # you want to take pictures of the same data from different perspectives,
302
+ # you can call and gr3_cameralookat(), gr3_getpixmap_(), gr3_cameralookat(),
303
+ # gr3_getpixmap_(), … without calling gr3_clear() and gr3_drawmesh() again.
304
+ #
272
305
  # @param camera_x [Array, NArray] The x-coordinate of the camera
273
306
  # @param camera_y [Array, NArray] The y-coordinate of the camera
274
307
  # @param camera_z [Array, NArray] The z-coordinate of the camera
275
308
  # @param center_x [Array, NArray] The x-coordinate of the center of focus
276
309
  # @param center_y [Array, NArray] The y-coordinate of the center of focus
277
310
  # @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
311
+ # @param up_x [Array, NArray] The x-component of the up direction
312
+ # @param up_y [Array, NArray] The y-component of the up direction
313
+ # @param up_z [Array, NArray] The z-component of the up direction
314
+ #
315
+ # @!method cameralookat
284
316
 
285
317
  # This function sets the projection parameters.
286
318
  # 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.
319
+ #
320
+ # The ratio between zFar and zNear influences the precision of the depth
321
+ # buffer, the greater (zFar/zNear), the more likely are errors. So you should
322
+ # try to keep both values as close to each other as possible while making
323
+ # sure everything you want to be visible, is visible.
324
+ #
325
+ # @param vertical_field_of_view [Numeric]
326
+ # This parameter is the vertical field of view in degrees.
327
+ # It must be greater than 0 and less than 180.
289
328
  # @param zNear [Numeric] The distance to the near clipping plane.
290
- # @param zFar [Numeric] The distance to the far clipping plane.
329
+ # @param zFar [Numeric] The distance to the far clipping plane.
330
+ #
291
331
  # @return [Integer]
292
- def setcameraprojectionparameters(*)
293
- super
294
- end
332
+ #
333
+ # @!method setcameraprojectionparameters
295
334
 
296
335
  # Get the projection parameters.
336
+ #
337
+ # @param vfov [Array, NArray] Vertical field of view in degrees
338
+ # @param znear [Array, NArray] The distance to the near clipping plane.
339
+ # @param zfar [Array, NArray] The distance to the far clipping plane.
340
+ #
297
341
  # @return [Integer]
298
- def getcameraprojectionparameters(*)
299
- super
300
- end
342
+ #
343
+ # @!method getcameraprojectionparameters
301
344
 
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.
345
+ # This function sets the direction of light. If it is called with (0, 0, 0),
346
+ # the light is always pointing into the same direction as the camera.
347
+ #
304
348
  # @param x [Numeric] The x-component of the light's direction
305
349
  # @param y [Numeric] The y-component of the light's direction
306
350
  # @param z [Numeric] The z-component of the light's direction
307
- def setlightdirection(*)
308
- super
309
- end
351
+ #
352
+ # @!method setlightdirection
310
353
 
311
354
  # This function sets the background color.
312
- def setbackgroundcolor(*)
313
- super
314
- end
355
+ # @!method setbackgroundcolor
315
356
 
316
357
  # @return [Integer]
317
- def createheightmapmesh(*)
318
- super
319
- end
358
+ # @!method createheightmapmesh
320
359
 
321
- def drawheightmap(*)
322
- super
323
- end
360
+ # @!method drawheightmap
324
361
 
325
362
  # This function allows drawing a cylinder without requiring a mesh.
326
- def drawconemesh(*)
327
- super
328
- end
363
+ # @!method drawconemesh
329
364
 
330
365
  # This function allows drawing a cylinder without requiring a mesh.
331
- def drawcylindermesh(*)
332
- super
333
- end
366
+ # @!method drawcylindermesh
334
367
 
335
368
  # This function allows drawing a sphere without requiring a mesh.
336
- def drawspheremesh(*)
337
- super
338
- end
369
+ # @!method drawspheremesh
339
370
 
340
- def drawcubemesh(*)
341
- super
342
- end
371
+ # @!method drawcubemesh
343
372
 
344
- def setobjectid(*)
345
- super
346
- end
373
+ # @!method setobjectid
347
374
 
348
375
  # @return [Integer]
349
- def selectid(*)
350
- super
351
- end
376
+ # @!method selectid
352
377
 
353
- def getviewmatrix(*)
354
- super
355
- end
378
+ # @param m [Array, NArray] the 4x4 column major view matrix
379
+ # @!method getviewmatrix
356
380
 
357
- def setviewmatrix(*)
358
- super
359
- end
381
+ # @param m [Array, NArray] the 4x4 column major view matrix
382
+ # @!method setviewmatrix
360
383
 
361
- # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
362
384
  # @return [Integer]
363
- def getprojectiontype(*)
364
- super
365
- end
385
+ # the current projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
386
+ # @!method getprojectiontype
366
387
 
367
- # @param type [Integer] the new projection type: GR3_PROJECTION_PERSPECTIVE or GR3_PROJECTION_PARALLEL
368
- def setprojectiontype(*)
369
- super
370
- end
388
+ # @param type [Integer]
389
+ # the new projection type: GR3_PROJECTION_PERSPECTIVE,
390
+ # GR3_PROJECTION_PARALLEL or GR3_PROJECTION_ORTHOGRAPHIC
391
+ # @!method setprojectiontype
371
392
 
372
393
  # This function creates an isosurface from voxel data using the
373
394
  # marching cubes algorithm.
374
395
  # 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
396
+ #
397
+ # @param grid [NArray] 3D narray array containing the voxel data
398
+ # @param step [Array, NArray] voxel sizes in each direction
399
+ # @param offset [Array, NArray] coordinate origin in each direction
400
+ # @param isolevel [Integer] isovalue at which the surface will be created
401
+ #
379
402
  # @return [Integer]
403
+ #
380
404
  def createisosurfacemesh(grid, step, offset, isolevel)
381
405
  args = _preprocess_createslicemesh(grid, step, offset)
382
406
  grid = args.shift
@@ -388,10 +412,11 @@ module GR3
388
412
  # Create a mesh of a surface plot similar to gr_surface.
389
413
  # Uses the current colormap. To apply changes of the colormap
390
414
  # 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
415
+ #
416
+ # @param nx [Integer] number of points in x-direction
417
+ # @param ny [Integer] number of points in y-direction
418
+ # @param x [Array, NArray] an array containing the x-coordinates
419
+ # @param y [Array, NArray] an array containing the y-coordinates
395
420
  # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
396
421
  # @param option [Integer] option for the surface mesh; the GR3_SURFACE constants can be combined with bitwise or. See the table below.
397
422
  # * 0 : GR3_SURFACE_DEFAULT
@@ -406,6 +431,7 @@ module GR3
406
431
  # * color the surface according to the current gr colormap
407
432
  # * 16 : GR3_SURFACE_GRZSHADED
408
433
  # * like GR3_SURFACE_GRCOLOR, but use the z-value directly as color index
434
+ #
409
435
  # @return [Integer]
410
436
  def createsurfacemesh(nx, ny, x, y, z, option = 0)
411
437
  inquiry_int do |mesh|
@@ -419,29 +445,32 @@ module GR3
419
445
  # the viewmatrix and the light direction. If necessary, the user has to
420
446
  # save them before the call to this function and restore them after
421
447
  # 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
448
+ #
449
+ # @param mesh [Integer] the mesh to be drawn
450
+ # @param n [Integer] the number of meshes to be drawn
451
+ # @param positions [Array, NArray] the positions where the meshes should be drawn
425
452
  # @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
453
+ # @param ups [Array, NArray] the up directions
454
+ # @param colors [Array, NArray] the colors the meshes should be drawn in,
455
+ # it will be multiplied with each vertex color
456
+ # @param scales [Array, NArray] the scaling factors
457
+ #
458
+ # @!method drawmesh_grlike
432
459
 
433
460
  # Convenience function for drawing a surfacemesh.
461
+ #
434
462
  # @param mesh [Integer] the mesh to be drawn
435
- def drawsurface(*)
436
- super
437
- end
463
+ #
464
+ # @!method drawsurface
438
465
 
439
466
  # 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.
467
+ #
468
+ # @param x [Array, NArray] an array containing the x-coordinates
469
+ # @param y [Array, NArray] an array containing the y-coordinates
470
+ # @param z [Array, NArray] an array of length nx * ny containing the z-coordinates
471
+ # @param option [Integer] see the option parameter of gr_surface.
472
+ # OPTION_COLORED_MESH and OPTION_Z_SHADED_MESH are supported.
473
+ #
445
474
  def surface(x, y, z, option)
446
475
  nx = x.length
447
476
  ny = y.length
@@ -449,17 +478,20 @@ module GR3
449
478
  super(nx, ny, x, y, z, option)
450
479
  end
451
480
 
452
- # drawtubemesh
453
481
  # Draw a tube following a path given by a list of points. The colors and
454
482
  # radii arrays specify the color and radius at each point.
455
- # @param n [Integer] the number of points given
483
+ #
484
+ # @param n [Integer] the number of points given
456
485
  # @param points [Array, NArray] the points the tube should go through
457
486
  # @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
487
+ # @param radii [Array, NArray] the desired tube radius at each point
488
+ # @param num_steps [Integer] the number of steps between each point,
489
+ # allowing for a more smooth tube
490
+ # @param num_segments [Integer] the number of segments each ring of the tube
491
+ # consists of, e.g. 3 would yield a triangular tube
492
+ #
462
493
  # @return [Integer]
494
+ #
463
495
  def drawtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
464
496
  super(n, points, colors, radii, num_steps, num_segments)
465
497
  end
@@ -467,12 +499,17 @@ module GR3
467
499
  # Create a mesh object in the shape of a tube following a path given by a
468
500
  # list of points. The colors and radii arrays specify the color and radius at
469
501
  # 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
502
+ #
503
+ # @param n [Integer] the number of points given
504
+ # @param points [Array, NArray] the points the tube should go through
505
+ # @param colors [Array, NArray] the color at each point
506
+ # @param radii [Array, NArray] the desired tube radius at each point
507
+ # @param num_steps [Integer] the number of steps between each point,
508
+ # allowing for a more smooth tube
509
+ # @param num_segments [Integer] the number of segments each ring of the
510
+ # tube consists of, e.g. 3 would yield a
511
+ # triangular tube
512
+ #
476
513
  # @return [Integer]
477
514
  def createtubemesh(n, points, colors, radii, num_steps = 10, num_segments = 20)
478
515
  inquiry_uint do |mesh| # mesh should be Int?
@@ -547,12 +584,14 @@ module GR3
547
584
  # drawn and at which positions they should go through the data. If neither
548
585
  # x nor y nor z are set, 0.5 will be used for all three.
549
586
  # 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
587
+ #
588
+ # @param grid [NArray] 3D narray array containing the voxel data
589
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
590
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
591
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
592
+ # @param step [Array, NArray] voxel sizes in each direction
593
+ # @param offset [Array, NArray] coordinate origin in each direction
594
+ #
556
595
  def createslicemeshes(grid, x = nil, y = nil, z = nil, step = nil, offset = nil)
557
596
  if [x, y, z].all?(&:nil?)
558
597
  x = 0.5
@@ -569,10 +608,11 @@ module GR3
569
608
  # using the current GR colormap. Use the x parameter to set the position of
570
609
  # the yz-slice.
571
610
  # 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
611
+ #
612
+ # @param grid [NArray] 3D narray array containing the voxel data
613
+ # @param x [Numeric] the position of the slice through the xz-plane (0 to 1)
614
+ # @param step [Array, NArray] voxel sizes in each direction
615
+ # @param offset [Array, NArray] coordinate origin in each direction
576
616
  def createxslicemesh(grid, x = 0.5, step = nil, offset = nil)
577
617
  args = _preprocess_createslicemesh(grid, step, offset)
578
618
  grid = args.shift
@@ -586,10 +626,12 @@ module GR3
586
626
  # using the current GR colormap. Use the y parameter to set the position of
587
627
  # the xz-slice.
588
628
  # 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
629
+ #
630
+ # @param grid [NArray] 3D narray array containing the voxel data
631
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
632
+ # @param step [Array, NArray] voxel sizes in each direction
633
+ # @param offset [Array, NArray] coordinate origin in each direction
634
+ #
593
635
  def createyslicemesh(grid, y = 0.5, step = nil, offset = nil)
594
636
  args = _preprocess_createslicemesh(grid, step, offset)
595
637
  grid = args.shift
@@ -603,10 +645,12 @@ module GR3
603
645
  # using the current GR colormap. Use the z parameter to set the position of
604
646
  # the xy-slice.
605
647
  # 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
648
+ #
649
+ # @param grid [NArray] 3D narray array containing the voxel data
650
+ # @param z [Numeric] the position of the slice through the xz-plane (0 to 1)
651
+ # @param step [Array, NArray] voxel sizes in each direction
652
+ # @param offset [Array, NArray] coordinate origin in each direction
653
+ #
610
654
  def createzslicemesh(grid, z = 0.5, step = nil, offset = nil)
611
655
  args = _preprocess_createslicemesh(grid, step, offset)
612
656
  grid = args.shift
@@ -617,15 +661,18 @@ module GR3
617
661
  end
618
662
 
619
663
  # 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
664
+ #
665
+ # @param grid [NArray] 3D narray array containing the voxel data
666
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
667
+ # @param step [Array, NArray] voxel sizes in each direction
668
+ # @param offset [Array, NArray] coordinate origin in each direction
669
+ # @param position [Array, NArray] the positions where the meshes should be drawn
670
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
671
+ # @param up [Array, NArray] the up directions
672
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
673
+ # it will be multiplied with each vertex color
674
+ # @param scale [Array, NArray] the scaling factors
675
+ #
629
676
  def drawxslicemesh(grid, x = 0.5, step = nil, offset = nil,
630
677
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
631
678
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -635,15 +682,18 @@ module GR3
635
682
  end
636
683
 
637
684
  # 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
685
+ #
686
+ # @param grid [NArray] 3D narray array containing the voxel data
687
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
688
+ # @param step [Array, NArray] voxel sizes in each direction
689
+ # @param offset [Array, NArray] coordinate origin in each direction
690
+ # @param position [Array, NArray] the positions where the meshes should be drawn
691
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
692
+ # @param up [Array, NArray] the up directions
693
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
694
+ # it will be multiplied with each vertex color
695
+ # @param scale [Array, NArray] the scaling factors
696
+ #
647
697
  def drawyslicemesh(grid, y = 0.5, step = nil, offset = nil,
648
698
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
649
699
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -653,15 +703,18 @@ module GR3
653
703
  end
654
704
 
655
705
  # 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
706
+ #
707
+ # @param grid [NArray] 3D narray array containing the voxel data
708
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
709
+ # @param step [Array, NArray] voxel sizes in each direction
710
+ # @param offset [Array, NArray] coordinate origin in each direction
711
+ # @param position [Array, NArray] the positions where the meshes should be drawn
712
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
713
+ # @param up [Array, NArray] the up directions
714
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
715
+ # it will be multiplied with each vertex color
716
+ # @param scale [Array, NArray] the scaling factors
717
+ #
665
718
  def drawzslicemesh(grid, z = 0.5, step = nil, offset = nil,
666
719
  position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
667
720
  color = [1, 1, 1], scale = [1, 1, 1])
@@ -674,17 +727,20 @@ module GR3
674
727
  # Use the parameters x, y or z to specify what slices should be drawn and at
675
728
  # which positions they should go through the data. If neither x nor y nor
676
729
  # z are set, 0.5 will be used for all three.
730
+ #
677
731
  # @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
732
+ # @param x [Numeric] the position of the slice through the yz-plane (0 to 1)
733
+ # @param y [Numeric] the position of the slice through the xz-plane (0 to 1)
734
+ # @param z [Numeric] the position of the slice through the xy-plane (0 to 1)
735
+ # @param step [Array, NArray] voxel sizes in each direction
736
+ # @param offset [Array, NArray] coordinate origin in each direction
737
+ # @param position [Array, NArray] the positions where the meshes should be drawn
738
+ # @param direction [Array, NArray] the forward directions the meshes should be facing at
739
+ # @param up [Array, NArray] the up directions
740
+ # @param color [Array, NArray] the colors the meshes should be drawn in,
741
+ # it will be multiplied with each vertex color
742
+ # @param scale [Array, NArray] the scaling factors
743
+ #
688
744
  def drawslicemeshes(grid, x = nil, y = nil, z = nil, step = nil,
689
745
  offset = nil, position = [0, 0, 0], direction = [0, 0, 1], up = [0, 1, 0],
690
746
  color = [1, 1, 1], scale = [1, 1, 1])