samer@47
|
1 function handles=scatui(fig2,plotfn,X,varargin)
|
samer@47
|
2 % scatui - scat with interactive point clicking ui
|
samer@47
|
3 %
|
samer@47
|
4 % scatui ::
|
samer@47
|
5 % handle ~'figure to do secondary plot',
|
samer@47
|
6 % (natural->unit) ~'function to do secondary plot',
|
samer@47
|
7 % [[N,E]] ~'array of N points in E-space'
|
samer@47
|
8 % -> action handle.
|
samer@47
|
9 %
|
samer@47
|
10 % This does several things:
|
samer@47
|
11 % 1. Plots 3d scatter plot as stereo pairs in fig 1
|
samer@47
|
12 % 2. Sets up stereo 3D cursor.
|
samer@47
|
13 % 3. Sets up button click callbacks so you can
|
samer@47
|
14 % click to select one of the points
|
samer@47
|
15 % 4. Starts the whole thing rotating so you can
|
samer@47
|
16 % see what shape it is without going cross-eyed
|
samer@47
|
17
|
samer@47
|
18 % transpose if it looks appropriate
|
samer@47
|
19 if size(X,1)<5, X=X'; end
|
samer@47
|
20 if size(X,2)>2
|
samer@47
|
21 pick=@(t,o)pick3d(t,get(o,'XData'),get(o,'YData'),get(o,'ZData'));
|
samer@47
|
22 curf=@(t,varargin)cursor3d(t(1:3),varargin{:});
|
samer@47
|
23 else
|
samer@47
|
24 pick=@(t,o)pick3d(t,get(o,'XData'),get(o,'YData'),zeros(size(X,1),1));
|
samer@47
|
25 curf=@(t,varargin)cursor2d(t(1:2),varargin{:});
|
samer@47
|
26 end
|
samer@47
|
27
|
samer@47
|
28 % do scat in current figure
|
samer@47
|
29 handles=scat(X,varargin{:}); fig1=gcf;
|
samer@47
|
30 curs=[];
|
samer@47
|
31
|
samer@47
|
32 % get info about scatter plot
|
samer@47
|
33 set(handles,'ButtonDownFcn',@btndown);
|
samer@47
|
34
|
samer@47
|
35 function btndown(obj,dummy)
|
samer@47
|
36 r=get(get(obj,'Parent'),'CurrentPoint'); % get clicked point from axes
|
samer@47
|
37 [x,i]=pick(r,obj); % find nearest point
|
samer@47
|
38 if isempty(curs)
|
samer@47
|
39 curs=curf(x);
|
samer@47
|
40 else
|
samer@47
|
41 curf(x,curs); % move cursor
|
samer@47
|
42 end
|
samer@47
|
43 % title(sprintf('pick: %d',i));
|
samer@47
|
44 figure(fig2); plotfn(i); % do plot in other figure
|
samer@47
|
45 figure(fig1); drawnow; % return to this figure
|
samer@47
|
46 end
|
samer@47
|
47 end
|
samer@47
|
48
|
samer@47
|
49
|
samer@47
|
50
|