The pick method because of the need to click on edges did
> not fullfill my needs. So I wrote a new method Called
> PickBigLine that does not required a mouse click close to
> the edge but close to the line you want to pick. This is
> particularly useful after zooming when the edges are
> sometimes out of the axis limits.
It is not clear to me what this method is for. It would help if you
posted an example where the current pick functionality failed and the
one you propose succeeds (perhaps you could define your function at
the top of the file for ease of use).
I have a couple of questions/comments about your code...
xt, yt = a.get_transform().numerix_x_y(xdata, ydata)
xt, yt = asarray(xt), asarray(yt)
There is no need to call asarray since numerix_x_y returns arrays.
xc, yc = xt-xt, yt-yt
What is the point of this? Why do you only look at the points xt,
xt, yt, yt? What if someone needs to click on another point
of the line?
if xc==0.0 and yc == 0.0: return 1000000.
D = xc*xc + yc*yc
D1 = -(xt-xywin)*yc+(yt-xywin)*xc
D2 = -(yt-xywin)*yc-(xt-xywin)*xc
What do D1 and D2 represent? I'm having trouble understanding why,
for example, you need to do (xt-xywin)*yc
if D2/D>1.001 or D2/D<-0.001: return 1000000.
I think the 1000000.0 sentinel value should be renamed to some useful
constant name so it will be self documenting.
artists = self.lines
if not len(artists): return None
ds = [ (dist(a),a) for a in artists]
> I also needed to add a
> new property to Line2D called tag (similar to matlab) for
> sorting purposes. I wonder if you have thought of adding
> such a possibility to some objects for which it can be very
Does the "label" property help here. Could you give a use case?