src/Visualise.jl

changeset 60
dcfc38ade15b
parent 34
fe9ef03a91b2
child 62
a6eed11d13df
equal deleted inserted replaced
45:097f95638dba 60:dcfc38ade15b
87 GR.fillrect(vp...) 87 GR.fillrect(vp...)
88 GR.selntran(1) 88 GR.selntran(1)
89 GR.restorestate() 89 GR.restorestate()
90 end 90 end
91 91
92 function do_visualise(imgs; refresh=true, fullscreen=false) 92 function do_visualise(imgs; refresh=true, fullscreen=false, windowsize=nothing)
93 n = length(imgs) 93 n = length(imgs)
94 # Get device dimensions in metres and pixels 94 # Get device dimensions in metres and pixels
95 scrw, scrh, pw, ph = GR.inqdspsize() 95 scrw, scrh, pw, ph = GR.inqdspsize()
96 imgaspect = n > 0 ? float(size(imgs[1], 1))/float(size(imgs[1], 2)) : 1 96 imgaspect = n > 0 ? float(size(imgs[1], 1))/float(size(imgs[1], 2)) : 1
97 # Scaling to maximum size window 97 # Scaling to maximum size window
99 # Set up window and transformations 99 # Set up window and transformations
100 GR.clearws() 100 GR.clearws()
101 GR.setscale(0); 101 GR.setscale(0);
102 GR.selntran(1) 102 GR.selntran(1)
103 # - First OS window size 103 # - First OS window size
104 if fullscreen 104 if !isnothing(windowsize)
105 w, h = float.(windowsize)
106 elseif fullscreen
105 w, h = float(scrw), float(scrh) 107 w, h = float(scrw), float(scrh)
106 elseif scrw/n>scrh 108 elseif scrw/n>scrh
107 w, h = float(sc*scrh*n), float(sc*scrh*imgaspect) 109 w, h = float(sc*scrh*n), float(sc*scrh*imgaspect)
108 else 110 else
109 w, h = float(sc*scrw), float(sc*scrw/n*imgaspect) 111 w, h = float(sc*scrw), float(sc*scrw/n*imgaspect)
128 x0 = (canvas[1]+canvas[2])/2 130 x0 = (canvas[1]+canvas[2])/2
129 hh = (canvas[4]-canvas[3])/2 131 hh = (canvas[4]-canvas[3])/2
130 x1 = x0-hh*(n/imgaspect) 132 x1 = x0-hh*(n/imgaspect)
131 x2 = x0+hh*(n/imgaspect) 133 x2 = x0+hh*(n/imgaspect)
132 GR.setviewport(x1, x2, canvas[3], canvas[4]) 134 GR.setviewport(x1, x2, canvas[3], canvas[4])
133 end 135 end
134 GR.setwindow(0, n, 0, 1) 136 GR.setwindow(0, n, 0, 1)
135 # Clear background 137 # Clear background
136 # Plot images 138 # Plot images
137 for i=1:n 139 for i=1:n
138 im = imgs[i]' 140 im = imgs[i]'

mercurial