I am working on making a simple interactive plotter in Matlab. What I am doing is simple: I use the command:
[x,y] = ginput(1)
to pin-point the location (x,y). Then, I use this point as a seed point to plot a curve and also I add some arrows (which show the direction) located on the top of the plotted curve.
Now my question is: After I am done with the figure, I would like to be able to select (and for instance delete) a single curve and ITS corresponding ARROWS with just one single click.
The problem is that those arrows and the curve are not part of the same object and that's why Matlab will only delete the curve or the arrows depending on which one was/were selected, to begin with.
Narrowing it down, I know that the curve and arrows do have separate object handlers. Rephrasing my question: Is there anyway that I could either group these two separate handlers or, for instance, make arrows children of the original curve?
Well you can approach this problem in different ways.
First about storing the informations:
Most cleanly would be if you would write your own classes with
classdef
to hold your objects, there is the classhandles
you can extend for such purposes. Alternatively you could store them in theuserdata
fields of all graphic objects.about the selection and deletion - lines can be assosiciated with a
ButtonDownFcn
andDeleteFcn
. The first can be used to highlight the related lines, the second to delete the related ones.