[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Selecting objects and PickData problem

I have used PickData in a very similar fashion as Richard wants to use
it. I did not modify the point value but used point's exact location to
go back to the process that created that particular point. I was unable
to directly use the output of PickData method. Instead, I had to locate
the point in my Plot data that was closest to the location returned by PickData:
	x_loc_hi = (where(plot_data[0, *] ge return_XY[0]))[0]
	x_loc_lo = (reverse(where(plot_data[0, *] le return_XY[0])))[0]
	if abs(x_loc_hi - return_XY[0]) le abs(x_loc_lo - return_XY[0]) then $
		x_loc = x_loc_hi else x_loc = x_loc_lo
In my case, data were sorted and no Y search was necessary. More general
approach would repeat this for the Y dimension, and Z too, I guess.
This way, I was able to extract the point I needed.
>From here, it would be very simple to make that point "follow" the
cursor (by turning ON drag events until mouse release and changing the
value of the found plot point). However, given the fact that mousing on
the plot area never seemed to hit the exact point I tried to hit, I am
not sure I'd like to set my data points using this method, unless for
some sort of initial guess.
I have a feeling that this uncertainty originates from PickData using
input device coordinates to figure out if a click hit a plot. Then, if
you happen to hit within some neighborhood of the plot object, PickData
will return TRUE, although from the display device (which uses pixels)
it can't tell what Plot value did you hit. Then PickData will return a
value, probably corresponding to the center of that neighborhood, which
is close to the value of Plot data point.
As you can tell, it is all pure speculation. But I used the workaround
and it worked for me.