0001 function cb_colorshift(handle, events)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 info = get(handle, 'UserData');
0018
0019 info.mouseSEL = (info.mode == 'V') + 1;
0020 if (info.mode == 'H'), info.limitstr = 'XLim'; info.datastr = 'XData';
0021 else, info.limitstr = 'YLim'; info.datastr = 'YData';
0022 end
0023
0024 info.climsinit = get(info.target,'CLim');
0025 info.incr_per_pix = diff(info.climsinit)./200;
0026
0027 info.cmap = get(info.fighdl, 'Colormap');
0028 info.cmaplen = size(info.cmap,1);
0029 info.shft_per_pix = info.cmaplen./256;
0030
0031
0032
0033 clickData = get(handle,'CurrentPoint'); clickData = clickData(1,info.mouseSEL);
0034
0035
0036 clickRoot = get(0, 'PointerLocation'); info.mouseinit = clickRoot(info.mouseSEL);
0037
0038
0039 dlims = get(handle, info.limitstr);
0040 click = [clickData - dlims(1)] ./ [dlims(2)-dlims(1)];
0041 if (click >= 0.95), mode = 'top'; info.limitSEL = 2;
0042 elseif (click <= 0.05), mode = 'bot'; info.limitSEL = 1;
0043 else mode = 'shf';
0044 end
0045
0046
0047 oldMotionFcn = get(info.fighdl, 'WindowButtonMotionFcn');
0048 oldButtonUpFcn = get(info.fighdl, 'WindowButtonUpFcn');
0049 set(info.fighdl, 'WindowButtonUpFcn', {@done_cbar});
0050 switch(mode),
0051 case {'top', 'bot'}
0052 set(info.fighdl, 'WindowButtonMotionFcn', {@scale_cbar, info});
0053 case 'shf',
0054 set(info.fighdl, 'WindowButtonMotionFcn', {@shift_cbar, info});
0055 end
0056 waitfor(info.fighdl, 'WindowButtonMotionFcn', '');
0057
0058 set(info.fighdl, 'WindowButtonMotionFcn', oldMotionFcn);
0059 set(info.fighdl, 'WindowButtonUpFcn', oldButtonUpFcn);
0060
0061 axes(info.target);
0062 if (info.mode == 'H')
0063 HGcolorshift('horiz', 'peer',info.target);
0064 else
0065 HGcolorshift('peer', info.target);
0066 end
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 function done_cbar(handle, event)
0079 set(handle, 'WindowButtonMotionFcn', '')
0080
0081
0082 function scale_cbar(handle, event, ud)
0083 mouse = get(0,'PointerLocation');
0084 ud.climsinit(ud.limitSEL) = ud.climsinit(ud.limitSEL) - (mouse(ud.mouseSEL)-ud.mouseinit)*ud.incr_per_pix;
0085 if (diff(ud.climsinit) > 0)
0086 set(ud.target, 'CLim', ud.climsinit);
0087 set(ud.cbrhdl, ud.limitstr, ud.climsinit);
0088 set(ud.cimage, ud.datastr, ud.climsinit);
0089 end
0090
0091
0092 function shift_cbar(handle, event, ud)
0093 mouse = get(0,'PointerLocation');
0094 shift = round((mouse(ud.mouseSEL)-ud.mouseinit)*ud.shft_per_pix);
0095 cmap = ud.cmap;
0096 set(ud.fighdl, 'Colormap', cmap(circshift([1:ud.cmaplen]', shift), :));