InteractiveDynamics.jl icon indicating copy to clipboard operation
InteractiveDynamics.jl copied to clipboard

Inspect on hover only for agents within red box

Open hbsmith opened this issue 3 years ago • 0 comments

It would be nice if there was an option to display only the agent2string information for agents that are actually within (or approximately within) the red rectangle around your cursor when inspecting agents.

In my continuous space model, I was having problems because too much agent info was always being concatenated when inspecting on hover, due to the inexact nature of nearby_ids here: https://github.com/JuliaDynamics/InteractiveDynamics.jl/blob/4a701abdb40abefc9e3bc6161bb223d22cd2ef2d/src/agents/inspection.jl#L103

It's a bit unintuitive that even when zooming in on the plot such that individual agents are clearly resolved, "nearby" agents are still shown on the hover inspection.

I think this could be (approximately) addressed by offering a parameter to switch to inspection using nearby_ids_exact, where r is scaled based on the ratio between the red box dimensions, and the projected scene size. I'm aware it wouldn't be perfect, because r is a radius, and the projected space corresponding the rectangle often won't have the same x and y dimensions, but even if you scaled based on the largest projected dimension of the red box, it would give a much more intuitive result for the hover inspection.

Unfortunately the Makie documentation is a bit opaque to me, and I couldn't figure out how to retrieve the projected scene size by which to scale by. But someone who understands Makie better would probably be able to implement this pretty quickly.

hbsmith avatar Sep 01 '22 07:09 hbsmith