Module: GR

Extended by:
GRCommons::GRCommonUtils, GRCommons::JupyterSupport
Defined in:
lib/gr.rb,
lib/gr.rb,
lib/gr/ffi.rb,
lib/gr/grbase.rb

Defined Under Namespace

Modules: FFI

Constant Summary collapse

ASF_BUNDLED =

Constants

0
ASF_INDIVIDUAL =
1
NOCLIP =
0
CLIP =
1
COORDINATES_WC =
0
COORDINATES_NDC =
1
INTSTYLE_HOLLOW =
0
INTSTYLE_SOLID =
1
INTSTYLE_PATTERN =
2
INTSTYLE_HATCH =
3
TEXT_HALIGN_NORMAL =
0
TEXT_HALIGN_LEFT =
1
TEXT_HALIGN_CENTER =
2
TEXT_HALIGN_RIGHT =
3
TEXT_VALIGN_NORMAL =
0
TEXT_VALIGN_TOP =
1
TEXT_VALIGN_CAP =
2
TEXT_VALIGN_HALF =
3
TEXT_VALIGN_BASE =
4
TEXT_VALIGN_BOTTOM =
5
TEXT_PATH_RIGHT =
0
TEXT_PATH_LEFT =
1
TEXT_PATH_UP =
2
TEXT_PATH_DOWN =
3
TEXT_PRECISION_STRING =
0
TEXT_PRECISION_CHAR =
1
TEXT_PRECISION_STROKE =
2
LINETYPE_SOLID =
1
LINETYPE_DASHED =
2
LINETYPE_DOTTED =
3
LINETYPE_DASHED_DOTTED =
4
LINETYPE_DASH_2_DOT =
-1
LINETYPE_DASH_3_DOT =
-2
LINETYPE_LONG_DASH =
-3
LINETYPE_LONG_SHORT_DASH =
-4
LINETYPE_SPACED_DASH =
-5
LINETYPE_SPACED_DOT =
-6
LINETYPE_DOUBLE_DOT =
-7
LINETYPE_TRIPLE_DOT =
-8
MARKERTYPE_DOT =
1
MARKERTYPE_PLUS =
2
MARKERTYPE_ASTERISK =
3
MARKERTYPE_CIRCLE =
4
MARKERTYPE_DIAGONAL_CROSS =
5
MARKERTYPE_SOLID_CIRCLE =
-1
MARKERTYPE_TRIANGLE_UP =
-2
MARKERTYPE_SOLID_TRI_UP =
-3
MARKERTYPE_TRIANGLE_DOWN =
-4
MARKERTYPE_SOLID_TRI_DOWN =
-5
MARKERTYPE_SQUARE =
-6
MARKERTYPE_SOLID_SQUARE =
-7
MARKERTYPE_BOWTIE =
-8
MARKERTYPE_SOLID_BOWTIE =
-9
MARKERTYPE_HOURGLASS =
-10
MARKERTYPE_SOLID_HGLASS =
-11
MARKERTYPE_DIAMOND =
-12
MARKERTYPE_SOLID_DIAMOND =
-13
MARKERTYPE_STAR =
-14
MARKERTYPE_SOLID_STAR =
-15
MARKERTYPE_TRI_UP_DOWN =
-16
MARKERTYPE_SOLID_TRI_RIGHT =
-17
MARKERTYPE_SOLID_TRI_LEFT =
-18
MARKERTYPE_HOLLOW_PLUS =
-19
MARKERTYPE_SOLID_PLUS =
-20
MARKERTYPE_PENTAGON =
-21
MARKERTYPE_HEXAGON =
-22
MARKERTYPE_HEPTAGON =
-23
MARKERTYPE_OCTAGON =
-24
MARKERTYPE_STAR_4 =
-25
MARKERTYPE_STAR_5 =
-26
MARKERTYPE_STAR_6 =
-27
MARKERTYPE_STAR_7 =
-28
MARKERTYPE_STAR_8 =
-29
MARKERTYPE_VLINE =
-30
MARKERTYPE_HLINE =
-31
MARKERTYPE_OMARK =
-32
OPTION_X_LOG =
1
OPTION_Y_LOG =
2
OPTION_Z_LOG =
4
OPTION_FLIP_X =
8
OPTION_FLIP_Y =
16
OPTION_FLIP_Z =
32
OPTION_LINES =
0
OPTION_MESH =
1
OPTION_FILLED_MESH =
2
OPTION_Z_SHADED_MESH =
3
OPTION_COLORED_MESH =
4
OPTION_CELL_ARRAY =
5
OPTION_SHADED_MESH =
6
MODEL_RGB =
0
MODEL_HSV =
1
COLORMAP_UNIFORM =
0
COLORMAP_TEMPERATURE =
1
COLORMAP_GRAYSCALE =
2
COLORMAP_GLOWING =
3
COLORMAP_RAINBOWLIKE =
4
COLORMAP_GEOLOGIC =
5
COLORMAP_GREENSCALE =
6
COLORMAP_CYANSCALE =
7
COLORMAP_BLUESCALE =
8
COLORMAP_MAGENTASCALE =
9
COLORMAP_REDSCALE =
10
COLORMAP_FLAME =
11
COLORMAP_BROWNSCALE =
12
COLORMAP_PILATUS =
13
COLORMAP_AUTUMN =
14
COLORMAP_BONE =
15
COLORMAP_COOL =
16
COLORMAP_COPPER =
17
COLORMAP_GRAY =
18
COLORMAP_HOT =
19
COLORMAP_HSV =
20
COLORMAP_JET =
21
COLORMAP_PINK =
22
COLORMAP_SPECTRAL =
23
COLORMAP_SPRING =
24
COLORMAP_SUMMER =
25
COLORMAP_WINTER =
26
COLORMAP_GIST_EARTH =
27
COLORMAP_GIST_HEAT =
28
COLORMAP_GIST_NCAR =
29
COLORMAP_GIST_RAINBOW =
30
COLORMAP_GIST_STERN =
31
COLORMAP_AFMHOT =
32
COLORMAP_BRG =
33
COLORMAP_BWR =
34
COLORMAP_COOLWARM =
35
COLORMAP_CMRMAP =
36
COLORMAP_CUBEHELIX =
37
COLORMAP_GNUPLOT =
38
COLORMAP_GNUPLOT2 =
39
COLORMAP_OCEAN =
40
COLORMAP_RAINBOW =
41
COLORMAP_SEISMIC =
42
COLORMAP_TERRAIN =
43
COLORMAP_VIRIDIS =
44
COLORMAP_INFERNO =
45
COLORMAP_PLASMA =
46
COLORMAP_MAGMA =
47
FONT_TIMES_ROMAN =
101
FONT_TIMES_ITALIC =
102
FONT_TIMES_BOLD =
103
FONT_TIMES_BOLDITALIC =
104
FONT_HELVETICA =
105
FONT_HELVETICA_OBLIQUE =
106
FONT_HELVETICA_BOLD =
107
FONT_HELVETICA_BOLDOBLIQUE =
108
FONT_COURIER =
109
FONT_COURIER_OBLIQUE =
110
FONT_COURIER_BOLD =
111
FONT_COURIER_BOLDOBLIQUE =
112
FONT_SYMBOL =
113
FONT_BOOKMAN_LIGHT =
114
FONT_BOOKMAN_LIGHTITALIC =
115
FONT_BOOKMAN_DEMI =
116
FONT_BOOKMAN_DEMIITALIC =
117
FONT_NEWCENTURYSCHLBK_ROMAN =
118
FONT_NEWCENTURYSCHLBK_ITALIC =
119
FONT_NEWCENTURYSCHLBK_BOLD =
120
FONT_NEWCENTURYSCHLBK_BOLDITALIC =
121
FONT_AVANTGARDE_BOOK =
122
FONT_AVANTGARDE_BOOKOBLIQUE =
123
FONT_AVANTGARDE_DEMI =
124
FONT_AVANTGARDE_DEMIOBLIQUE =
125
FONT_PALATINO_ROMAN =
126
FONT_PALATINO_ITALIC =
127
FONT_PALATINO_BOLD =
128
FONT_PALATINO_BOLDITALIC =
129
FONT_ZAPFCHANCERY_MEDIUMITALIC =
130
FONT_ZAPFDINGBATS =
131
PATH_STOP =
0x00
PATH_MOVETO =
0x01
PATH_LINETO =
0x02
PATH_CURVE3 =
0x03
PATH_CURVE4 =
0x04
PATH_CLOSEPOLY =
0x4f
MPL_SUPPRESS_CLEAR =
1
MPL_POSTPONE_UPDATE =
2
XFORM_BOOLEAN =
0
XFORM_LINEAR =
1
XFORM_LOG =
2
XFORM_LOGLOG =
3
XFORM_CUBIC =
4
XFORM_EQUALIZED =
5

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from GRCommons::JupyterSupport

