Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Picking a line is too difficult #349

Closed
dpsanders opened this issue May 1, 2019 · 5 comments
Closed

Picking a line is too difficult #349

dpsanders opened this issue May 1, 2019 · 5 comments

Comments

@dpsanders
Copy link

Is it possible to increase the tolerance for picking a line?

@asinghvi17
Copy link
Member

If you mean increasing the bounding box, then I think so; but are you trying to select a line using the mouse? If so, how are you selecting it?

@dpsanders
Copy link
Author

Yes, selecting using mouse -- in the "standard" way from https://simondanisch.github.io/ReferenceImages/gallery//edit_polygon/index.html, i.e.

plot, _idx = mouse_selection(scene)
                 if plot == pplot

@SimonDanisch
Copy link
Member

you could draw a thicker transparent line underneath... or implement your own is point close to line ;) That'd be nice to have as a fallback anyways

@ffreyer
Copy link
Collaborator

ffreyer commented Apr 30, 2021

JuliaPlots/AbstractPlotting.jl#696 + JuliaPlots/GLMakie.jl#177 make pick(scene, pos, range) more available (it picks the closest point within range to the given position) and it adds a pick_sorted(scene, pos, range) for when you want to filter out plots yourself (which is very useful with Axis drawing a background rectangle).

JuliaPlots/AbstractPlotting.jl#677 also adds some magic for finding the closest point on a line in both 2D and 3D.

I think this can be closed with those pr's merged

@ffreyer
Copy link
Collaborator

ffreyer commented May 31, 2021

Minor update on this - all these pr's have been merged now. If you want to pick a line with tolerance you can use something like

for (plot, idx) in pick_sorted(fig.scene, mouseposition_px(fig.scene), 10)
    if plot == my_line_plot
        do_something(plot, idx)
        break
    end
end

Note that for 2d Axis there is a mesh in the background which will take priority with pick. So you need to sort through selections like in the example. In 3d you can probably get by with pick(scene, pos, range).

There also a mouse_selection(scene, range) which calls pick(scene, pos, range).

@ffreyer ffreyer closed this as completed Oct 16, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants