fix mesh particle size issue
This commit is contained in:
parent
612ca15fc0
commit
8a58190cce
@ -108,18 +108,23 @@ function empty_screen!(screen)
|
|||||||
end
|
end
|
||||||
nothing
|
nothing
|
||||||
end
|
end
|
||||||
|
function poll_reactive()
|
||||||
|
# run_till_now blocks when message queue is empty!
|
||||||
|
Base.n_avail(Reactive._messages) > 0 && Reactive.run_till_now()
|
||||||
|
end
|
||||||
function create_window(plt::Plot{GLVisualizeBackend}, visible)
|
function create_window(plt::Plot{GLVisualizeBackend}, visible)
|
||||||
# init a screen
|
# init a screen
|
||||||
if isempty(GLVisualize.get_screens())
|
if isempty(GLVisualize.get_screens())
|
||||||
screen = GLVisualize.glscreen(resolution = plt[:size], visible = visible)
|
screen = GLVisualize.glscreen("Plots.jl", resolution = plt[:size], visible = visible)
|
||||||
Reactive.stop()
|
Reactive.stop()
|
||||||
|
|
||||||
@async begin
|
@async begin
|
||||||
while isopen(screen)
|
while isopen(screen)
|
||||||
tic()
|
tic()
|
||||||
GLWindow.pollevents()
|
GLWindow.pollevents()
|
||||||
if Base.n_avail(Reactive._messages) > 0
|
if Base.n_avail(Reactive._messages) > 0
|
||||||
Reactive.run_till_now()
|
poll_reactive()
|
||||||
Base.n_avail(Reactive._messages) > 0 && Reactive.run_till_now() # two times for secondary signals
|
poll_reactive() # two times for secondary signals
|
||||||
GLWindow.render_frame(screen)
|
GLWindow.render_frame(screen)
|
||||||
GLWindow.swapbuffers(screen)
|
GLWindow.swapbuffers(screen)
|
||||||
end
|
end
|
||||||
@ -131,6 +136,8 @@ function create_window(plt::Plot{GLVisualizeBackend}, visible)
|
|||||||
diff -= toq()
|
diff -= toq()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# empty message queue
|
||||||
|
poll_reactive()
|
||||||
GLWindow.destroy!(screen)
|
GLWindow.destroy!(screen)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -168,7 +175,12 @@ function gl_marker(shape)
|
|||||||
shape
|
shape
|
||||||
end
|
end
|
||||||
function gl_marker(shape::Shape)
|
function gl_marker(shape::Shape)
|
||||||
points = Point2f0[Vec{2,Float32}(p)*10f0 for p in zip(shape.x, shape.y)]
|
points = Point2f0[Vec{2,Float32}(p) for p in zip(shape.x, shape.y)]
|
||||||
|
bb = GeometryTypes.AABB(points)
|
||||||
|
mini, maxi = minimum(bb), maximum(bb)
|
||||||
|
w3 = maxi-mini
|
||||||
|
origin, width = Point2f0(mini[1], mini[2]), Point2f0(w3[1], w3[2])
|
||||||
|
map!(p -> ((p - origin) ./ width) - 0.5f0, points) # normalize and center
|
||||||
GeometryTypes.GLNormalMesh(points)
|
GeometryTypes.GLNormalMesh(points)
|
||||||
end
|
end
|
||||||
# create a marker/shape type
|
# create a marker/shape type
|
||||||
@ -417,13 +429,13 @@ function hover(to_hover, to_display, window)
|
|||||||
window,
|
window,
|
||||||
hidden = map(mh-> !(mh.id == to_hover.id), mh),
|
hidden = map(mh-> !(mh.id == to_hover.id), mh),
|
||||||
area = area,
|
area = area,
|
||||||
stroke = (2f0/100f0, RGBA(0f0, 0f0, 0f0, 0.8f0))
|
stroke = (2f0, RGBA(0f0, 0f0, 0f0, 0.8f0))
|
||||||
)
|
)
|
||||||
cam = get!(popup.cameras, :perspective) do
|
cam = get!(popup.cameras, :perspective) do
|
||||||
GLAbstraction.PerspectiveCamera(
|
GLAbstraction.PerspectiveCamera(
|
||||||
popup.inputs, Vec3f0(3), Vec3f0(0),
|
popup.inputs, Vec3f0(3), Vec3f0(0),
|
||||||
keep=Signal(false),
|
keep = Signal(false),
|
||||||
theta= Signal(Vec3f0(0)), trans= Signal(Vec3f0(0))
|
theta = Signal(Vec3f0(0)), trans= Signal(Vec3f0(0))
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -881,7 +893,7 @@ end
|
|||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
function _display(plt::Plot{GLVisualizeBackend}, visible=true)
|
function _display(plt::Plot{GLVisualizeBackend}, visible = true)
|
||||||
screen = create_window(plt, visible)
|
screen = create_window(plt, visible)
|
||||||
sw, sh = plt[:size]
|
sw, sh = plt[:size]
|
||||||
sw, sh = sw*px, sh*px
|
sw, sh = sw*px, sh*px
|
||||||
@ -1135,7 +1147,7 @@ function gl_scatter(points, kw_args)
|
|||||||
kw_args[:scale] = GLAbstraction.const_lift(kw_args[:model], kw_args[:scale], p) do m, sc, p
|
kw_args[:scale] = GLAbstraction.const_lift(kw_args[:model], kw_args[:scale], p) do m, sc, p
|
||||||
s = Vec3f0(m[1,1], m[2,2], m[3,3])
|
s = Vec3f0(m[1,1], m[2,2], m[3,3])
|
||||||
ps = Vec3f0(p[1,1], p[2,2], p[3,3])
|
ps = Vec3f0(p[1,1], p[2,2], p[3,3])
|
||||||
r = 1f0./(s.*ps)
|
r = sc./(s.*ps)
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1355,11 +1367,10 @@ function generate_legend(sp, screen, model_m)
|
|||||||
x,y = round(Int, p[1])+30, round(Int, p[2]-h)-30
|
x,y = round(Int, p[1])+30, round(Int, p[2]-h)-30
|
||||||
GeometryTypes.SimpleRectangle(x, y, w, h)
|
GeometryTypes.SimpleRectangle(x, y, w, h)
|
||||||
end
|
end
|
||||||
px_scale = minimum(GeometryTypes.widths(Reactive.value(area)))
|
|
||||||
sscren = GLWindow.Screen(
|
sscren = GLWindow.Screen(
|
||||||
screen, area=area,
|
screen, area = area,
|
||||||
color=sp[:background_color_legend],
|
color = sp[:background_color_legend],
|
||||||
stroke=(2f0/px_scale, RGBA{Float32}(0.3,0.3,0.3,0.9))
|
stroke = (2f0, RGBA(0.3, 0.3, 0.3, 0.9))
|
||||||
)
|
)
|
||||||
GLAbstraction.translate!(list, Vec3f0(10,10,0))
|
GLAbstraction.translate!(list, Vec3f0(10,10,0))
|
||||||
GLVisualize._view(list, sscren, camera=:fixed_pixel)
|
GLVisualize._view(list, sscren, camera=:fixed_pixel)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user