extended, show

Class Attribute Details

.ffi_libObject (readonly)

Returns the value of attribute ffi_lib.



7
8
9
# File 'lib/gr.rb', line 7

def ffi_lib
  @ffi_lib
end

Class Method Details

.adjustlimits(_amin, _amax) ⇒ Object



311
312
313
314
315
# File 'lib/gr.rb', line 311

def adjustlimits(_amin, _amax)
  inquiry %i[double double] do |*pts|
    super(*pts)
  end
end

.cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color) ⇒ Object



64
65
66
# File 'lib/gr.rb', line 64

def cellarray(xmin, xmax, ymin, ymax, dimx, dimy, color)
  super(xmin, xmax, ymin, ymax, dimx, dimy, 1, 1, dimx, dimy, int(color))
end

.contour(px, py, h, pz, major_h) ⇒ Object



206
207
208
209
210
211
212
# File 'lib/gr.rb', line 206

def contour(px, py, h, pz, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = length(px)
  ny = length(py)
  nh = h.size
  super(nx, ny, nh, px, py, h, pz, major_h)
end

.contourf(px, py, h, pz, major_h) ⇒ Object



214
215
216
217
218
219
220
# File 'lib/gr.rb', line 214

def contourf(px, py, h, pz, major_h)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = length(px)
  ny = length(py)
  nh = h.size
  super(nx, ny, nh, px, py, h, pz, major_h)
end

.drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0) ⇒ Object



