crosshair.m
来自「含有多种ICA算法的eeglab工具箱」· M 代码 · 共 953 行 · 第 1/3 页
M
953 行
black = find(bgcolor <= .6); fgcolor = [0 0 0]; %black text if length(black)>2, fgcolor = [1 1 1]; end Font.FontName = 'Helvetica'; Font.FontUnits = 'Pixels'; Font.FontSize = 10; Font.FontWeight = 'normal'; Font.FontAngle = 'normal'; H.yflip = uicontrol(H.gui,'Style','pushbutton','Units','Normalized',Font,... 'Position',[.00 .70 .08 .05],... 'Tag','YFLIP',... 'TooltipString','Flip Y Axis', ... 'String','Flip',... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'ydir = get(XHR.axis,''YDir'');',... 'if isequal(ydir,''normal''),',... ' set(XHR.axis,''YDir'',''reverse'');',... 'else,',... ' set(XHR.axis,''YDir'',''normal'');',... 'end;',... 'set(gcbf,''userdata'',XHR); figure(XHR.gui); clear XHR;')); H.yreset = uicontrol(H.gui,'Style','pushbutton','Units','Normalized',Font,... 'Position',[.00 .65 .08 .05],... 'Tag','YRESET',... 'TooltipString','Reset Axis Limits', ... 'String','Reset',... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'XHR.ylim = get(XHR.axis,''ylim'');',... 'set(XHR.ymin,''string'',sprintf(''%7.1f'',XHR.ylim(1)));',... 'set(XHR.ymax,''string'',sprintf(''%7.1f'',XHR.ylim(2)));',... 'set(gcbf,''userdata'',XHR); figure(XHR.gui); clear XHR;')); H.ymin = uicontrol(H.gui,'Style','edit','Units','Normalized',Font,... 'Position',[.00 .60 .08 .05],... 'HorizontalAlign','left',... 'Tag','YMIN',... 'TooltipString','Set Y min', ... 'String',sprintf('%7.1f',H.ylim(1)),... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'ymin = str2num(get(XHR.ymin,''string''));',... 'XHR.ylim(1) = ymin;',... 'set(XHR.axis,''ylim'',XHR.ylim);',... 'set(XHR.ymin,''string'',sprintf(''%7.1f'',XHR.ylim(1)));',... 'set(gcbf,''userdata'',XHR); figure(XHR.gui); clear XHR ymin;')); H.ymax = uicontrol(H.gui,'Style','edit','Units','Normalized',Font,... 'Position',[.00 .55 .08 .05],... 'HorizontalAlign','left',... 'Tag','YMAX',... 'TooltipString','Set Y max', ... 'String',sprintf('%7.1f',H.ylim(2)),... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'ymax = str2num(get(XHR.ymax,''string''));',... 'XHR.ylim(2) = ymax;',... 'set(XHR.axis,''ylim'',XHR.ylim);',... 'set(XHR.ymax,''string'',sprintf(''%7.1f'',XHR.ylim(2)));',... 'set(gcbf,''userdata'',XHR); figure(XHR.gui); clear XHR ymax;')); H.grid = uicontrol(H.gui,'Style','checkbox','Units','Normalized',Font,... 'Position',[.00 .50 .08 .05],... 'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,... 'Tag','GRID',... 'TooltipString','Toggle plot grid on/off.', ... 'String','grid',... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'grid(XHR.axis);',... 'set(gcbf,''userdata'',XHR); figure(XHR.gui); clear XHR;')); H.xvalue = uicontrol(H.gui,'Style','edit','Units','Normalized',Font,... 'Position',[.13 .95 .15 .05],... 'BackGroundColor',[ 0 .9 0],'ForeGroundColor',[ 0 0 0],... 'Tag','XVALUE',... 'TooltipString','X value (Read Only)',... 'String',' '); H.yvalue = uicontrol(H.gui,'Style','edit','Units','Normalized',Font,... 'Position',[.28 .95 .15 .05],... 'BackGroundColor',[ 0 0 .9],'ForeGroundColor',[ 1 1 1],... 'Tag','YVALUE',... 'TooltipString','Y value (Read Only)',... 'String',' '); H.fxeq = uicontrol('Style','edit','Units','Normalized',... 'Position',[.45 .95 .10 .05],... 'Tag','FXDEFINE',... 'TooltipString','Define f(x) equation here',... 'BackGroundColor',[ 0 .9 0],... 'ForeGroundColor',[ 0 0 0],'String','x'); H.fxvalue = uicontrol('Style','edit','Units','Normalized',... 'Position',[.55 .95 .15 .05],... 'Tag','FYVALUE',... 'TooltipString','f(x) result',... 'BackGroundColor',[ 0 .9 0],... 'ForeGroundColor',[ 0 0 0],'String',' '); H.fyeq = uicontrol('Style','edit','Units','Normalized',... 'Position',[.70 .95 .10 .05],... 'Tag','FYDEFINE',... 'TooltipString','Define f(y) equation here',... 'BackGroundColor',[ 0 0 .9],... 'ForeGroundColor',[ 1 1 1],'String','y'); H.fyvalue = uicontrol('Style','edit','Units','Normalized',... 'Position',[.80 .95 .15 .05],... 'Tag','FYVALUE',... 'TooltipString','f(y) result',... 'BackGroundColor',[ 0 0 .9],... 'ForeGroundColor',[ 1 1 1],'String',' '); H.yindex = uicontrol('Style','edit','Units','Normalized',Font,... 'Position',[.92 .87 .08 .05],... 'BackGroundColor',[ 0 0 .9],'ForeGroundColor',[ 1 1 1],... 'Tag','YINDEX',... 'TooltipString','Enter Y index into plot data matrix. Same as trace number.',... 'String','1',... 'Value',1,... 'Callback',strcat('H = get(gcbf,''userdata'');',... 'yi = str2num(get(H.yindex,''String''));',... 'H.data.yindex = yi;',... 'set(H.gui,''userdata'',H); clear H yi; ',... '[Xpoint,Ypoint] = crosshair(''changey'');')); H.yprev = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.92 .82 .04 .05],... 'String','<',... 'Tag','YPREV',... 'TooltipString','Goto Previous Y Index (channel).',... 'CallBack','[Xpoint,Ypoint] = crosshair(''prevy'');'); H.ynext = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.96 .82 .04 .05],... 'String','>',... 'Tag','YNEXT',... 'TooltipString','Goto Next Y Index (channel).',... 'CallBack','[Xpoint,Ypoint] = crosshair(''nexty'');'); H.yLT = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.92 .77 .04 .05],... 'String','LT',... 'Tag','YLT',... 'TooltipString','Goto next Y Less Than current Y.',... 'CallBack','[Xpoint,Ypoint] = crosshair(''yLT'');'); H.yGT = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.96 .77 .04 .05],... 'String','GT',... 'Tag','YGT',... 'TooltipString','Goto next Y Greater Than current Y.',... 'CallBack','[Xpoint,Ypoint] = crosshair(''yGT'');'); H.xindex = uicontrol('Style','edit','Units','Normalized',Font,... 'Position',[.92 .70 .08 .05],... 'BackGroundColor',[ 0 .9 0],'ForeGroundColor',[ 0 0 0],... 'Tag','XINDEX',... 'TooltipString','Enter X index into plot data matrix. Only available for interpolation = ''none''.',... 'String','1',... 'Value',1,... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'xi = str2num(get(XHR.xindex,''String''));',... 'XHR.data.xindex = xi;',... 'set(XHR.xinterp,''value'',0); ',... 'set(XHR.xinterp,''string'',''0''); ',... 'set(XHR.interp, ''value'',1); ',... 'set(XHR.gui,''userdata'',XHR); clear XHR; ',... '[Xpoint,Ypoint] = crosshair(''changex'');')); H.xprev = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.92 .65 .04 .05],... 'String','<',... 'Tag','XPREV',... 'TooltipString','Goto Previous X Index (no interpolation).',... 'CallBack','[Xpoint,Ypoint] = crosshair(''prevx'');'); H.xnext = uicontrol('Style','Push','Units','Normalized',Font,... 'Position',[.96 .65 .04 .05],... 'String','>',... 'Tag','XNEXT',... 'TooltipString','Goto Next X Index (no interpolation).',... 'CallBack','[Xpoint,Ypoint] = crosshair(''nextx'');'); H.xinterp = uicontrol('Style','Edit','Units','Normalized',... 'Position',[.92 .60 .08 .05],... 'String','0',... 'Value',0,.... 'Tag','XINTERP',... 'TooltipString','Interpolation X increment (zero = nearest X).',... 'Callback',strcat('XHR = get(gcf,''userdata''); ',... 'xint = str2num(get(XHR.xinterp,''string'')); ',... 'set(XHR.xinterp,''value'',xint); figure(XHR.gui); clear XHR; ')); interpstr = 'none|nearest|linear|spline|cubic'; H.interp = uicontrol('Style','popup','Units','Normalized',Font,... 'Position',[.92 .55 .08 .05],... 'Tag','INTERP',... 'TooltipString','INTERP1 methods (none = raw values).', ... 'String',interpstr,... 'Callback',strcat('XHR = get(gcbf,''userdata'');',... 'xint = get(XHR.xinterp,''Value''); ',... 'if xint == 0, ',... ' xint = 0.5; ',... ' set(XHR.xinterp,''value'',xint); ',... ' set(XHR.xinterp,''string'',num2str(xint)); ',... ' set(XHR.xindex, ''string'',''interp''); ',... 'end; ',... 'set(XHR.gui,''userdata'',XHR); figure(XHR.gui); clear XHR; ')); H.store = uicontrol('Style','Push','Units','Normalized',... 'Position',[.92 .40 .08 .05],... 'String','Store',... 'Tag','STORE',... 'TooltipString','Store current Channel & XY values into base XYhist array.', ... 'CallBack','crosshair(''store'');'); H.done = uicontrol('Style','Push','Units','Normalized',... 'Position',[.80 .00 .10 .05],... 'BackgroundColor',[.8 .5 0],... 'ForegroundColor',[1 1 1],... 'FontWeight','bold',... 'String','Done',... 'Tag','DONE',... 'TooltipString','Close crosshair', ... 'CallBack','crosshair(''done'');'); H.exit = uicontrol('Style','Push','Units','Normalized',... 'Position',[.90 .00 .10 .05],... 'BackgroundColor',[.8 0 0],... 'ForegroundColor',[1 1 1],... 'FontWeight','bold',... 'String','Exit',... 'Tag','EXIT',... 'TooltipString','Close crosshair and Figure', ... 'CallBack','crosshair(''exit'');'); %%%%%%%%%%%%%%%%%%%%%%%%% % Get Line Data from Plot % Lines are referenced as axis children, among other % axis children; so first get all axis children sibs = get(H.axis,'Children'); % Now search axis children for any line types. % Because the columns of the y data matrix in a plot % command seem to be reversed in the axis children, % count down from max sibs to the first sib. lines = 0; H.data.xdata = []; H.data.ydata = []; H.data.xpoint = []; H.data.ypoint = []; H.data.xindex = 1; H.data.yindex = 1; i = max(size(sibs)); while i >= 1 if strcmp(get(sibs(i),'Type'),'line') % OK, found a line among the axis children. lines = lines + 1; % put line data into a column of DATA.xdata|DATA.ydata H.data.xdata(:,lines) = get(sibs(i),'XData').'; H.data.ydata(:,lines) = get(sibs(i),'YData').'; end i = i - 1; end % 'traces' string variable must be in ascending order traces = ''; i = 1; while i <= lines; if i < lines tracelabel = sprintf('Column %4d|',i); else tracelabel = sprintf('Column %4d',i); end traces = strcat(traces,tracelabel); i = i + 1; end % If more than one line, provide GUI for line selection % Switch off||on Trace Selection GUI Vis = 'Off'; if lines > 1, Vis = 'On'; elseif lines == 0 error('No lines found in the current plot window\n'); end % Create Trace Index GUI H.traceLabel = uicontrol('Style','Edit', 'Units','Normalized',... 'Position',[.00 .00 .15 .05],... 'Tag','TRACELABEL',... 'Visible',Vis,'String','Select Trace :',... 'TooltipString','Select trace to follow with crosshairs.'); H.trace = uicontrol('Style','Popup','Units','Normalized',... 'Position',[.15 .00 .20 .05],... 'Tag','TRACESWITCH',... 'BackGroundColor','w','String',traces,... 'Visible',Vis,... 'CallBack','crosshair(''up'');'); H.traceNearest = uicontrol('Style','checkbox', 'Units','Normalized',... 'Position',[.36 .00 .19 .05],... 'BackgroundColor',bgcolor,'ForegroundColor',fgcolor,... 'Tag','TRACENEAREST',... 'Visible',Vis,'String','Nearest Trace','Value',1,... 'TooltipString','Trace nearest to mouse click; switch off to keep trace constant.'); % Set X,Y cross hair lines % Do this after finding all the line axis children % to avoid confusing these lines with those of the % plot itself (counted above). x_rng = get(H.axis,'Xlim'); y_rng = get(H.axis,'Ylim'); H.xline = line(x_rng,[y_rng(1) y_rng(1)]); H.yline = line(x_rng,[y_rng(1) y_rng(1)]); set(H.xline,'Color','r','EraseMode','xor','Tag','XLINE'); set(H.yline,'Color','r','EraseMode','xor','Tag','YLINE'); return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?