From 6c647e8607097e93829b961bf40e853a239948bb Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Fri, 2 Feb 2024 16:30:40 +0100 Subject: [PATCH 1/6] Check 'GR_SCALE_FACTOR' regular heatmaps --- src/jlgr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jlgr.jl b/src/jlgr.jl index 6f8028e..064246b 100644 --- a/src/jlgr.jl +++ b/src/jlgr.jl @@ -1487,7 +1487,7 @@ function plot_data(flag=true, plt=plt[]) cmin, cmax = plt.kvs[:crange] levels = get(plt.kvs, :levels, 256) data = map(x -> normalize_color(x, cmin, cmax), z) - if kind === :heatmap + if kind === :heatmap && !haskey(ENV, "GR_SCALE_FACTOR") rgba = [to_rgba(value, cmap) for value = data] GR.drawimage(0.5, w + 0.5, h + 0.5, 0.5, w, h, rgba) else From e4b592cefef9e46ba36dfbbc8a670ee5b4b5bc10 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 5 Feb 2024 11:54:03 +0100 Subject: [PATCH 2/6] Add clip region functions --- src/GR.jl | 20 +++++++++++++++++++- src/libgr_syms.jl | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/GR.jl b/src/GR.jl index 8e4d7d0..48f51bc 100644 --- a/src/GR.jl +++ b/src/GR.jl @@ -187,6 +187,8 @@ export inqprojectiontype, setmathfont, inqmathfont, + setclipregion, + inqclipregion, # Convenience functions jlgr, colormap, @@ -2484,7 +2486,7 @@ Set axis titles to be displayed in subsequent axes calls. **Parameters:** `x_title`, `y_title`, `z_title` : - The text to be displayed on each axis + The text to be displayed on each axis """ function settitles3d(x_title, y_title, z_title) @@ -4358,6 +4360,22 @@ function inqmathfont() return _font[1] end +function setclipregion(region::Int) + ccall( libGR_ptr(:gr_setclipregion), + Nothing, + (Int32, ), + region) +end + +function inqclipregion() + _region = Cint[0] + ccall( libGR_ptr(:gr_inqclipregion), + Nothing, + (Ptr{Cint}, ), + _region) + return _region[1] +end + # JS functions include("js.jl") diff --git a/src/libgr_syms.jl b/src/libgr_syms.jl index a6c7548..0f371fc 100644 --- a/src/libgr_syms.jl +++ b/src/libgr_syms.jl @@ -161,4 +161,6 @@ :gr_moveselection :gr_setmathfont :gr_inqmathfont +:gr_setclipregion +:gr_inqclipregion ] From 360acfaa7bea7c23177d3dbea4e71e2e04df6c40 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Wed, 7 Feb 2024 12:44:45 +0100 Subject: [PATCH 3/6] Improve behaviour of size and figsize keyword args --- src/jlgr.jl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/jlgr.jl b/src/jlgr.jl index 064246b..311c3be 100644 --- a/src/jlgr.jl +++ b/src/jlgr.jl @@ -119,7 +119,7 @@ mutable struct PlotObject kvs::Dict{Symbol, Any} end -function Figure(width=600, height=450, dpi=100) +function Figure(width=600, height=450, dpi=nothing) obj = Dict{Symbol, Any}() args = [] kvs = copy(default_kvs) @@ -158,12 +158,17 @@ isvector(x::AbstractMatrix) = size(x, 1) == 1 function set_viewport(kind, subplot, plt=plt[]) mwidth, mheight, width, height = GR.inqdspsize() if haskey(plt.kvs, :figsize) - w = 0.0254 * width * plt.kvs[:figsize][1] / mwidth - h = 0.0254 * height * plt.kvs[:figsize][2] / mheight + w, h = plt.kvs[:figsize] + if w < 2 && h < 2 + # size values < 2 are interpreted as metric values + w = width * w / mwidth + h = height * h / mheight + end else if haskey(plt.kvs, :dpi) dpi = plt.kvs[:dpi] - else + end + if (dpi === nothing) dpi = round(width / mwidth * 0.0254, RoundNearestTiesUp) end if dpi > 200 From f833a41c064bdae8fb7a74169d60b759b3e8892b Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 12 Feb 2024 08:51:41 +0100 Subject: [PATCH 4/6] Support 'linewidth' attribute for 3d line plot --- src/jlgr.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/jlgr.jl b/src/jlgr.jl index 311c3be..0555a57 100644 --- a/src/jlgr.jl +++ b/src/jlgr.jl @@ -1539,6 +1539,8 @@ function plot_data(flag=true, plt=plt[]) plt.kvs[:zrange] = dmin, dmax colorbar(0.05) elseif kind === :plot3 + linewidth = get(plt.kvs, :linewidth, 1) + GR.setlinewidth(linewidth) GR.polyline3d(x, y, z) draw_axes(kind, 2) elseif kind === :scatter3 From aad0fea8d15e654233897b5c6a87cc27186b7a77 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 26 Feb 2024 13:05:54 +0100 Subject: [PATCH 5/6] Avoid 'inexact error' --- examples/brain.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/brain.jl b/examples/brain.jl index e2b856f..63a5dc6 100644 --- a/examples/brain.jl +++ b/examples/brain.jl @@ -32,7 +32,9 @@ function cursor(motion, x, y) center = spherical_to_cartesian(-2, pi * y / height + pi/2, pi * x / width) up = spherical_to_cartesian(1, pi * y / height + pi, pi * x / width) elseif GLFW.GetMouseButton(window, GLFW.MOUSE_BUTTON_2) - isolevel = round(Int, 255 * y / height) + if y >= 0 + isolevel = round(Int, 255 * y / height) + end end display() end From 4d9abc34c63c5d963f2433296b72c62a7d54114c Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Fri, 8 Mar 2024 13:22:55 +0100 Subject: [PATCH 6/6] release 0.73.3 --- Project.toml | 4 ++-- build_tarballs.jl | 6 +++--- src/downloader.jl | 2 +- src/js.jl | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Project.toml b/Project.toml index 2eca8bd..365ce8f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GR" uuid = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71" author = ["Josef Heinen (@jheinen)"] -version = "0.73.2" +version = "0.73.3" [deps] Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -29,7 +29,7 @@ p7zip_jll = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" Artifacts = "1" DelimitedFiles = "1" Downloads = "1" -GR_jll = "=0.73.2" +GR_jll = "=0.73.3" HTTP = "0.8, 0.9, 1" JSON = "0.20, 0.21, 1" Preferences = "1" diff --git a/build_tarballs.jl b/build_tarballs.jl index cb4b697..5330586 100644 --- a/build_tarballs.jl +++ b/build_tarballs.jl @@ -3,13 +3,13 @@ using BinaryBuilder name = "GR" -version = v"0.73.2" +version = v"0.73.3" # Collection of sources required to complete build sources = [ - GitSource("https://github.com/sciapp/gr.git", "eb444397b006c02e91201fcfe48c79b00c7009e7"), + GitSource("https://github.com/sciapp/gr.git", "9a2d15ddf0946274f9d662aaff857a7373b5ecd7"), FileSource("https://github.com/sciapp/gr/releases/download/v$version/gr-$version.js", - "56e34e09194f8d168853206bd737fa34439b88edea49a0e675d52536bba5ae7a", "gr.js"), + "f572f7f21733a3ba2c9b442c1a835b704bfca1dcfc1faee59832d0fc3766b4ef", "gr.js"), ArchiveSource("https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX10.14.sdk.tar.xz", "0f03869f72df8705b832910517b47dd5b79eb4e160512602f593ed243b28715f") ] diff --git a/src/downloader.jl b/src/downloader.jl index 0fa37f1..e7e9a58 100644 --- a/src/downloader.jl +++ b/src/downloader.jl @@ -11,7 +11,7 @@ using Tar using Downloads using p7zip_jll -const version = v"0.73.2" +const version = v"0.73.3" const GR_UUID = UUID("28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71") diff --git a/src/js.jl b/src/js.jl index c1048bf..cf04db2 100644 --- a/src/js.jl +++ b/src/js.jl @@ -391,7 +391,7 @@ function ws_cb(webs) end const plutoisinit = Ref(false) -const jssource = Ref("https://gr-framework.org/downloads/gr-0.73.2.js") +const jssource = Ref("https://gr-framework.org/downloads/gr-0.73.3.js") function init_pluto(source=jssource[]::String) plutoisinit[] = true