Select points in a ZedGraph graph by dragging the mouse
Asked Answered
O

1

7

I would like to select points on my curve by dragging a square with my mouse. Of course I can build this myself, but I was wondering if it can be done easier?

Oxidize answered 1/9, 2010 at 20:2 Comment(0)
M
8

Unfortunately not. You would have to do it by yourself. ZG doesn't provide any more sophisticated tools for interaction.

You would probably need to subscribe for "mouse down" and "mouse up" events, perform the reverse transform of found points and then find all points in range (i.e. by searching inside the Points collection of your curve(s)).

Just remember, that the action you described is by default connected width zooming and you would have to disable it.

Mclane answered 2/9, 2010 at 7:52 Comment(3)
Thanks, do you know any simple way of obtaining some kind of HitInfo for the Points?Oxidize
Well something like checking the area you drag with the mouse to collect the points that are in there.Oxidize
As I said, you should subscribe for mouse down event, get the point (in pixels) (px1, py1), then transform it to get X and Y scale coordinates (see reverse transform). Do the same for mouse up, get another point - (px2, py2), reverse it. Now you have two points that represent the rectangle you selected. All you need to do is to search the points in your curve to find all points for which x is in range (px1, px2) and y is in (py1, py2)Mclane

© 2022 - 2024 — McMap. All rights reserved.