view arrows/@plotter/construct.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 672052bd81f8
children
line wrap: on
line source
function u=construct(s,sizes_in)
	acquire(s);
	eff_size=sizes_in{1};
	if s.opts.transpose, eff_size = eff_size([2,1]); end
	if isempty(s.opts.dom), dom=1:eff_size(1); else dom=s.opts.dom; end
	figure(fig(s)); set(gcf,'Name',name(s));

	if s.opts.transpose, pre=@transpose; else pre=@id; end
	if isempty(dom)
		h=s.opts.plotfn(pre(zeros(sizes_in{1})),s.opts.args{:});
	else
		h=s.opts.plotfn(dom,pre(zeros(sizes_in{1})),s.opts.args{:});
	end

	if isempty(s.opts.xlim) && numel(dom)>1, s.opts.xlim=[dom(1),dom(end)]; end
	if ~isempty(s.opts.ylim), ylim(s.opts.ylim); end
	if ~isempty(s.opts.xlim), xlim(s.opts.xlim); end
	if isfield(s.opts,'ylabel'), ylabel(s.opts.ylabel); end
	if isfield(s.opts,'xlabel'), xlabel(s.opts.xlabel); end

	u=mkunit(s);
	if length(h)==1
		if autoflush(s), u.process =@proc_flush;
		else u.process=@proc_noflush; end
	else
		af=autoflush(s);
		u.process =@proc_mat;
	end

	u.sizes_out = {};
	u.dispose = @dispose;

	function dispose, delete(h); release(s); end
	function proc_flush(x), set(h,'YData',pre(x)); drawnow; end
	function proc_noflush(x), set(h,'YData',pre(x)); end
	function proc_mat(x), 
		if s.opts.transpose
			for i=1:length(h)
				set(h(i),'YData',x(i,:)'); 
			end
		else
			for i=1:length(h)
				set(h(i),'YData',x(:,i)); 
			end
		end
		if af, drawnow; end
	end
end