samer@0: function u=construct(s,sizes_in) samer@0: fg=fig(s); figure(fg); samer@0: ax=gca; samer@0: samer@0: current_pos=get(ax,'CurrentPoint'); samer@0: samer@0: if ~isempty(s.opts.xlim), xlim(s.opts.xlim); end samer@0: if ~isempty(s.opts.ylim), xlim(s.opts.ylim); end samer@0: if isfield(s.opts,'ylabel'), ylabel(s.opts.ylabel); end samer@0: if isfield(s.opts,'xlabel'), xlabel(s.opts.xlabel); end samer@0: if isfield(s.opts,'box'), box(s.opts.box); end samer@0: samer@0: u=mkunit(s); samer@0: u.process=@proc; samer@0: u.sizes_out = {[2,1]}; samer@0: u.dispose = @dispose; samer@0: u.starting = @starting; samer@0: u.stopping = @stopping; samer@0: samer@0: function starting samer@0: set(ax,'ButtonDownFcn',@btndown); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: samer@0: function stopping samer@0: set(ax,'ButtonDownFcn',[]); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: samer@0: function x=proc, samer@0: % pos=get(ax,'CurrentPoint'); samer@0: x=current_pos(1,1:2)'; samer@0: end samer@0: samer@0: function btndown(a,b), samer@0: set(fg,'WindowButtonMotionFcn',@move,'WindowButtonUpFcn',@btnup); samer@0: current_pos=get(ax,'CurrentPoint'); samer@0: end samer@0: function btnup(a,b), set(fg,'WindowButtonMotionFcn',[]); end samer@0: function move(a,b), current_pos=get(ax,'CurrentPoint'); end samer@0: samer@0: function dispose samer@0: set(ax,'ButtonDownFcn',[]); samer@0: set(fg,'WindowButtonMotionFcn',[]); samer@0: end samer@0: end