289
290
291
# File 'lib/gr.rb', line 289

def drawimage(xmin, xmax, ymin, ymax, width, height, data, model = 0)
  super(xmin, xmax, ymin, ymax, width, height, int(data), model)
end

.drawpath(points, codes, fill) ⇒ Object



284
285
286
287
# File 'lib/gr.rb', line 284

def drawpath(points, codes, fill)
  len = length(codes)
  super(len, points, uint8(codes), fill)
end

.fillarea(x, y) ⇒ Object



59
60
61
62
# File 'lib/gr.rb', line 59

def fillarea(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.gdp(x, y, primid, datrec) ⇒ Object



78
79
80
81
82
# File 'lib/gr.rb', line 78

def gdp(x, y, primid, datrec)
  n = equal_length(x, y)
  ldr = length(datrec, :int)
  super(n, x, y, primid, ldr, datrec)
end

.gradient(x, y, z) ⇒ Object



190
191
192
193
194
195
196
197
# File 'lib/gr.rb', line 190

def gradient(x, y, z)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = length(x)
  ny = length(y)
  inquiry [{ double: nx * ny }, { double: nx * ny }] do |pu, pv|
    super(nx, ny, x, y, z, pu, pv)
  end
end

.gridit(xd, yd, zd, nx, ny) ⇒ Object



89
90
91
92
93
94
# File 'lib/gr.rb', line 89

def gridit(xd, yd, zd, nx, ny)
  nd = equal_length(xd, yd, zd)
  inquiry [{ double: nx }, { double: ny }, { double: nx * ny }] do |px, py, pz|
    super(nd, xd, yd, zd, nx, ny, px, py, pz)
  end
end

.herrorbars(px, py, e1, e2) ⇒ Object



163
164
165
166
# File 'lib/gr.rb', line 163

def herrorbars(px, py, e1, e2)
  n = equal_length(px, py, e1, e2)
  super(n, px, py, e1, e2)
end

.hexbin(x, y, nbins) ⇒ Object



228
229
230
231
# File 'lib/gr.rb', line 228

def hexbin(x, y, nbins)
  n = length(x)
  super(n, x, y, nbins)
end

.hsvtorgb(h, s, v) ⇒ Object



253
254
255
256
257
# File 'lib/gr.rb', line 253

def hsvtorgb(h, s, v)
  inquiry %i[double double double] do |r, g, b|
    super(h, s, v, r, g, b)
  end
end

.inqbboxObject



305
306
307
308
309
# File 'lib/gr.rb', line 305

def inqbbox
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.inqcolor(color) ⇒ Object



247
248
249
250
251
# File 'lib/gr.rb', line 247

def inqcolor(color)
  inquiry_int do |rgb|
    super(color, rgb)
  end
end

.inqcolormapObject



233
234
235
# File 'lib/gr.rb', line 233

def inqcolormap
  inquiry_int { |pt| super(pt) }
end

.inqdspsizeObject



37
38
39
40
41
# File 'lib/gr.rb', line 37

def inqdspsize
  inquiry %i[double double int int] do |*pts|
    super(*pts)
  end
end

.inqfillcolorindObject



124
125
126
# File 'lib/gr.rb', line 124

def inqfillcolorind
  inquiry_int { |pt| super(pt) }
end

.inqfillintstyleObject



116
117
118
# File 'lib/gr.rb', line 116

def inqfillintstyle
  inquiry_int { |pt| super(pt) }
end

.inqfillstyleObject



120
121
122
# File 'lib/gr.rb', line 120

def inqfillstyle
  inquiry_int { |pt| super(pt) }
end

.inqlinecolorindObject



104
105
106
# File 'lib/gr.rb', line 104

def inqlinecolorind
  inquiry_int { |pt| super(pt) }
end

.inqlinetypeObject



96
97
98
# File 'lib/gr.rb', line 96

def inqlinetype
  inquiry_int { |pt| super(pt) }
end

.inqlinewidthObject



100
101
102
# File 'lib/gr.rb', line 100

def inqlinewidth
  inquiry_double { |pt| super(pt) }
end

.inqmarkercolorindObject



112
113
114
# File 'lib/gr.rb', line 112

def inqmarkercolorind
  inquiry_int { |pt| super(pt) }
end

.inqmarkertypeObject



108
109
110
# File 'lib/gr.rb', line 108

def inqmarkertype
  inquiry_int { |pt| super(pt) }
end

.inqmathtex(x, y, string) ⇒ Object



299
300
301
302
303
# File 'lib/gr.rb', line 299

def inqmathtex(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqscaleObject



128
129
130
# File 'lib/gr.rb', line 128

def inqscale
  inquiry_int { |pt| super(pt) }
end

.inqspaceObject



150
151
152
153
154
# File 'lib/gr.rb', line 150

def inqspace
  inquiry %i[double double int int] do |*pts|
    super(*pts)
  end
end

.inqtext(x, y, string) ⇒ Object



53
54
55
56
57
# File 'lib/gr.rb', line 53

def inqtext(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqtextext(x, y, string) ⇒ Object



132
133
134
135
136
# File 'lib/gr.rb', line 132

def inqtextext(x, y, string)
  inquiry [{ double: 4 }, { double: 4 }] do |tbx, tby|
    super(x, y, string, tbx, tby)
  end
end

.inqviewportObject



144
145
146
147
148
# File 'lib/gr.rb', line 144

def inqviewport
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.inqwindowObject



138
139
140
141
142
# File 'lib/gr.rb', line 138

def inqwindow
  inquiry %i[double double double double] do |*pts|
    super(*pts)
  end
end

.ndctowc(x, y) ⇒ Object



259
260
261
262
263
264
265
# File 'lib/gr.rb', line 259

def ndctowc(x, y)
  inquiry %i[double double] do |px, py|
    px.write_double x
    py.write_double y
    super(px, py)
  end
end

.nonuniformcellarray(x, y, dimx, dimy, color) ⇒ Object

Raises:

  • (ArgumentError)


68
69
70
71
72
# File 'lib/gr.rb', line 68

def nonuniformcellarray(x, y, dimx, dimy, color)
  raise ArgumentError unless length(x) == dimx + 1 && length(y) == dimy + 1

  super(x, y, dimx, dimy, 1, 1, dimx, dimy, int(color))
end

.panzoom(x, y, zoom) ⇒ Object



341
342
343
344
345
# File 'lib/gr.rb', line 341

def panzoom(x, y, zoom)
  inquiry %i[double double double double] do |xmin, xmax, ymin, ymax|
    super(x, y, zoom, zoom, xmin, xmax, ymin, ymax)
  end
end

.polarcellarray(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, color) ⇒ Object



74
75
76
# File 'lib/gr.rb', line 74

def polarcellarray(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, color)
  super(x_org, y_org, phimin, phimax, rmin, rmax, dimphi, dimr, 1, 1, dimphi, dimr, int(color))
end

.polyline(x, y) ⇒ Object



43
44
45
46
# File 'lib/gr.rb', line 43

def polyline(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.polyline3d(px, py, pz) ⇒ Object



168
169
170
171
# File 'lib/gr.rb', line 168

def polyline3d(px, py, pz)
  n = equal_length(px, py, pz)
  super(n, px, py, pz)
end

.polymarker(x, y) ⇒ Object



48
49
50
51
# File 'lib/gr.rb', line 48

def polymarker(x, y)
  n = equal_length(x, y)
  super(n, x, y)
end

.polymarker3d(px, py, pz) ⇒ Object



173
174
175
176
# File 'lib/gr.rb', line 173

def polymarker3d(px, py, pz)
  n = equal_length(px, py, pz)
  super(n, px, py, pz)
end

.quiver(x, y, u, v, color) ⇒ Object



199
200
201
202
203
204
# File 'lib/gr.rb', line 199

def quiver(x, y, u, v, color)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = length(x)
  ny = length(y)
  super(nx, ny, x, y, u, v, (color ? 1 : 0))
end

.reducepoints(xd, yd, n) ⇒ Object



321
322
323
324
325
326
327
# File 'lib/gr.rb', line 321

def reducepoints(xd, yd, n)
  nd = equal_length(xd, yd)
  inquiry [{ double: n }, { double: n }] do |x, y|
    # Different from Julia. x, y are initialized zero.
    super(nd, xd, yd, n, x, y)
  end
end

.setcolormapfromrgb(r, g, b, positions: nil) ⇒ Object



237
238
239
240
241
242
243
244
245
# File 'lib/gr.rb', line 237

def setcolormapfromrgb(r, g, b, positions: nil)
  n = equal_length(r, g, b)
  if positions.nil?
    positions = ::FFI::Pointer::NULL
  else
    raise if length(positions) != n
  end
  super(n, r, g, b, positions)
end

.setcoordxform(mat) ⇒ Object



293
294
295
296
297
# File 'lib/gr.rb', line 293

def setcoordxform(mat)
  raise if mat.size != 6

  super(mat)
end

.shadelines(x, y, dims: [1200, 1200], xform: 1) ⇒ Object



335
336
337
338
339
# File 'lib/gr.rb', line 335

def shadelines(x, y, dims: [1200, 1200], xform: 1)
  n = length(x)
  w, h = dims
  super(n, x, y, xform, w, h)
end

.shadepoints(x, y, dims: [1200, 1200], xform: 1) ⇒ Object



329
330
331
332
333
# File 'lib/gr.rb', line 329

def shadepoints(x, y, dims: [1200, 1200], xform: 1)
  n = length(x)
  w, h = dims
  super(n, x, y, xform, w, h)
end

.spline(px, py, m, method) ⇒ Object



84
85
86
87
# File 'lib/gr.rb', line 84

def spline(px, py, m, method)
  n = equal_length(px, py)
  super(n, px, py, m, method)
end

.surface(px, py, pz, option) ⇒ Object



178
179
180
181
182
183
# File 'lib/gr.rb', line 178

def surface(px, py, pz, option)
  # TODO: check: Arrays have incorrect length or dimension.
  nx = length(px)
  ny = length(py)
  super(nx, ny, px, py, pz, option)
end

.tricontour(x, y, z, levels) ⇒ Object



222
223
224
225
226
# File 'lib/gr.rb', line 222

def tricontour(x, y, z, levels)
  npoints = length(x) # equal_length ?
  nlevels = length(levels)
  super(npoints, x, y, z, nlevels, levels)
end

.trisurface(px, py, pz) ⇒ Object



185
186
187
188
# File 'lib/gr.rb', line 185

def trisurface(px, py, pz)
  n = [length(px), length(py), length(pz)].min
  super(n, px, py, pz)
end

.verrorbars(px, py, e1, e2) ⇒ Object



158
159
160
161
# File 'lib/gr.rb', line 158

def verrorbars(px, py, e1, e2)
  n = equal_length(px, py, e1, e2)
  super(n, px, py, e1, e2)
end

.versionObject



317
318
319
# File 'lib/gr.rb', line 317

def version
  super.read_string
end

.wc3towc(x, y, z) ⇒ Object



275
276
277
278
279
280
281
282
# File 'lib/gr.rb', line 275

def wc3towc(x, y, z)
  inquiry %i[double double double] do |px, py, pz|
    px.write_double x
    py.write_double y
    pz.write_double z
    super(px, py, pz)
  end
end

.wctondc(x, y) ⇒ Object



267
268
269
270
271
272
273
# File 'lib/gr.rb', line 267

def wctondc(x, y)
  inquiry %i[double double] do |px, py|
    px.write_double x
    py.write_double y
    super(px, py)
  end
end