samer@0
|
1 function u=construct(s,sizes_in)
|
samer@0
|
2 fg=fig(s); figure(fg);
|
samer@0
|
3 ax=gca;
|
samer@0
|
4
|
samer@0
|
5 current_pos={}; %[nan;nan];
|
samer@0
|
6 btnisup=1;
|
samer@0
|
7
|
samer@0
|
8 if ~isempty(s.opts.xlim), xlim(s.opts.xlim); end
|
samer@0
|
9 if ~isempty(s.opts.ylim), xlim(s.opts.ylim); end
|
samer@0
|
10 if isfield(s.opts,'ylabel'), ylabel(s.opts.ylabel); end
|
samer@0
|
11 if isfield(s.opts,'xlabel'), xlabel(s.opts.xlabel); end
|
samer@0
|
12 if isfield(s.opts,'box'), box(s.opts.box); end
|
samer@0
|
13
|
samer@0
|
14 u=mkunit(s);
|
samer@0
|
15 u.process=@proc;
|
samer@0
|
16 u.sizes_out = {[2,1]};
|
samer@0
|
17 u.dispose = @dispose;
|
samer@0
|
18 u.starting = @starting;
|
samer@0
|
19 u.stopping = @stopping;
|
samer@0
|
20
|
samer@0
|
21 function starting
|
samer@0
|
22 set(ax,'ButtonDownFcn',@btndown);
|
samer@0
|
23 set(fg,'WindowButtonMotionFcn',[]);
|
samer@0
|
24 end
|
samer@0
|
25
|
samer@0
|
26 function stopping
|
samer@0
|
27 set(ax,'ButtonDownFcn',[]);
|
samer@0
|
28 set(fg,'WindowButtonMotionFcn',[]);
|
samer@0
|
29 end
|
samer@0
|
30
|
samer@0
|
31 function x=proc,
|
samer@0
|
32 x=current_pos;
|
samer@0
|
33 if btnisup, current_pos={}; end % [nan;nan]; end
|
samer@0
|
34 end
|
samer@0
|
35
|
samer@0
|
36 function btndown(a,b),
|
samer@0
|
37 set(fg,'WindowButtonMotionFcn',@move,'WindowButtonUpFcn',@btnup);
|
samer@0
|
38 btnisup=0;
|
samer@0
|
39 move(a,b);
|
samer@0
|
40 end
|
samer@0
|
41 function btnup(a,b), set(fg,'WindowButtonMotionFcn',[]); btnisup=1; end
|
samer@0
|
42 function move(a,b), cp=get(ax,'CurrentPoint'); current_pos={cp(1,1:2)'}; end
|
samer@0
|
43
|
samer@0
|
44 function dispose
|
samer@0
|
45 set(ax,'ButtonDownFcn',[]);
|
samer@0
|
46 set(fg,'WindowButtonMotionFcn',[]);
|
samer@0
|
47 end
|
samer@0
|
48 end
|