cconvdemo_callbacks.m
来自「这是一个基于matlab开发的关于c语言的图形转换程序,可实现直方图的生成和传输」· M 代码 · 共 449 行 · 第 1/2 页
M
449 行
case 'Conserve Space' hHideable = [ findobj(h.Axis.Hideable); h.Button.Hideable ]; Axes_Pos = get(h.Axis.Big,'Position'); TutorialButton_Pos = get(h.Button.Tutorial,'Position'); if umtoggle(gcbo); set(hHideable,'visible','off'); for i = 1:length(h.Axis.Big), Axes_Pos{i}(3) = 0.9; end TutorialButton_Pos(1) = 0.4; set(h.Axis.Big,{'Position'},Axes_Pos); set(h.Button.Tutorial,'Position', TutorialButton_Pos); changemenu('ConservedSpaceMenu'); else for i = 1:length(h.Axis.Big), Axes_Pos{i}(3) = 0.53; end TutorialButton_Pos(1) = 0.2150; set(h.Axis.Big,{'Position'},Axes_Pos); set(h.Button.Tutorial, 'Position', TutorialButton_Pos); set(hHideable,'visible','on'); changemenu('NormalMenu'); endcase 'Grid On' hAxes = findobj(gcbf, 'Type', 'axes'); if umtoggle(gcbo) set(hAxes, 'XGrid', 'on', 'YGrid', 'on'); else set(hAxes, 'XGrid', 'off', 'YGrid', 'off'); endcase 'Reset Axes' if h.State.DataInitialized set(h.Axis.Big, 'XLim', h.State.AxisXLim); h = sethandles(h,'State.t',h.State.tResetValue); initialize(h); end
case 'Set t Value'
if h.State.DataInitialized
ans = inputdlg('New value for t?','Get t Value');
if ~isempty(ans)
t = str2num(ans{:});
if ~isempty(t)
h = sethandles(h,'State.t',t);
initialize(h);
end
end
endcase 'Set Line Width' LineWidth = linewidthdlg(h.State.LineWidth); set(findobj(gcbf,'Type','line'), 'LineWidth', LineWidth); sethandles(h, 'State.LineWidth', LineWidth);case 'Help'
msgbox('Help is not available in this version yet.');
if 0
h = waitbar(0.25,'Trying to lauch internet browser...'); DefPath = which(mfilename); DefPath = ['file:///' strrep(DefPath,filesep,'/') ]; URL = [ DefPath(1:end-21) , 'help/','index.html']; STAT = web(URL); waitbar(1); close(h); switch STAT case {1,2} s = {'Either your internet browser could not be launched or' , ... 'it was unable to load the help page. Please use your' , ... 'browser to read the file:' , ... ' ', ' index.html', ' ', ... 'which is located in the CConvDemo help directory.'}; errordlg(s,'Error launching browser.'); end
end
%-----------------------------------------------------------
case 'Close' %-----------------------------------------------------------
delete(gcbf);
%-----------------------------------------------------------
otherwise %-----------------------------------------------------------
error('Illegal Action');end%%%%%%%%%%%%%%%%%%%%%%%%%%%% positionplots() %%%%%%%%%%%%%%%%%%%%%%%%%%%%function positionplots()h = get(gcbf,'UserData');SPACING = 0.05;LEFT = 0.05;if strcmp( lower( get(h.Menu.ConserveSpace, 'Checked') ), 'on') WIDTH = 0.9;else WIDTH = 0.53;endnVisiblePlots = 3;set(h.Axis.Output,'XTickLabelMode','auto');hPlots = [h.Axis.Output, h.Axis.Multiply h.Axis.Signal];HEIGHT = (1-(2+nVisiblePlots-1)*SPACING)/nVisiblePlots;Bottom = (HEIGHT+SPACING)*[0:nVisiblePlots-1] + SPACING;for i = 1:nVisiblePlots set(hPlots(i),'Position',[LEFT Bottom(i) WIDTH HEIGHT]);endPos = get(h.Button.Tutorial,'Position');Pos{1}(2) = Bottom(1)+(HEIGHT-0.05)/2; % Linear Buttonset(h.Button.Tutorial, {'Position'}, Pos); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% changemenu(NewMenu) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function changemenu(NewMenu)h = get(gcbf, 'UserData');switch NewMenucase 'ConservedSpaceMenu' delete(h.Menu.Help); uimenu('Parent',h.Menu.PlotOptions,'Label','C&lose','Tag','ConservedModeMenu', ... 'Separator','on','CallBack',[mfilename ' Close']); a = uimenu('Parent',gcbf,'Label','&Signal','Tag','ConservedModeMenu'); b = uimenu('Parent',a,'Label','Get &x(t)','Tag','ConservedModeMenu',... 'CallBack',[mfilename '(''Get x(t)'');']); b = uimenu('Parent',a,'Label','Get &h(t)','Tag','ConservedModeMenu',... 'CallBack',[mfilename '(''Get h(t)'');']); if strcmp(h.State.SignalToFlip, 'Flip x(t)') Label = '&Flip h(t)'; else Label = '&Flip x(t)'; end b = uimenu('Parent',a,'Label',Label,'Tag','TempMenu',... 'CallBack',[mfilename '(''FlipButton'');'], 'Separator','on'); a = uimenu('Parent',gcbf,'Label','&Help','Tag','ConservedModeMenu'); b = uimenu('Parent',a,'Label','&Navigate to help files with default browser', ... 'Tag','ConservedModeMenu','CallBack',[mfilename ' Help;']);case 'NormalMenu' delete(findobj(gcbf,'Tag','ConservedModeMenu')); a = uimenu('Parent',gcbf,'Label','&Help','Tag','Help'); b = uimenu('Parent',a,'Label','&Navigate to help files with default browser', ... 'Tag','ConservedModeMenu','CallBack',[mfilename ' Help;']); sethandles(h,'Menu.Help',a);end%-----------------------------------------------------------
% getsignal(Sig,h)%-----------------------------------------------------------
function getsignal(Sig,h)
YES = 1; NO = 0;switch Sigcase 'x(t)' CurrentSignal = h.Data.Input.x; hSigAxis = h.Axis.x; AxisTitle = 'Input'; SigName = 'Data.Input.x'; OtherSigName = 'Data.Input.h';case 'h(t)' CurrentSignal = h.Data.Input.h; hSigAxis = h.Axis.h; AxisTitle = 'Impulse Response'; SigName = 'Data.Input.h'; OtherSigName = 'Data.Input.x';endif ~isempty(CurrentSignal)
if CurrentSignal.IsImpulse
CurrentSignal.Object.PlotScale = 1;
end
eval(['SigTemplate=' class(CurrentSignal.Object) '(CurrentSignal.Object);']); NewSignal.Object = csiggendlg( SigTemplate, ... 'Title',['Get ' Sig], 'LineWidth', h.State.LineWidth );
else NewSignal.Object = csiggendlg('Title',['Get ' Sig],'LineWidth',h.State.LineWidth);end
if ~isempty( NewSignal.Object )
supp = support(NewSignal.Object);
if isa(NewSignal.Object,'cimpulse')
NewSignal.IsImpulse = YES;
a = supp - 10;
b = supp + 10;
NSamples = -inf;
else
NewSignal.IsImpulse = NO;
a = supp(1) - 0.5*diff(supp);
b = supp(2) + 0.5*diff(supp);
fs = suggestrate(NewSignal.Object,[a b]);
NSamples = diff([a b])*fs + 1;
end
if NSamples > h.State.MaxPlotPoints
msg = {'This signal you chose requires too much memory to', ...
' accurately model. Please choose a different signal.'};
errordlg(msg,'Error','modal');
else axes(hSigAxis);
hObj = ezplot(NewSignal.Object,'LineWidth',h.State.LineWidth);
title(AxisTitle,'FontWeight','bold','FontUnits','normalized','FontSize',0.13); if strcmp( lower( get(h.Menu.ConserveSpace, 'Checked') ), 'on') set(findobj(hSigAxis),'Visible','off'); end
if NewSignal.IsImpulse
% : Set the axis x limits, y-limits, and turn off the YTicks.
% : Change the color of the arrow
% : Make the text fit better in the axis
% : Adjust the arrow data so it fits better later in the signal axis
% : Save the text object for later use
set(hSigAxis,'XLim',10/1.2*[-1 1] + NewSignal.Object.Delay, ...
'YLim',[0 1.1],'YTick',[]);
set(hObj(1),'facecolor','b','edgecolor','b');
NewSignal.Object.PlotScale = 0.5;
txtData = get(hObj(2),{'FontSize','Pos'});
OFFSET = [0.75 0 0];
FONTSCALING = 3;
set(hObj(2),'fontsize',FONTSCALING*txtData{1},'pos',txtData{2} + OFFSET);
NewSignal.XData = get(hObj(1),'XData');
NewSignal.YData = get(hObj(1),'YData');
NewSignal.ImpulseTextPos = get(hObj(2),'Pos');
else
% : Set the axis x limits, y-limits, and turn on the YTicks
% : Save the object plot data for later
% : Set the text object data to null since that only applies to impulses
NewSignal.XData = get(hObj,'XData');
NewSignal.YData = get(hObj,'YData');
NewSignal.ImpulseTextPos = [];
YLims = [min(NewSignal.YData) max(NewSignal.YData)];
YLims = YLims + diff(YLims)/10*[-1 1];
set(hSigAxis,'XLim',[a b],'YLim',YLims,'YTickMode','auto');
end h = sethandles(h, SigName, NewSignal); if ~isempty( getfield(h, OtherSigName) )
initialize(h); end
endend
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?